pidgin/gtkutils.c

changeset 40704
09fc97ff0b52
parent 40697
81f81f5d2f39
child 40765
a5381c20e802
equal deleted inserted replaced
40703:153098577f8c 40704:09fc97ff0b52
185 185
186 gtk_widget_show_all(menuitem); 186 gtk_widget_show_all(menuitem);
187 187
188 return menuitem; 188 return menuitem;
189 } 189 }
190
191 GtkWidget *
192 pidgin_pixbuf_button_from_stock(const char *text, const char *icon,
193 PidginButtonOrientation style)
194 {
195 GtkWidget *button, *image, *bbox, *ibox, *lbox = NULL;
196
197 button = gtk_button_new();
198
199 if (style == PIDGIN_BUTTON_HORIZONTAL) {
200 bbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
201 ibox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
202 if (text)
203 lbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0);
204 } else {
205 bbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
206 ibox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
207 if (text)
208 lbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
209 }
210
211 gtk_container_add(GTK_CONTAINER(button), bbox);
212
213 if (icon) {
214 gtk_box_pack_start(GTK_BOX(bbox), ibox, TRUE, TRUE, 0);
215 image = gtk_image_new_from_stock(icon, GTK_ICON_SIZE_BUTTON);
216 gtk_box_pack_end(GTK_BOX(ibox), image, FALSE, TRUE, 0);
217 }
218
219 if (text) {
220 GtkLabel *label;
221
222 gtk_box_pack_start(GTK_BOX(bbox), lbox, TRUE, TRUE, 0);
223 label = GTK_LABEL(gtk_label_new(NULL));
224 gtk_label_set_text_with_mnemonic(label, text);
225 gtk_label_set_mnemonic_widget(label, button);
226 gtk_box_pack_start(GTK_BOX(lbox), GTK_WIDGET(label),
227 FALSE, TRUE, 0);
228 pidgin_set_accessible_label(button, label);
229 }
230
231 gtk_widget_show_all(bbox);
232
233 return button;
234 }
235
236 190
237 GtkWidget *pidgin_new_menu_item(GtkWidget *menu, const char *mnemonic, 191 GtkWidget *pidgin_new_menu_item(GtkWidget *menu, const char *mnemonic,
238 const char *icon, GCallback cb, gpointer data) 192 const char *icon, GCallback cb, gpointer data)
239 { 193 {
240 GtkWidget *menuitem; 194 GtkWidget *menuitem;

mercurial