Mercurial > cropper
comparison support.c @ 10:5e282003f0c1
minor changes; besser indenting
author | meillo@marmaro.de |
---|---|
date | Thu, 04 Mar 2010 13:54:17 +0100 |
parents | e359bea4c8ac |
children | c18ba4ea1514 |
comparison
equal
deleted
inserted
replaced
9:7e1cf00de1df | 10:5e282003f0c1 |
---|---|
8 | 8 |
9 #include "support.h" | 9 #include "support.h" |
10 | 10 |
11 | 11 |
12 GtkWidget* lookup_widget(GtkWidget* widget, const gchar* widget_name) { | 12 GtkWidget* lookup_widget(GtkWidget* widget, const gchar* widget_name) { |
13 GtkWidget* parent; | 13 GtkWidget* parent; |
14 GtkWidget* found_widget; | 14 GtkWidget* found_widget; |
15 | 15 |
16 for (;;) { | 16 for (;;) { |
17 if (GTK_IS_MENU (widget)) { | 17 if (GTK_IS_MENU (widget)) { |
18 parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); | 18 parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); |
19 } else { | 19 } else { |
20 parent = widget->parent; | 20 parent = widget->parent; |
21 } | 21 } |
26 break; | 26 break; |
27 } | 27 } |
28 widget = parent; | 28 widget = parent; |
29 } | 29 } |
30 | 30 |
31 found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name); | 31 found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name); |
32 if (!found_widget) { | 32 if (!found_widget) { |
33 g_warning ("Widget not found: %s", widget_name); | 33 g_warning ("Widget not found: %s", widget_name); |
34 } | 34 } |
35 return found_widget; | 35 return found_widget; |
36 } | 36 } |
37 | 37 |
38 | 38 |
39 static GList *pixmaps_directories = NULL; | 39 static GList *pixmaps_directories = NULL; |
40 | 40 |
41 /* Use this function to set the directory containing installed pixmaps. */ | 41 /* Use this function to set the directory containing installed pixmaps. */ |
42 void add_pixmap_directory(const gchar* directory) { | 42 void add_pixmap_directory(const gchar* directory) { |
43 pixmaps_directories = g_list_prepend (pixmaps_directories, g_strdup (directory)); | 43 pixmaps_directories = g_list_prepend (pixmaps_directories, g_strdup (directory)); |
44 } | 44 } |
45 | 45 |
46 /* This is an internally used function to find pixmap files. */ | 46 /* This is an internally used function to find pixmap files. */ |
47 static gchar* find_pixmap_file(const gchar* filename) { | 47 static gchar* find_pixmap_file(const gchar* filename) { |
48 GList* elem; | 48 GList* elem; |
49 | 49 |
50 /* We step through each of the pixmaps directory to find it. */ | 50 /* We step through each of the pixmaps directory to find it. */ |
51 elem = pixmaps_directories; | 51 elem = pixmaps_directories; |
52 while (elem) { | 52 while (elem) { |
53 gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, G_DIR_SEPARATOR_S, filename); | 53 gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, G_DIR_SEPARATOR_S, filename); |
54 if (g_file_test (pathname, G_FILE_TEST_EXISTS)) { | 54 if (g_file_test (pathname, G_FILE_TEST_EXISTS)) { |
55 return pathname; | 55 return pathname; |
56 } | 56 } |
57 g_free (pathname); | 57 g_free (pathname); |
58 elem = elem->next; | 58 elem = elem->next; |
59 } | 59 } |
60 return NULL; | 60 return NULL; |
61 } | 61 } |
62 | 62 |
63 | 63 |
64 /* This is an internally used function to create pixmaps. */ | 64 /* This is an internally used function to create pixmaps. */ |
65 GtkWidget* create_pixmap(GtkWidget* widget, const gchar* filename) { | 65 GtkWidget* create_pixmap(GtkWidget* widget, const gchar* filename) { |
66 gchar* pathname = NULL; | 66 gchar* pathname = NULL; |
67 GtkWidget* pixmap; | 67 GtkWidget* pixmap; |
68 | 68 |
69 if (!filename || !filename[0]) { | 69 if (!filename || !filename[0]) { |
70 return gtk_image_new (); | 70 return gtk_image_new (); |
71 } | 71 } |
72 | 72 |
73 pathname = find_pixmap_file (filename); | 73 pathname = find_pixmap_file (filename); |
74 | 74 |
75 if (!pathname) { | 75 if (!pathname) { |
76 g_warning ("Couldn't find pixmap file: %s", filename); | 76 g_warning ("Couldn't find pixmap file: %s", filename); |
77 return gtk_image_new (); | 77 return gtk_image_new (); |
78 } | 78 } |
79 | 79 |
80 pixmap = gtk_image_new_from_file (pathname); | 80 pixmap = gtk_image_new_from_file (pathname); |
81 g_free(pathname); | 81 g_free(pathname); |
82 return pixmap; | 82 return pixmap; |
83 } | 83 } |
84 | 84 |
85 | 85 |
86 /* This is an internally used function to create pixmaps. */ | 86 /* This is an internally used function to create pixmaps. */ |
87 GdkPixbuf* create_pixbuf(const gchar* filename) { | 87 GdkPixbuf* create_pixbuf(const gchar* filename) { |
88 gchar* pathname = NULL; | 88 gchar* pathname = NULL; |
89 GdkPixbuf* pixbuf; | 89 GdkPixbuf* pixbuf; |
90 GError* error = NULL; | 90 GError* error = NULL; |
91 | 91 |
92 if (!filename || !filename[0]) { | 92 if (!filename || !filename[0]) { |
93 return NULL; | 93 return NULL; |
94 } | 94 } |
95 | 95 |
96 pathname = find_pixmap_file(filename); | 96 pathname = find_pixmap_file(filename); |
97 | 97 |
98 if (!pathname) { | 98 if (!pathname) { |
99 g_warning ("Couldn't find pixmap file: %s", filename); | 99 g_warning ("Couldn't find pixmap file: %s", filename); |
100 return NULL; | 100 return NULL; |
101 } | 101 } |
102 | 102 |
103 pixbuf = gdk_pixbuf_new_from_file (pathname, &error); | 103 pixbuf = gdk_pixbuf_new_from_file (pathname, &error); |
104 if (!pixbuf) { | 104 if (!pixbuf) { |
105 fprintf(stderr, "Failed to load pixbuf file: %s: %s\n", pathname, error->message); | 105 fprintf(stderr, "Failed to load pixbuf file: %s: %s\n", pathname, error->message); |
106 g_error_free(error); | 106 g_error_free(error); |
107 } | 107 } |
108 g_free(pathname); | 108 g_free(pathname); |
109 return pixbuf; | 109 return pixbuf; |
110 } | 110 } |
111 | 111 |
112 | 112 |
113 /* This is used to set ATK action descriptions. */ | 113 /* This is used to set ATK action descriptions. */ |
114 void glade_set_atk_action_description(AtkAction* action, const gchar* action_name, const gchar* description) { | 114 void glade_set_atk_action_description(AtkAction* action, const gchar* action_name, const gchar* description) { |
115 gint n_actions; | 115 gint n_actions; |
116 gint i; | 116 gint i; |
117 | 117 |
118 n_actions = atk_action_get_n_actions (action); | 118 n_actions = atk_action_get_n_actions (action); |
119 for (i = 0; i < n_actions; i++) { | 119 for (i = 0; i < n_actions; i++) { |
120 if (!strcmp (atk_action_get_name (action, i), action_name)) { | 120 if (!strcmp (atk_action_get_name (action, i), action_name)) { |
121 atk_action_set_description (action, i, description); | 121 atk_action_set_description (action, i, description); |
122 } | 122 } |
123 } | 123 } |
124 } | 124 } |