[gnome-applets/wip/gnome-3.10+: 2/29] don't use deprecated GtkAction and GtkActionGroup
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets/wip/gnome-3.10+: 2/29] don't use deprecated GtkAction and GtkActionGroup
- Date: Thu, 28 Aug 2014 15:50:33 +0000 (UTC)
commit 315fe4e7b1adb5d5ebedcebef108cb4009c17d3c
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Jul 5 21:12:33 2014 +0300
don't use deprecated GtkAction and GtkActionGroup
This also is required by libpanel-applet library changes.
accessx-status/accessx-status-applet-menu.xml | 19 +++-
accessx-status/applet.c | 63 +++++++-------
battstat/battstat-applet-menu.xml | 18 +++-
battstat/battstat.h | 2 +-
battstat/battstat_applet.c | 52 ++++++------
battstat/properties.c | 8 ++-
charpick/charpick-applet-menu.xml | 18 +++-
charpick/charpick.c | 57 +++++++-------
charpick/charpick.h | 5 +-
charpick/properties.c | 7 +-
cpufreq/cpufreq-applet-menu.xml | 18 +++-
cpufreq/src/cpufreq-applet.c | 68 ++++++++-------
drivemount/drivemount-applet-menu.xml | 13 +++-
drivemount/drivemount.c | 42 +++++-----
geyes/geyes-applet-menu.xml | 19 +++-
geyes/geyes.c | 57 +++++++-------
geyes/geyes.h | 5 +-
geyes/themes.c | 6 +-
gweather/gweather-applet-menu.xml | 31 ++++++--
gweather/gweather-applet.c | 90 +++++++++++----------
mini-commander/src/about.c | 5 +-
mini-commander/src/about.h | 5 +-
mini-commander/src/help.c | 6 +-
mini-commander/src/help.h | 5 +-
mini-commander/src/mini-commander-applet-menu.xml | 18 +++-
mini-commander/src/mini-commander_applet.c | 42 +++++-----
mini-commander/src/preferences.c | 7 +-
mini-commander/src/preferences.h | 5 +-
mixer/applet.c | 85 +++++++++----------
mixer/applet.h | 2 +-
mixer/mixer-applet-menu.xml | 31 ++++++--
multiload/global.h | 5 +-
multiload/main.c | 73 ++++++++---------
multiload/multiload-applet-menu.xml | 26 +++++--
multiload/properties.c | 6 +-
stickynotes/stickynotes-applet-menu.xml | 42 +++++++---
stickynotes/stickynotes_applet.c | 82 ++++++-------------
stickynotes/stickynotes_applet.h | 2 +-
stickynotes/stickynotes_applet_callbacks.c | 28 +++++--
stickynotes/stickynotes_applet_callbacks.h | 17 ++--
trashapplet/src/trashapplet.c | 86 +++++++++++---------
trashapplet/trashapplet-menu.xml | 26 +++++--
42 files changed, 680 insertions(+), 522 deletions(-)
---
diff --git a/accessx-status/accessx-status-applet-menu.xml b/accessx-status/accessx-status-applet-menu.xml
index f4d1c26..2fc1d2f 100644
--- a/accessx-status/accessx-status-applet-menu.xml
+++ b/accessx-status/accessx-status-applet-menu.xml
@@ -1,5 +1,14 @@
-<menuitem name="Item 1" action="Dialog" />
-<menuitem name="Item 2" action="Help" />
-<menuitem name="Item 3" action="About" />
-
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Keyboard Accessibility Preferences</attribute>
+ <attribute name="action">accessx.dialog</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">accessx.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">accessx.about</attribute>
+ </item>
+</section>
diff --git a/accessx-status/applet.c b/accessx-status/applet.c
index 4c928d9..3358193 100644
--- a/accessx-status/applet.c
+++ b/accessx-status/applet.c
@@ -118,9 +118,11 @@ static void popup_error_dialog (AccessxStatusApplet *sapplet);
/* cribbed from geyes */
static void
-about_cb (GtkAction *action,
- AccessxStatusApplet *sapplet)
+about_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ AccessxStatusApplet *sapplet = (AccessxStatusApplet *) user_data;
static const gchar *authors [] = {
"Calum Benson <calum benson sun com>",
"Bill Haneman <bill haneman sun com>",
@@ -146,9 +148,11 @@ about_cb (GtkAction *action,
}
static void
-help_cb (GtkAction *action,
- AccessxStatusApplet *sapplet)
+help_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ AccessxStatusApplet *sapplet = (AccessxStatusApplet *) user_data;
GError *error = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (sapplet->applet)),
@@ -182,9 +186,11 @@ help_cb (GtkAction *action,
}
static void
-dialog_cb (GtkAction *action,
- AccessxStatusApplet *sapplet)
+dialog_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ AccessxStatusApplet *sapplet = (AccessxStatusApplet *) user_data;
GError *error = NULL;
GdkScreen *screen;
GdkAppLaunchContext *launch_context;
@@ -233,16 +239,10 @@ dialog_cb (GtkAction *action,
g_object_unref (appinfo);
}
-static const GtkActionEntry accessx_status_applet_menu_actions [] = {
- { "Dialog", GTK_STOCK_PROPERTIES, N_("_Keyboard Accessibility Preferences"),
- NULL, NULL,
- G_CALLBACK (dialog_cb) },
- { "Help", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (help_cb) },
- { "About", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (about_cb) }
+static const GActionEntry accessx_status_applet_menu_actions [] = {
+ { "dialog", dialog_cb, NULL, NULL, NULL },
+ { "help", help_cb, NULL, NULL, NULL },
+ { "about", about_cb, NULL, NULL, NULL }
};
static XkbDescPtr
@@ -1171,7 +1171,7 @@ static gboolean
button_press_cb (GtkWidget *widget, GdkEventButton *event, AccessxStatusApplet *sapplet)
{
if (event->button == 1 && event->type == GDK_BUTTON_PRESS)
- dialog_cb (NULL, sapplet);
+ dialog_cb (NULL, NULL, sapplet);
return FALSE;
}
@@ -1186,7 +1186,7 @@ key_press_cb (GtkWidget *widget, GdkEventKey *event, AccessxStatusApplet *sapple
case GDK_KEY_Return:
case GDK_KEY_space:
case GDK_KEY_KP_Space:
- dialog_cb (NULL, sapplet);
+ dialog_cb (NULL, NULL, sapplet);
return TRUE;
default:
@@ -1241,7 +1241,8 @@ accessx_status_applet_fill (PanelApplet *applet)
{
AccessxStatusApplet *sapplet;
AtkObject *atk_object;
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
+ GAction *action;
gchar *ui_path;
gboolean was_realized = FALSE;
@@ -1267,22 +1268,22 @@ accessx_status_applet_fill (PanelApplet *applet)
g_signal_connect (sapplet->applet, "key_press_event",
G_CALLBACK (key_press_cb), sapplet);
- action_group = gtk_action_group_new ("Accessx Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
- accessx_status_applet_menu_actions,
- G_N_ELEMENTS (accessx_status_applet_menu_actions),
- sapplet);
+ action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
+ accessx_status_applet_menu_actions,
+ G_N_ELEMENTS (accessx_status_applet_menu_actions),
+ sapplet);
ui_path = g_build_filename (ACCESSX_MENU_UI_DIR, "accessx-status-applet-menu.xml", NULL);
- panel_applet_setup_menu_from_file (sapplet->applet, ui_path, action_group);
+ panel_applet_setup_menu_from_file (sapplet->applet, ui_path, action_group, GETTEXT_PACKAGE);
g_free (ui_path);
- if (panel_applet_get_locked_down (sapplet->applet)) {
- GtkAction *action;
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "accessx",
+ G_ACTION_GROUP (action_group));
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "dialog");
+ g_object_bind_property (applet, "locked-down", action, "enabled",
+ G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
- action = gtk_action_group_get_action (action_group, "Dialog");
- gtk_action_set_visible (action, FALSE);
- }
g_object_unref (action_group);
gtk_widget_set_tooltip_text (GTK_WIDGET (sapplet->applet), _("Keyboard Accessibility Status"));
diff --git a/battstat/battstat-applet-menu.xml b/battstat/battstat-applet-menu.xml
index d6eb579..b9436f5 100644
--- a/battstat/battstat-applet-menu.xml
+++ b/battstat/battstat-applet-menu.xml
@@ -1,4 +1,14 @@
-<menuitem name="Battstat Properties Item" action="BattstatProperties" />
-<menuitem name="Battstat Help Item" action="BattstatHelp" />
-<menuitem name="Battstat About Item" action="BattstatAbout" />
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">battstat.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">battstat.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">battstat.about</attribute>
+ </item>
+</section>
diff --git a/battstat/battstat.h b/battstat/battstat.h
index 908d800..ccf2f82 100644
--- a/battstat/battstat.h
+++ b/battstat/battstat.h
@@ -153,7 +153,7 @@ typedef struct _ProgressData {
} ProgressData;
/* properties.c */
-void prop_cb (GtkAction *, ProgressData *);
+void prop_cb (GSimpleAction *, GVariant *, gpointer);
/* battstat_applet.c */
void reconfigure_layout( ProgressData *battstat );
diff --git a/battstat/battstat_applet.c b/battstat/battstat_applet.c
index ffcc733..bace1d0 100644
--- a/battstat/battstat_applet.c
+++ b/battstat/battstat_applet.c
@@ -54,19 +54,13 @@
#define GCONF_PATH ""
static gboolean check_for_updates (gpointer data);
-static void about_cb( GtkAction *, ProgressData * );
-static void help_cb( GtkAction *, ProgressData * );
-
-static const GtkActionEntry battstat_menu_actions [] = {
- { "BattstatProperties", GTK_STOCK_PROPERTIES, N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (prop_cb) },
- { "BattstatHelp", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (help_cb) },
- { "BattstatAbout", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (about_cb) }
+static void about_cb( GSimpleAction *, GVariant *, gpointer );
+static void help_cb( GSimpleAction *, GVariant *, gpointer );
+
+static const GActionEntry battstat_menu_actions [] = {
+ { "preferences", prop_cb, NULL, NULL, NULL },
+ { "help", help_cb, NULL, NULL, NULL },
+ { "about", about_cb, NULL, NULL, NULL }
};
#define AC_POWER_STRING _("System is running on AC power")
@@ -1159,16 +1153,22 @@ battstat_show_help( ProgressData *battstat, const char *section )
/* Called when the user selects the 'help' menu item.
*/
static void
-help_cb( GtkAction *action, ProgressData *battstat )
+help_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ ProgressData *battstat = (ProgressData *) user_data;
battstat_show_help( battstat, NULL );
}
/* Called when the user selects the 'about' menu item.
*/
static void
-about_cb( GtkAction *action, ProgressData *battstat )
+about_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ ProgressData *battstat = (ProgressData *) user_data;
const gchar *authors[] = {
"J\xC3\xB6rgen Pehrson <jp spektr eu org>",
"Lennart Poettering <lennart poettering de> (Linux ACPI support)",
@@ -1560,7 +1560,8 @@ battstat_applet_fill (PanelApplet *applet)
{
ProgressData *battstat;
AtkObject *atk_widget;
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
+ GAction *action;
gchar *ui_path;
const char *err;
@@ -1598,23 +1599,24 @@ battstat_applet_fill (PanelApplet *applet)
create_layout (battstat);
setup_text_orientation( battstat );
- action_group = gtk_action_group_new ("Battstat Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
+ action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
battstat_menu_actions,
G_N_ELEMENTS (battstat_menu_actions),
battstat);
ui_path = g_build_filename (BATTSTAT_MENU_UI_DIR, "battstat-applet-menu.xml", NULL);
panel_applet_setup_menu_from_file (PANEL_APPLET (battstat->applet),
- ui_path, action_group);
+ ui_path, action_group,
+ GETTEXT_PACKAGE);
g_free (ui_path);
- if (panel_applet_get_locked_down (PANEL_APPLET (battstat->applet))) {
- GtkAction *action;
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "battstat",
+ G_ACTION_GROUP (action_group));
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
+ g_object_bind_property (applet, "locked-down", action, "enabled",
+ G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
- action = gtk_action_group_get_action (action_group, "BattstatProperties");
- gtk_action_set_visible (action, FALSE);
- }
g_object_unref (action_group);
atk_widget = gtk_widget_get_accessible (battstat->applet);
diff --git a/battstat/properties.c b/battstat/properties.c
index 9eb54f3..4e11bf6 100644
--- a/battstat/properties.c
+++ b/battstat/properties.c
@@ -243,15 +243,19 @@ response_cb (GtkDialog *dialog, gint id, gpointer data)
}
void
-prop_cb (GtkAction *action,
- ProgressData *battstat)
+prop_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ ProgressData *battstat;
GtkBuilder *builder;
GtkWidget *combo_ptr, *spin_ptr;
GtkListStore *liststore;
GtkCellRenderer *renderer;
GtkTreeIter iter;
+ battstat = (ProgressData *) user_data;
+
if (DEBUG) g_print("prop_cb()\n");
if (battstat->prop_win) {
diff --git a/charpick/charpick-applet-menu.xml b/charpick/charpick-applet-menu.xml
index b1af96a..4838034 100644
--- a/charpick/charpick-applet-menu.xml
+++ b/charpick/charpick-applet-menu.xml
@@ -1,4 +1,14 @@
-<menuitem name="Item 1" action="Preferences" />
-<menuitem name="Item 2" action="Help" />
-<menuitem name="Item 3" action="About" />
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">charpick.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">charpick.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">charpick.about</attribute>
+ </item>
+</section>
diff --git a/charpick/charpick.c b/charpick/charpick.c
index f508f1c..628f3c0 100644
--- a/charpick/charpick.c
+++ b/charpick/charpick.c
@@ -587,9 +587,12 @@ static void applet_change_orient(PanelApplet *applet, PanelAppletOrient o, gpoin
static void
-about (GtkAction *action,
- charpick_data *curr_data)
+about (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ charpick_data *curr_data = (charpick_data *) user_data;
+
static const char * const authors[] = {
"Alexandre Muñiz <munizao xprt net>",
"Kevin Vandersloot",
@@ -618,9 +621,11 @@ about (GtkAction *action,
static void
-help_cb (GtkAction *action,
- charpick_data *curr_data)
+help_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ charpick_data *curr_data = (charpick_data *) user_data;
GError *error = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (curr_data->applet)),
@@ -714,16 +719,10 @@ get_chartable (charpick_data *curr_data)
}
-static const GtkActionEntry charpick_applet_menu_actions [] = {
- { "Preferences", GTK_STOCK_PROPERTIES, N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (show_preferences_dialog) },
- { "Help", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (help_cb) },
- { "About", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (about) }
+static const GActionEntry charpick_applet_menu_actions [] = {
+ { "preferences", show_preferences_dialog, NULL, NULL, NULL },
+ { "help", help_cb, NULL, NULL, NULL },
+ { "about", about, NULL, NULL, NULL }
};
void
@@ -755,7 +754,8 @@ charpicker_applet_fill (PanelApplet *applet)
GdkAtom utf8_atom;
GList *list;
gchar *string;
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
+ GAction *action;
gchar *ui_path;
g_set_application_name (_("Character Palette"));
@@ -834,23 +834,24 @@ charpicker_applet_fill (PanelApplet *applet)
gtk_widget_show_all (GTK_WIDGET (applet));
- action_group = gtk_action_group_new ("Charpicker Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
- charpick_applet_menu_actions,
- G_N_ELEMENTS (charpick_applet_menu_actions),
- curr_data);
+ action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
+ charpick_applet_menu_actions,
+ G_N_ELEMENTS (charpick_applet_menu_actions),
+ curr_data);
ui_path = g_build_filename (CHARPICK_MENU_UI_DIR, "charpick-applet-menu.xml", NULL);
- panel_applet_setup_menu_from_file (PANEL_APPLET (applet),
- ui_path, action_group);
+ panel_applet_setup_menu_from_file (applet,
+ ui_path, action_group,
+ GETTEXT_PACKAGE);
g_free (ui_path);
- if (panel_applet_get_locked_down (PANEL_APPLET (applet))) {
- GtkAction *action;
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "charpick",
+ G_ACTION_GROUP (action_group));
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
+ g_object_bind_property (applet, "locked-down", action, "enabled",
+ G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
- action = gtk_action_group_get_action (action_group, "Preferences");
- gtk_action_set_visible (action, FALSE);
- }
g_object_unref (action_group);
register_stock_for_edit ();
diff --git a/charpick/charpick.h b/charpick/charpick.h
index 1ce2a72..6e87153 100644
--- a/charpick/charpick.h
+++ b/charpick/charpick.h
@@ -47,8 +47,9 @@ void build_table (charpick_data *curr_data);
void add_to_popup_menu (charpick_data *curr_data);
void populate_menu (charpick_data *curr_data);
void save_chartable (charpick_data *curr_data);
-void show_preferences_dialog (GtkAction *action,
- charpick_data *curr_data);
+void show_preferences_dialog (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
void add_edit_dialog_create (charpick_data *curr_data,
gchar *string,
diff --git a/charpick/properties.c b/charpick/properties.c
index a24c639..a6bcdf5 100644
--- a/charpick/properties.c
+++ b/charpick/properties.c
@@ -527,9 +527,12 @@ response_cb (GtkDialog *dialog, gint id, gpointer data)
}
void
-show_preferences_dialog (GtkAction *action,
- charpick_data *curr_data)
+show_preferences_dialog (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ charpick_data *curr_data = (charpick_data *) user_data;
+
if (curr_data->propwindow) {
gtk_window_set_screen (GTK_WINDOW (curr_data->propwindow),
gtk_widget_get_screen (curr_data->applet));
diff --git a/cpufreq/cpufreq-applet-menu.xml b/cpufreq/cpufreq-applet-menu.xml
index 9837581..86ddac1 100644
--- a/cpufreq/cpufreq-applet-menu.xml
+++ b/cpufreq/cpufreq-applet-menu.xml
@@ -1,4 +1,14 @@
-<menuitem name="CPUFreq Preferences Item" action="CPUFreqAppletPreferences" />
-<menuitem name="CPUFreq Help Item" action="CPUFreqAppletHelp" />
-<menuitem name="CPUFreq About Item" action="CPUFreqAppletAbout" />
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">cpufreq.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">cpufreq.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">cpufreq.about</attribute>
+ </item>
+</section>
diff --git a/cpufreq/src/cpufreq-applet.c b/cpufreq/src/cpufreq-applet.c
index 8f2b05c..90869f3 100644
--- a/cpufreq/src/cpufreq-applet.c
+++ b/cpufreq/src/cpufreq-applet.c
@@ -79,12 +79,15 @@ struct _CPUFreqAppletClass {
static void cpufreq_applet_init (CPUFreqApplet *applet);
static void cpufreq_applet_class_init (CPUFreqAppletClass *klass);
-static void cpufreq_applet_preferences_cb (GtkAction *action,
- CPUFreqApplet *applet);
-static void cpufreq_applet_help_cb (GtkAction *action,
- CPUFreqApplet *applet);
-static void cpufreq_applet_about_cb (GtkAction *action,
- CPUFreqApplet *applet);
+static void cpufreq_applet_preferences_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
+static void cpufreq_applet_help_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
+static void cpufreq_applet_about_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
static void cpufreq_applet_pixmap_set_image (CPUFreqApplet *applet,
gint perc);
@@ -119,16 +122,10 @@ static const gchar *const cpufreq_icons[] = {
NULL
};
-static const GtkActionEntry cpufreq_applet_menu_actions[] = {
- { "CPUFreqAppletPreferences", GTK_STOCK_PROPERTIES, N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (cpufreq_applet_preferences_cb) },
- { "CPUFreqAppletHelp", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (cpufreq_applet_help_cb) },
- { "CPUFreqAppletAbout", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (cpufreq_applet_about_cb) }
+static const GActionEntry cpufreq_applet_menu_actions [] = {
+ { "preferences", cpufreq_applet_preferences_cb, NULL, NULL, NULL },
+ { "help", cpufreq_applet_help_cb, NULL, NULL, NULL },
+ { "about", cpufreq_applet_about_cb, NULL, NULL, NULL }
};
G_DEFINE_TYPE (CPUFreqApplet, cpufreq_applet, PANEL_TYPE_APPLET)
@@ -557,17 +554,21 @@ cpufreq_applet_change_orient (PanelApplet *pa, PanelAppletOrient orient)
}
static void
-cpufreq_applet_preferences_cb (GtkAction *action,
- CPUFreqApplet *applet)
+cpufreq_applet_preferences_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ CPUFreqApplet *applet = (CPUFreqApplet *) user_data;
cpufreq_preferences_dialog_run (applet->prefs,
gtk_widget_get_screen (GTK_WIDGET (applet)));
}
static void
-cpufreq_applet_help_cb (GtkAction *action,
- CPUFreqApplet *applet)
+cpufreq_applet_help_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ CPUFreqApplet *applet = (CPUFreqApplet *) user_data;
GError *error = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (applet)),
@@ -583,8 +584,9 @@ cpufreq_applet_help_cb (GtkAction *action,
}
static void
-cpufreq_applet_about_cb (GtkAction *action,
- CPUFreqApplet *applet)
+cpufreq_applet_about_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
static const gchar *const authors[] = {
"Carlos Garcia Campos <carlosgc gnome org>",
@@ -936,7 +938,8 @@ cpufreq_applet_prefs_show_mode_changed (CPUFreqPrefs *prefs,
static void
cpufreq_applet_setup (CPUFreqApplet *applet)
{
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
+ GAction *action;
gchar *ui_path;
AtkObject *atk_obj;
gchar *prefs_key;
@@ -978,23 +981,24 @@ cpufreq_applet_setup (CPUFreqApplet *applet)
(gpointer) applet);
/* Setup the menus */
- action_group = gtk_action_group_new ("CPUFreq Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
+ action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
cpufreq_applet_menu_actions,
G_N_ELEMENTS (cpufreq_applet_menu_actions),
applet);
ui_path = g_build_filename (CPUFREQ_MENU_UI_DIR, "cpufreq-applet-menu.xml", NULL);
panel_applet_setup_menu_from_file (PANEL_APPLET (applet),
- ui_path, action_group);
+ ui_path, action_group,
+ GETTEXT_PACKAGE);
g_free (ui_path);
- if (panel_applet_get_locked_down (PANEL_APPLET (applet))) {
- GtkAction *action;
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "cpufreq",
+ G_ACTION_GROUP (action_group));
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
+ g_object_bind_property (applet, "locked-down", action, "enabled",
+ G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
- action = gtk_action_group_get_action (action_group, "CPUFreqPreferences");
- gtk_action_set_visible (action, FALSE);
- }
g_object_unref (action_group);
atk_obj = gtk_widget_get_accessible (GTK_WIDGET (applet));
diff --git a/drivemount/drivemount-applet-menu.xml b/drivemount/drivemount-applet-menu.xml
index efc2659..0c5f5cf 100644
--- a/drivemount/drivemount-applet-menu.xml
+++ b/drivemount/drivemount-applet-menu.xml
@@ -1,3 +1,10 @@
-<menuitem name="Help" action="Help" />
-<menuitem name="About" action="About" />
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">drivemount.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">drivemount.about</attribute>
+ </item>
+</section>
diff --git a/drivemount/drivemount.c b/drivemount/drivemount.c
index b8ce52a..cceea8d 100644
--- a/drivemount/drivemount.c
+++ b/drivemount/drivemount.c
@@ -84,9 +84,12 @@ change_background (PanelApplet *applet,
}
static void
-display_about_dialog (GtkAction *action,
- DriveList *drive_list)
+display_about_dialog (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ DriveList *drive_list = (DriveList *) user_data;
+
const gchar *authors[] = {
"James Henstridge <jamesh canonical com>",
NULL
@@ -109,9 +112,11 @@ display_about_dialog (GtkAction *action,
}
static void
-display_help (GtkAction *action,
- DriveList *drive_list)
+display_help (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ DriveList *drive_list = (DriveList *) user_data;
GdkScreen *screen;
GError *error = NULL;
@@ -140,13 +145,9 @@ display_help (GtkAction *action,
}
}
-static const GtkActionEntry applet_menu_actions[] = {
- { "Help", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (display_help) },
- { "About", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (display_about_dialog) }
+static const GActionEntry applet_menu_actions [] = {
+ { "help", display_help, NULL, NULL, NULL },
+ { "about", display_about_dialog, NULL, NULL, NULL }
};
static gboolean
@@ -157,7 +158,7 @@ applet_factory (PanelApplet *applet,
gboolean ret = FALSE;
GtkWidget *drive_list;
AtkObject *ao;
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
gchar *ui_path;
if (!strcmp (iid, drivemount_iid)) {
@@ -186,15 +187,18 @@ applet_factory (PanelApplet *applet,
panel_applet_get_orient (applet),
DRIVE_LIST (drive_list));
- action_group = gtk_action_group_new ("DriveMount Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
- applet_menu_actions,
- G_N_ELEMENTS (applet_menu_actions),
- drive_list);
+ action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
+ applet_menu_actions,
+ G_N_ELEMENTS (applet_menu_actions),
+ drive_list);
ui_path = g_build_filename (DRIVEMOUNT_MENU_UI_DIR, "drivemount-applet-menu.xml", NULL);
- panel_applet_setup_menu_from_file (applet, ui_path, action_group);
+ panel_applet_setup_menu_from_file (applet, ui_path, action_group, GETTEXT_PACKAGE);
g_free (ui_path);
+
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "drivemount",
+ G_ACTION_GROUP (action_group));
+
g_object_unref (action_group);
ao = gtk_widget_get_accessible (GTK_WIDGET (applet));
diff --git a/geyes/geyes-applet-menu.xml b/geyes/geyes-applet-menu.xml
index 860052a..631f7ea 100644
--- a/geyes/geyes-applet-menu.xml
+++ b/geyes/geyes-applet-menu.xml
@@ -1,5 +1,14 @@
-<menuitem name="Item 1" action="Props" />
-<menuitem name="Item 2" action="Help" />
-<menuitem name="Item 3" action="About" />
-
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">geyes.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">geyes.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">geyes.about</attribute>
+ </item>
+</section>
diff --git a/geyes/geyes.c b/geyes/geyes.c
index 1cfebd7..a0213a2 100644
--- a/geyes/geyes.c
+++ b/geyes/geyes.c
@@ -133,9 +133,12 @@ timer_cb (EyesApplet *eyes_applet)
}
static void
-about_cb (GtkAction *action,
- EyesApplet *eyes_applet)
+about_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ EyesApplet *eyes_applet = (EyesApplet *) user_data;
+
static const gchar *authors [] = {
"Dave Camp <campd oit edu>",
NULL
@@ -294,9 +297,11 @@ destroy_cb (GtkWidget *object, EyesApplet *eyes_applet)
}
static void
-help_cb (GtkAction *action,
- EyesApplet *eyes_applet)
+help_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ EyesApplet *eyes_applet = (EyesApplet *) user_data;
GError *error = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (eyes_applet->applet)),
@@ -316,17 +321,10 @@ help_cb (GtkAction *action,
}
}
-
-static const GtkActionEntry geyes_applet_menu_actions [] = {
- { "Props", GTK_STOCK_PROPERTIES, N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (properties_cb) },
- { "Help", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (help_cb) },
- { "About", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (about_cb) }
+static const GActionEntry geyes_applet_menu_actions [] = {
+ { "preferences", properties_cb, NULL, NULL, NULL },
+ { "help", help_cb, NULL, NULL, NULL },
+ { "about", about_cb, NULL, NULL, NULL }
};
static void
@@ -348,7 +346,8 @@ static gboolean
geyes_applet_fill (PanelApplet *applet)
{
EyesApplet *eyes_applet;
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
+ GAction *action;
gchar *ui_path;
g_set_application_name (_("Eyes"));
@@ -363,23 +362,25 @@ geyes_applet_fill (PanelApplet *applet)
eyes_applet->timeout_id = g_timeout_add (
UPDATE_TIMEOUT, (GSourceFunc) timer_cb, eyes_applet);
- action_group = gtk_action_group_new ("Geyes Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
- geyes_applet_menu_actions,
- G_N_ELEMENTS (geyes_applet_menu_actions),
- eyes_applet);
+ action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
+ geyes_applet_menu_actions,
+ G_N_ELEMENTS (geyes_applet_menu_actions),
+ eyes_applet);
ui_path = g_build_filename (GEYES_MENU_UI_DIR, "geyes-applet-menu.xml", NULL);
panel_applet_setup_menu_from_file (eyes_applet->applet,
- ui_path, action_group);
+ ui_path, action_group,
+ GETTEXT_PACKAGE);
g_free (ui_path);
- if (panel_applet_get_locked_down (eyes_applet->applet)) {
- GtkAction *action;
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "geyes",
+ G_ACTION_GROUP (action_group));
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
+ g_object_bind_property (applet, "locked-down",
+ action, "enabled",
+ G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
- action = gtk_action_group_get_action (action_group, "Props");
- gtk_action_set_visible (action, FALSE);
- }
g_object_unref (action_group);
gtk_widget_set_tooltip_text (GTK_WIDGET (eyes_applet->applet), _("Eyes"));
diff --git a/geyes/geyes.h b/geyes/geyes.h
index d8266a0..1057801 100644
--- a/geyes/geyes.h
+++ b/geyes/geyes.h
@@ -80,7 +80,8 @@ void theme_dirs_create (void);
int load_theme (EyesApplet *eyes_applet,
const gchar *theme_dir);
-void properties_cb (GtkAction *action,
- EyesApplet *eyes_applet);
+void properties_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
#endif
diff --git a/geyes/themes.c b/geyes/themes.c
index 1929cba..fc30dca 100644
--- a/geyes/themes.c
+++ b/geyes/themes.c
@@ -243,9 +243,11 @@ presponse_cb (GtkDialog *dialog, gint id, gpointer data)
}
void
-properties_cb (GtkAction *action,
- EyesApplet *eyes_applet)
+properties_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ EyesApplet *eyes_applet = (EyesApplet *) user_data;
GtkWidget *pbox, *hbox;
GtkWidget *vbox, *indent;
GtkWidget *categories_vbox;
diff --git a/gweather/gweather-applet-menu.xml b/gweather/gweather-applet-menu.xml
index 8fc0a35..4020bc0 100644
--- a/gweather/gweather-applet-menu.xml
+++ b/gweather/gweather-applet-menu.xml
@@ -1,7 +1,24 @@
-<menuitem name="Item 1" action="Details" />
-<menuitem name="Item 2" action="Update" />
-<separator/>
-<menuitem name="Item 3" action="Props" />
-<menuitem name="Item 4" action="Help" />
-<menuitem name="Item 5" action="About" />
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Details</attribute>
+ <attribute name="action">gweather.details</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Update</attribute>
+ <attribute name="action">gweather.update</attribute>
+ </item>
+</section>
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">gweather.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">gweather.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">gweather.about</attribute>
+ </item>
+</section>
diff --git a/gweather/gweather-applet.c b/gweather/gweather-applet.c
index 15a61c4..3b5f817 100644
--- a/gweather/gweather-applet.c
+++ b/gweather/gweather-applet.c
@@ -46,16 +46,19 @@
#define MAX_CONSECUTIVE_FAULTS (3)
-static void about_cb (GtkAction *action,
- GWeatherApplet *gw_applet)
+static void about_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
-
+ GWeatherApplet *gw_applet = (GWeatherApplet *) user_data;
gweather_about_run (gw_applet);
}
-static void help_cb (GtkAction *action,
- GWeatherApplet *gw_applet)
+static void help_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ GWeatherApplet *gw_applet = (GWeatherApplet *) user_data;
GError *error = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (gw_applet->applet)),
@@ -75,9 +78,12 @@ static void help_cb (GtkAction *action,
}
}
-static void pref_cb (GtkAction *action,
- GWeatherApplet *gw_applet)
+static void pref_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ GWeatherApplet *gw_applet = (GWeatherApplet *) user_data;
+
if (gw_applet->pref_dialog) {
gtk_window_present (GTK_WINDOW (gw_applet->pref_dialog));
} else {
@@ -88,9 +94,12 @@ static void pref_cb (GtkAction *action,
}
}
-static void details_cb (GtkAction *action,
- GWeatherApplet *gw_applet)
+static void details_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ GWeatherApplet *gw_applet = (GWeatherApplet *) user_data;
+
if (gw_applet->details_dialog) {
gtk_window_present (GTK_WINDOW (gw_applet->details_dialog));
} else {
@@ -102,29 +111,20 @@ static void details_cb (GtkAction *action,
}
}
-static void update_cb (GtkAction *action,
- GWeatherApplet *gw_applet)
+static void update_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ GWeatherApplet *gw_applet = (GWeatherApplet *) user_data;
gweather_update (gw_applet);
}
-
-static const GtkActionEntry weather_applet_menu_actions [] = {
- { "Details", NULL, N_("_Details"),
- NULL, NULL,
- G_CALLBACK (details_cb) },
- { "Update", GTK_STOCK_REFRESH, N_("_Update"),
- NULL, NULL,
- G_CALLBACK (update_cb) },
- { "Props", GTK_STOCK_PROPERTIES, N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (pref_cb) },
- { "Help", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (help_cb) },
- { "About", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (about_cb) }
+static const GActionEntry weather_applet_menu_actions [] = {
+ { "details", details_cb, NULL, NULL, NULL },
+ { "update", update_cb, NULL, NULL, NULL },
+ { "preferences", pref_cb, NULL, NULL, NULL },
+ { "help", help_cb, NULL, NULL, NULL },
+ { "about", about_cb, NULL, NULL, NULL }
};
static void place_widgets (GWeatherApplet *gw_applet)
@@ -236,7 +236,7 @@ static gboolean clicked_cb (GtkWidget *widget, GdkEventButton *ev, gpointer data
if (ev->type == GDK_BUTTON_PRESS) {
if (!gw_applet->details_dialog)
- details_cb (NULL, gw_applet);
+ details_cb (NULL, NULL, gw_applet);
else
gtk_widget_destroy (GTK_WIDGET (gw_applet->details_dialog));
@@ -258,7 +258,7 @@ key_press_cb (GtkWidget *widget, GdkEventKey *event, GWeatherApplet *gw_applet)
break;
case GDK_KEY_d:
if (event->state == GDK_CONTROL_MASK) {
- details_cb (NULL, gw_applet);
+ details_cb (NULL, NULL, gw_applet);
return TRUE;
}
break;
@@ -268,7 +268,7 @@ key_press_cb (GtkWidget *widget, GdkEventKey *event, GWeatherApplet *gw_applet)
case GDK_KEY_Return:
case GDK_KEY_space:
case GDK_KEY_KP_Space:
- details_cb (NULL, gw_applet);
+ details_cb (NULL, NULL, gw_applet);
return TRUE;
default:
break;
@@ -309,7 +309,8 @@ static void setup_network_monitor (GWeatherApplet *gw_applet);
void gweather_applet_create (GWeatherApplet *gw_applet)
{
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
+ GAction *action;
gchar *ui_path;
AtkObject *atk_obj;
@@ -346,23 +347,24 @@ void gweather_applet_create (GWeatherApplet *gw_applet)
gw_applet->orient = panel_applet_get_orient (gw_applet->applet);
- action_group = gtk_action_group_new ("GWeather Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
- weather_applet_menu_actions,
- G_N_ELEMENTS (weather_applet_menu_actions),
- gw_applet);
+ action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
+ weather_applet_menu_actions,
+ G_N_ELEMENTS (weather_applet_menu_actions),
+ gw_applet);
ui_path = g_build_filename (GWEATHER_MENU_UI_DIR, "gweather-applet-menu.xml", NULL);
panel_applet_setup_menu_from_file (gw_applet->applet,
- ui_path, action_group);
+ ui_path, action_group,
+ GETTEXT_PACKAGE);
g_free (ui_path);
- if (panel_applet_get_locked_down (gw_applet->applet)) {
- GtkAction *action;
+ gtk_widget_insert_action_group (GTK_WIDGET (gw_applet->applet), "gweather",
+ G_ACTION_GROUP (action_group));
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
+ g_object_bind_property (gw_applet->applet, "locked-down", action, "enabled",
+ G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
- action = gtk_action_group_get_action (action_group, "Props");
- gtk_action_set_visible (action, FALSE);
- }
g_object_unref (action_group);
place_widgets(gw_applet);
diff --git a/mini-commander/src/about.c b/mini-commander/src/about.c
index 2832127..3ee01b9 100644
--- a/mini-commander/src/about.c
+++ b/mini-commander/src/about.c
@@ -26,8 +26,9 @@
#include "about.h"
-void about_box (GtkAction *action,
- MCData *mcdata)
+void about_box (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
static const gchar *authors[] = {
"Oliver Maruhn <oliver maruhn com>",
diff --git a/mini-commander/src/about.h b/mini-commander/src/about.h
index 875ea62..cf56872 100644
--- a/mini-commander/src/about.h
+++ b/mini-commander/src/about.h
@@ -1,4 +1,5 @@
#include "mini-commander_applet.h"
-void about_box (GtkAction *action,
- MCData *mcdata);
+void about_box (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
diff --git a/mini-commander/src/help.c b/mini-commander/src/help.c
index b5c4b66..608828e 100644
--- a/mini-commander/src/help.c
+++ b/mini-commander/src/help.c
@@ -24,9 +24,11 @@
#include "help.h"
void
-show_help (GtkAction *action,
- MCData *mcdata)
+show_help (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ MCData *mcdata = (MCData *) user_data;
GError *error = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (mcdata->applet)),
diff --git a/mini-commander/src/help.h b/mini-commander/src/help.h
index 495984a..3daac03 100644
--- a/mini-commander/src/help.h
+++ b/mini-commander/src/help.h
@@ -1,4 +1,5 @@
#include "mini-commander_applet.h"
-void show_help (GtkAction *action,
- MCData *mcdata);
+void show_help (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
diff --git a/mini-commander/src/mini-commander-applet-menu.xml
b/mini-commander/src/mini-commander-applet-menu.xml
index 5cef44f..8ed4bcf 100644
--- a/mini-commander/src/mini-commander-applet-menu.xml
+++ b/mini-commander/src/mini-commander-applet-menu.xml
@@ -1,4 +1,14 @@
-<menuitem name="Item 1" action="Props" />
-<menuitem name="Item 2" action="Help" />
-<menuitem name="Item 3" action="About" />
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">mc.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">mc.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">mc.about</attribute>
+ </item>
+</section>
diff --git a/mini-commander/src/mini-commander_applet.c b/mini-commander/src/mini-commander_applet.c
index 1bc0ee2..abfc328 100644
--- a/mini-commander/src/mini-commander_applet.c
+++ b/mini-commander/src/mini-commander_applet.c
@@ -49,16 +49,10 @@
static gboolean icons_initialized = FALSE;
static GtkIconSize button_icon_size = 0;
-static const GtkActionEntry mini_commander_menu_actions [] = {
- { "Props", GTK_STOCK_PROPERTIES, N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (mc_show_preferences) },
- { "Help", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (show_help) },
- { "About", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (about_box) }
+static const GActionEntry mini_commander_menu_actions [] = {
+ { "preferences", mc_show_preferences, NULL, NULL, NULL },
+ { "help", show_help, NULL, NULL, NULL },
+ { "about", about_box, NULL, NULL, NULL }
};
typedef struct {
@@ -334,7 +328,8 @@ mini_commander_applet_fill (PanelApplet *applet)
{
MCData *mc;
GConfClient *client;
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
+ GAction *action;
gchar *ui_path;
client = gconf_client_get_default ();
@@ -387,21 +382,22 @@ mini_commander_applet_fill (PanelApplet *applet)
g_signal_connect (mc->applet, "key_press_event",
G_CALLBACK (key_press_cb), mc);
- action_group = gtk_action_group_new ("MiniCommander Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
- mini_commander_menu_actions,
- G_N_ELEMENTS (mini_commander_menu_actions),
- mc);
+ action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
+ mini_commander_menu_actions,
+ G_N_ELEMENTS (mini_commander_menu_actions),
+ mc);
ui_path = g_build_filename (MC_MENU_UI_DIR, "mini-commander-applet-menu.xml", NULL);
- panel_applet_setup_menu_from_file (mc->applet, ui_path, action_group);
+ panel_applet_setup_menu_from_file (mc->applet, ui_path, action_group, GETTEXT_PACKAGE);
- if (panel_applet_get_locked_down (mc->applet)) {
- GtkAction *action;
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "mc",
+ G_ACTION_GROUP (action_group));
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
+ g_object_bind_property (applet, "locked-down",
+ action, "enabled",
+ G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
- action = gtk_action_group_get_action (action_group, "Props");
- gtk_action_set_visible (action, FALSE);
- }
g_object_unref (action_group);
set_atk_name_description (GTK_WIDGET (applet),
diff --git a/mini-commander/src/preferences.c b/mini-commander/src/preferences.c
index 7eb4a55..805a0a5 100644
--- a/mini-commander/src/preferences.c
+++ b/mini-commander/src/preferences.c
@@ -795,9 +795,12 @@ mc_preferences_setup_dialog (GtkBuilder *builder,
}
void
-mc_show_preferences (GtkAction *action,
- MCData *mc)
+mc_show_preferences (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ MCData *mc = (MCData *) user_data;
+
if (!mc->prefs_dialog.dialog) {
GtkBuilder *builder;
diff --git a/mini-commander/src/preferences.h b/mini-commander/src/preferences.h
index 875a7fa..2b1940a 100644
--- a/mini-commander/src/preferences.h
+++ b/mini-commander/src/preferences.h
@@ -97,8 +97,9 @@ typedef struct {
#include "mini-commander_applet.h"
void mc_load_preferences (MCData *mc);
-void mc_show_preferences (GtkAction *action,
- MCData *mc);
+void mc_show_preferences (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
void mc_macros_free (GSList *macros);
gboolean mc_key_writable (MCData *mc,
diff --git a/mixer/applet.c b/mixer/applet.c
index 19d366f..057f289 100644
--- a/mixer/applet.c
+++ b/mixer/applet.c
@@ -88,8 +88,9 @@ static void cb_gconf (GConfClient *client,
GConfEntry *entry,
gpointer data);
-static void cb_verb (GtkAction *action,
- gpointer data);
+static void cb_verb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
static void cb_theme_change (GtkIconTheme *icon_theme,
gpointer data);
@@ -370,28 +371,26 @@ gnome_volume_applet_setup_timeout (GnomeVolumeApplet *applet)
}
}
+static void
+cb_activate (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GVariant *state = g_action_get_state (G_ACTION (action));
+ g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state)));
+ g_variant_unref (state);
+}
+
gboolean
gnome_volume_applet_setup (GnomeVolumeApplet *applet,
GList *elements)
{
- static const GtkActionEntry actions[] = {
- { "RunMixer", NULL, N_("_Open Volume Control"),
- NULL, NULL,
- G_CALLBACK (cb_verb) },
- { "Help", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (cb_verb) },
- { "About", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (cb_verb) },
- { "Pref", GTK_STOCK_PROPERTIES, N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (cb_verb) }
- };
- static const GtkToggleActionEntry toggle_actions[] = {
- { "Mute", NULL, N_("Mu_te"),
- NULL, NULL,
- G_CALLBACK (cb_verb), FALSE }
+ static const GActionEntry actions [] = {
+ { "mute", cb_activate, NULL, "false", cb_verb },
+ { "run", cb_verb, NULL, NULL, NULL },
+ { "preferences", cb_verb, NULL, NULL, NULL },
+ { "help", cb_verb, NULL, NULL, NULL },
+ { "about", cb_verb, NULL, NULL, NULL }
};
gchar *key;
@@ -434,21 +433,20 @@ gnome_volume_applet_setup (GnomeVolumeApplet *applet,
panel_applet_get_orient (PANEL_APPLET (applet)));
/* menu */
- applet->action_group = gtk_action_group_new ("Mixer Applet Actions");
- gtk_action_group_set_translation_domain (applet->action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (applet->action_group,
+ applet->action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (applet->action_group),
actions,
G_N_ELEMENTS (actions),
applet);
- gtk_action_group_add_toggle_actions (applet->action_group,
- toggle_actions,
- G_N_ELEMENTS (toggle_actions),
- applet);
ui_path = g_build_filename (MIXER_MENU_UI_DIR, "mixer-applet-menu.xml", NULL);
panel_applet_setup_menu_from_file (PANEL_APPLET (applet),
- ui_path, applet->action_group);
+ ui_path, applet->action_group,
+ GETTEXT_PACKAGE);
g_free (ui_path);
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "mixer",
+ G_ACTION_GROUP (applet->action_group));
+
gnome_volume_applet_refresh (applet, TRUE, -1, -1);
if (res) {
gnome_volume_applet_setup_timeout (applet);
@@ -678,18 +676,16 @@ static void
gnome_volume_applet_update_mute_action (GnomeVolumeApplet *applet,
gboolean newmute)
{
- GtkAction *action;
+ GSimpleAction *action;
if (!applet->action_group)
return;
- action = gtk_action_group_get_action (applet->action_group, "Mute");
- if (newmute == gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)))
+ action = (GSimpleAction *) g_action_map_lookup_action (G_ACTION_MAP (applet->action_group), "mute");
+ if (newmute == g_variant_get_boolean (g_action_get_state (G_ACTION (action))))
return;
- gtk_action_block_activate (action);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), newmute);
- gtk_action_unblock_activate (action);
+ g_simple_action_set_state (action, g_variant_new_boolean (newmute));
}
gboolean
@@ -1378,15 +1374,16 @@ cb_prefs_destroy (GtkWidget *widget,
}
static void
-cb_verb (GtkAction *action,
- gpointer data)
+cb_verb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
- GnomeVolumeApplet *applet = GNOME_VOLUME_APPLET (data);
- const gchar *verbname = gtk_action_get_name (action);
+ GnomeVolumeApplet *applet = GNOME_VOLUME_APPLET (user_data);
+ const gchar *verbname = g_action_get_name (G_ACTION (action));
- if (!strcmp (verbname, "RunMixer")) {
+ if (!strcmp (verbname, "run")) {
gnome_volume_applet_run_mixer (applet);
- } else if (!strcmp (verbname, "Help")) {
+ } else if (!strcmp (verbname, "help")) {
GError *error = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (applet)),
@@ -1406,7 +1403,7 @@ cb_verb (GtkAction *action,
gtk_widget_show (dialog);
g_error_free (error);
}
- } else if (!strcmp (verbname, "About")) {
+ } else if (!strcmp (verbname, "about")) {
const gchar *authors[] = { "Ronald Bultje <rbultje ronald bitfreak net>",
NULL };
@@ -1427,7 +1424,7 @@ cb_verb (GtkAction *action,
g_free (comments);
- } else if (!strcmp (verbname, "Pref")) {
+ } else if (!strcmp (verbname, "preferences")) {
if (!applet->mixer) {
show_no_mixer_dialog (applet);
} else {
@@ -1445,12 +1442,12 @@ cb_verb (GtkAction *action,
G_CALLBACK (cb_prefs_destroy), applet);
gtk_widget_show (applet->prefs);
}
- } else if (!strcmp (verbname, "Mute")) {
+ } else if (!strcmp (verbname, "mute")) {
if (!applet->mixer) {
show_no_mixer_dialog (applet);
} else {
gboolean mute = applet->state & 1,
- want_mute = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ want_mute = g_variant_get_boolean (parameter);
if (mute != want_mute)
gnome_volume_applet_toggle_mute (applet);
}
diff --git a/mixer/applet.h b/mixer/applet.h
index dac2844..110dadd 100644
--- a/mixer/applet.h
+++ b/mixer/applet.h
@@ -53,7 +53,7 @@ struct _GnomeVolumeApplet {
PanelApplet parent;
/* menu actions */
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
/* our main icon, which is our panel user interface */
GtkImage *image;
diff --git a/mixer/mixer-applet-menu.xml b/mixer/mixer-applet-menu.xml
index d0d2ab6..a4c7d4d 100644
--- a/mixer/mixer-applet-menu.xml
+++ b/mixer/mixer-applet-menu.xml
@@ -1,7 +1,24 @@
-<menuitem name="Mute" action="Mute" />
-<menuitem name="RunMixer" action="RunMixer" />
-<separator/>
-<menuitem name="Pref" action="Pref" />
-<menuitem name="Help" action="Help" />
-<menuitem name="About" action="About" />
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Open Volume Control</attribute>
+ <attribute name="action">mixer.run</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Mu_te</attribute>
+ <attribute name="action">mixer.mute</attribute>
+ </item>
+</section>
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">mixer.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">mixer.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">mixer.about</attribute>
+ </item>
+</section>
diff --git a/multiload/global.h b/multiload/global.h
index 4830c1a..2d200a2 100644
--- a/multiload/global.h
+++ b/multiload/global.h
@@ -81,8 +81,9 @@ struct _MultiloadApplet
/* show properties dialog */
G_GNUC_INTERNAL void
-multiload_properties_cb (GtkAction *action,
- MultiloadApplet *ma);
+multiload_properties_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
/* remove the old graphs and rebuild them */
G_GNUC_INTERNAL void
diff --git a/multiload/main.c b/multiload/main.c
index a8030b1..cf027d9 100644
--- a/multiload/main.c
+++ b/multiload/main.c
@@ -30,9 +30,12 @@
#include "global.h"
static void
-about_cb (GtkAction *action,
- MultiloadApplet *ma)
+about_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ MultiloadApplet *ma = (MultiloadApplet *) user_data;
+
const gchar * const authors[] =
{
"Martin Baulig <martin home-of-linux org>",
@@ -64,10 +67,11 @@ about_cb (GtkAction *action,
}
static void
-help_cb (GtkAction *action,
- MultiloadApplet *ma)
+help_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
-
+ MultiloadApplet *ma = (MultiloadApplet *) user_data;
GError *error = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (ma->applet)),
@@ -166,9 +170,11 @@ start_procman (MultiloadApplet *ma)
}
static void
-start_procman_cb (GtkAction *action,
- MultiloadApplet *ma)
+start_procman_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ MultiloadApplet *ma = (MultiloadApplet *) user_data;
start_procman (ma);
}
@@ -455,20 +461,12 @@ multiload_applet_refresh(MultiloadApplet *ma)
return;
}
-static const GtkActionEntry multiload_menu_actions [] = {
- { "MultiLoadProperties", GTK_STOCK_PROPERTIES, N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (multiload_properties_cb) },
- { "MultiLoadRunProcman", GTK_STOCK_EXECUTE, N_("_Open System Monitor"),
- NULL, NULL,
- G_CALLBACK (start_procman_cb) },
- { "MultiLoadHelp", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (help_cb) },
- { "MultiLoadAbout", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (about_cb) }
-};
+static const GActionEntry multiload_menu_actions [] = {
+ { "run", start_procman_cb, NULL, NULL, NULL },
+ { "preferences", multiload_properties_cb, NULL, NULL, NULL },
+ { "help", help_cb, NULL, NULL, NULL },
+ { "about", about_cb, NULL, NULL, NULL }
+};
/* create a box and stuff the load graphs inside of it */
static gboolean
@@ -476,7 +474,8 @@ multiload_applet_new(PanelApplet *applet, const gchar *iid, gpointer data)
{
MultiloadApplet *ma;
GConfClient *client;
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
+ GAction *action;
gchar *ui_path;
ma = g_new0(MultiloadApplet, 1);
@@ -495,33 +494,29 @@ multiload_applet_new(PanelApplet *applet, const gchar *iid, gpointer data)
panel_applet_add_preferences (applet, "/schemas/apps/multiload/prefs", NULL);
panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);
- action_group = gtk_action_group_new ("Multiload Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
- multiload_menu_actions,
- G_N_ELEMENTS (multiload_menu_actions),
- ma);
+ action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
+ multiload_menu_actions,
+ G_N_ELEMENTS (multiload_menu_actions),
+ ma);
ui_path = g_build_filename (MULTILOAD_MENU_UI_DIR, "multiload-applet-menu.xml", NULL);
- panel_applet_setup_menu_from_file (applet, ui_path, action_group);
+ panel_applet_setup_menu_from_file (applet, ui_path, action_group, GETTEXT_PACKAGE);
g_free (ui_path);
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "multiload",
+ G_ACTION_GROUP (action_group));
- if (panel_applet_get_locked_down (applet)) {
- GtkAction *action;
-
- action = gtk_action_group_get_action (action_group, "MultiLoadProperties");
- gtk_action_set_visible (action, FALSE);
- }
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
+ g_object_bind_property (applet, "locked-down", action, "enabled",
+ G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
client = gconf_client_get_default ();
if (gconf_client_get_bool (client, "/desktop/gnome/lockdown/inhibit_command_line", NULL) ||
panel_applet_get_locked_down (applet)) {
- GtkAction *action;
-
/* When the panel is locked down or when the command line is inhibited,
it seems very likely that running the procman would be at least harmful */
- action = gtk_action_group_get_action (action_group, "MultiLoadRunProcman");
- gtk_action_set_visible (action, FALSE);
+ action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "run");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action), FALSE);
}
g_object_unref (action_group);
diff --git a/multiload/multiload-applet-menu.xml b/multiload/multiload-applet-menu.xml
index 88d28dd..9866441 100644
--- a/multiload/multiload-applet-menu.xml
+++ b/multiload/multiload-applet-menu.xml
@@ -1,6 +1,20 @@
-<menuitem name="Procman Item" action="MultiLoadRunProcman" />
-<separator/>
-<menuitem name="Properties Item" action="MultiLoadProperties" />
-<menuitem name="Help" action="MultiLoadHelp" />
-<menuitem name="About Item" action="MultiLoadAbout" />
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Open System Monitor</attribute>
+ <attribute name="action">multiload.run</attribute>
+ </item>
+</section>
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">multiload.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">multiload.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">multiload.about</attribute>
+ </item>
+</section>
diff --git a/multiload/properties.c b/multiload/properties.c
index c9b37a0..8a6bbc6 100644
--- a/multiload/properties.c
+++ b/multiload/properties.c
@@ -636,9 +636,11 @@ fill_properties(GtkWidget *dialog, MultiloadApplet *ma)
/* show properties dialog */
void
-multiload_properties_cb (GtkAction *action,
- MultiloadApplet *ma)
+multiload_properties_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ MultiloadApplet *ma = (MultiloadApplet *) user_data;
GtkWidget *dialog = NULL;
if (ma->prop_dialog) {
diff --git a/stickynotes/stickynotes-applet-menu.xml b/stickynotes/stickynotes-applet-menu.xml
index 95d5659..12cd779 100644
--- a/stickynotes/stickynotes-applet-menu.xml
+++ b/stickynotes/stickynotes-applet-menu.xml
@@ -1,10 +1,32 @@
-<menuitem name="new_note" action="new_note" />
-<menuitem name="hide_notes" action="hide_notes" />
-<menuitem name="lock" action="lock" />
-<menuitem name="destroy_all" action="destroy_all" />
-<separator/>
-<menuitem name="preferences" action="preferences" />
-<menuitem name="help" action="help" />
-<menuitem name="about" action="about" />
-
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_New Note</attribute>
+ <attribute name="action">stickynotes.new-note</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Hi_de Notes</attribute>
+ <attribute name="action">stickynotes.hide-notes</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Lock Notes</attribute>
+ <attribute name="action">stickynotes.lock</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Delete Notes</attribute>
+ <attribute name="action">stickynotes.destroy-all</attribute>
+ </item>
+</section>
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Preferences</attribute>
+ <attribute name="action">stickynotes.preferences</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">stickynotes.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">stickynotes.about</attribute>
+ </item>
+</section>
diff --git a/stickynotes/stickynotes_applet.c b/stickynotes/stickynotes_applet.c
index 0a13a3b..eae6d1d 100644
--- a/stickynotes/stickynotes_applet.c
+++ b/stickynotes/stickynotes_applet.c
@@ -28,33 +28,14 @@
StickyNotes *stickynotes = NULL;
/* Popup menu on the applet */
-static const GtkActionEntry stickynotes_applet_menu_actions[] =
-{
- { "new_note", GTK_STOCK_NEW, N_("_New Note"),
- NULL, NULL,
- G_CALLBACK (menu_new_note_cb) },
- { "hide_notes", NULL, N_("Hi_de Notes"),
- NULL, NULL,
- G_CALLBACK (menu_hide_notes_cb) },
- { "destroy_all", GTK_STOCK_DELETE, N_("_Delete Notes"),
- NULL, NULL,
- G_CALLBACK (menu_destroy_all_cb) },
- { "preferences", GTK_STOCK_PROPERTIES, N_("_Preferences"),
- NULL, NULL,
- G_CALLBACK (menu_preferences_cb) },
- { "help", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (menu_help_cb) },
- { "about", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (menu_about_cb) }
-};
-
-static const GtkToggleActionEntry stickynotes_applet_menu_toggle_actions[] =
-{
- { "lock", NULL, N_("_Lock Notes"),
- NULL, NULL,
- G_CALLBACK (menu_toggle_lock_cb), FALSE }
+static const GActionEntry stickynotes_applet_menu_actions [] = {
+ { "new-note", menu_new_note_cb, NULL, NULL, NULL },
+ { "hide-notes", menu_hide_notes_cb, NULL, NULL, NULL },
+ { "lock", menu_toggle_lock_cb, NULL, "false", menu_toggle_lock_state },
+ { "destroy-all", menu_destroy_all_cb, NULL, NULL, NULL },
+ { "preferences", menu_preferences_cb, NULL, NULL, NULL },
+ { "help", menu_help_cb, NULL, NULL, NULL },
+ { "about", menu_about_cb, NULL, NULL, NULL }
};
/* Sticky Notes Icons */
@@ -357,6 +338,7 @@ StickyNotesApplet * stickynotes_applet_new(PanelApplet *panel_applet)
{
AtkObject *atk_obj;
gchar *ui_path;
+ GAction *action;
/* Create Sticky Notes Applet */
StickyNotesApplet *applet = g_new(StickyNotesApplet, 1);
@@ -380,26 +362,22 @@ StickyNotesApplet * stickynotes_applet_new(PanelApplet *panel_applet)
stickynotes_applet_update_icon(applet);
/* Add the popup menu */
- applet->action_group = gtk_action_group_new ("StickyNotes Applet Actions");
- gtk_action_group_set_translation_domain (applet->action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (applet->action_group,
- stickynotes_applet_menu_actions,
- G_N_ELEMENTS (stickynotes_applet_menu_actions),
- applet);
- gtk_action_group_add_toggle_actions (applet->action_group,
- stickynotes_applet_menu_toggle_actions,
- G_N_ELEMENTS (stickynotes_applet_menu_toggle_actions),
- applet);
+ applet->action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (applet->action_group),
+ stickynotes_applet_menu_actions,
+ G_N_ELEMENTS (stickynotes_applet_menu_actions),
+ applet);
ui_path = g_build_filename (STICKYNOTES_MENU_UI_DIR, "stickynotes-applet-menu.xml", NULL);
- panel_applet_setup_menu_from_file(panel_applet, ui_path, applet->action_group);
+ panel_applet_setup_menu_from_file(panel_applet, ui_path, applet->action_group, GETTEXT_PACKAGE);
g_free (ui_path);
- if (panel_applet_get_locked_down (panel_applet)) {
- GtkAction *action;
+ gtk_widget_insert_action_group (GTK_WIDGET (panel_applet), "stickynotes",
+ G_ACTION_GROUP (applet->action_group));
- action = gtk_action_group_get_action (applet->action_group, "preferences");
- gtk_action_set_visible (action, FALSE);
- }
+ action = g_action_map_lookup_action (G_ACTION_MAP (applet->action_group), "preferences");
+ g_object_bind_property (panel_applet, "locked-down",
+ action, "enabled",
+ G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
/* Connect all signals for applet management */
g_signal_connect(G_OBJECT(applet->w_applet), "button-press-event",
@@ -588,22 +566,10 @@ void stickynotes_applet_update_menus(void)
for (l = stickynotes->applets; l != NULL; l = l->next) {
StickyNotesApplet *applet = l->data;
- GSList *proxies, *p;
-
- GtkAction *action = gtk_action_group_get_action (applet->action_group, "lock");
- g_object_set (action,
- "active", locked,
- "sensitive", locked_writable,
- NULL);
-
- proxies = gtk_action_get_proxies (action);
- for (p = proxies; p; p = g_slist_next (p)) {
- if (GTK_IS_CHECK_MENU_ITEM (p->data)) {
- gtk_check_menu_item_set_inconsistent (GTK_CHECK_MENU_ITEM (p->data),
- inconsistent);
- }
- }
+ GSimpleAction *action = (GSimpleAction *) g_action_map_lookup_action (G_ACTION_MAP
(applet->action_group), "lock");
+ g_simple_action_set_enabled (action, locked_writable);
+ g_simple_action_set_state (action, g_variant_new_boolean (locked));
}
}
diff --git a/stickynotes/stickynotes_applet.h b/stickynotes/stickynotes_applet.h
index 779491f..e22f919 100644
--- a/stickynotes/stickynotes_applet.h
+++ b/stickynotes/stickynotes_applet.h
@@ -92,7 +92,7 @@ typedef struct
gint panel_size;
PanelAppletOrient panel_orient;
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
GtkWidget *menu_tip;
} StickyNotesApplet;
diff --git a/stickynotes/stickynotes_applet_callbacks.c b/stickynotes/stickynotes_applet_callbacks.c
index 2aa8aaf..aa5bcd7 100644
--- a/stickynotes/stickynotes_applet_callbacks.c
+++ b/stickynotes/stickynotes_applet_callbacks.c
@@ -278,20 +278,22 @@ destroy_all_response_cb (GtkDialog *dialog, gint id, StickyNotesApplet *applet)
}
/* Menu Callback : New Note */
-void menu_new_note_cb(GtkAction *action, StickyNotesApplet *applet)
+void menu_new_note_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
+ StickyNotesApplet *applet = (StickyNotesApplet *) user_data;
popup_add_note (applet, NULL);
}
/* Menu Callback : Hide Notes */
-void menu_hide_notes_cb(GtkAction *action, StickyNotesApplet *applet)
+void menu_hide_notes_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
stickynote_show_notes (FALSE);
}
/* Menu Callback : Destroy all sticky notes */
-void menu_destroy_all_cb(GtkAction *action, StickyNotesApplet *applet)
+void menu_destroy_all_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
+ StickyNotesApplet *applet = (StickyNotesApplet *) user_data;
GtkBuilder *builder;
builder = gtk_builder_new ();
@@ -320,25 +322,34 @@ void menu_destroy_all_cb(GtkAction *action, StickyNotesApplet *applet)
}
/* Menu Callback: Lock/Unlock sticky notes */
-void menu_toggle_lock_cb(GtkAction *action, StickyNotesApplet *applet)
+void menu_toggle_lock_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
- gboolean locked = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ GVariant *state = g_action_get_state (G_ACTION (action));
+ g_action_change_state (G_ACTION (action), g_variant_new_boolean (!g_variant_get_boolean (state)));
+ g_variant_unref (state);
+}
+
+void menu_toggle_lock_state(GSimpleAction *action, GVariant *value, gpointer user_data)
+{
+ gboolean locked = g_variant_get_boolean (value);
if (gconf_client_key_is_writable(stickynotes->gconf, GCONF_PATH "/settings/locked", NULL))
gconf_client_set_bool(stickynotes->gconf, GCONF_PATH "/settings/locked", locked, NULL);
}
/* Menu Callback : Configure preferences */
-void menu_preferences_cb(GtkAction *action, StickyNotesApplet *applet)
+void menu_preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
+ StickyNotesApplet *applet = (StickyNotesApplet *) user_data;
stickynotes_applet_update_prefs();
gtk_window_set_screen(GTK_WINDOW(stickynotes->w_prefs), gtk_widget_get_screen(applet->w_applet));
gtk_window_present(GTK_WINDOW(stickynotes->w_prefs));
}
/* Menu Callback : Show help */
-void menu_help_cb(GtkAction *action, StickyNotesApplet *applet)
+void menu_help_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
+ StickyNotesApplet *applet = (StickyNotesApplet *) user_data;
GError *error = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (applet->w_applet)),
"help:stickynotes_applet",
@@ -357,8 +368,7 @@ void menu_help_cb(GtkAction *action, StickyNotesApplet *applet)
/* Menu Callback : Display About window */
void
-menu_about_cb (GtkAction *action,
- StickyNotesApplet *applet)
+menu_about_cb (GSimpleAction *action, GVariant *parameter, gpointer user_data)
{
static const gchar *authors[] = {
"Loban A Rahman <loban earthling net>",
diff --git a/stickynotes/stickynotes_applet_callbacks.h b/stickynotes/stickynotes_applet_callbacks.h
index 95b66a4..de43854 100644
--- a/stickynotes/stickynotes_applet_callbacks.h
+++ b/stickynotes/stickynotes_applet_callbacks.h
@@ -32,14 +32,15 @@ void applet_change_orient_cb(PanelApplet *panel_applet, PanelAppletOrient orient
void applet_size_allocate_cb(GtkWidget *widget, GtkAllocation *allocation, StickyNotesApplet *applet);
void applet_destroy_cb (PanelApplet *panel_applet, StickyNotesApplet *applet);
/* Callbacks for sticky notes applet menu */
-void menu_create_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_new_note_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_hide_notes_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_destroy_all_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_toggle_lock_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_preferences_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_help_cb(GtkAction *action, StickyNotesApplet *applet);
-void menu_about_cb(GtkAction *action, StickyNotesApplet *applet);
+void menu_create_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
+void menu_new_note_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
+void menu_hide_notes_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
+void menu_destroy_all_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
+void menu_toggle_lock_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
+void menu_toggle_lock_state(GSimpleAction *action, GVariant *value, gpointer user_data);
+void menu_preferences_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
+void menu_help_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
+void menu_about_cb(GSimpleAction *action, GVariant *parameter, gpointer user_data);
/* Callbacks for sticky notes preferences dialog */
void preferences_save_cb(gpointer data);
diff --git a/trashapplet/src/trashapplet.c b/trashapplet/src/trashapplet.c
index d8dc2d5..ec9604a 100644
--- a/trashapplet/src/trashapplet.c
+++ b/trashapplet/src/trashapplet.c
@@ -57,28 +57,24 @@ G_DEFINE_TYPE (TrashApplet, trash_applet, PANEL_TYPE_APPLET);
#define TRASH_APPLET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
TRASH_TYPE_APPLET, TrashApplet))
-static void trash_applet_do_empty (GtkAction *action,
- TrashApplet *applet);
-static void trash_applet_show_about (GtkAction *action,
- TrashApplet *applet);
-static void trash_applet_open_folder (GtkAction *action,
- TrashApplet *applet);
-static void trash_applet_show_help (GtkAction *action,
- TrashApplet *applet);
-
-static const GtkActionEntry trash_applet_menu_actions [] = {
- { "EmptyTrash", GTK_STOCK_CLEAR, N_("_Empty Trash"),
- NULL, NULL,
- G_CALLBACK (trash_applet_do_empty) },
- { "OpenTrash", GTK_STOCK_OPEN, N_("_Open Trash"),
- NULL, NULL,
- G_CALLBACK (trash_applet_open_folder) },
- { "HelpTrash", GTK_STOCK_HELP, N_("_Help"),
- NULL, NULL,
- G_CALLBACK (trash_applet_show_help) },
- { "AboutTrash", GTK_STOCK_ABOUT, N_("_About"),
- NULL, NULL,
- G_CALLBACK (trash_applet_show_about) }
+static void trash_applet_do_empty (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
+static void trash_applet_show_about (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
+static void trash_applet_open_folder (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
+static void trash_applet_show_help (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data);
+
+static const GActionEntry trash_applet_menu_actions [] = {
+ { "open", trash_applet_open_folder, NULL, NULL, NULL },
+ { "empty", trash_applet_do_empty, NULL, NULL, NULL },
+ { "help", trash_applet_show_help, NULL, NULL, NULL },
+ { "about", trash_applet_show_about, NULL, NULL, NULL }
};
static void
@@ -260,7 +256,7 @@ trash_applet_button_release (GtkWidget *widget,
if (gconf_client_get_bool (client, PANEL_ENABLE_ANIMATIONS, NULL))
xstuff_zoom_animate (widget, NULL);
- trash_applet_open_folder (NULL, applet);
+ trash_applet_open_folder (NULL, NULL, applet);
return TRUE;
}
@@ -285,7 +281,7 @@ trash_applet_key_press (GtkWidget *widget,
case GDK_KEY_Return:
case GDK_KEY_space:
case GDK_KEY_KP_Space:
- trash_applet_open_folder (NULL, applet);
+ trash_applet_open_folder (NULL, NULL, applet);
return TRUE;
default:
@@ -356,16 +352,20 @@ error_dialog (TrashApplet *applet, const gchar *error, ...)
}
static void
-trash_applet_do_empty (GtkAction *action,
- TrashApplet *applet)
+trash_applet_do_empty (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ TrashApplet *applet = (TrashApplet *) user_data;
trash_empty (GTK_WIDGET (applet));
}
static void
-trash_applet_open_folder (GtkAction *action,
- TrashApplet *applet)
+trash_applet_open_folder (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ TrashApplet *applet = (TrashApplet *) user_data;
GError *err = NULL;
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (applet)),
@@ -382,9 +382,11 @@ trash_applet_open_folder (GtkAction *action,
}
static void
-trash_applet_show_help (GtkAction *action,
- TrashApplet *applet)
+trash_applet_show_help (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
+ TrashApplet *applet = (TrashApplet *) user_data;
GError *err = NULL;
/* FIXME - Actually, we need a user guide */
@@ -404,8 +406,9 @@ trash_applet_show_help (GtkAction *action,
static void
-trash_applet_show_about (GtkAction *action,
- TrashApplet *applet)
+trash_applet_show_about (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
{
static const char *authors[] = {
"Michiel Sikkes <michiel eyesopened nl>",
@@ -610,7 +613,7 @@ trash_applet_factory (PanelApplet *applet,
if (!strcmp (iid, "TrashApplet"))
{
- GtkActionGroup *action_group;
+ GSimpleActionGroup *action_group;
gchar *ui_path;
g_set_application_name (_("Trash Applet"));
@@ -618,15 +621,18 @@ trash_applet_factory (PanelApplet *applet,
gtk_window_set_default_icon_name ("user-trash");
/* Set up the menu */
- action_group = gtk_action_group_new ("Trash Applet Actions");
- gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
- gtk_action_group_add_actions (action_group,
- trash_applet_menu_actions,
- G_N_ELEMENTS (trash_applet_menu_actions),
- applet);
+ action_group = g_simple_action_group_new ();
+ g_action_map_add_action_entries (G_ACTION_MAP (action_group),
+ trash_applet_menu_actions,
+ G_N_ELEMENTS (trash_applet_menu_actions),
+ applet);
ui_path = g_build_filename (TRASH_MENU_UI_DIR, "trashapplet-menu.xml", NULL);
- panel_applet_setup_menu_from_file (applet, ui_path, action_group);
+ panel_applet_setup_menu_from_file (applet, ui_path, action_group, GETTEXT_PACKAGE);
g_free (ui_path);
+
+ gtk_widget_insert_action_group (GTK_WIDGET (applet), "trash",
+ G_ACTION_GROUP (action_group));
+
g_object_unref (action_group);
gtk_widget_show (GTK_WIDGET (applet));
diff --git a/trashapplet/trashapplet-menu.xml b/trashapplet/trashapplet-menu.xml
index e2bc535..a1a85c6 100644
--- a/trashapplet/trashapplet-menu.xml
+++ b/trashapplet/trashapplet-menu.xml
@@ -1,6 +1,20 @@
-<menuitem name="Open Trash Item" action="OpenTrash" />
-<menuitem name="Empty Trash Item" action="EmptyTrash" />
-<separator/>
-<menuitem name="Open Help Item" action="HelpTrash" />
-<menuitem name="About Item" action="AboutTrash" />
-
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Open Trash</attribute>
+ <attribute name="action">trash.open</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Empty Trash</attribute>
+ <attribute name="action">trash.empty</attribute>
+ </item>
+</section>
+<section>
+ <item>
+ <attribute name="label" translatable="yes">_Help</attribute>
+ <attribute name="action">trash.help</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_About</attribute>
+ <attribute name="action">trash.about</attribute>
+ </item>
+</section>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]