[epiphany] EphyHistoryWindow: Create popup menu from a model.
- From: Arnaud Bonatti <arnaudb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] EphyHistoryWindow: Create popup menu from a model.
- Date: Sat, 31 Oct 2015 18:16:08 +0000 (UTC)
commit 0db0c12cd64e57b43efe99d533ddad1e159c2535
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date: Sat Oct 31 19:05:22 2015 +0100
EphyHistoryWindow: Create popup menu from a model.
https://bugzilla.gnome.org/show_bug.cgi?id=757228#c26
src/ephy-history-window.c | 11 ++++---
src/resources/history-dialog.ui | 58 ++++++++++++++-------------------------
2 files changed, 27 insertions(+), 42 deletions(-)
---
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index a93493e..c9831e6 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -55,7 +55,7 @@ struct _EphyHistoryWindowPrivate
GtkTreeViewColumn *location_column;
GtkWidget *date_renderer;
GtkWidget *location_renderer;
- GtkWidget *treeview_popup_menu;
+ GMenuModel *treeview_popup_menu_model;
GActionGroup *action_group;
@@ -476,6 +476,7 @@ on_treeview_button_press_event (GtkWidget *widget,
{
if (event->button == 3) {
int n;
+ GtkMenu *menu;
n = gtk_tree_selection_count_selected_rows (self->priv->tree_selection);
if (n <= 0)
@@ -483,9 +484,9 @@ on_treeview_button_press_event (GtkWidget *widget,
update_popup_menu_actions (G_ACTION_MAP (self->priv->action_group), (n == 1));
- gtk_menu_popup (GTK_MENU (self->priv->treeview_popup_menu),
- NULL, NULL, NULL, NULL,
- event->button, event->time);
+ menu = gtk_menu_new_from_model (self->priv->treeview_popup_menu_model);
+ gtk_menu_attach_to_widget (menu, self, NULL);
+ gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time);
return TRUE;
}
@@ -715,7 +716,7 @@ ephy_history_window_class_init (EphyHistoryWindowClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, EphyHistoryWindow, location_column);
gtk_widget_class_bind_template_child_private (widget_class, EphyHistoryWindow, date_renderer);
gtk_widget_class_bind_template_child_private (widget_class, EphyHistoryWindow, location_renderer);
- gtk_widget_class_bind_template_child_private (widget_class, EphyHistoryWindow, treeview_popup_menu);
+ gtk_widget_class_bind_template_child_private (widget_class, EphyHistoryWindow,
treeview_popup_menu_model);
gtk_widget_class_bind_template_callback (widget_class, on_treeview_row_activated);
gtk_widget_class_bind_template_callback (widget_class, on_treeview_key_press_event);
diff --git a/src/resources/history-dialog.ui b/src/resources/history-dialog.ui
index 73e2fa2..0b968e1 100644
--- a/src/resources/history-dialog.ui
+++ b/src/resources/history-dialog.ui
@@ -11,6 +11,26 @@
<column type="gchararray"/>
</columns>
</object>
+ <menu id="treeview_popup_menu_model">
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">_Open</attribute>
+ <attribute name="action">history.open-selection</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Copy Location</attribute>
+ <attribute name="action">history.copy-url</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">Add _Bookmark</attribute>
+ <attribute name="action">history.bookmark</attribute>
+ </item>
+ <item>
+ <attribute name="label" translatable="yes">_Delete</attribute>
+ <attribute name="action">history.forget</attribute>
+ </item>
+ </section>
+ </menu>
<template class="EphyHistoryWindow" parent="GtkDialog">
<property name="height_request">500</property>
<property name="modal">True</property>
@@ -107,7 +127,7 @@
<property name="clickable">True</property>
<signal name="clicked" handler="on_treeview_column_clicked_event"/>
<child>
- <object class="GtkCellRendererText" id="cellrenderertext2">
+ <object class="GtkCellRendererText">
<property name="ellipsize">end</property>
</object>
<attributes>
@@ -211,40 +231,4 @@
</object>
</child>
</template>
- <object class="GtkMenu" id="treeview_popup_menu">
- <property name="visible">True</property>
- <property name="attach-widget">treeview</property>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Open</property>
- <property name="use_underline">True</property>
- <property name="action-name">history.open-selection</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Copy Location</property>
- <property name="use_underline">True</property>
- <property name="action-name">history.copy-url</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Add _Bookmark</property>
- <property name="use_underline">True</property>
- <property name="action-name">history.bookmark</property>
- </object>
- </child>
- <child>
- <object class="GtkMenuItem">
- <property name="visible">True</property>
- <property name="label" translatable="yes">_Delete</property>
- <property name="use_underline">True</property>
- <property name="action-name">history.forget</property>
- </object>
- </child>
- </object>
</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]