aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2014-03-26 17:07:21 +0100
committerLars Uebernickel <lars.uebernickel@canonical.com>2014-03-26 17:07:21 +0100
commit7614e880579dce57aca4ba01dca328d03a1271fc (patch)
tree234c6c3e5eadaf6f84aace1f1425e75be9beb5a8
parente14ab5db2988d48b6087844443cbbefa312db761 (diff)
downloadayatana-ido-7614e880579dce57aca4ba01dca328d03a1271fc.tar.gz
ayatana-ido-7614e880579dce57aca4ba01dca328d03a1271fc.tar.bz2
ayatana-ido-7614e880579dce57aca4ba01dca328d03a1271fc.zip
idobasicmenuitem: put progress menu item into its own file
-rw-r--r--src/Makefile.am2
-rw-r--r--src/idobasicmenuitem.c84
-rw-r--r--src/idobasicmenuitem.h8
-rw-r--r--src/idomenuitemfactory.c1
-rw-r--r--src/idoprogressmenuitem.c101
-rw-r--r--src/idoprogressmenuitem.h28
6 files changed, 132 insertions, 92 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 3a3ea31..9b722cb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,6 +21,7 @@ sources_h = \
idousermenuitem.h \
idoappointmentmenuitem.h \
idobasicmenuitem.h \
+ idoprogressmenuitem.h \
idotimestampmenuitem.h \
idolocationmenuitem.h \
idotimeline.h \
@@ -88,6 +89,7 @@ libido_0_1_la_SOURCES = \
idoplaybackmenuitem.c \
idoappointmentmenuitem.c \
idobasicmenuitem.c \
+ idoprogressmenuitem.c \
idotimestampmenuitem.c \
idolocationmenuitem.c \
idoapplicationmenuitem.c \
diff --git a/src/idobasicmenuitem.c b/src/idobasicmenuitem.c
index f07cc14..d5ab0de 100644
--- a/src/idobasicmenuitem.c
+++ b/src/idobasicmenuitem.c
@@ -305,87 +305,3 @@ ido_basic_menu_item_set_secondary_text (IdoBasicMenuItem * self, const char * se
NULL);
}
}
-
-/***
-****
-**** Progress Menu Item
-****
-***/
-
-static void
-on_progress_action_state_changed (IdoActionHelper * helper,
- GVariant * state,
- gpointer unused G_GNUC_UNUSED)
-{
- IdoBasicMenuItem * ido_menu_item;
- char * str;
-
- ido_menu_item = IDO_BASIC_MENU_ITEM (ido_action_helper_get_widget (helper));
-
- g_return_if_fail (ido_menu_item != NULL);
- g_return_if_fail (g_variant_is_of_type (state, G_VARIANT_TYPE_UINT32));
-
- str = g_strdup_printf ("%"G_GUINT32_FORMAT"%%", g_variant_get_uint32 (state));
- ido_basic_menu_item_set_secondary_text (ido_menu_item, str);
- g_free (str);
-}
-
-/**
- * ido_progress_menu_item_new_from_model:
- * @menu_item: the corresponding menuitem
- * @actions: action group to tell when this GtkMenuItem is activated
- *
- * Creates a new progress menuitem with properties initialized from
- * the menuitem's attributes.
- *
- * If the menuitem's 'action' attribute is set, trigger that action
- * in @actions when this IdoBasicMenuItem is activated.
- */
-GtkMenuItem *
-ido_progress_menu_item_new_from_model (GMenuItem * menu_item,
- GActionGroup * actions)
-{
- guint i;
- guint n;
- gchar * str;
- IdoBasicMenuItem * ido_menu_item;
- GParameter parameters[4];
-
- /* create the ido menuitem */;
-
- n = 0;
-
- if (g_menu_item_get_attribute (menu_item, "label", "s", &str))
- {
- GParameter p = { "text", G_VALUE_INIT };
- g_value_init (&p.value, G_TYPE_STRING);
- g_value_take_string (&p.value, str);
- parameters[n++] = p;
- }
-
- g_assert (n <= G_N_ELEMENTS (parameters));
- ido_menu_item = g_object_newv (IDO_TYPE_BASIC_MENU_ITEM, n, parameters);
-
- for (i=0; i<n; i++)
- g_value_unset (&parameters[i].value);
-
- /* give it an ActionHelper */
-
- if (g_menu_item_get_attribute (menu_item, "action", "s", &str))
- {
- IdoActionHelper * helper;
-
- helper = ido_action_helper_new (GTK_WIDGET(ido_menu_item),
- actions,
- str,
- NULL);
- g_signal_connect (helper, "action-state-changed",
- G_CALLBACK (on_progress_action_state_changed), NULL);
- g_signal_connect_swapped (ido_menu_item, "destroy",
- G_CALLBACK (g_object_unref), helper);
-
- g_free (str);
- }
-
- return GTK_MENU_ITEM (ido_menu_item);
-}
diff --git a/src/idobasicmenuitem.h b/src/idobasicmenuitem.h
index 01aa4b3..da1216e 100644
--- a/src/idobasicmenuitem.h
+++ b/src/idobasicmenuitem.h
@@ -64,14 +64,6 @@ void ido_basic_menu_item_set_text (IdoBasicMenuItem * self,
void ido_basic_menu_item_set_secondary_text (IdoBasicMenuItem * self,
const char * text);
-/**
-***
-**/
-
-GtkMenuItem * ido_progress_menu_item_new_from_model (GMenuItem * menuitem,
- GActionGroup * actions);
-
-
G_END_DECLS
#endif
diff --git a/src/idomenuitemfactory.c b/src/idomenuitemfactory.c
index 11beaa8..7f5d932 100644
--- a/src/idomenuitemfactory.c
+++ b/src/idomenuitemfactory.c
@@ -32,6 +32,7 @@
#include "idoapplicationmenuitem.h"
#include "idosourcemenuitem.h"
#include "idoswitchmenuitem.h"
+#include "idoprogressmenuitem.h"
#define IDO_TYPE_MENU_ITEM_FACTORY (ido_menu_item_factory_get_type ())
#define IDO_MENU_ITEM_FACTORY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), IDO_TYPE_MENU_ITEM_FACTORY, IdoMenuItemFactory))
diff --git a/src/idoprogressmenuitem.c b/src/idoprogressmenuitem.c
new file mode 100644
index 0000000..9d456b8
--- /dev/null
+++ b/src/idoprogressmenuitem.c
@@ -0,0 +1,101 @@
+/**
+ * Copyright 2013 Canonical Ltd.
+ *
+ * Authors:
+ * Charles Kerr <charles.kerr@canonical.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "idoprogressmenuitem.h"
+#include "idobasicmenuitem.h"
+#include "idoactionhelper.h"
+
+static void
+on_progress_action_state_changed (IdoActionHelper * helper,
+ GVariant * state,
+ gpointer unused G_GNUC_UNUSED)
+{
+ IdoBasicMenuItem * ido_menu_item;
+ char * str;
+
+ ido_menu_item = IDO_BASIC_MENU_ITEM (ido_action_helper_get_widget (helper));
+
+ g_return_if_fail (ido_menu_item != NULL);
+ g_return_if_fail (g_variant_is_of_type (state, G_VARIANT_TYPE_UINT32));
+
+ str = g_strdup_printf ("%"G_GUINT32_FORMAT"%%", g_variant_get_uint32 (state));
+ ido_basic_menu_item_set_secondary_text (ido_menu_item, str);
+ g_free (str);
+}
+
+/**
+ * ido_progress_menu_item_new_from_model:
+ * @menu_item: the corresponding menuitem
+ * @actions: action group to tell when this GtkMenuItem is activated
+ *
+ * Creates a new progress menuitem with properties initialized from
+ * the menuitem's attributes.
+ *
+ * If the menuitem's 'action' attribute is set, trigger that action
+ * in @actions when this IdoBasicMenuItem is activated.
+ */
+GtkMenuItem *
+ido_progress_menu_item_new_from_model (GMenuItem * menu_item,
+ GActionGroup * actions)
+{
+ guint i;
+ guint n;
+ gchar * str;
+ IdoBasicMenuItem * ido_menu_item;
+ GParameter parameters[4];
+
+ /* create the ido menuitem */;
+
+ n = 0;
+
+ if (g_menu_item_get_attribute (menu_item, "label", "s", &str))
+ {
+ GParameter p = { "text", G_VALUE_INIT };
+ g_value_init (&p.value, G_TYPE_STRING);
+ g_value_take_string (&p.value, str);
+ parameters[n++] = p;
+ }
+
+ g_assert (n <= G_N_ELEMENTS (parameters));
+ ido_menu_item = g_object_newv (IDO_TYPE_BASIC_MENU_ITEM, n, parameters);
+
+ for (i=0; i<n; i++)
+ g_value_unset (&parameters[i].value);
+
+ /* give it an ActionHelper */
+
+ if (g_menu_item_get_attribute (menu_item, "action", "s", &str))
+ {
+ IdoActionHelper * helper;
+
+ helper = ido_action_helper_new (GTK_WIDGET(ido_menu_item),
+ actions,
+ str,
+ NULL);
+ g_signal_connect (helper, "action-state-changed",
+ G_CALLBACK (on_progress_action_state_changed), NULL);
+ g_signal_connect_swapped (ido_menu_item, "destroy",
+ G_CALLBACK (g_object_unref), helper);
+
+ g_free (str);
+ }
+
+ return GTK_MENU_ITEM (ido_menu_item);
+}
+
diff --git a/src/idoprogressmenuitem.h b/src/idoprogressmenuitem.h
new file mode 100644
index 0000000..3b0028b
--- /dev/null
+++ b/src/idoprogressmenuitem.h
@@ -0,0 +1,28 @@
+/**
+ * Copyright 2013 Canonical Ltd.
+ *
+ * Authors:
+ * Charles Kerr <charles.kerr@canonical.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __IDO_PROGRESS_MENU_ITEM_H__
+#define __IDO_PROGRESS_MENU_ITEM_H__
+
+#include <gtk/gtk.h>
+
+GtkMenuItem * ido_progress_menu_item_new_from_model (GMenuItem * menuitem,
+ GActionGroup * actions);
+
+#endif