aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
authorMatthew Barnes <mbarnes@redhat.com>2013-06-11 03:06:36 +0800
committerMatthew Barnes <mbarnes@redhat.com>2013-06-11 03:06:36 +0800
commite51e1d6e4bbd6d33a841a87b15680c824adf8988 (patch)
treed47149d8a1166c0a3a22f07ff8792ec9043f0bd9 /e-util
parentdecc4aa9a760b8eb54c97ce4067150ced472f70c (diff)
downloadgsoc2013-evolution-e51e1d6e4bbd6d33a841a87b15680c824adf8988.tar.gz
gsoc2013-evolution-e51e1d6e4bbd6d33a841a87b15680c824adf8988.tar.zst
gsoc2013-evolution-e51e1d6e4bbd6d33a841a87b15680c824adf8988.zip
EMenuToolButton cleanups.
Diffstat (limited to 'e-util')
-rw-r--r--e-util/e-menu-tool-button.c59
-rw-r--r--e-util/e-menu-tool-button.h12
2 files changed, 38 insertions, 33 deletions
diff --git a/e-util/e-menu-tool-button.c b/e-util/e-menu-tool-button.c
index 16340dc483..61327f7ae1 100644
--- a/e-util/e-menu-tool-button.c
+++ b/e-util/e-menu-tool-button.c
@@ -80,26 +80,33 @@ menu_tool_button_get_prefer_menu_item (GtkMenuToolButton *menu_tool_button)
E_MENU_TOOL_BUTTON (menu_tool_button));
if (prefer_item != NULL && *prefer_item != '\0') {
GtkAction *action;
- GList *iter;
+ GList *link;
- for (iter = children; iter != NULL; iter = iter->next) {
- item = GTK_MENU_ITEM (iter->data);
+ for (link = children; link != NULL; link = g_list_next (link)) {
+ GtkWidget *child;
+ const gchar *name;
- if (!item)
+ child = GTK_WIDGET (link->data);
+
+ if (!GTK_IS_MENU_ITEM (child))
continue;
action = gtk_activatable_get_related_action (
- GTK_ACTIVATABLE (item));
- if (action && g_strcmp0 (gtk_action_get_name (action), prefer_item) == 0)
- break;
- else if (!action && g_strcmp0 (gtk_widget_get_name (GTK_WIDGET (item)), prefer_item) == 0)
- break;
+ GTK_ACTIVATABLE (child));
- item = NULL;
+ if (action != NULL)
+ name = gtk_action_get_name (action);
+ else
+ name = gtk_widget_get_name (child);
+
+ if (g_strcmp0 (name, prefer_item) == 0) {
+ item = GTK_MENU_ITEM (child);
+ break;
+ }
}
}
- if (!item)
+ if (item == NULL)
item = GTK_MENU_ITEM (children->data);
g_list_free (children);
@@ -189,19 +196,16 @@ menu_tool_button_get_property (GObject *object,
}
static void
-menu_tool_button_dispose (GObject *object)
+menu_tool_button_finalize (GObject *object)
{
EMenuToolButtonPrivate *priv;
priv = E_MENU_TOOL_BUTTON_GET_PRIVATE (object);
- if (priv->prefer_item) {
- g_free (priv->prefer_item);
- priv->prefer_item = NULL;
- }
+ g_free (priv->prefer_item);
- /* Chain up to parent's dispose() method. */
- G_OBJECT_CLASS (e_menu_tool_button_parent_class)->dispose (object);
+ /* Chain up to parent's finalize() method. */
+ G_OBJECT_CLASS (e_menu_tool_button_parent_class)->finalize (object);
}
static void
@@ -215,7 +219,7 @@ e_menu_tool_button_class_init (EMenuToolButtonClass *class)
object_class = G_OBJECT_CLASS (class);
object_class->set_property = menu_tool_button_set_property;
object_class->get_property = menu_tool_button_get_property;
- object_class->dispose = menu_tool_button_dispose;
+ object_class->finalize = menu_tool_button_finalize;
tool_button_class = GTK_TOOL_BUTTON_CLASS (class);
tool_button_class->clicked = menu_tool_button_clicked;
@@ -249,11 +253,18 @@ e_menu_tool_button_new (const gchar *label)
return g_object_new (E_TYPE_MENU_TOOL_BUTTON, "label", label, NULL);
}
+const gchar *
+e_menu_tool_button_get_prefer_item (EMenuToolButton *button)
+{
+ g_return_val_if_fail (E_IS_MENU_TOOL_BUTTON (button), NULL);
+
+ return button->priv->prefer_item;
+}
+
void
e_menu_tool_button_set_prefer_item (EMenuToolButton *button,
const gchar *prefer_item)
{
- g_return_if_fail (button != NULL);
g_return_if_fail (E_IS_MENU_TOOL_BUTTON (button));
if (g_strcmp0 (button->priv->prefer_item, prefer_item) == 0)
@@ -265,11 +276,3 @@ e_menu_tool_button_set_prefer_item (EMenuToolButton *button,
g_object_notify (G_OBJECT (button), "prefer-item");
}
-const gchar *
-e_menu_tool_button_get_prefer_item (EMenuToolButton *button)
-{
- g_return_val_if_fail (button != NULL, NULL);
- g_return_val_if_fail (E_IS_MENU_TOOL_BUTTON (button), NULL);
-
- return button->priv->prefer_item;
-}
diff --git a/e-util/e-menu-tool-button.h b/e-util/e-menu-tool-button.h
index c16ba09b64..e99d3e9bdf 100644
--- a/e-util/e-menu-tool-button.h
+++ b/e-util/e-menu-tool-button.h
@@ -66,11 +66,13 @@ struct _EMenuToolButtonClass {
GtkMenuToolButtonClass parent_class;
};
-GType e_menu_tool_button_get_type (void) G_GNUC_CONST;
-GtkToolItem * e_menu_tool_button_new (const gchar *label);
-void e_menu_tool_button_set_prefer_item (EMenuToolButton *button,
- const gchar *prefer_item);
-const gchar * e_menu_tool_button_get_prefer_item (EMenuToolButton *button);
+GType e_menu_tool_button_get_type (void) G_GNUC_CONST;
+GtkToolItem * e_menu_tool_button_new (const gchar *label);
+const gchar * e_menu_tool_button_get_prefer_item
+ (EMenuToolButton *button);
+void e_menu_tool_button_set_prefer_item
+ (EMenuToolButton *button,
+ const gchar *prefer_item);
G_END_DECLS