r17754 - gnucash/branches/2.2/src/gnome-search - [17705] Bug #115066: Enable "Search For" dialog that matches all.
Christian Stimming
cstim at cvs.gnucash.org
Sat Dec 6 17:07:08 EST 2008
Author: cstim
Date: 2008-12-06 17:07:08 -0500 (Sat, 06 Dec 2008)
New Revision: 17754
Trac: http://svn.gnucash.org/trac/changeset/17754
Modified:
gnucash/branches/2.2/src/gnome-search/dialog-search.c
gnucash/branches/2.2/src/gnome-search/search.glade
Log:
[17705] Bug #115066: Enable "Search For" dialog that matches all.
Allow to remove all elements which results in an "empty" new/refinement/...
search matching all available items. In that case grey out the match-type
combo in the upper right corner and add a label "Match all entries" where the
criteria list used to sit.
Patch by andi5.
Modified: gnucash/branches/2.2/src/gnome-search/dialog-search.c
===================================================================
--- gnucash/branches/2.2/src/gnome-search/dialog-search.c 2008-12-06 22:07:00 UTC (rev 17753)
+++ gnucash/branches/2.2/src/gnome-search/dialog-search.c 2008-12-06 22:07:08 UTC (rev 17754)
@@ -62,6 +62,8 @@
struct _GNCSearchWindow {
GtkWidget * dialog;
+ GtkWidget * grouping_combo;
+ GtkWidget * match_all_label;
GtkWidget * criteria_table;
GtkWidget * result_hbox;
@@ -437,6 +439,14 @@
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (sw->new_rb), FALSE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (sw->narrow_rb), TRUE);
}
+
+ if (sw->crit_list) {
+ gtk_widget_set_sensitive(sw->grouping_combo, TRUE);
+ gtk_widget_hide(sw->match_all_label);
+ } else {
+ gtk_widget_set_sensitive(sw->grouping_combo, FALSE);
+ gtk_widget_show(sw->match_all_label);
+ }
}
static gboolean
@@ -446,6 +456,9 @@
GList *l;
gboolean ret;
+ if (!sw->crit_list)
+ return TRUE;
+
l = g_list_last (sw->crit_list);
data = l->data;
ret = gnc_search_core_type_validate (data->element);
@@ -523,7 +536,7 @@
GtkWidget *element;
struct _elem_data *data;
- if (g_list_length (sw->crit_list) < 2)
+ if (!sw->crit_list)
return;
element = g_object_get_data (G_OBJECT (button), "element");
@@ -535,6 +548,12 @@
/* and from the display */
gtk_container_remove (GTK_CONTAINER (sw->criteria_table), element);
gtk_container_remove (GTK_CONTAINER (sw->criteria_table), button);
+
+ /* disable match-type menu when there is no criterion */
+ if (!sw->crit_list) {
+ gtk_widget_set_sensitive(sw->grouping_combo, FALSE);
+ gtk_widget_show(sw->match_all_label);
+ }
}
static void
@@ -689,9 +708,14 @@
if (sw->crit_list) {
if (!gnc_search_dialog_crit_ok (sw))
return;
- } else
+ } else {
sw->last_param = sw->params_list->data;
+ /* no match-all situation anymore */
+ gtk_widget_set_sensitive(sw->grouping_combo, TRUE);
+ gtk_widget_hide(sw->match_all_label);
+ }
+
/* create a new criterion element */
new = gnc_search_core_type_new_type_name
@@ -803,7 +827,8 @@
gtk_widget_show (add);
/* Set the match-type menu */
- combo_box = GTK_COMBO_BOX(gtk_combo_box_new_text());
+ sw->grouping_combo = gtk_combo_box_new_text();
+ combo_box = GTK_COMBO_BOX(sw->grouping_combo);
gtk_combo_box_append_text(combo_box, _("all criteria are met"));
gtk_combo_box_append_text(combo_box, _("any criteria are met"));
gtk_combo_box_set_active(combo_box, sw->grouping);
@@ -813,6 +838,9 @@
gtk_box_pack_start (GTK_BOX (box), GTK_WIDGET(combo_box), FALSE, FALSE, 3);
gtk_widget_show(GTK_WIDGET(combo_box));
+ /* Grab the 'all items match' label */
+ sw->match_all_label = glade_xml_get_widget (xml, "match_all_label");
+
/* if there's no original query, make the narrow, add, delete
* buttons inaccessible */
sw->new_rb = glade_xml_get_widget (xml, "new_search_radiobutton");
Modified: gnucash/branches/2.2/src/gnome-search/search.glade
===================================================================
--- gnucash/branches/2.2/src/gnome-search/search.glade 2008-12-06 22:07:00 UTC (rev 17753)
+++ gnucash/branches/2.2/src/gnome-search/search.glade 2008-12-06 22:07:08 UTC (rev 17754)
@@ -345,6 +345,31 @@
</child>
<child>
+ <widget class="GtkLabel" id="match_all_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"><b>Match all entries</b></property>
+ <property name="use_underline">False</property>
+ <property name="use_markup">True</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">3</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
<widget class="GtkTable" id="criteria_table">
<property name="border_width">3</property>
<property name="visible">True</property>
More information about the gnucash-changes
mailing list