1 /* This file is part of the Linux Trace Toolkit viewer
2 * Copyright (C) 2003-2004 XangXiu Yang
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation;
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 * DO NOT EDIT THIS FILE - it is generated by Glade.
27 #include <sys/types.h>
38 lookup_widget (GtkWidget *widget,
39 const gchar *widget_name)
41 GtkWidget *parent, *found_widget;
45 if (GTK_IS_MENU (widget))
46 parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
48 parent = widget->parent;
50 parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
56 found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
59 g_warning ("Widget not found: %s", widget_name);
63 static GList *pixmaps_directories = NULL;
65 /* Use this function to set the directory containing installed pixmaps. */
67 add_pixmap_directory (const gchar *directory)
69 pixmaps_directories = g_list_prepend (pixmaps_directories,
70 g_strdup (directory));
73 /* This is an internally used function to find pixmap files. */
75 find_pixmap_file (const gchar *filename)
79 /* We step through each of the pixmaps directory to find it. */
80 elem = pixmaps_directories;
83 gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
84 G_DIR_SEPARATOR_S, filename);
85 if (g_file_test (pathname, G_FILE_TEST_EXISTS))
93 /* This is an internally used function to create pixmaps. */
95 create_pixmap (GtkWidget *widget,
96 const gchar *filename)
98 gchar *pathname = NULL;
101 if (!filename || !filename[0])
102 return gtk_image_new ();
104 pathname = find_pixmap_file (filename);
108 g_warning ("Couldn't find pixmap file: %s", filename);
109 return gtk_image_new ();
112 pixmap = gtk_image_new_from_file (pathname);
117 /* This is an internally used function to create pixmaps. */
119 create_pixbuf (const gchar *filename)
121 gchar *pathname = NULL;
123 GError *error = NULL;
125 if (!filename || !filename[0])
128 pathname = find_pixmap_file (filename);
132 g_warning ("Couldn't find pixmap file: %s", filename);
136 pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
139 fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
140 pathname, error->message);
141 g_error_free (error);
147 /* This is used to set ATK action descriptions. */
149 glade_set_atk_action_description (AtkAction *action,
150 const gchar *action_name,
151 const gchar *description)
155 n_actions = atk_action_get_n_actions (action);
156 for (i = 0; i < n_actions; i++)
158 if (!strcmp (atk_action_get_name (action, i), action_name))
159 atk_action_set_description (action, i, description);