[uim-commit] r3078 - trunk/helper
ekato at freedesktop.org
ekato at freedesktop.org
Thu Feb 2 03:30:18 PST 2006
Author: ekato
Date: 2006-02-02 03:30:13 -0800 (Thu, 02 Feb 2006)
New Revision: 3078
Modified:
trunk/helper/toolbar-common-gtk.c
Log:
* helper/toolbar-common-gtk.c (popup_pop_menu) : New. Mostly
moved from prop_button_released.
(prop_button_pressed) : Popup menu with button 1.
(prop_button_released) : Don't popup menu.
(tool_button_pressed) : Don't exec command at button-press.
(tool_button_clicked_cb) : New. Exec command here.
(helper_toolbar_prop_list_update) : Connect clicked signal.
Modified: trunk/helper/toolbar-common-gtk.c
===================================================================
--- trunk/helper/toolbar-common-gtk.c 2006-02-02 10:37:53 UTC (rev 3077)
+++ trunk/helper/toolbar-common-gtk.c 2006-02-02 11:30:13 UTC (rev 3078)
@@ -182,36 +182,9 @@
g_string_free(msg, TRUE);
}
-static gboolean
-prop_button_pressed(GtkButton *prop_button, GdkEventButton *event,
- GtkWidget *widget)
-{
- gint type;
-
- switch (event->button) {
- case 3:
- type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget),
- OBJECT_DATA_TOOLBAR_TYPE));
- if (type == TYPE_APPLET)
- gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)),
- (GdkEvent *)event);
- else
- right_button_pressed(prop_button, event, widget);
- break;
- case 2:
- gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)),
- (GdkEvent *) event);
- break;
- default:
- break;
- }
-
- return FALSE;
-}
-
-static gboolean
-prop_button_released(GtkButton *prop_button, GdkEventButton *event,
- GtkWidget *widget)
+static void
+popup_prop_menu(GtkButton *prop_button, GdkEventButton *event,
+ GtkWidget *widget)
{
GtkWidget *menu_item;
GtkTooltips *tooltip;
@@ -221,12 +194,6 @@
gboolean has_state = FALSE;
uim_toolbar_check_helper_connection(widget);
-
- if (event->button == 2 || event->button == 3) {
- gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)),
- (GdkEvent *)event);
- return FALSE;
- }
menu_item_list = gtk_container_get_children(GTK_CONTAINER(prop_menu));
label_list = g_object_get_data(G_OBJECT(prop_button), "prop_label");
@@ -286,17 +253,58 @@
(GtkMenuPositionFunc)calc_menu_position,
(gpointer)prop_button, event->button,
gtk_get_current_event_time());
+}
+static gboolean
+prop_button_pressed(GtkButton *prop_button, GdkEventButton *event,
+ GtkWidget *widget)
+{
+ gint type;
+
+ switch (event->button) {
+ case 3:
+ type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget),
+ OBJECT_DATA_TOOLBAR_TYPE));
+ if (type == TYPE_APPLET)
+ gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)),
+ (GdkEvent *)event);
+ else
+ right_button_pressed(prop_button, event, widget);
+ break;
+ case 2:
+ gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)),
+ (GdkEvent *) event);
+ break;
+ default:
+ popup_prop_menu(prop_button, event, widget);
+ break;
+ }
+
return FALSE;
}
static gboolean
+prop_button_released(GtkButton *prop_button, GdkEventButton *event,
+ GtkWidget *widget)
+{
+ switch (event->button) {
+ case 2:
+ case 3:
+ gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)),
+ (GdkEvent *)event);
+ break;
+ default:
+ break;
+ }
+
+ return FALSE;
+}
+
+static gboolean
tool_button_pressed_cb(GtkButton *tool_button, GdkEventButton *event,
GtkWidget *widget)
{
- const gchar *command;
gint type;
- gboolean ret;
switch (event->button) {
case 3:
@@ -307,24 +315,27 @@
(GdkEvent *)event);
else
right_button_pressed(tool_button, event, NULL);
- ret = TRUE;
break;
case 2:
gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(tool_button)),
(GdkEvent *)event);
- ret = TRUE;
break;
default:
- command = g_object_get_data(G_OBJECT(tool_button), OBJECT_DATA_COMMAND);
- if (command)
- system(command);
- ret = FALSE;
break;
}
- return ret;
+ return FALSE;
}
+static void
+tool_button_clicked_cb(GtkButton *tool_button, GtkWidget *widget)
+{
+ const gchar *command;
+
+ command = g_object_get_data(G_OBJECT(tool_button), OBJECT_DATA_COMMAND);
+ if (command)
+ system(command);
+}
static void
@@ -545,8 +556,10 @@
gtk_container_add(GTK_CONTAINER(tool_button), img);
gtk_button_set_relief(GTK_BUTTON(tool_button), GTK_RELIEF_NONE);
gtk_size_group_add_widget(sg, tool_button);
- g_signal_connect(G_OBJECT(tool_button), "button_press_event",
+ g_signal_connect(G_OBJECT(tool_button), "button-press-event",
G_CALLBACK(tool_button_pressed_cb), widget);
+ g_signal_connect(G_OBJECT(tool_button), "clicked",
+ G_CALLBACK(tool_button_clicked_cb), widget);
/* tooltip */
tooltip = gtk_tooltips_new();
@@ -737,7 +750,7 @@
button = gtk_button_new_with_label(" x");
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
- g_signal_connect(G_OBJECT(button), "button_press_event",
+ g_signal_connect(G_OBJECT(button), "button-press-event",
G_CALLBACK(prop_button_pressed), NULL);
gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
More information about the uim-commit
mailing list