summaryrefslogtreecommitdiff
path: root/garcon/garcon-menu-item-action.c
diff options
context:
space:
mode:
Diffstat (limited to 'garcon/garcon-menu-item-action.c')
-rw-r--r--garcon/garcon-menu-item-action.c66
1 files changed, 65 insertions, 1 deletions
diff --git a/garcon/garcon-menu-item-action.c b/garcon/garcon-menu-item-action.c
index b416895..dd21a0e 100644
--- a/garcon/garcon-menu-item-action.c
+++ b/garcon/garcon-menu-item-action.c
@@ -35,6 +35,7 @@ enum
PROP_0,
PROP_NAME,
PROP_COMMAND,
+ PROP_ICON_NAME,
};
static void garcon_menu_item_action_finalize (GObject *object);
@@ -54,6 +55,9 @@ struct _GarconMenuItemActionPrivate
/* Command to be executed when the action is clicked */
gchar *command;
+
+ /* Name of the icon associated with the action */
+ gchar *icon_name;
};
G_DEFINE_TYPE (GarconMenuItemAction, garcon_menu_item_action, G_TYPE_OBJECT)
@@ -97,6 +101,20 @@ garcon_menu_item_action_class_init (GarconMenuItemActionClass *klass)
NULL,
G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GarconMenuItemAction:icon-name:
+ *
+ * Name of the custom icon associated with this action.
+ **/
+ g_object_class_install_property (gobject_class,
+ PROP_ICON_NAME,
+ g_param_spec_string ("icon-name",
+ "icon-name",
+ "Custom icon name",
+ NULL,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
}
static void
@@ -114,6 +132,7 @@ garcon_menu_item_action_finalize (GObject *object)
g_free (action->priv->name);
g_free (action->priv->command);
+ g_free (action->priv->icon_name);
(*G_OBJECT_CLASS (garcon_menu_item_action_parent_class)->finalize) (object);
}
@@ -138,6 +157,10 @@ garcon_menu_item_action_get_property (GObject *object,
g_value_set_string (value, garcon_menu_item_action_get_command (action));
break;
+ case PROP_ICON_NAME:
+ g_value_set_string (value, garcon_menu_item_action_get_icon_name (action));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -164,6 +187,10 @@ garcon_menu_item_action_set_property (GObject *object,
garcon_menu_item_action_set_command (action, g_value_get_string (value));
break;
+ case PROP_ICON_NAME:
+ garcon_menu_item_action_set_icon_name (action, g_value_get_string (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -200,6 +227,43 @@ garcon_menu_item_action_set_name (GarconMenuItemAction *action,
}
+
+const gchar*
+garcon_menu_item_action_get_icon_name (GarconMenuItemAction *action)
+{
+ g_return_val_if_fail (GARCON_IS_MENU_ITEM_ACTION (action), NULL);
+ return action->priv->icon_name;
+}
+
+
+
+void
+garcon_menu_item_action_set_icon_name (GarconMenuItemAction *action,
+ const gchar *icon_name)
+{
+ g_return_if_fail (GARCON_IS_MENU_ITEM_ACTION (action));
+
+ /* Abort if old and new name are equal */
+ if (g_strcmp0 (action->priv->icon_name, icon_name) == 0)
+ return;
+
+ /* Assign new name */
+ g_free (action->priv->icon_name);
+ if (icon_name != NULL)
+ {
+ action->priv->icon_name = g_strdup (icon_name);
+ }
+ else
+ {
+ action->priv->icon_name = NULL;
+ }
+
+ /* Notify listeners */
+ g_object_notify (G_OBJECT (action), "icon-name");
+}
+
+
+
const gchar*
garcon_menu_item_action_get_command (GarconMenuItemAction *action)
{
@@ -246,4 +310,4 @@ garcon_menu_item_action_unref (GarconMenuItemAction *action)
/* Decrement the reference counter */
g_object_unref (G_OBJECT (action));
-} \ No newline at end of file
+}