summaryrefslogtreecommitdiff
path: root/src/searches
diff options
context:
space:
mode:
Diffstat (limited to 'src/searches')
-rw-r--r--src/searches/Branch.vala20
-rw-r--r--src/searches/SavedSearchDialog.vala67
-rw-r--r--src/searches/SavedSearchPage.vala2
-rw-r--r--src/searches/SearchBoolean.vala21
-rw-r--r--src/searches/Searches.vala2
5 files changed, 62 insertions, 50 deletions
diff --git a/src/searches/Branch.vala b/src/searches/Branch.vala
index 229c710..00a9ea7 100644
--- a/src/searches/Branch.vala
+++ b/src/searches/Branch.vala
@@ -1,4 +1,4 @@
-/* Copyright 2011-2014 Yorba Foundation
+/* Copyright 2011-2015 Yorba Foundation
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
@@ -9,7 +9,7 @@ public class Searches.Branch : Sidebar.Branch {
new Gee.HashMap<SavedSearch, Searches.SidebarEntry>();
public Branch() {
- base (new Searches.Grouping(),
+ base (new Searches.Header(),
Sidebar.Branch.Options.HIDE_IF_EMPTY
| Sidebar.Branch.Options.AUTO_OPEN_ON_NEW_CHILD
| Sidebar.Branch.Options.STARTUP_EXPAND_TO_FIRST_CHILD,
@@ -60,12 +60,12 @@ public class Searches.Branch : Sidebar.Branch {
}
}
-public class Searches.Grouping : Sidebar.Grouping, Sidebar.Contextable {
+public class Searches.Header : Sidebar.Header, Sidebar.Contextable {
private Gtk.UIManager ui = new Gtk.UIManager();
private Gtk.Menu? context_menu = null;
- public Grouping() {
- base (_("Saved Searches"), new ThemedIcon(Gtk.Stock.FIND));
+ public Header() {
+ base (_("Saved Searches"));
setup_context_menu();
}
@@ -104,7 +104,7 @@ public class Searches.Grouping : Sidebar.Grouping, Sidebar.Contextable {
public class Searches.SidebarEntry : Sidebar.SimplePageEntry, Sidebar.RenameableEntry,
Sidebar.DestroyableEntry {
- private static Icon single_search_icon;
+ private static string single_search_icon = "find";
private SavedSearch search;
@@ -113,11 +113,9 @@ public class Searches.SidebarEntry : Sidebar.SimplePageEntry, Sidebar.Renameable
}
internal static void init() {
- single_search_icon = new ThemedIcon(Gtk.Stock.FIND);
}
internal static void terminate() {
- single_search_icon = null;
}
public SavedSearch for_saved_search() {
@@ -128,7 +126,7 @@ public class Searches.SidebarEntry : Sidebar.SimplePageEntry, Sidebar.Renameable
return search.get_name();
}
- public override Icon? get_sidebar_icon() {
+ public override string? get_sidebar_icon() {
return single_search_icon;
}
@@ -136,6 +134,10 @@ public class Searches.SidebarEntry : Sidebar.SimplePageEntry, Sidebar.Renameable
return new SavedSearchPage(search);
}
+ public bool is_user_renameable() {
+ return true;
+ }
+
public void rename(string new_name) {
if (!SavedSearchTable.get_instance().exists(new_name))
AppWindow.get_command_manager().execute(new RenameSavedSearchCommand(search, new_name));
diff --git a/src/searches/SavedSearchDialog.vala b/src/searches/SavedSearchDialog.vala
index da7f7db..eb016d3 100644
--- a/src/searches/SavedSearchDialog.vala
+++ b/src/searches/SavedSearchDialog.vala
@@ -1,4 +1,4 @@
-/* Copyright 2011-2014 Yorba Foundation
+/* Copyright 2011-2015 Yorba Foundation
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
@@ -48,13 +48,12 @@ public class SavedSearchDialog {
set_type_combo_box(SearchCondition.SearchType.ANY_TEXT); // Sets default.
type_combo.changed.connect(on_type_changed);
- remove_button = new Gtk.Button();
- remove_button.set_label(" – ");
+ remove_button = new Gtk.Button.from_icon_name("list-remove-symbolic", Gtk.IconSize.BUTTON);
remove_button.button_press_event.connect(on_removed);
align = new Gtk.Alignment(0,0,0,0);
- box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
+ box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 3);
box.pack_start(type_combo, false, false, 0);
box.pack_start(align, false, false, 0);
box.pack_start(new Gtk.Alignment(0,0,0,0), true, true, 0); // Fill space.
@@ -172,6 +171,7 @@ public class SavedSearchDialog {
text_context.append_text(_("ends with"));
text_context.append_text(_("does not contain"));
text_context.append_text(_("is not set"));
+ text_context.append_text(_("is set"));
text_context.set_active(0);
text_context.changed.connect(on_changed);
@@ -180,7 +180,7 @@ public class SavedSearchDialog {
entry.set_activates_default(true);
entry.changed.connect(on_changed);
- box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
+ box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 3);
box.pack_start(text_context, false, false, 0);
box.pack_start(entry, false, false, 0);
box.show_all();
@@ -212,7 +212,9 @@ public class SavedSearchDialog {
}
public override bool is_complete() {
- return entry.text.chomp() != "" || get_text_context() == SearchConditionText.Context.IS_NOT_SET;
+ return entry.text.chomp() != "" ||
+ get_text_context() == SearchConditionText.Context.IS_NOT_SET ||
+ get_text_context() == SearchConditionText.Context.IS_SET;
}
private SearchConditionText.Context get_text_context() {
@@ -220,7 +222,8 @@ public class SavedSearchDialog {
}
private void on_changed() {
- if (get_text_context() == SearchConditionText.Context.IS_NOT_SET) {
+ if (get_text_context() == SearchConditionText.Context.IS_NOT_SET
+ || get_text_context() == SearchConditionText.Context.IS_SET) {
entry.hide();
} else {
entry.show();
@@ -255,7 +258,7 @@ public class SavedSearchDialog {
media_type.set_active(0);
media_type.changed.connect(on_changed);
- box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
+ box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 3);
box.pack_start(media_context, false, false, 0);
box.pack_start(media_type, false, false, 0);
box.show_all();
@@ -317,7 +320,7 @@ public class SavedSearchDialog {
modified_state.set_active(0);
modified_state.changed.connect(on_changed);
- box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
+ box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 3);
box.pack_start(modified_context, false, false, 0);
box.pack_start(modified_state, false, false, 0);
box.show_all();
@@ -372,7 +375,7 @@ public class SavedSearchDialog {
flagged_state.set_active(0);
flagged_state.changed.connect(on_changed);
- box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
+ box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 3);
box.pack_start(new Gtk.Label(_("is")), false, false, 0);
box.pack_start(flagged_state, false, false, 0);
box.show_all();
@@ -437,7 +440,7 @@ public class SavedSearchDialog {
context.set_active(0);
context.changed.connect(on_changed);
- box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
+ box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 3);
box.pack_start(new Gtk.Label(_("is")), false, false, 0);
box.pack_start(rating, false, false, 0);
box.pack_start(context, false, false, 0);
@@ -512,7 +515,7 @@ public class SavedSearchDialog {
and = new Gtk.Label(_("and"));
- box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 8);
+ box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 3);
box.pack_start(context, false, false, 0);
box.pack_start(label_one, false, false, 0);
box.pack_start(and, false, false, 0);
@@ -604,14 +607,16 @@ public class SavedSearchDialog {
int orig_month = cal.month;
int orig_year = cal.year;
Gtk.Dialog d = new Gtk.Dialog.with_buttons(null, null,
- Gtk.DialogFlags.MODAL, Gtk.Stock.CANCEL, Gtk.ResponseType.REJECT,
- Gtk.Stock.OK, Gtk.ResponseType.ACCEPT);
+ Gtk.DialogFlags.MODAL, Resources.CANCEL_LABEL, Gtk.ResponseType.REJECT,
+ Resources.OK_LABEL, Gtk.ResponseType.ACCEPT);
d.set_modal(true);
d.set_resizable(false);
d.set_decorated(false);
((Gtk.Box) d.get_content_area()).add(cal);
ulong id_1 = cal.day_selected.connect(()=>{update_date_labels();});
- ulong id_2 = cal.day_selected_double_click.connect(()=>{d.close();});
+ ulong id_2 = cal.day_selected_double_click.connect(()=> {
+ d.response(Gtk.ResponseType.ACCEPT);
+ });
d.show_all();
int res = d.run();
if (res != Gtk.ResponseType.ACCEPT) {
@@ -656,14 +661,7 @@ public class SavedSearchDialog {
// Default is text search.
add_text_search();
row_list.get(0).allow_removal(false);
-
- // Add buttons for new search.
- dialog.add_action_widget(new Gtk.Button.from_stock(Gtk.Stock.CANCEL), Gtk.ResponseType.CANCEL);
- Gtk.Button ok_button = new Gtk.Button.from_stock(Gtk.Stock.OK);
- ok_button.can_default = true;
- dialog.add_action_widget(ok_button, Gtk.ResponseType.OK);
- dialog.set_default_response(Gtk.ResponseType.OK);
-
+
dialog.show_all();
set_valid(false);
}
@@ -673,12 +671,6 @@ public class SavedSearchDialog {
edit_mode = true;
setup_dialog();
- // Add close button.
- Gtk.Button close_button = new Gtk.Button.from_stock(Gtk.Stock.CLOSE);
- close_button.can_default = true;
- dialog.add_action_widget(close_button, Gtk.ResponseType.OK);
- dialog.set_default_response(Gtk.ResponseType.OK);
-
dialog.show_all();
// Load existing search into dialog.
@@ -701,12 +693,21 @@ public class SavedSearchDialog {
// Builds the dialog UI. Doesn't add buttons to the dialog or call dialog.show().
private void setup_dialog() {
builder = AppWindow.create_builder();
-
- dialog = builder.get_object("Search criteria") as Gtk.Dialog;
- dialog.set_parent_window(AppWindow.get_instance().get_parent_window());
+
+ dialog = new Gtk.Dialog.with_buttons(_("Search"),
+ (Gtk.Window) AppWindow.get_instance().get_parent_window(),
+ Gtk.DialogFlags.MODAL |
+ Gtk.DialogFlags.DESTROY_WITH_PARENT |
+ Gtk.DialogFlags.USE_HEADER_BAR,
+ _("Cancel"), Gtk.ResponseType.CANCEL,
+ _("OK"), Gtk.ResponseType.OK,
+ null);
+ dialog.set_resizable(false);
dialog.set_transient_for(AppWindow.get_instance());
+ dialog.set_default_response(Gtk.ResponseType.OK);
dialog.response.connect(on_response);
-
+ dialog.get_content_area().add(builder.get_object("criteria") as Gtk.Widget);
+
add_criteria = builder.get_object("Add search button") as Gtk.Button;
add_criteria.button_press_event.connect(on_add_criteria);
diff --git a/src/searches/SavedSearchPage.vala b/src/searches/SavedSearchPage.vala
index 8e6672e..99473fb 100644
--- a/src/searches/SavedSearchPage.vala
+++ b/src/searches/SavedSearchPage.vala
@@ -1,4 +1,4 @@
-/* Copyright 2011-2014 Yorba Foundation
+/* Copyright 2011-2015 Yorba Foundation
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
diff --git a/src/searches/SearchBoolean.vala b/src/searches/SearchBoolean.vala
index 431e398..8031814 100644
--- a/src/searches/SearchBoolean.vala
+++ b/src/searches/SearchBoolean.vala
@@ -1,4 +1,4 @@
-/* Copyright 2011-2014 Yorba Foundation
+/* Copyright 2011-2015 Yorba Foundation
*
* This software is licensed under the GNU LGPL (version 2.1 or later).
* See the COPYING file in this distribution.
@@ -206,7 +206,8 @@ public class SearchConditionText : SearchCondition {
STARTS_WITH,
ENDS_WITH,
DOES_NOT_CONTAIN,
- IS_NOT_SET;
+ IS_NOT_SET,
+ IS_SET;
public string to_string() {
switch (this) {
@@ -228,6 +229,9 @@ public class SearchConditionText : SearchCondition {
case Context.IS_NOT_SET:
return "IS_NOT_SET";
+ case Context.IS_SET:
+ return "IS_SET";
+
default:
error("unrecognized text search context enumeration value");
}
@@ -252,6 +256,9 @@ public class SearchConditionText : SearchCondition {
else if (str == "IS_NOT_SET")
return Context.IS_NOT_SET;
+ else if (str == "IS_SET")
+ return Context.IS_SET;
+
else
error("unrecognized text search context name: %s", str);
}
@@ -287,6 +294,9 @@ public class SearchConditionText : SearchCondition {
case Context.IS_NOT_SET:
return (is_string_empty(haystack));
+
+ case Context.IS_SET:
+ return (!is_string_empty(haystack));
}
return false;
@@ -298,10 +308,9 @@ public class SearchConditionText : SearchCondition {
// title
if (SearchType.ANY_TEXT == search_type || SearchType.TITLE == search_type) {
- string title = source.get_title();
- if(title != null){
- ret |= string_match(text, String.remove_diacritics(title.down()));
- }
+ string? title = (null != source.get_title()) ?
+ String.remove_diacritics(source.get_title().down()) : null;
+ ret |= string_match(text, title);
}
// tags
diff --git a/src/searches/Searches.vala b/src/searches/Searches.vala
index 478de86..691bcf0 100644
--- a/src/searches/Searches.vala
+++ b/src/searches/Searches.vala
@@ -1,4 +1,4 @@
-/* Copyright 2011-2014 Yorba Foundation
+/* Copyright 2011-2015 Yorba Foundation
*
* This software is licensed under the GNU Lesser General Public License
* (version 2.1 or later). See the COPYING file in this distribution.