4
* Copyright (C) 1997 Rasca Gmelch, Berlin
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23
#include "../config.h"
25
#include <sys/types.h>
33
#include "gtk2_support.h"
36
lookup_widget (GtkWidget *widget,
37
const gchar *widget_name)
39
GtkWidget *parent, *found_widget;
43
if (GTK_IS_MENU (widget))
44
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
46
parent = widget->parent;
48
parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
54
found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
57
g_warning ("Widget not found: %s", widget_name);
61
static GList *pixmaps_directories = NULL;
63
/* Use this function to set the directory containing installed pixmaps. */
65
add_pixmap_directory (const gchar *directory)
67
pixmaps_directories = g_list_prepend (pixmaps_directories,
68
g_strdup (directory));
71
/* This is an internally used function to find pixmap files. */
73
find_pixmap_file (const gchar *filename)
77
/* We step through each of the pixmaps directory to find it. */
78
elem = pixmaps_directories;
81
gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
82
G_DIR_SEPARATOR_S, filename);
83
if (g_file_test (pathname, G_FILE_TEST_EXISTS))
91
/* This is an internally used function to create pixmaps. */
93
create_pixmap (GtkWidget *widget,
94
const gchar *filename)
96
gchar *pathname = NULL;
99
if (!filename || !filename[0])
100
return gtk_image_new ();
102
pathname = find_pixmap_file (filename);
106
g_warning (_("Couldn't find pixmap file: %s"), filename);
107
return gtk_image_new ();
110
pixmap = gtk_image_new_from_file (pathname);
115
/* This is an internally used function to create pixmaps. */
117
create_pixbuf (const gchar *filename)
119
gchar *pathname = NULL;
121
GError *error = NULL;
123
if (!filename || !filename[0])
126
pathname = find_pixmap_file (filename);
130
g_warning (_("Couldn't find pixmap file: %s"), filename);
134
pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
137
fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
138
pathname, error->message);
139
g_error_free (error);
145
/* This is used to set ATK action descriptions. */
147
glade_set_atk_action_description (AtkAction *action,
148
const gchar *action_name,
149
const gchar *description)
153
n_actions = atk_action_get_n_actions (action);
154
for (i = 0; i < n_actions; i++)
156
if (!strcmp (atk_action_get_name (action, i), action_name))
157
atk_action_set_description (action, i, description);