[Gnucash-changes] r14332 - gnucash/branches/deprecated-cleanup -
Convert the search selection widgets over from the deprecated
David Hampton
hampton at cvs.gnucash.org
Mon Jun 5 01:06:31 EDT 2006
Author: hampton
Date: 2006-06-05 01:06:30 -0400 (Mon, 05 Jun 2006)
New Revision: 14332
Trac: http://svn.gnucash.org/trac/changeset/14332
Added:
gnucash/branches/deprecated-cleanup/src/gnome-search/search-core-utils.c
gnucash/branches/deprecated-cleanup/src/gnome-search/search-core-utils.h
Modified:
gnucash/branches/deprecated-cleanup/ChangeLog
gnucash/branches/deprecated-cleanup/src/business/business-gnome/search-owner.c
gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.c
gnucash/branches/deprecated-cleanup/src/gnome-search/Makefile.am
gnucash/branches/deprecated-cleanup/src/gnome-search/search-account.c
gnucash/branches/deprecated-cleanup/src/gnome-search/search-boolean.c
gnucash/branches/deprecated-cleanup/src/gnome-search/search-date.c
gnucash/branches/deprecated-cleanup/src/gnome-search/search-double.c
gnucash/branches/deprecated-cleanup/src/gnome-search/search-int64.c
gnucash/branches/deprecated-cleanup/src/gnome-search/search-numeric.c
gnucash/branches/deprecated-cleanup/src/gnome-search/search-reconciled.c
gnucash/branches/deprecated-cleanup/src/gnome-search/search-string.c
Log:
Convert the search selection widgets over from the deprecated
GtkOptionMenu to a GtkComboBox.
Modified: gnucash/branches/deprecated-cleanup/ChangeLog
===================================================================
--- gnucash/branches/deprecated-cleanup/ChangeLog 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/ChangeLog 2006-06-05 05:06:30 UTC (rev 14332)
@@ -1,5 +1,18 @@
2006-06-04 David Hampton <hampton at employees.org>
+ * src/business/business-gnome/search-owner.c:
+ * src/core-utils/gnc-gtk-utils.[ch]:
+ * src/gnome-search/search-account.c:
+ * src/gnome-search/search-boolean.c:
+ * src/gnome-search/search-core-utils.[ch]:
+ * src/gnome-search/search-date.c:
+ * src/gnome-search/search-double.c:
+ * src/gnome-search/search-int64.c:
+ * src/gnome-search/search-numeric.c:
+ * src/gnome-search/search-reconciled.c:
+ * src/gnome-search/search-string.c: Convert the search selection
+ widgets over from the deprecated GtkOptionMenu to a GtkComboBox.
+
* src/core-utils/gnc-gtk-utils.c:
* src/gnome-utils/gnc-currency-edit.c:
* src/gnome-utils/gnc-account-sel.c: Set up the list store
Modified: gnucash/branches/deprecated-cleanup/src/business/business-gnome/search-owner.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/business/business-gnome/search-owner.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/business/business-gnome/search-owner.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -32,6 +32,7 @@
#include "business-gnome-utils.h"
#include "search-owner.h"
+#include "search-core-utils.h"
#define d(x)
@@ -199,12 +200,15 @@
}
static void
-type_option_changed (GtkWidget *widget, GNCSearchOwner *fe)
+type_combo_changed (GtkWidget *widget, GNCSearchOwner *fe)
{
GNCSearchOwnerPrivate *priv;
- GncOwnerType type = (GncOwnerType)
- g_object_get_data (G_OBJECT (widget), "option");
+ GncOwnerType type;
+ g_return_if_fail(GTK_IS_COMBO_BOX(widget));
+
+ type = gnc_combo_box_search_get_active(GTK_COMBO_BOX(widget));
+
/* If the type changed or if we don't have a type create the owner_choice */
priv = GNC_SEARCH_OWNER_GET_PRIVATE(fe);
if (type != gncOwnerGetType (&(priv->owner))) {
@@ -216,99 +220,43 @@
}
static GtkWidget *
-add_type_menu_item (GtkWidget *menu, gpointer user_data, char *label,
- GncOwnerType type)
-{
- GtkWidget *item = gtk_menu_item_new_with_label (label);
- g_object_set_data (G_OBJECT (item), "option", (gpointer) type);
- g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (type_option_changed),
- user_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- return item;
-}
-
-#define ADD_TYPE_MENU_ITEM(str,tp) { \
- item = add_type_menu_item (menu, fe, str, tp); \
- if (type == tp) { current = index; first = item; } \
- index++; \
-}
-
-static GtkWidget *
make_type_menu (GNCSearchCoreType *fe)
{
GNCSearchOwner *fi = (GNCSearchOwner *)fe;
GNCSearchOwnerPrivate *priv;
- GtkWidget *menu, *item, *first, *opmenu;
- int current = 0, index = 0;
+ GtkComboBox *combo;
GncOwnerType type;
- menu = gtk_menu_new ();
-
priv = GNC_SEARCH_OWNER_GET_PRIVATE(fi);
type = gncOwnerGetType (&(priv->owner));
- ADD_TYPE_MENU_ITEM (_("Customer"), GNC_OWNER_CUSTOMER);
- first = item;
- ADD_TYPE_MENU_ITEM (_("Vendor"), GNC_OWNER_VENDOR);
- ADD_TYPE_MENU_ITEM (_("Employee"), GNC_OWNER_EMPLOYEE);
- ADD_TYPE_MENU_ITEM (_("Job"), GNC_OWNER_JOB);
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
+ gnc_combo_box_search_add(combo, _("Customer"), GNC_OWNER_CUSTOMER);
+ gnc_combo_box_search_add(combo, _("Vendor"), GNC_OWNER_VENDOR);
+ gnc_combo_box_search_add(combo, _("Employee"), GNC_OWNER_EMPLOYEE);
+ gnc_combo_box_search_add(combo, _("Job"), GNC_OWNER_JOB);
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
+ g_signal_connect (combo, "changed", G_CALLBACK (type_combo_changed), fe);
+ gnc_combo_box_search_set_active(combo, type);
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
+ return GTK_WIDGET(combo);
- return opmenu;
-}
-static void
-how_option_changed (GtkWidget *widget, GNCSearchOwner *fe)
-{
- fe->how = (query_compare_t)
- g_object_get_data (G_OBJECT (widget), "option");
}
static GtkWidget *
-add_how_menu_item (GtkWidget *menu, gpointer user_data, char *label,
- query_compare_t option)
-{
- GtkWidget *item = gtk_menu_item_new_with_label (label);
- g_object_set_data (G_OBJECT (item), "option", (gpointer) option);
- g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (how_option_changed),
- user_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- return item;
-}
-
-#define ADD_HOW_MENU_ITEM(str,op) { \
- item = add_how_menu_item (menu, fe, str, op); \
- if (fi->how == op) { current = index; first = item; } \
- index++; \
-}
-
-static GtkWidget *
make_how_menu (GNCSearchCoreType *fe)
{
GNCSearchOwner *fi = (GNCSearchOwner *)fe;
- GtkWidget *menu, *item, *first, *opmenu;
- int current = 0, index = 0;
+ GtkComboBox *combo;
- menu = gtk_menu_new ();
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
+ gnc_combo_box_search_add(combo, _("is"), GUID_MATCH_ANY);
+ gnc_combo_box_search_add(combo, _("is not"), GUID_MATCH_NONE);
+ gnc_combo_box_search_changed(combo, &fi->how);
+ gnc_combo_box_search_set_active(combo, fi->how ? fi->how : GUID_MATCH_ANY);
- ADD_HOW_MENU_ITEM (_("is"), GUID_MATCH_ANY);
- first = item; /* Force one */
- ADD_HOW_MENU_ITEM (_("is not"), GUID_MATCH_NONE);
-
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
-
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
-
- return opmenu;
+ return GTK_WIDGET(combo);
}
static GtkWidget *
Modified: gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/core-utils/gnc-gtk-utils.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -49,6 +49,7 @@
model = gtk_combo_box_get_model(GTK_COMBO_BOX(cbe));
if (!gtk_tree_model_get_iter_first(model, &iter)) {
/* empty tree */
+ gtk_combo_box_set_active(GTK_COMBO_BOX(cbe), -1);
return;
}
Modified: gnucash/branches/deprecated-cleanup/src/gnome-search/Makefile.am
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/Makefile.am 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/Makefile.am 2006-06-05 05:06:30 UTC (rev 14332)
@@ -27,6 +27,7 @@
search-account.c \
search-boolean.c \
search-core-type.c \
+ search-core-utils.c \
search-date.c \
search-double.c \
search-int64.c \
@@ -43,6 +44,7 @@
search-account.h \
search-boolean.h \
search-core-type.h \
+ search-core-utils.h \
search-date.h \
search-double.h \
search-int64.h \
Modified: gnucash/branches/deprecated-cleanup/src/gnome-search/search-account.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/search-account.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/search-account.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -31,6 +31,7 @@
#include "gnc-gui-query.h"
#include "search-account.h"
+#include "search-core-utils.h"
#define d(x)
@@ -172,58 +173,30 @@
return valid;
}
-static void
-option_changed (GtkWidget *widget, GNCSearchAccount *fe)
-{
- fe->how = (query_compare_t)
- g_object_get_data (G_OBJECT (widget), "option");
-}
-
static GtkWidget *
-add_menu_item (GtkWidget *menu, gpointer user_data, char *label,
- query_compare_t option)
-{
- GtkWidget *item = gtk_menu_item_new_with_label (label);
- g_object_set_data (G_OBJECT (item), "option", (gpointer) option);
- g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (option_changed), user_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- return item;
-}
-
-#define ADD_MENU_ITEM(str,op) { \
- item = add_menu_item (menu, fe, str, op); \
- if (fi->how == op) { current = index; first = item; } \
- index++; \
-}
-
-static GtkWidget *
make_menu (GNCSearchCoreType *fe)
{
GNCSearchAccount *fi = (GNCSearchAccount *)fe;
GNCSearchAccountPrivate *priv;
- GtkWidget *menu, *item, *first, *opmenu;
- int current = 0, index = 0;
+ GtkComboBox *combo;
+ int initial = 0;
- menu = gtk_menu_new ();
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
priv = _PRIVATE(fi);
if (priv->match_all) {
- ADD_MENU_ITEM (_("matches all accounts"), GUID_MATCH_ALL);
- first = item;
+ gnc_combo_box_search_add(combo, _("matches all accounts"), GUID_MATCH_ALL);
+ initial = GUID_MATCH_ALL;
} else {
- ADD_MENU_ITEM (_("matches any account"), GUID_MATCH_ANY);
- first = item; /* Force one */
- ADD_MENU_ITEM (_("matches no accounts"), GUID_MATCH_NONE);
+ gnc_combo_box_search_add(combo, _("matches any account"), GUID_MATCH_ANY);
+ gnc_combo_box_search_add(combo, _("matches no accounts"), GUID_MATCH_NONE);
+ initial = GUID_MATCH_ANY;
}
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
+ gnc_combo_box_search_changed(combo, &fi->how);
+ gnc_combo_box_search_set_active(combo, fi->how ? fi->how : initial);
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
-
- return opmenu;
+ return GTK_WIDGET(combo);
}
static char *
Modified: gnucash/branches/deprecated-cleanup/src/gnome-search/search-boolean.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/search-boolean.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/search-boolean.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -28,6 +28,7 @@
#include "QueryCore.h"
#include "search-boolean.h"
+#include "search-core-utils.h"
#define d(x)
@@ -159,56 +160,24 @@
}
static void
-option_changed (GtkWidget *widget, GNCSearchBoolean *fe)
-{
- fe->how = (query_compare_t)
- g_object_get_data (G_OBJECT (widget), "option");
-}
-
-static void
toggle_changed (GtkToggleButton *button, GNCSearchBoolean *fe)
{
fe->value = gtk_toggle_button_get_active (button);
}
static GtkWidget *
-add_menu_item (GtkWidget *menu, gpointer user_data, char *label,
- query_compare_t option)
-{
- GtkWidget *item = gtk_menu_item_new_with_label (label);
- g_object_set_data (G_OBJECT (item), "option", (gpointer) option);
- g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (option_changed), user_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- return item;
-}
-
-#define ADD_MENU_ITEM(str,op) { \
- item = add_menu_item (menu, fe, str, op); \
- if (fi->how == op) { current = index; first = item; } \
- index++; \
-}
-
-static GtkWidget *
make_menu (GNCSearchCoreType *fe)
{
GNCSearchBoolean *fi = (GNCSearchBoolean *)fe;
- GtkWidget *menu, *item, *first, *opmenu;
- int current = 0, index = 0;
+ GtkComboBox *combo;
- menu = gtk_menu_new ();
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
+ gnc_combo_box_search_add(combo, _("is"), COMPARE_EQUAL);
+ gnc_combo_box_search_add(combo, _("is not"), COMPARE_NEQ);
+ gnc_combo_box_search_changed(combo, &fi->how);
+ gnc_combo_box_search_set_active(combo, fi->how ? fi->how : COMPARE_EQUAL);
- ADD_MENU_ITEM (_("is"), COMPARE_EQUAL);
- first = item; /* Force one */
- ADD_MENU_ITEM (_("is not"), COMPARE_NEQ);
-
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
-
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
-
- return opmenu;
+ return GTK_WIDGET(combo);
}
static GtkWidget *
Added: gnucash/branches/deprecated-cleanup/src/gnome-search/search-core-utils.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/search-core-utils.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/search-core-utils.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -0,0 +1,138 @@
+/*
+ * search-core-utils.c -- common functions for search code
+ * Copyright (C) 2006 David Hampton <hampton at employees.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation Voice: +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
+ * Boston, MA 02110-1301, USA gnu at gnu.org
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+
+#include "search-core-utils.h"
+
+
+static void
+search_combo_changed (GtkWidget *widget, gint *value)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ g_return_if_fail(GTK_IS_COMBO_BOX(widget));
+ g_return_if_fail(value);
+
+ model = gtk_combo_box_get_model(GTK_COMBO_BOX(widget));
+ if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(widget), &iter))
+ return;
+
+ gtk_tree_model_get(model, &iter,
+ GNC_COMBO_SEARCH_COL_VALUE, value,
+ -1);
+}
+
+GtkWidget *
+gnc_combo_box_new_search (void)
+{
+ GtkWidget *combo;
+ GtkListStore *store;
+ GtkCellRenderer *renderer;
+
+ store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_UINT);
+ combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), renderer,
+ "text", GNC_COMBO_SEARCH_COL_TEXT,
+ NULL);
+ return combo;
+}
+
+void
+gnc_combo_box_search_add (GtkComboBox *combo, const gchar *text, guint value)
+{
+ GtkListStore *store;
+ GtkTreeIter iter;
+
+ g_return_if_fail(GTK_IS_COMBO_BOX(combo));
+ g_return_if_fail(text);
+
+ store = GTK_LIST_STORE(gtk_combo_box_get_model(combo));
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ GNC_COMBO_SEARCH_COL_TEXT, text,
+ GNC_COMBO_SEARCH_COL_VALUE, value,
+ -1);
+}
+
+guint
+gnc_combo_box_search_get_active (GtkComboBox *combo)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ guint value;
+
+ g_return_val_if_fail(GTK_IS_COMBO_BOX(combo), 0);
+
+ model = gtk_combo_box_get_model(combo);
+ if (!gtk_combo_box_get_active_iter(combo, &iter))
+ return 0;
+
+ gtk_tree_model_get(model, &iter,
+ GNC_COMBO_SEARCH_COL_VALUE, &value,
+ -1);
+ return value;
+}
+
+void
+gnc_combo_box_search_set_active (GtkComboBox *combo, guint value)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ guint row_value = 0;
+
+ g_return_if_fail(GTK_IS_COMBO_BOX(combo));
+
+ model = gtk_combo_box_get_model(combo);
+ if (!gtk_tree_model_get_iter_first(model, &iter))
+ return;
+
+ do {
+ gtk_tree_model_get(model, &iter,
+ GNC_COMBO_SEARCH_COL_VALUE, &row_value,
+ -1);
+ if (value == row_value) {
+ gtk_combo_box_set_active_iter(combo, &iter);
+ return;
+ }
+ } while (gtk_tree_model_iter_next(model, &iter));
+
+ /* No match found. Select the first item. */
+ gtk_combo_box_set_active(combo, 0);
+}
+
+void
+gnc_combo_box_search_changed(GtkComboBox *combo, guint *value)
+{
+ g_signal_connect (combo, "changed",
+ G_CALLBACK (search_combo_changed), value);
+}
Added: gnucash/branches/deprecated-cleanup/src/gnome-search/search-core-utils.h
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/search-core-utils.h 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/search-core-utils.h 2006-06-05 05:06:30 UTC (rev 14332)
@@ -0,0 +1,35 @@
+/*
+ * search-core-utils.h -- common functions for search code
+ * Copyright (C) 2006 David Hampton <hampton at employees.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation Voice: +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
+ * Boston, MA 02110-1301, USA gnu at gnu.org
+ *
+ */
+
+/* Functions for creating the common two column GtkComboBox used by
+ * all the search widgets. */
+
+#define GNC_COMBO_SEARCH_COL_TEXT 0
+#define GNC_COMBO_SEARCH_COL_VALUE 1
+
+GtkWidget *gnc_combo_box_new_search (void);
+void gnc_combo_box_search_add (GtkComboBox *combo, const gchar *text, guint value);
+guint gnc_combo_box_search_get_active (GtkComboBox *combo);
+void gnc_combo_box_search_set_active (GtkComboBox *combo, guint value);
+void gnc_combo_box_search_changed(GtkComboBox *combo, guint *value);
+
Modified: gnucash/branches/deprecated-cleanup/src/gnome-search/search-date.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/search-date.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/search-date.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -30,6 +30,7 @@
#include "QueryCore.h"
#include "search-date.h"
+#include "search-core-utils.h"
#define d(x)
@@ -172,60 +173,29 @@
}
static void
-option_changed (GtkWidget *widget, GNCSearchDate *fe)
-{
- fe->how = (query_compare_t)
- g_object_get_data (G_OBJECT (widget), "option");
-}
-
-static void
date_changed (GNCDateEdit *date_edit, GNCSearchDate *fe)
{
fe->ts = gnc_date_edit_get_date_ts (date_edit);
}
static GtkWidget *
-add_menu_item (GtkWidget *menu, gpointer user_data, char *label,
- query_compare_t option)
-{
- GtkWidget *item = gtk_menu_item_new_with_label (label);
- g_object_set_data (G_OBJECT (item), "option", (gpointer) option);
- g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK(option_changed), user_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- return item;
-}
-
-#define ADD_MENU_ITEM(str,op) { \
- item = add_menu_item (menu, fe, str, op); \
- if (fi->how == op) { current = index; first = item; } \
- index++; \
-}
-
-static GtkWidget *
make_menu (GNCSearchCoreType *fe)
{
GNCSearchDate *fi = (GNCSearchDate *)fe;
- GtkWidget *menu, *item, *first, *opmenu;
- int current = 0, index = 0;
+ GtkComboBox *combo;
- menu = gtk_menu_new ();
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
- ADD_MENU_ITEM (_("is before"), COMPARE_LT);
- first = item; /* Force one */
- ADD_MENU_ITEM (_("is before or on"), COMPARE_LTE);
- ADD_MENU_ITEM (_("is on"), COMPARE_EQUAL);
- ADD_MENU_ITEM (_("is not on"), COMPARE_NEQ);
- ADD_MENU_ITEM (_("is after"), COMPARE_GT);
- ADD_MENU_ITEM (_("is on or after"), COMPARE_GTE);
+ gnc_combo_box_search_add(combo, _("is before"), COMPARE_LT);
+ gnc_combo_box_search_add(combo, _("is before or on"), COMPARE_LTE);
+ gnc_combo_box_search_add(combo, _("is on"), COMPARE_EQUAL);
+ gnc_combo_box_search_add(combo, _("is not on"), COMPARE_NEQ);
+ gnc_combo_box_search_add(combo, _("is after"), COMPARE_GT);
+ gnc_combo_box_search_add(combo, _("is on or after"), COMPARE_GTE);
+ gnc_combo_box_search_changed(combo, &fi->how);
+ gnc_combo_box_search_set_active(combo, fi->how ? fi->how : COMPARE_LT);
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
-
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
-
- return opmenu;
+ return GTK_WIDGET(combo);
}
static void
Modified: gnucash/branches/deprecated-cleanup/src/gnome-search/search-double.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/search-double.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/search-double.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -29,6 +29,7 @@
#include "QueryCore.h"
#include "search-double.h"
+#include "search-core-utils.h"
#define d(x)
@@ -164,60 +165,29 @@
}
static void
-option_changed (GtkWidget *widget, GNCSearchDouble *fe)
-{
- fe->how = (query_compare_t)
- g_object_get_data (G_OBJECT (widget), "option");
-}
-
-static void
entry_changed (GNCAmountEdit *entry, GNCSearchDouble *fe)
{
fe->value = gnc_amount_edit_get_damount (entry);
}
static GtkWidget *
-add_menu_item (GtkWidget *menu, gpointer user_data, char *label,
- query_compare_t option)
-{
- GtkWidget *item = gtk_menu_item_new_with_label (label);
- g_object_set_data (G_OBJECT (item), "option", (gpointer) option);
- g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (option_changed), user_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- return item;
-}
-
-#define ADD_MENU_ITEM(str,op) { \
- item = add_menu_item (menu, fe, str, op); \
- if (fi->how == op) { current = index; first = item; } \
- index++; \
-}
-
-static GtkWidget *
make_menu (GNCSearchCoreType *fe)
{
GNCSearchDouble *fi = (GNCSearchDouble *)fe;
- GtkWidget *menu, *item, *first = NULL, *opmenu;
- int current = 0, index = 0;
+ GtkComboBox *combo;
- menu = gtk_menu_new ();
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
- ADD_MENU_ITEM (_("is less than"), COMPARE_LT);
- first = item; /* Force one */
- ADD_MENU_ITEM (_("is less than or equal to"), COMPARE_LTE);
- ADD_MENU_ITEM (_("equals"), COMPARE_EQUAL);
- ADD_MENU_ITEM (_("does not equal"), COMPARE_NEQ);
- ADD_MENU_ITEM (_("is greater than"), COMPARE_GT);
- ADD_MENU_ITEM (_("is greater than or equal to"), COMPARE_GTE);
+ gnc_combo_box_search_add(combo, _("is less than"), COMPARE_LT);
+ gnc_combo_box_search_add(combo, _("is less than or equal to"), COMPARE_LTE);
+ gnc_combo_box_search_add(combo, _("equals"), COMPARE_EQUAL);
+ gnc_combo_box_search_add(combo, _("does not equal"), COMPARE_NEQ);
+ gnc_combo_box_search_add(combo, _("is greater than"), COMPARE_GT);
+ gnc_combo_box_search_add(combo, _("is greater than or equal to"), COMPARE_GTE);
+ gnc_combo_box_search_changed(combo, &fi->how);
+ gnc_combo_box_search_set_active(combo, fi->how ? fi->how : COMPARE_LT);
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
-
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
-
- return opmenu;
+ return GTK_WIDGET(combo);
}
static void
Modified: gnucash/branches/deprecated-cleanup/src/gnome-search/search-int64.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/search-int64.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/search-int64.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -29,6 +29,7 @@
#include "QueryCore.h"
#include "search-int64.h"
+#include "search-core-utils.h"
#define d(x)
@@ -165,13 +166,6 @@
}
static void
-option_changed (GtkWidget *widget, GNCSearchInt64 *fe)
-{
- fe->how = (query_compare_t)
- g_object_get_data (G_OBJECT (widget), "option");
-}
-
-static void
entry_changed (GNCAmountEdit *entry, GNCSearchInt64 *fe)
{
gnc_numeric value = gnc_amount_edit_get_amount (entry);
@@ -180,47 +174,22 @@
}
static GtkWidget *
-add_menu_item (GtkWidget *menu, gpointer user_data, char *label,
- query_compare_t option)
-{
- GtkWidget *item = gtk_menu_item_new_with_label (label);
- g_object_set_data (G_OBJECT (item), "option", (gpointer) option);
- g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (option_changed), user_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- return item;
-}
-
-#define ADD_MENU_ITEM(str,op) { \
- item = add_menu_item (menu, fe, str, op); \
- if (fi->how == op) { current = index; first = item; } \
- index++; \
-}
-
-static GtkWidget *
make_menu (GNCSearchCoreType *fe)
{
GNCSearchInt64 *fi = (GNCSearchInt64 *)fe;
- GtkWidget *menu, *item, *first = NULL, *opmenu;
- int current = 0, index = 0;
+ GtkComboBox *combo;
- menu = gtk_menu_new ();
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
+ gnc_combo_box_search_add(combo, _("is less than"), COMPARE_LT);
+ gnc_combo_box_search_add(combo, _("is less than or equal to"), COMPARE_LTE);
+ gnc_combo_box_search_add(combo, _("equals"), COMPARE_EQUAL);
+ gnc_combo_box_search_add(combo, _("does not equal"), COMPARE_NEQ);
+ gnc_combo_box_search_add(combo, _("is greater than"), COMPARE_GT);
+ gnc_combo_box_search_add(combo, _("is greater than or equal to"), COMPARE_GTE);
+ gnc_combo_box_search_changed(combo, &fi->how);
+ gnc_combo_box_search_set_active(combo, fi->how ? fi->how : COMPARE_LT);
- ADD_MENU_ITEM (_("is less than"), COMPARE_LT);
- first = item; /* Force one */
- ADD_MENU_ITEM (_("is less than or equal to"), COMPARE_LTE);
- ADD_MENU_ITEM (_("equals"), COMPARE_EQUAL);
- ADD_MENU_ITEM (_("does not equal"), COMPARE_NEQ);
- ADD_MENU_ITEM (_("is greater than"), COMPARE_GT);
- ADD_MENU_ITEM (_("is greater than or equal to"), COMPARE_GTE);
-
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
-
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
-
- return opmenu;
+ return GTK_WIDGET(combo);
}
static void
Modified: gnucash/branches/deprecated-cleanup/src/gnome-search/search-numeric.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/search-numeric.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/search-numeric.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -29,6 +29,7 @@
#include "QueryCore.h"
#include "search-numeric.h"
+#include "search-core-utils.h"
#define d(x)
@@ -194,109 +195,62 @@
}
static void
-how_option_changed (GtkWidget *widget, GNCSearchNumeric *fe)
-{
- fe->how = (query_compare_t)
- g_object_get_data (G_OBJECT (widget), "option");
-}
-
-static void
-option_changed (GtkWidget *widget, GNCSearchNumeric *fe)
-{
- fe->option = (query_compare_t)
- g_object_get_data (G_OBJECT (widget), "option");
-}
-
-static void
entry_changed (GNCAmountEdit *entry, GNCSearchNumeric *fe)
{
fe->value = gnc_amount_edit_get_amount (entry);
}
static GtkWidget *
-add_menu_item (GtkWidget *menu, gpointer user_data, char *label,
- query_compare_t option, GCallback fcn)
-{
- GtkWidget *item = gtk_menu_item_new_with_label (label);
- g_object_set_data (G_OBJECT (item), "option", (gpointer) option);
- g_signal_connect (G_OBJECT (item), "activate", fcn, user_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- return item;
-}
-
-#define ADD_MENU_ITEM(cmp,str,op,fcn) { \
- item = add_menu_item (menu, fe, str, op, fcn); \
- if (cmp == op) { current = index; first = item; } \
- index++; \
-}
-
-static GtkWidget *
make_how_menu (GNCSearchCoreType *fe)
{
GNCSearchNumeric *fi = (GNCSearchNumeric *)fe;
GNCSearchNumericPrivate *priv;
- GtkWidget *menu, *item, *first = NULL, *opmenu;
- int current = 0, index = 0;
+ GtkComboBox *combo;
- menu = gtk_menu_new ();
-
priv = _PRIVATE(fi);
- ADD_MENU_ITEM (fi->how, (priv->is_debcred ?
- _("less than") : _("is less than")),
- COMPARE_LT, G_CALLBACK (how_option_changed));
- first = item; /* Force one */
- ADD_MENU_ITEM (fi->how, (priv->is_debcred ?
- _("less than or equal to") :
- _("is less than or equal to")),
- COMPARE_LTE, G_CALLBACK (how_option_changed));
- ADD_MENU_ITEM (fi->how, (priv->is_debcred ?
- _("equal to") : _("equals")),
- COMPARE_EQUAL, G_CALLBACK (how_option_changed));
- ADD_MENU_ITEM (fi->how, (priv->is_debcred ?
- _("not equal to") : _("does not equal")),
- COMPARE_NEQ, G_CALLBACK (how_option_changed));
- ADD_MENU_ITEM (fi->how, (priv->is_debcred ?
- _("greater than") : _("is greater than")),
- COMPARE_GT, G_CALLBACK (how_option_changed));
- ADD_MENU_ITEM (fi->how, (priv->is_debcred ?
- _("greater than or equal to") :
- _("is greater than or equal to")),
- COMPARE_GTE, G_CALLBACK (how_option_changed));
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
+ gnc_combo_box_search_add(combo, (priv->is_debcred ?
+ _("less than") : _("is less than")),
+ COMPARE_LT);
+ gnc_combo_box_search_add(combo, (priv->is_debcred ?
+ _("less than or equal to") :
+ _("is less than or equal to")),
+ COMPARE_LTE);
+ gnc_combo_box_search_add(combo, (priv->is_debcred ?
+ _("equal to") : _("equals")),
+ COMPARE_EQUAL);
+ gnc_combo_box_search_add(combo, (priv->is_debcred ?
+ _("not equal to") : _("does not equal")),
+ COMPARE_NEQ);
+ gnc_combo_box_search_add(combo, (priv->is_debcred ?
+ _("greater than") : _("is greater than")),
+ COMPARE_GT);
+ gnc_combo_box_search_add(combo, (priv->is_debcred ?
+ _("greater than or equal to") :
+ _("is greater than or equal to")),
+ COMPARE_GTE);
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
+ gnc_combo_box_search_changed(combo, &fi->how);
+ gnc_combo_box_search_set_active(combo, fi->how ? fi->how : COMPARE_LT);
- return opmenu;
+ return GTK_WIDGET(combo);
}
static GtkWidget *
make_option_menu (GNCSearchCoreType *fe)
{
GNCSearchNumeric *fi = (GNCSearchNumeric *)fe;
- GtkWidget *menu, *item, *first, *opmenu;
- int current = 0, index = 0;
+ GtkComboBox *combo;
- menu = gtk_menu_new ();
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
+ gnc_combo_box_search_add(combo, _("has credits or debits"), NUMERIC_MATCH_ANY);
+ gnc_combo_box_search_add(combo, _("has debits"), NUMERIC_MATCH_DEBIT);
+ gnc_combo_box_search_add(combo, _("has credits"), NUMERIC_MATCH_CREDIT);
+ gnc_combo_box_search_changed(combo, &fi->option);
+ gnc_combo_box_search_set_active(combo, fi->option ? fi->option : NUMERIC_MATCH_ANY);
- ADD_MENU_ITEM (fi->option, _("has credits or debits"), NUMERIC_MATCH_ANY,
- G_CALLBACK (option_changed));
- first = item; /* Force one */
- ADD_MENU_ITEM (fi->option, _("has debits"), NUMERIC_MATCH_DEBIT,
- G_CALLBACK (option_changed));
- ADD_MENU_ITEM (fi->option, _("has credits"), NUMERIC_MATCH_CREDIT,
- G_CALLBACK (option_changed));
-
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
-
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
-
- return opmenu;
+ return GTK_WIDGET(combo);
}
static void
Modified: gnucash/branches/deprecated-cleanup/src/gnome-search/search-reconciled.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/search-reconciled.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/search-reconciled.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -29,6 +29,7 @@
#include "Transaction.h" /* for ?REC */
#include "search-reconciled.h"
+#include "search-core-utils.h"
#define d(x)
@@ -160,13 +161,6 @@
}
static void
-option_changed (GtkWidget *widget, GNCSearchReconciled *fe)
-{
- fe->how = (char_match_t)
- g_object_get_data (G_OBJECT (widget), "option");
-}
-
-static void
toggle_changed (GtkToggleButton *button, GNCSearchReconciled *fe)
{
gboolean is_on = gtk_toggle_button_get_active (button);
@@ -180,43 +174,18 @@
}
static GtkWidget *
-add_menu_item (GtkWidget *menu, gpointer user_data, char *label,
- char_match_t option)
-{
- GtkWidget *item = gtk_menu_item_new_with_label (label);
- g_object_set_data (G_OBJECT (item), "option", (gpointer) option);
- g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (option_changed), user_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- return item;
-}
-
-#define ADD_MENU_ITEM(str,op) { \
- item = add_menu_item (menu, fe, str, op); \
- if (fi->how == op) { current = index; first = item; } \
- index++; \
-}
-
-static GtkWidget *
make_menu (GNCSearchCoreType *fe)
{
GNCSearchReconciled *fi = (GNCSearchReconciled *)fe;
- GtkWidget *menu, *item, *first, *opmenu;
- int current = 0, index = 0;
+ GtkComboBox *combo;
- menu = gtk_menu_new ();
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
+ gnc_combo_box_search_add(combo, _("is"), CHAR_MATCH_ANY);
+ gnc_combo_box_search_add(combo, _("is not"), CHAR_MATCH_NONE);
+ gnc_combo_box_search_changed(combo, &fi->how);
+ gnc_combo_box_search_set_active(combo, fi->how ? fi->how : CHAR_MATCH_ANY);
- ADD_MENU_ITEM (_("is"), CHAR_MATCH_ANY);
- first = item; /* Force one */
- ADD_MENU_ITEM (_("is not"), CHAR_MATCH_NONE);
-
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
-
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
-
- return opmenu;
+ return GTK_WIDGET(combo);
}
static GtkWidget *
Modified: gnucash/branches/deprecated-cleanup/src/gnome-search/search-string.c
===================================================================
--- gnucash/branches/deprecated-cleanup/src/gnome-search/search-string.c 2006-06-05 04:21:09 UTC (rev 14331)
+++ gnucash/branches/deprecated-cleanup/src/gnome-search/search-string.c 2006-06-05 05:06:30 UTC (rev 14332)
@@ -29,6 +29,7 @@
#include <regex.h>
#include "search-string.h"
+#include "search-core-utils.h"
#include "QueryCore.h"
#define d(x)
@@ -235,13 +236,6 @@
}
static void
-option_changed (GtkWidget *widget, GNCSearchString *fe)
-{
- fe->how = (GNCSearchString_Type)
- g_object_get_data (G_OBJECT (widget), "option");
-}
-
-static void
entry_changed (GtkEntry *entry, GNCSearchString *fe)
{
const char *new;
@@ -251,49 +245,22 @@
}
static GtkWidget *
-add_menu_item (GtkWidget *menu, gpointer user_data, char *label,
- GNCSearchString_Type option)
-{
- GtkWidget *item = gtk_menu_item_new_with_label (label);
- g_object_set_data (G_OBJECT (item), "option", (gpointer) option);
- g_signal_connect (G_OBJECT (item), "activate", G_CALLBACK (option_changed), user_data);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show (item);
- return item;
-}
-
-static GtkWidget *
make_menu (GNCSearchCoreType *fe)
{
GNCSearchString *fi = (GNCSearchString *)fe;
- GtkWidget *menu, *item, *first, *opmenu;
- int current = 0;
+ GtkComboBox *combo;
- menu = gtk_menu_new ();
+ combo = GTK_COMBO_BOX(gnc_combo_box_new_search());
- item = add_menu_item (menu, fe, _("contains"), SEARCH_STRING_CONTAINS);
- first = item;
+ gnc_combo_box_search_add(combo, _("contains"), SEARCH_STRING_CONTAINS);
+ gnc_combo_box_search_add(combo, _("matches regex"),
+ SEARCH_STRING_MATCHES_REGEX);
+ gnc_combo_box_search_add(combo, _("does not match regex"),
+ SEARCH_STRING_NOT_MATCHES_REGEX);
+ gnc_combo_box_search_changed(combo, &fi->how);
+ gnc_combo_box_search_set_active(combo, fi->how ? fi->how : SEARCH_STRING_CONTAINS);
- item = add_menu_item (menu, fe, _("does not contain"),
- SEARCH_STRING_NOT_CONTAINS);
- if (fi->how == SEARCH_STRING_NOT_CONTAINS) { current = 1; first = item; }
-
- item = add_menu_item (menu, fe, _("matches regex"),
- SEARCH_STRING_MATCHES_REGEX);
- if (fi->how == SEARCH_STRING_MATCHES_REGEX) { current = 2; first = item; }
-
- item = add_menu_item (menu, fe, _("does not match regex"),
- SEARCH_STRING_NOT_MATCHES_REGEX);
- if (fi->how == SEARCH_STRING_NOT_MATCHES_REGEX)
- { current = 3; first = item; }
-
- opmenu = gtk_option_menu_new ();
- gtk_option_menu_set_menu (GTK_OPTION_MENU (opmenu), menu);
-
- g_signal_emit_by_name (G_OBJECT (first), "activate", fe);
- gtk_option_menu_set_history (GTK_OPTION_MENU (opmenu), current);
-
- return opmenu;
+ return GTK_WIDGET(combo);
}
static void
More information about the gnucash-changes
mailing list