2004-12-23 13:58:39 +01:00
|
|
|
/*
|
2009-11-19 16:38:13 +01:00
|
|
|
support.c
|
|
|
|
|
|
|
|
Bygfoot Football Manager -- a small and simple GTK2-based
|
|
|
|
football management game.
|
|
|
|
|
|
|
|
http://bygfoot.sourceforge.net
|
|
|
|
|
|
|
|
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
2008-12-06 18:07:03 +01:00
|
|
|
|
2004-12-23 13:58:39 +01:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2009-10-16 13:52:32 +02:00
|
|
|
#include "main.h"
|
2004-12-23 13:58:39 +01:00
|
|
|
#include "support.h"
|
|
|
|
|
|
|
|
GtkWidget*
|
|
|
|
lookup_widget (GtkWidget *widget,
|
|
|
|
const gchar *widget_name)
|
|
|
|
{
|
|
|
|
GtkWidget *parent, *found_widget;
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
if (GTK_IS_MENU (widget))
|
|
|
|
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
|
|
|
|
else
|
|
|
|
parent = widget->parent;
|
|
|
|
if (!parent)
|
|
|
|
parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
|
|
|
|
if (parent == NULL)
|
|
|
|
break;
|
|
|
|
widget = parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
|
|
|
|
widget_name);
|
|
|
|
if (!found_widget)
|
|
|
|
g_warning ("Widget not found: %s", widget_name);
|
|
|
|
return found_widget;
|
|
|
|
}
|
|
|
|
|
2009-10-16 13:52:32 +02:00
|
|
|
/** This will load the ui file, connect the signals and return the builder
|
|
|
|
*/
|
|
|
|
GtkBuilder*
|
|
|
|
load_ui (const gchar *filename)
|
|
|
|
{
|
|
|
|
GtkBuilder *builder;
|
|
|
|
GError *error = NULL;
|
|
|
|
|
|
|
|
builder = gtk_builder_new ();
|
|
|
|
|
|
|
|
if (!gtk_builder_add_from_file (builder, filename, &error))
|
|
|
|
{
|
|
|
|
main_exit_program(EXIT_FILE_NOT_FOUND,
|
2009-11-04 14:46:37 +01:00
|
|
|
": Problems found in the glade file: %s\n", error->message);
|
2009-10-16 13:52:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_builder_connect_signals (builder, NULL);
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-23 13:58:39 +01:00
|
|
|
static GList *pixmaps_directories = NULL;
|
|
|
|
|
|
|
|
/* Use this function to set the directory containing installed pixmaps. */
|
|
|
|
void
|
|
|
|
add_pixmap_directory (const gchar *directory)
|
|
|
|
{
|
|
|
|
pixmaps_directories = g_list_prepend (pixmaps_directories,
|
|
|
|
g_strdup (directory));
|
2009-10-16 13:52:32 +02:00
|
|
|
GtkIconTheme *icon_theme;
|
|
|
|
icon_theme = gtk_icon_theme_get_default ();
|
|
|
|
|
|
|
|
gtk_icon_theme_append_search_path (icon_theme, g_strdup(directory));
|
2004-12-23 13:58:39 +01:00
|
|
|
}
|