[uim-commit] r462 - trunk/helper
tkng at freedesktop.org
tkng at freedesktop.org
Tue Feb 1 09:17:12 PST 2005
Author: tkng
Date: 2005-02-01 09:17:08 -0800 (Tue, 01 Feb 2005)
New Revision: 462
Modified:
trunk/helper/toolbar-applet-gnome.c
trunk/helper/toolbar-common-gtk.c
Log:
* toolbar-common-gtk.c:
-(switcher_button_create, pref_button_create): Take second argument.
-(switcher_button_pressed, pref_button_pressed): Function prototype
changed.
-(uim_helper_applet_new): New function.
* toolbar-applet-gnome.c:
-(uim_menu_xml): Updated menu items.
Modified: trunk/helper/toolbar-applet-gnome.c
===================================================================
--- trunk/helper/toolbar-applet-gnome.c 2005-02-01 15:15:38 UTC (rev 461)
+++ trunk/helper/toolbar-applet-gnome.c 2005-02-01 17:17:08 UTC (rev 462)
@@ -44,17 +44,19 @@
PanelApplet *uimapplet;
-
-static void
-display_help_dialog (BonoboUIComponent *uic, gpointer data, const gchar *verbname);
static void
+exec_switcher(BonoboUIComponent *uic, gpointer data, const gchar *verbname);
+static void
+exec_pref(BonoboUIComponent *uic, gpointer data, const gchar *verbname);
+static void
display_about_dialog(BonoboUIComponent *uic, gpointer data, const gchar *verbname);
-GtkWidget *uim_helper_toolbar_new(void);
+GtkWidget *uim_helper_applet_new(void);
static const BonoboUIVerb uim_menu_verbs [] = {
- BONOBO_UI_VERB ("UimHelp", display_help_dialog),
+ BONOBO_UI_VERB ("UimExecSwitcher", exec_switcher),
+ BONOBO_UI_VERB ("UimExecPref", exec_pref),
BONOBO_UI_VERB ("UimAbout", display_about_dialog),
BONOBO_UI_VERB_END
};
@@ -62,18 +64,34 @@
static const char uim_menu_xml [] =
"<popup name=\"button3\">\n"
- " <menuitem name=\"Help Item\" verb=\"UimHelp\" _label=\"Help\"\n"
- " pixtype=\"stock\" pixname=\"gtk-help\"/>\n"
+ " <menuitem name=\"Switcher Item\" verb=\"UimExecSwitcher\" _label=\"Execute uim's input method switcher\"\n"
+ " pixtype=\"filename\" pixname=\""UIM_PIXMAPSDIR"/switcher-icon.png\"/>\n"
+ " <menuitem name=\"Pref Item\" verb=\"UimExecPref\" _label=\"Execute uim's preference tool\"\n"
+ " pixtype=\"stock\" pixname=\"preferences\"/>\n"
" <menuitem name=\"About Item\" verb=\"UimAbout\" _label=\"About ...\"\n"
" pixtype=\"stock\" pixname=\"gnome-stock-about\"/>\n"
"</popup>\n";
+static void
+exec_switcher(BonoboUIComponent *uic, gpointer data, const gchar *verbname)
+{
+ system("uim-im-switcher &");
+}
+
+static void
+exec_pref(BonoboUIComponent *uic, gpointer data, const gchar *verbname)
+{
+ system("uim-pref-gtk &");
+}
+
+
/* Opens gnome help application
*/
+#if 0
static void
-display_help_dialog (BonoboUIComponent *uic, gpointer data, const gchar *verbname)
+display_help_dialog(BonoboUIComponent *uic, gpointer data, const gchar *verbname)
{
GError *error = NULL;
@@ -92,6 +110,7 @@
error = NULL;
}
}
+#endif
/* Just the about window... If it's already open, just focus it
*/
@@ -100,15 +119,14 @@
{
/* GdkPixbuf *icon;*/
GtkWidget *dialog;
- const char *authors[] =
- {"Yusuke TABATA <yusuke at cherubim.icw.co.jp> \nTOKUNAGA Hiroyuki <tkng at xem.jp>",NULL};
+ const char *authors[] = {"uim Project", NULL};
/* Feel free to put your names here translators */
char *translators = _("TRANSLATORS");
/* icon = gdk_pixbuf_new_from_xpm_data(ICON_APPLET);*/
- dialog = GTK_WIDGET(gnome_about_new (_("Uim Helper Applet"), VERSION, "Copyright 2003 TOKUNAGA Hiroyuki",
+ dialog = GTK_WIDGET(gnome_about_new (_("Uim Applet for GNOME"), VERSION, "Copyright 2003-2005 uim Project.",
_("Applet for indicate uim's status"),
(const char **) authors, NULL,
strcmp("TRANSLATORS", translators) ? translators : NULL,
@@ -129,8 +147,10 @@
if (strcmp (iid, "OAFIID:GNOME_UimApplet") != 0)
return FALSE;
- toolbar = (GtkWidget*)uim_helper_toolbar_new();
+ uim_init();
+ toolbar = (GtkWidget*)uim_helper_applet_new();
+
gtk_container_add (GTK_CONTAINER (applet), toolbar);
gtk_widget_show_all (GTK_WIDGET (applet));
@@ -146,7 +166,7 @@
PANEL_APPLET_BONOBO_FACTORY ("OAFIID:GNOME_UimApplet_Factory",
PANEL_TYPE_APPLET,
- "uim gnome2 Applet",
+ "uim Applet for GNOME",
"0",
(PanelAppletFactoryCallback)uim_applet_new,
NULL)
Modified: trunk/helper/toolbar-common-gtk.c
===================================================================
--- trunk/helper/toolbar-common-gtk.c 2005-02-01 15:15:38 UTC (rev 461)
+++ trunk/helper/toolbar-common-gtk.c 2005-02-01 17:17:08 UTC (rev 462)
@@ -49,6 +49,7 @@
#define OBJECT_DATA_MENU_BUTTONS "MENU_BUTTONS"
#define OBJECT_DATA_SIZE_GROUP "SIZE_GROUP"
+#define OBJECT_DATA_TOOLBAR_TYPE "TOOLBAR_TYPE"
static GtkWidget *prop_menu;
static GtkWidget *right_click_menu;
@@ -56,20 +57,26 @@
static unsigned int read_tag;
static int uim_fd;
+enum {
+ TYPE_TOOLBAR,
+ TYPE_APPLET,
+ TYPE_ICON
+};
+
static gboolean
prop_button_pressed(GtkButton *prop_button, GdkEventButton *event, GtkWidget *widget);
static gboolean
prop_button_released(GtkButton *prop_button, GdkEventButton *event, GtkWidget *widget);
static GtkWidget *
-switcher_button_create(GtkSizeGroup *sg);
+switcher_button_create(GtkSizeGroup *sg, GtkWidget *widget);
static void
-switcher_button_pressed(GtkButton *prop_button, GdkEventButton *event, gpointer user_data);
+switcher_button_pressed(GtkButton *prop_button, GdkEventButton *event, GtkWidget *widget);
static GtkWidget *
-pref_button_create(GtkSizeGroup *sg);
+pref_button_create(GtkSizeGroup *sg, GtkWidget *widget);
static void
-pref_button_pressed(GtkButton *prop_button, GdkEventButton *event, gpointer user_data);
+pref_button_pressed(GtkButton *prop_button, GdkEventButton *event, GtkWidget *widget);
static void
calc_menu_position(GtkMenu *prop_menu, gint *x, gint *y, gboolean *push_in, GtkWidget *prop_button);
@@ -81,6 +88,8 @@
uim_helper_toolbar_new(void);
GtkWidget *
uim_helper_trayicon_new(void);
+GtkWidget *
+uim_helper_applet_new(void);
static void
prop_menu_activate(GtkMenu *menu_item, gpointer data)
@@ -271,10 +280,10 @@
i++;
}
- button = switcher_button_create(sg);
+ button = switcher_button_create(sg, widget);
append_button(widget, button);
- button = pref_button_create(sg);
+ button = pref_button_create(sg, widget);
append_button(widget, button);
gtk_widget_show_all(widget);
@@ -512,8 +521,12 @@
static gboolean
prop_button_pressed(GtkButton *prop_button, GdkEventButton *event, GtkWidget *widget)
{
+ gint type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), OBJECT_DATA_TOOLBAR_TYPE));
if(event->button == 3) {
- prop_right_button_pressed(prop_button, event, widget);
+ if(type == TYPE_APPLET)
+ gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)), (GdkEvent *) event);
+ else
+ prop_right_button_pressed(prop_button, event, widget);
} else if(event->button == 2) {
gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)), (GdkEvent *) event);
}
@@ -646,7 +659,7 @@
}
static GtkWidget *
-switcher_button_create(GtkSizeGroup *sg)
+switcher_button_create(GtkSizeGroup *sg, GtkWidget *widget)
{
GtkWidget *button;
GtkTooltips *tooltip;
@@ -666,7 +679,7 @@
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
gtk_size_group_add_widget(sg, button);
g_signal_connect(G_OBJECT(button), "button_press_event",
- G_CALLBACK(switcher_button_pressed), NULL);
+ G_CALLBACK(switcher_button_pressed), widget);
/* tooltip */
tooltip = gtk_tooltips_new();
@@ -676,10 +689,14 @@
}
static void
-switcher_button_pressed(GtkButton *prop_button, GdkEventButton *event, gpointer user_data)
+switcher_button_pressed(GtkButton *prop_button, GdkEventButton *event, GtkWidget *widget)
{
+ gint type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), OBJECT_DATA_TOOLBAR_TYPE));
if(event->button == 3) {
- prop_right_button_pressed(prop_button, event, prop_menu);
+ if(type == TYPE_APPLET)
+ gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)), (GdkEvent *) event);
+ else
+ prop_right_button_pressed(prop_button, event, prop_menu);
} else if(event->button == 2) {
gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)), (GdkEvent *) event);
} else {
@@ -689,7 +706,7 @@
}
static GtkWidget *
-pref_button_create(GtkSizeGroup *sg)
+pref_button_create(GtkSizeGroup *sg, GtkWidget *widget)
{
GtkWidget *button;
@@ -706,7 +723,7 @@
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
gtk_size_group_add_widget(sg, button);
g_signal_connect(G_OBJECT(button), "button_press_event",
- G_CALLBACK(pref_button_pressed), NULL);
+ G_CALLBACK(pref_button_pressed), widget);
gtk_container_add(GTK_CONTAINER(button), img);
/* tooltip */
@@ -717,10 +734,14 @@
}
static void
-pref_button_pressed(GtkButton *prop_button, GdkEventButton *event, gpointer user_data)
+pref_button_pressed(GtkButton *prop_button, GdkEventButton *event, GtkWidget *widget)
{
+ gint type = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), OBJECT_DATA_TOOLBAR_TYPE));
if(event->button == 3) {
- prop_right_button_pressed(prop_button, event, prop_menu);
+ if(type == TYPE_APPLET)
+ gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)), (GdkEvent *) event);
+ else
+ prop_right_button_pressed(prop_button, event, prop_menu);
} else if(event->button == 2) {
gtk_propagate_event(gtk_widget_get_parent(GTK_WIDGET(prop_button)), (GdkEvent *) event);
} else {
@@ -729,8 +750,8 @@
}
}
-GtkWidget *
-uim_helper_toolbar_new(void)
+static GtkWidget *
+toolbar_new(gint type)
{
GtkWidget *button;
GtkWidget *hbox;
@@ -754,7 +775,8 @@
menu_buttons);
g_object_set_data(G_OBJECT(hbox), OBJECT_DATA_SIZE_GROUP,
sg);
-
+ g_object_set_data(G_OBJECT(hbox), OBJECT_DATA_TOOLBAR_TYPE,
+ GINT_TO_POINTER(type));
uim_fd = -1;
check_helper_connection(hbox);
@@ -763,8 +785,20 @@
return hbox;
}
+GtkWidget *
+uim_helper_toolbar_new(void)
+{
+ return toolbar_new(TYPE_TOOLBAR);
+}
GtkWidget *
+uim_helper_applet_new(void)
+{
+ return toolbar_new(TYPE_APPLET);
+}
+
+
+GtkWidget *
uim_helper_trayicon_new(void)
{
GtkWidget *button;
More information about the Uim-commit
mailing list