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>
35 #include <ltt/compiler.h>
40 lookup_widget (GtkWidget *widget,
41 const gchar *widget_name)
43 GtkWidget *parent, *found_widget;
47 if (GTK_IS_MENU (widget))
48 parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
50 parent = widget->parent;
52 parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
58 found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
61 g_warning ("Widget not found: %s", widget_name);
65 static GList *pixmaps_directories = NULL;
67 /* Use this function to set the directory containing installed pixmaps. */
69 add_pixmap_directory (const gchar *directory)
71 pixmaps_directories = g_list_prepend (pixmaps_directories,
72 g_strdup (directory));
75 /* This is an internally used function to find pixmap files. */
77 find_pixmap_file (const gchar *filename)
81 /* We step through each of the pixmaps directory to find it. */
82 elem = pixmaps_directories;
85 gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
86 G_DIR_SEPARATOR_S, filename);
87 if (g_file_test (pathname, G_FILE_TEST_EXISTS))
95 /* This is an internally used function to create pixmaps. */
97 create_pixmap (GtkWidget *widget,
98 const gchar *filename)
100 gchar *pathname = NULL;
103 if (!filename || !filename[0])
104 return gtk_image_new ();
106 pathname = find_pixmap_file (filename);
110 g_warning ("Couldn't find pixmap file: %s", filename);
111 return gtk_image_new ();
114 pixmap = gtk_image_new_from_file (pathname);
119 /* This is an internally used function to create pixmaps. */
121 create_pixbuf (const gchar *filename)
123 gchar *pathname = NULL;
125 GError *error = NULL;
127 if (!filename || !filename[0])
130 pathname = find_pixmap_file (filename);
134 g_warning ("Couldn't find pixmap file: %s", filename);
138 pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
141 fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
142 pathname, error->message);
143 g_error_free (error);
149 /* This is used to set ATK action descriptions. */
151 glade_set_atk_action_description (AtkAction *action,
152 const gchar *action_name,
153 const gchar *description)
157 n_actions = atk_action_get_n_actions (action);
158 for (i = 0; i < n_actions; i++)
160 if (!strcmp (atk_action_get_name (action, i), action_name))
161 atk_action_set_description (action, i, description);