[shotwell/wip/dedeprecate: 14/38] wip: Remove UI manager
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/dedeprecate: 14/38] wip: Remove UI manager
- Date: Wed, 2 Nov 2016 19:57:45 +0000 (UTC)
commit 7e02c238ff19bf24e4f4a21c9cfe738526288474
Author: Jens Georg <mail jensge org>
Date: Wed Oct 19 21:56:15 2016 +0200
wip: Remove UI manager
Signed-off-by: Jens Georg <mail jensge org>
src/org.gnome.Shotwell.gresource.xml | 1 +
src/searches/Branch.vala | 45 ++++++++++++++++------------------
ui/search_sidebar_context.ui | 18 +++++++++----
3 files changed, 34 insertions(+), 30 deletions(-)
---
diff --git a/src/org.gnome.Shotwell.gresource.xml b/src/org.gnome.Shotwell.gresource.xml
index a7e3d8d..bf973f1 100644
--- a/src/org.gnome.Shotwell.gresource.xml
+++ b/src/org.gnome.Shotwell.gresource.xml
@@ -2,5 +2,6 @@
<gresources>
<gresource prefix="/org/gnome/Shotwell">
<file>crop-pivot-reticle.png</file>
+ <file>search_sidebar_context.ui</file>
</gresource>
</gresources>
diff --git a/src/searches/Branch.vala b/src/searches/Branch.vala
index 0c86733..f9824da 100644
--- a/src/searches/Branch.vala
+++ b/src/searches/Branch.vala
@@ -61,44 +61,41 @@ public class Searches.Branch : Sidebar.Branch {
}
public class Searches.Header : Sidebar.Header, Sidebar.Contextable {
- private Gtk.UIManager ui = new Gtk.UIManager();
+ private Gtk.Builder builder;
private Gtk.Menu? context_menu = null;
public Header() {
base (_("Saved Searches"));
setup_context_menu();
}
-
+
+ private const GLib.ActionEntry[] entries = { { "new", on_new_search } };
+
private void setup_context_menu() {
- Gtk.ActionGroup group = new Gtk.ActionGroup("SidebarDefault");
- Gtk.ActionEntry[] actions = new Gtk.ActionEntry[0];
-
- Gtk.ActionEntry new_search = { "CommonNewSearch", null, TRANSLATABLE, null, null, on_new_search };
- new_search.label = _("Ne_w Saved Search…");
- actions += new_search;
-
- group.add_actions(actions, this);
- ui.insert_action_group(group, 0);
-
- File ui_file = Resources.get_ui("search_sidebar_context.ui");
+ this.builder = new Gtk.Builder ();
try {
- ui.add_ui_from_file(ui_file.get_path());
- } catch (Error err) {
- AppWindow.error_message("Error loading UI file %s: %s".printf(
- ui_file.get_path(), err.message));
+ this.builder.add_from_resource
+ ("/org/gnome/Shotwell/search_sidebar_context.ui");
+ var model = builder.get_object ("popup-menu") as GLib.MenuModel;
+ this.context_menu = new Gtk.Menu.from_model (model);
+ var group = new GLib.SimpleActionGroup ();
+ group.add_action_entries (entries, this);
+ this.context_menu.insert_action_group ("search", group);
+ } catch (Error error) {
+ AppWindow.error_message("Error loading UI resource: %s".printf(
+ error.message));
Application.get_instance().panic();
}
- context_menu = (Gtk.Menu) ui.get_widget("/SidebarSearchContextMenu");
-
- ui.ensure_update();
}
-
+
public Gtk.Menu? get_sidebar_context_menu(Gdk.EventButton? event) {
return context_menu;
}
-
- private void on_new_search() {
- (new SavedSearchDialog()).show();
+
+ private void on_new_search(GLib.SimpleAction action,
+ GLib.Variant? parameter) {
+ var dialog = new SavedSearchDialog ();
+ dialog.show ();
}
}
diff --git a/ui/search_sidebar_context.ui b/ui/search_sidebar_context.ui
index 9db976e..3b6e493 100644
--- a/ui/search_sidebar_context.ui
+++ b/ui/search_sidebar_context.ui
@@ -1,6 +1,12 @@
-<ui>
- <popup name="SidebarSearchContextMenu">
- <menuitem name="NewSearch" action="CommonNewSearch" />
- </popup>
-</ui>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<interface domain="shotwell">
+ <menu id='popup-menu'>
+ <section>
+ <item>
+ <attribute name="label" translatable="yes">Ne_w Saved Search…</attribute>
+ <attribute name="action">search.new</attribute>
+ <attribute name="accel"><Primary>s</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]