A multilingual input method framework
Revisão | 756370bd3c4c31e32daa56d5df4d31dcf6227b92 (tree) |
---|---|
Hora | 2013-10-31 22:49:44 |
Autor | Muneyuki Noguchi <nogu.dev@gmai...> |
Commiter | Muneyuki Noguchi |
Remove duplicate code in common-gtk.c
* gtk2/toolbar/common-gtk.c
@@ -605,14 +605,11 @@ tool_button_destroy(gpointer data, gpointer user_data) | ||
605 | 605 | gtk_widget_destroy(GTK_WIDGET(data)); |
606 | 606 | } |
607 | 607 | |
608 | -static GtkWidget * | |
609 | -prop_button_create(GtkWidget *widget, const gchar *icon_name, | |
610 | - const gchar *label, const gchar *tip_text) | |
608 | +static GtkWidget* | |
609 | +button_create(GtkWidget *widget, GtkSizeGroup *sg, const gchar *icon_name, | |
610 | + const gchar *label, gint type) | |
611 | 611 | { |
612 | 612 | GtkWidget *button; |
613 | - GtkSizeGroup *sg; | |
614 | - | |
615 | - sg = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_SIZE_GROUP); | |
616 | 613 | |
617 | 614 | if (register_icon(icon_name)) { |
618 | 615 | GtkWidget *img = gtk_image_new_from_stock(icon_name, GTK_ICON_SIZE_MENU); |
@@ -622,18 +619,36 @@ prop_button_create(GtkWidget *widget, const gchar *icon_name, | ||
622 | 619 | button = gtk_button_new_with_label(label); |
623 | 620 | } |
624 | 621 | |
625 | - if (GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), | |
626 | - OBJECT_DATA_TOOLBAR_TYPE)) == TYPE_ICON) | |
622 | + if (type == TYPE_ICON) | |
627 | 623 | set_button_style(button); |
628 | 624 | |
629 | 625 | gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
630 | 626 | gtk_size_group_add_widget(sg, button); |
631 | 627 | g_object_set_data(G_OBJECT(button), OBJECT_DATA_BUTTON_TYPE, |
632 | 628 | GINT_TO_POINTER(BUTTON_PROP)); |
633 | - gtk_widget_set_tooltip_text(button, tip_text); | |
634 | 629 | |
635 | 630 | g_signal_connect(G_OBJECT(button), "button-press-event", |
636 | 631 | G_CALLBACK(button_pressed), widget); |
632 | + | |
633 | + return button; | |
634 | +} | |
635 | + | |
636 | +static GtkWidget * | |
637 | +prop_button_create(GtkWidget *widget, const gchar *icon_name, | |
638 | + const gchar *label, const gchar *tip_text) | |
639 | +{ | |
640 | + GtkWidget *button; | |
641 | + GtkSizeGroup *sg; | |
642 | + gint type; | |
643 | + | |
644 | + sg = g_object_get_data(G_OBJECT(widget), OBJECT_DATA_SIZE_GROUP); | |
645 | + type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), | |
646 | + OBJECT_DATA_TOOLBAR_TYPE)); | |
647 | + | |
648 | + button = button_create(widget, sg, icon_name, label, type); | |
649 | + | |
650 | + gtk_widget_set_tooltip_text(button, tip_text); | |
651 | + | |
637 | 652 | g_signal_connect(G_OBJECT(button), "button-release-event", |
638 | 653 | G_CALLBACK(prop_button_released), widget); |
639 | 654 |
@@ -1102,24 +1117,9 @@ toolbar_new(gint type) | ||
1102 | 1117 | sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
1103 | 1118 | |
1104 | 1119 | /* prop menu button */ |
1105 | - if (register_icon("uim-icon")) { | |
1106 | - GtkWidget *img = gtk_image_new_from_stock("uim-icon", GTK_ICON_SIZE_MENU); | |
1107 | - button = gtk_button_new(); | |
1108 | - gtk_container_add(GTK_CONTAINER(button), img); | |
1109 | - } else { | |
1110 | - button = gtk_button_new_with_label(" x"); | |
1111 | - } | |
1120 | + button = button_create(hbox, sg, "uim-icon", " x", type); | |
1112 | 1121 | |
1113 | - if (type == TYPE_ICON) | |
1114 | - set_button_style(button); | |
1115 | - | |
1116 | - gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
1117 | - gtk_size_group_add_widget(sg, button); | |
1118 | - g_signal_connect(G_OBJECT(button), "button-press-event", | |
1119 | - G_CALLBACK(button_pressed), hbox); | |
1120 | 1122 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); |
1121 | - g_object_set_data(G_OBJECT(button), OBJECT_DATA_BUTTON_TYPE, | |
1122 | - GINT_TO_POINTER(BUTTON_PROP)); | |
1123 | 1123 | |
1124 | 1124 | prop_buttons = g_list_append(prop_buttons, button); |
1125 | 1125 |