[shotwell/wip/gtk4: 87/154] Fix SavedSearch popover
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/gtk4: 87/154] Fix SavedSearch popover
- Date: Sat, 1 Oct 2022 17:53:16 +0000 (UTC)
commit 6ca217a07fa805ab404f985fca47d21936f35d58
Author: Jens Georg <mail jensge org>
Date: Wed Apr 6 01:00:31 2022 +0200
Fix SavedSearch popover
data/ui/saved_search_dialog.ui | 197 +++++++++---------------------------
meson.build | 2 +-
src/AppWindow.vala | 17 +++-
src/Dialogs.vala | 8 +-
src/SavedSearchPopover.vala | 101 ++++++++++++++++++
src/SearchFilter.vala | 180 ++++++--------------------------
src/meson.build | 1 +
src/searches/SavedSearchDialog.vala | 9 +-
src/searches/SavedSearchPage.vala | 7 +-
src/tags/TagPage.vala | 7 +-
src/tags/TagsBranch.vala | 7 +-
11 files changed, 217 insertions(+), 319 deletions(-)
---
diff --git a/data/ui/saved_search_dialog.ui b/data/ui/saved_search_dialog.ui
index f56fd179..e38b8815 100644
--- a/data/ui/saved_search_dialog.ui
+++ b/data/ui/saved_search_dialog.ui
@@ -1,139 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.22.0 -->
<interface domain="shotwell">
- <requires lib="gtk+" version="3.18"/>
+ <requires lib="gtk" version="4.0"/>
<template class="SavedSearchDialog" parent="GtkDialog">
- <property name="can_focus">False</property>
- <property name="border_width">0</property>
<property name="title" translatable="yes">Search</property>
- <property name="resizable">False</property>
- <property name="modal">True</property>
- <property name="destroy_with_parent">True</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
+ <property name="resizable">0</property>
+ <property name="modal">1</property>
+ <property name="destroy_with_parent">1</property>
+ <property name="default-widget">button2</property>
+ <child internal-child="content_area">
<object class="GtkBox">
- <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox">
- <property name="can_focus">False</property>
- <property name="margin_right">18</property>
- <property name="margin_bottom">12</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="button1">
- <property name="label" translatable="yes">Cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="button2">
- <property name="label" translatable="yes">OK</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="receives_default">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
<child>
<object class="GtkBox" id="criteria">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">18</property>
+ <property name="margin-top">18</property>
+ <property name="margin-bottom">18</property>
+ <property name="margin-start">18</property>
+ <property name="margin-end">18</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="hbox3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="margin_bottom">18</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
+ <property name="hexpand">1</property>
+ <property name="vexpand">1</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="Name of search:">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="label" translatable="yes">_Name of search:</property>
- <property name="use_underline">True</property>
+ <property name="use_underline">1</property>
<property name="mnemonic_widget">search_title</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkEntry" id="search_title">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="hexpand">1</property>
+ <property name="focusable">1</property>
<property name="invisible_char">•</property>
- <property name="activates_default">True</property>
+ <property name="activates_default">1</property>
<property name="width_chars">20</property>
- <property name="primary_icon_activatable">False</property>
- <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_activatable">0</property>
+ <property name="secondary_icon_activatable">0</property>
</object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkBox" id="hbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="margin_bottom">6</property>
- <property name="hexpand">True</property>
- <property name="vexpand">True</property>
+ <property name="hexpand">1</property>
+ <property name="vexpand">1</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="Match">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="label" translatable="yes">_Match</property>
- <property name="use_underline">True</property>
+ <property name="use_underline">1</property>
<property name="justify">right</property>
<property name="mnemonic_widget">operator</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
</child>
<child>
<object class="GtkComboBoxText" id="operator">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="halign">center</property>
<property name="active">0</property>
<items>
<item translatable="yes">any</item>
@@ -141,66 +68,38 @@
<item translatable="yes">none</item>
</items>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">1</property>
- <property name="position">1</property>
- </packing>
</child>
<child>
<object class="GtkLabel" id="of the following:">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="label" translatable="yes">of the following:</property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
<child>
<placeholder/>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
<child>
<object class="GtkScrolledWindow" id="scrolled">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="focusable">1</property>
<property name="hscrollbar_policy">never</property>
- <property name="shadow_type">in</property>
<property name="min_content_height">176</property>
- <child>
+ <property name="child">
<object class="GtkViewport">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
+ <property name="child">
<object class="GtkListBox" id="row_listbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<child>
<object class="GtkListBoxRow">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
+ <property name="focusable">1</property>
<property name="valign">center</property>
- <child>
+ <property name="child">
<object class="GtkButton" id="add_criteria">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
+ <property name="focusable">1</property>
+ <property name="receives_default">1</property>
<property name="valign">start</property>
- <property name="relief">none</property>
+ <property name="has-frame">false</property>
<child>
<object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="icon_name">list-add-symbolic</property>
<property name="icon_size">1</property>
</object>
@@ -209,35 +108,39 @@
<class name="image-button"/>
</style>
</object>
- </child>
+ </property>
</object>
</child>
</object>
- </child>
+ </property>
</object>
- </child>
+ </property>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
</child>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">button1</action-widget>
- <action-widget response="-5">button2</action-widget>
+ <action-widget response="-5" default="true">button2</action-widget>
</action-widgets>
- <child type="titlebar">
- <placeholder/>
+ <child type="action">
+ <object class="GtkButton" id="button1">
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="focusable">1</property>
+ <property name="receives_default">1</property>
+ </object>
+ </child>
+ <child type="action">
+ <object class="GtkButton" id="button2">
+ <property name="label" translatable="yes">OK</property>
+ <property name="focusable">1</property>
+ <property name="receives_default">1</property>
+ <style>
+ <class name="suggested-action" />
+ </style>
+ </object>
</child>
</template>
</interface>
diff --git a/meson.build b/meson.build
index 2e884adf..ac3b9271 100644
--- a/meson.build
+++ b/meson.build
@@ -50,7 +50,7 @@ gio = dependency('gio-2.0', version: '>= 2.40')
gmodule = dependency('gmodule-2.0', version: '>= 2.40')
gio_unix = dependency('gio-unix-2.0', version: '>= 2.40')
gee = dependency('gee-0.8', version: '>= 0.8.5')
-webkit = dependency('webkit2gtk-4.1', version: '>= 2.26')
+webkit = dependency('webkit2gtk-5.0', version: '>= 2.26')
soup = dependency('libsoup-3.0')
json_glib = dependency('json-glib-1.0')
xml = dependency('libxml-2.0')
diff --git a/src/AppWindow.vala b/src/AppWindow.vala
index 78f57242..82942d63 100644
--- a/src/AppWindow.vala
+++ b/src/AppWindow.vala
@@ -503,7 +503,7 @@ public abstract class AppWindow : PageWindow {
dialog.response.connect(() => dialog.destroy());
}
- public static bool negate_affirm_question(string message, string negative, string affirmative,
+ public static async bool negate_affirm_question(string message, string negative, string affirmative,
string? title = null, Gtk.Window? parent = null) {
Gtk.MessageDialog dialog = new Gtk.MessageDialog((parent != null) ? parent : get_instance(),
Gtk.DialogFlags.MODAL, Gtk.MessageType.QUESTION, Gtk.ButtonsType.NONE, "%s",
build_alert_body_text(title, message));
@@ -511,11 +511,18 @@ public abstract class AppWindow : PageWindow {
dialog.set_markup(build_alert_body_text(title, message));
dialog.add_buttons(negative, Gtk.ResponseType.NO, affirmative, Gtk.ResponseType.YES);
- bool response = false; // TODO (dialog.run() == Gtk.ResponseType.YES);
+ dialog.show();
- dialog.destroy();
-
- return response;
+ int response_id = 0;
+ SourceFunc callback = negate_affirm_question.callback;
+ dialog.response.connect((source, resp) => {
+ response_id = resp;
+ dialog.destroy();
+ callback();
+ });
+ yield;
+
+ return response_id == Gtk.ResponseType.YES;
}
public static Gtk.ResponseType negate_affirm_cancel_question(string message, string negative,
diff --git a/src/Dialogs.vala b/src/Dialogs.vala
index 8c1ace82..fa2766da 100644
--- a/src/Dialogs.vala
+++ b/src/Dialogs.vala
@@ -8,7 +8,7 @@
// place: https://bugzilla.gnome.org/show_bug.cgi?id=717659
namespace Dialogs {
-public bool confirm_delete_tag(Tag tag) {
+public async bool confirm_delete_tag(Tag tag) {
int count = tag.get_sources_count();
if (count == 0)
return true;
@@ -17,15 +17,15 @@ public bool confirm_delete_tag(Tag tag) {
"This will remove the tag “%s” from %d photos. Continue?",
count).printf(tag.get_user_visible_name(), count);
- return AppWindow.negate_affirm_question(msg, _("_Cancel"), _("_Delete"),
+ return yield AppWindow.negate_affirm_question(msg, _("_Cancel"), _("_Delete"),
Resources.DELETE_TAG_TITLE);
}
-public bool confirm_delete_saved_search(SavedSearch search) {
+public async bool confirm_delete_saved_search(SavedSearch search) {
string msg = _("This will remove the saved search “%s”. Continue?")
.printf(search.get_name());
- return AppWindow.negate_affirm_question(msg, _("_Cancel"), _("_Delete"),
+ return yield AppWindow.negate_affirm_question(msg, _("_Cancel"), _("_Delete"),
Resources.DELETE_SAVED_SEARCH_DIALOG_TITLE);
}
diff --git a/src/SavedSearchPopover.vala b/src/SavedSearchPopover.vala
new file mode 100644
index 00000000..f1c56a3f
--- /dev/null
+++ b/src/SavedSearchPopover.vala
@@ -0,0 +1,101 @@
+protected class SavedSearchPopover {
+ public Gtk.Popover popover = null;
+ private Gtk.ListBox list_box = null;
+ private Gtk.Button[] edit_buttons = null;
+ private Gtk.Button[] delete_buttons = null;
+ Gtk.Button add = null;
+
+ public signal void search_activated(SavedSearch search);
+ public signal void edit_clicked(SavedSearch search);
+ public signal void delete_clicked(SavedSearch search);
+ public signal void add_clicked();
+
+ public signal void closed();
+
+ public SavedSearchPopover() {
+ popover = new Gtk.Popover();
+ popover.closed.connect(on_popover_closed);
+ list_box = new Gtk.ListBox();
+ edit_buttons = new Gtk.Button[0];
+ delete_buttons = new Gtk.Button[0];
+
+ foreach (var search in SavedSearchTable.get_instance().get_all()) {
+ Gtk.Box row = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 1);
+ row.set_data("search", search);
+ row.set_homogeneous(false);
+ Gtk.Label label = new Gtk.Label(search.get_name());
+ label.halign = Gtk.Align.START;
+ label.xalign = 0.0f;
+ label.hexpand = true;
+ row.prepend(label);
+
+ var edit_button = new Gtk.Button.from_icon_name("text-editor-symbolic");
+ row.append(edit_button);
+ edit_button.add_css_class("toolbar");
+ edit_button.has_frame = false;
+ edit_button.clicked.connect(() => {
+ edit_clicked(search);
+ });
+ edit_buttons += edit_button;
+
+ var delete_button = new Gtk.Button.from_icon_name("edit-delete-symbolic");
+ row.append(delete_button);
+ delete_button.add_css_class("toolbar");
+ delete_button.has_frame = false;
+ delete_button.clicked.connect(() => {
+ delete_clicked (search);
+ });
+ delete_buttons += delete_button;
+
+ list_box.insert(row, -1);
+ }
+
+ add = new Gtk.Button.from_icon_name("list-add-symbolic");
+ add.clicked.connect(on_add_click);
+ list_box.insert(add, -1);
+
+ list_box.row_activated.connect(on_activate_row);
+ list_box.selection_mode = Gtk.SelectionMode.NONE;
+ popover.set_child(list_box);
+ popover.autohide = false;
+
+ }
+
+ ~SavedSearchPopover() {
+ add.clicked.disconnect(on_add_click);
+ list_box.row_activated.disconnect(on_activate_row);
+ popover.closed.disconnect(on_popover_closed);
+ }
+
+ private bool is_search_row(Gtk.ListBoxRow? row) {
+ if (row == null) return false;
+ if (row.get_child() is Gtk.Button) return false;
+ return true;
+ }
+
+ private SavedSearch? get_search(Gtk.ListBoxRow row) {
+ return row.get_child().get_data("search");
+ }
+
+ private void on_activate_row(Gtk.ListBoxRow? row) {
+ if (is_search_row(row))
+ search_activated(get_search(row));
+ popover.hide();
+ }
+
+ private void on_add_click() {
+ add_clicked();
+ }
+
+ private void on_popover_closed() {
+ closed();
+ }
+
+ public void show_all() {
+ popover.show();
+ }
+
+ public void hide() {
+ popover.hide();
+ }
+}
diff --git a/src/SearchFilter.vala b/src/SearchFilter.vala
index 761a953b..93562f73 100644
--- a/src/SearchFilter.vala
+++ b/src/SearchFilter.vala
@@ -646,27 +646,38 @@ public class SearchFilterToolbar : Gtk.Box {
private class ToggleActionToolButton : Gtk.Box {
private Gtk.ToggleButton button;
+ private Gtk.Image image;
+ private Gtk.Label label;
public ToggleActionToolButton(string action) {
+ var content = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 6);
+ image = new Gtk.Image();
+ label = new Gtk.Label(null);
+ content.prepend(image);
+ content.append(label);
+ image.set_visible(false);
+ label.set_visible(false);
button = new Gtk.ToggleButton();
button.set_can_focus(false);
button.set_action_name (action);
button.set_has_tooltip(true);
button.set_margin_start(2);
+ button.set_child(content);
this.append (button);
}
public void set_icon_name(string icon_name) {
- Gtk.Image? image = null;
- image = new Gtk.Image.from_icon_name(icon_name);
if (button.get_label() != "" && button.get_label() != null) {
image.margin_end = 6;
}
+ image.set_from_icon_name(icon_name);
+ image.set_visible(true);
}
public void set_label(string label) {
- button.set_label(label);
+ this.label.set_text(label);
+ this.label.set_visible(true);
}
}
@@ -882,7 +893,7 @@ public class SearchFilterToolbar : Gtk.Box {
Gtk.Image? image = new Gtk.Image.from_icon_name("edit-find-symbolic");
image.set_margin_end(6);
- //button.set_image(image);
+ this.prepend (image);
button.set_can_focus(false);
button.clicked.connect(on_clicked);
@@ -915,145 +926,6 @@ public class SearchFilterToolbar : Gtk.Box {
}
}
- protected class SavedSearchPopover {
- private Gtk.Popover popover = null;
- private Gtk.ListBox list_box = null;
- private DataButton[] edit_buttons = null;
- private DataButton[] delete_buttons = null;
- Gtk.Button add = null;
-
- public signal void search_activated(SavedSearch search);
- public signal void edit_clicked(SavedSearch search);
- public signal void delete_clicked(SavedSearch search);
- public signal void add_clicked();
-
- public signal void closed();
-
- private class DataButton : Gtk.Box {
- private Gtk.Button button = null;
- public SavedSearch search { get; private set; }
-
- public signal void clicked(SavedSearch search);
-
- public DataButton(SavedSearch search, string name) {
- button = new Gtk.Button.from_icon_name(name);
- this.search = search;
- this.append(button);
-
- restyle();
-
- button.clicked.connect(on_click);
- }
-
- ~DataButton() {
- button.clicked.disconnect(on_click);
- }
-
- public void restyle() {
- button.set_size_request(24, 24);
- }
-
- private void on_click() {
- clicked(this.search);
- }
- }
-
- public SavedSearchPopover(Gtk.Widget relative_to) {
- popover = new Gtk.Popover();
- popover.closed.connect(on_popover_closed);
- list_box = new Gtk.ListBox();
- edit_buttons = new DataButton[0];
- delete_buttons = new DataButton[0];
-
- foreach (SavedSearch search in SavedSearchTable.get_instance().get_all()) {
- Gtk.Box row = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 1);
- row.set_homogeneous(false);
- Gtk.Label label = new Gtk.Label(search.get_name());
- label.halign = Gtk.Align.START;
- row.append(label);
-
- DataButton delete_button = new DataButton(search, "edit-delete-symbolic");
- row.append(delete_button);
- delete_button.clicked.connect(on_delete_click);
- delete_buttons += delete_button;
-
- DataButton edit_button = new DataButton(search, "text-editor-symbolic");
- row.append(edit_button);
- edit_button.clicked.connect(on_edit_click);
- edit_buttons += edit_button;
-
- list_box.insert(row, -1);
- }
- add = new Gtk.Button.from_icon_name("list-add-symbolic");
- add.clicked.connect(on_add_click);
- list_box.insert(add, -1);
- list_box.row_activated.connect(on_activate_row);
- list_box.selection_mode = Gtk.SelectionMode.NONE;
- popover.set_child(list_box);
-
- restyle();
- }
-
- ~SavedSearchPopover() {
- foreach (DataButton button in edit_buttons) button.clicked.disconnect(on_edit_click);
- foreach (DataButton button in delete_buttons) button.clicked.disconnect(on_delete_click);
- add.clicked.disconnect(on_add_click);
- list_box.row_activated.disconnect(on_activate_row);
- popover.closed.disconnect(on_popover_closed);
- }
-
- public void restyle() {
- foreach (DataButton button in edit_buttons) button.restyle();
- foreach (DataButton button in delete_buttons) button.restyle();
- }
-
- private bool is_search_row(Gtk.ListBoxRow? row) {
- if (row == null) return false;
- if (row.get_child() is Gtk.Button) return false;
- return true;
- }
-
- private SavedSearch? get_search(Gtk.ListBoxRow row) {
- #if 0
- var box = (Gtk.Box) row.get_child();
- DataButton button; // = box.get_children().last().data as DataButton;
- return button.search;
- #endif
-
- return null;
- }
-
- private void on_activate_row(Gtk.ListBoxRow? row) {
- if (is_search_row(row))
- search_activated(get_search(row));
- popover.hide();
- }
-
- private void on_edit_click(SavedSearch search) {
- edit_clicked(search);
- }
-
- private void on_delete_click(SavedSearch search) {
- delete_clicked(search);
- }
-
- private void on_add_click() {
- add_clicked();
- }
-
- private void on_popover_closed() {
- closed();
- }
-
- public void show_all() {
- popover.show();
- }
-
- public void hide() {
- popover.hide();
- }
- }
-
public Gtk.Builder builder = new Gtk.Builder ();
private SearchFilterActions actions;
@@ -1074,6 +946,7 @@ public class SearchFilterToolbar : Gtk.Box {
this.actions = actions;
actions.media_context_changed.connect(on_media_context_changed);
search_box = new SearchBox(actions.text);
+ add_css_class("toolbar");
set_name("search-filter-toolbar");
@@ -1114,6 +987,7 @@ public class SearchFilterToolbar : Gtk.Box {
append(toolbtn_raw);
// separator
+ append(new Gtk.Separator(Gtk.Orientation.VERTICAL));
// Flagged button
@@ -1124,6 +998,7 @@ public class SearchFilterToolbar : Gtk.Box {
append(toolbtn_flag);
// separator
+ append(new Gtk.Separator(Gtk.Orientation.VERTICAL));
// Rating button
var model = this.builder.get_object ("popup-menu") as GLib.MenuModel;
@@ -1132,6 +1007,7 @@ public class SearchFilterToolbar : Gtk.Box {
append(rating_button);
// separator
+ append(new Gtk.Separator(Gtk.Orientation.VERTICAL));
// Saved search button
saved_search_button.set_label(_("Saved Search"));
@@ -1139,7 +1015,11 @@ public class SearchFilterToolbar : Gtk.Box {
saved_search_button.clicked.connect(on_saved_search_button_clicked);
append(saved_search_button);
- // Separator to right-align the text box
+ // separator
+ var separator = new Gtk.Separator(Gtk.Orientation.VERTICAL);
+ separator.hexpand = true;
+ separator.halign = Gtk.Align.START;
+ append(separator);
// Search box.
append(search_box);
@@ -1354,8 +1234,11 @@ public class SearchFilterToolbar : Gtk.Box {
private void delete_dialog(SavedSearch search) {
saved_search_button.filter_popup.hide();
- if (Dialogs.confirm_delete_saved_search(search))
- AppWindow.get_command_manager().execute(new DeleteSavedSearchCommand(search));
+ Dialogs.confirm_delete_saved_search.begin(search, (source, res) => {
+ if (Dialogs.confirm_delete_saved_search.end(res)) {
+ AppWindow.get_command_manager().execute(new DeleteSavedSearchCommand(search));
+ }
+ });
}
private void add_dialog() {
@@ -1370,6 +1253,7 @@ public class SearchFilterToolbar : Gtk.Box {
saved_search_button.filter_popup.hide();
}
+
private void on_saved_search_button_clicked() {
if (elide_showing_again && saved_search == null) {
} else if (saved_search != null) {
@@ -1384,13 +1268,13 @@ public class SearchFilterToolbar : Gtk.Box {
saved_search_button.filter_popup.add_clicked.disconnect(add_dialog);
saved_search_button.filter_popup.closed.disconnect(on_popover_closed);
}
- saved_search_button.filter_popup = new SavedSearchPopover(saved_search_button);
+ saved_search_button.filter_popup = new SavedSearchPopover();
+ saved_search_button.filter_popup.popover.set_parent(saved_search_button);
saved_search_button.filter_popup.edit_clicked.connect(edit_dialog);
saved_search_button.filter_popup.search_activated.connect(on_savedsearch_selected);
saved_search_button.filter_popup.delete_clicked.connect(delete_dialog);
saved_search_button.filter_popup.add_clicked.connect(add_dialog);
saved_search_button.filter_popup.closed.connect(on_popover_closed);
-
saved_search_button.filter_popup.show_all();
}
elide_showing_again = false;
diff --git a/src/meson.build b/src/meson.build
index 0a8e2b9b..4aaeebdd 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -201,6 +201,7 @@ executable(
'PhotoMonitor.vala',
'VideoMonitor.vala',
'SearchFilter.vala',
+ 'SavedSearchPopover.vala',
'MediaViewTracker.vala',
'Upgrades.vala',
'dialogs/AdjustDateTimeDialog.vala',
diff --git a/src/searches/SavedSearchDialog.vala b/src/searches/SavedSearchDialog.vala
index 9cb7ff6c..a3e1c54e 100644
--- a/src/searches/SavedSearchDialog.vala
+++ b/src/searches/SavedSearchDialog.vala
@@ -667,6 +667,7 @@ public class SavedSearchDialog : Gtk.Dialog {
show();
set_valid(false);
+ response.connect (() => {destroy();});
}
public SavedSearchDialog.edit_existing(SavedSearch saved_search) {
@@ -707,14 +708,6 @@ public class SavedSearchDialog : Gtk.Dialog {
}
}
- // Displays the dialog.
- public new void show() {
- //run();
- base.show();
- // TODO
- destroy();
- }
-
double upper;
// Adds a row of search criteria.
private void on_add_criteria() {
diff --git a/src/searches/SavedSearchPage.vala b/src/searches/SavedSearchPage.vala
index 9267137f..271f3165 100644
--- a/src/searches/SavedSearchPage.vala
+++ b/src/searches/SavedSearchPage.vala
@@ -68,8 +68,11 @@ public class SavedSearchPage : CollectionPage {
private void on_delete_search() {
- if (Dialogs.confirm_delete_saved_search(search))
- AppWindow.get_command_manager().execute(new DeleteSavedSearchCommand(search));
+ Dialogs.confirm_delete_saved_search.begin(search, (source, res) => {
+ if (Dialogs.confirm_delete_saved_search.end(res)) {
+ AppWindow.get_command_manager().execute(new DeleteSavedSearchCommand(search));
+ }
+ });
}
private void on_rename_search() {
diff --git a/src/tags/TagPage.vala b/src/tags/TagPage.vala
index 431eaf4a..9345535a 100644
--- a/src/tags/TagPage.vala
+++ b/src/tags/TagPage.vala
@@ -109,8 +109,11 @@ public class TagPage : CollectionPage {
}
private void on_delete_tag() {
- if (Dialogs.confirm_delete_tag(tag))
- AppWindow.get_command_manager().execute(new DeleteTagCommand(tag));
+ Dialogs.confirm_delete_tag.begin(tag, (source, res) => {
+ if (Dialogs.confirm_delete_tag.end(res)) {
+ AppWindow.get_command_manager().execute(new DeleteTagCommand(tag));
+ }
+ });
}
private void on_remove_tag_from_photos() {
diff --git a/src/tags/TagsBranch.vala b/src/tags/TagsBranch.vala
index b5ef052b..12056b08 100644
--- a/src/tags/TagsBranch.vala
+++ b/src/tags/TagsBranch.vala
@@ -239,8 +239,11 @@ public class Tags.SidebarEntry : Sidebar.SimplePageEntry, Sidebar.RenameableEntr
}
public void destroy_source() {
- if (Dialogs.confirm_delete_tag(tag))
- AppWindow.get_command_manager().execute(new DeleteTagCommand(tag));
+ Dialogs.confirm_delete_tag.begin(tag, (source, res) => {
+ if (Dialogs.confirm_delete_tag.end(res)) {
+ AppWindow.get_command_manager().execute(new DeleteTagCommand(tag));
+ }
+ });
}
public bool internal_drop_received(Gee.List<MediaSource> media) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]