From 12a5f15581d2c8ba5e6b4ec4baa19bd436e4fd8d Mon Sep 17 00:00:00 2001 From: Lars Uebernickel Date: Wed, 22 May 2013 23:19:50 -0400 Subject: Add IdoActionHelper This class contains some functionality that all menu items that are bound to an action need. It listens for action additions and removals, changes in enabled state, and state changes. It is _not_ intended to be used by specific menu items, but rather as the glue in IdoMenuItemFactory, to bind a widget to an action. An alternative way to reach the same goal is to have an IdoMenuItem base class which contains the common functionality. This would have required touching all existing menu items (slider, user menu item, media player items) and would have added more complexity to them. It is similar in spirit to GtkActionHelper (a private class in gtk), but very different in API and implementation. --- src/idoactionhelper.h | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/idoactionhelper.h (limited to 'src/idoactionhelper.h') diff --git a/src/idoactionhelper.h b/src/idoactionhelper.h new file mode 100644 index 0000000..22cdcae --- /dev/null +++ b/src/idoactionhelper.h @@ -0,0 +1,44 @@ +/* +* Copyright 2013 Canonical Ltd. +* +* 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 . +* +* Authors: +* Lars Uebernickel +*/ + +#ifndef __IDO_ACTION_HELPER_H__ +#define __IDO_ACTION_HELPER_H__ + +#include + +#define IDO_TYPE_ACTION_HELPER (ido_action_helper_get_type ()) +#define IDO_ACTION_HELPER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), IDO_TYPE_ACTION_HELPER, IdoActionHelper)) +#define IDO_IS_ACTION_HELPER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), IDO_TYPE_ACTION_HELPER)) + +typedef struct _IdoActionHelper IdoActionHelper; + +GType ido_menu_item_get_type (void); + +IdoActionHelper * ido_action_helper_new (GtkWidget *widget, + GActionGroup *action_group, + const gchar *action_name, + GVariant *target); + +GtkWidget * ido_action_helper_get_widget (IdoActionHelper *helper); + +GVariant * ido_action_helper_get_action_target (IdoActionHelper *helper); + +void ido_action_helper_activate (IdoActionHelper *helper); + +#endif -- cgit v1.2.3