[gtk+/popover-menu-buttons: 3/5] Add a display-hint to menu tracker sections and items
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/popover-menu-buttons: 3/5] Add a display-hint to menu tracker sections and items
- Date: Wed, 2 Apr 2014 05:10:29 +0000 (UTC)
commit c0390ceddefc1cc864b221f6c856a871c2ba8ea7
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Apr 2 01:06:30 2014 -0400
Add a display-hint to menu tracker sections and items
This section attribute will be used to indicate that iconic
rendering is preferred in the following commits.
gtk/gtkmenutracker.c | 24 +++++++++++++++++-------
gtk/gtkmenutrackeritem.c | 12 +++++++++++-
gtk/gtkmenutrackeritem.h | 4 +++-
3 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkmenutracker.c b/gtk/gtkmenutracker.c
index 86ee9fc..ac7a784 100644
--- a/gtk/gtkmenutracker.c
+++ b/gtk/gtkmenutracker.c
@@ -72,6 +72,7 @@ struct _GtkMenuTrackerSection
gpointer model; /* may be a GtkMenuTrackerItem or a GMenuModel */
GSList *items;
gchar *action_namespace;
+ gchar *display_hint;
guint separator_label : 1;
guint with_separators : 1;
@@ -86,7 +87,8 @@ static GtkMenuTrackerSection * gtk_menu_tracker_section_new (GtkMenuTracker
gboolean with_separators,
gboolean separator_label,
gint offset,
- const gchar *action_namespace);
+ const gchar *action_namespace,
+ const gchar *display_hint);
static void gtk_menu_tracker_section_free (GtkMenuTrackerSection *section);
static GtkMenuTrackerSection *
@@ -199,7 +201,7 @@ gtk_menu_tracker_section_sync_separators (GtkMenuTrackerSection *section,
/* Add a separator */
GtkMenuTrackerItem *item;
- item = _gtk_menu_tracker_item_new (tracker->observable, parent_model, parent_index, NULL, TRUE);
+ item = _gtk_menu_tracker_item_new (tracker->observable, parent_model, parent_index, NULL, TRUE, NULL);
(* tracker->insert_func) (item, offset, tracker->user_data);
g_object_unref (item);
@@ -312,12 +314,16 @@ gtk_menu_tracker_add_items (GtkMenuTracker *tracker,
{
GtkMenuTrackerSection *subsection;
gchar *action_namespace = NULL;
+ gchar *display_hint = NULL;
gboolean has_label;
has_label = g_menu_model_get_item_attribute (model, position + n_items,
G_MENU_ATTRIBUTE_LABEL, "s", NULL);
g_menu_model_get_item_attribute (model, position + n_items,
+ "display-hint", "s", &display_hint);
+
+ g_menu_model_get_item_attribute (model, position + n_items,
G_MENU_ATTRIBUTE_ACTION_NAMESPACE, "s", &action_namespace);
if (section->action_namespace)
@@ -325,14 +331,15 @@ gtk_menu_tracker_add_items (GtkMenuTracker *tracker,
gchar *namespace;
namespace = g_strjoin (".", section->action_namespace, action_namespace, NULL);
- subsection = gtk_menu_tracker_section_new (tracker, submenu, FALSE, has_label, offset,
namespace);
+ subsection = gtk_menu_tracker_section_new (tracker, submenu, FALSE, has_label, offset,
namespace, display_hint);
g_free (namespace);
}
else
- subsection = gtk_menu_tracker_section_new (tracker, submenu, FALSE, has_label, offset,
action_namespace);
+ subsection = gtk_menu_tracker_section_new (tracker, submenu, FALSE, has_label, offset,
action_namespace, display_hint);
*change_point = g_slist_prepend (*change_point, subsection);
g_free (action_namespace);
+ g_free (display_hint);
g_object_unref (submenu);
}
else
@@ -340,7 +347,7 @@ gtk_menu_tracker_add_items (GtkMenuTracker *tracker,
GtkMenuTrackerItem *item;
item = _gtk_menu_tracker_item_new (tracker->observable, model, position + n_items,
- section->action_namespace, FALSE);
+ section->action_namespace, FALSE, section->display_hint);
/* In the case that the item may disappear we handle that by
* treating the item that we just created as being its own
@@ -459,6 +466,7 @@ gtk_menu_tracker_section_free (GtkMenuTrackerSection *section)
g_signal_handler_disconnect (section->model, section->handler);
g_slist_free_full (section->items, (GDestroyNotify) gtk_menu_tracker_section_free);
g_free (section->action_namespace);
+ g_free (section->display_hint);
g_object_unref (section->model);
g_slice_free (GtkMenuTrackerSection, section);
}
@@ -469,7 +477,8 @@ gtk_menu_tracker_section_new (GtkMenuTracker *tracker,
gboolean with_separators,
gboolean separator_label,
gint offset,
- const gchar *action_namespace)
+ const gchar *action_namespace,
+ const gchar *display_hint)
{
GtkMenuTrackerSection *section;
@@ -477,6 +486,7 @@ gtk_menu_tracker_section_new (GtkMenuTracker *tracker,
section->model = g_object_ref (model);
section->with_separators = with_separators;
section->action_namespace = g_strdup (action_namespace);
+ section->display_hint = g_strdup (display_hint);
section->separator_label = separator_label;
gtk_menu_tracker_add_items (tracker, section, §ion->items, offset, model, 0, g_menu_model_get_n_items
(model));
@@ -553,7 +563,7 @@ gtk_menu_tracker_new (GtkActionObservable *observable,
tracker->remove_func = remove_func;
tracker->user_data = user_data;
- tracker->toplevel = gtk_menu_tracker_section_new (tracker, model, with_separators, FALSE, 0,
action_namespace);
+ tracker->toplevel = gtk_menu_tracker_section_new (tracker, model, with_separators, FALSE, 0,
action_namespace, NULL);
gtk_menu_tracker_section_sync_separators (tracker->toplevel, tracker, 0, FALSE, NULL, 0);
return tracker;
diff --git a/gtk/gtkmenutrackeritem.c b/gtk/gtkmenutrackeritem.c
index 8477a6b..9f6251a 100644
--- a/gtk/gtkmenutrackeritem.c
+++ b/gtk/gtkmenutrackeritem.c
@@ -87,6 +87,7 @@ struct _GtkMenuTrackerItem
GtkActionObservable *observable;
gchar *action_namespace;
gchar *action_and_target;
+ gchar *display_hint;
GMenuItem *item;
GtkMenuTrackerItemRole role : 4;
guint is_separator : 1;
@@ -200,6 +201,7 @@ gtk_menu_tracker_item_finalize (GObject *object)
GtkMenuTrackerItem *self = GTK_MENU_TRACKER_ITEM (object);
g_free (self->action_namespace);
+ g_free (self->display_hint);
if (self->observable)
g_object_unref (self->observable);
@@ -467,7 +469,8 @@ _gtk_menu_tracker_item_new (GtkActionObservable *observable,
GMenuModel *model,
gint item_index,
const gchar *action_namespace,
- gboolean is_separator)
+ gboolean is_separator,
+ const gchar *display_hint)
{
GtkMenuTrackerItem *self;
const gchar *action_name;
@@ -481,6 +484,7 @@ _gtk_menu_tracker_item_new (GtkActionObservable *observable,
self->action_namespace = g_strdup (action_namespace);
self->observable = g_object_ref (observable);
self->is_separator = is_separator;
+ self->display_hint = g_strdup (display_hint);
if (!is_separator && g_menu_item_get_attribute (self->item, "hidden-when", "&s", &hidden_when))
{
@@ -663,6 +667,12 @@ gtk_menu_tracker_item_get_special (GtkMenuTrackerItem *self)
return special;
}
+const gchar *
+gtk_menu_tracker_item_get_display_hint (GtkMenuTrackerItem *self)
+{
+ return self->display_hint;
+}
+
GMenuModel *
_gtk_menu_tracker_item_get_submenu (GtkMenuTrackerItem *self)
{
diff --git a/gtk/gtkmenutrackeritem.h b/gtk/gtkmenutrackeritem.h
index 2d9ff16..3c62050 100644
--- a/gtk/gtkmenutrackeritem.h
+++ b/gtk/gtkmenutrackeritem.h
@@ -46,9 +46,11 @@ GtkMenuTrackerItem * _gtk_menu_tracker_item_new (GtkActi
GMenuModel *model,
gint item_index,
const gchar
*action_namespace,
- gboolean is_separator);
+ gboolean is_separator,
+ const gchar *display_hint);
const gchar * gtk_menu_tracker_item_get_special (GtkMenuTrackerItem *self);
+const gchar * gtk_menu_tracker_item_get_display_hint (GtkMenuTrackerItem *self);
GtkActionObservable * _gtk_menu_tracker_item_get_observable (GtkMenuTrackerItem *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]