r20204 - gnucash/trunk/src - Get rid of gtk dependency in <app-util/option-util.h> header by storing only a gpointer for the widget.
Christian Stimming
cstim at code.gnucash.org
Sun Jan 30 05:21:48 EST 2011
Author: cstim
Date: 2011-01-30 05:21:48 -0500 (Sun, 30 Jan 2011)
New Revision: 20204
Trac: http://svn.gnucash.org/trac/changeset/20204
Modified:
gnucash/trunk/src/app-utils/option-util.c
gnucash/trunk/src/app-utils/option-util.h
gnucash/trunk/src/business/business-gnome/business-options-gnome.c
gnucash/trunk/src/gnome-utils/dialog-options.c
gnucash/trunk/src/gnome-utils/dialog-options.h
Log:
Get rid of gtk dependency in <app-util/option-util.h> header by storing only a gpointer for the widget.
This means the very last part of a gtk-dependency in app-util is in option-util.c
in one error message. My goal is to remove gtk completely from app-util
so that all code in our dependency chain up to app-util can be packaged
into a GUI-independent library, which can then be used by the python wrappers
and other GUI frontends alike.
Modified: gnucash/trunk/src/app-utils/option-util.c
===================================================================
--- gnucash/trunk/src/app-utils/option-util.c 2011-01-30 09:24:27 UTC (rev 20203)
+++ gnucash/trunk/src/app-utils/option-util.c 2011-01-30 10:21:48 UTC (rev 20204)
@@ -56,7 +56,7 @@
gboolean changed;
/* The widget which is holding this option */
- GncOptionWidgetPtr widget;
+ gpointer widget;
/* The option db which holds this option */
GNCOptionDB *odb;
@@ -140,7 +140,7 @@
option->changed = changed;
}
-GncOptionWidgetPtr
+gpointer
gnc_option_get_widget (GNCOption *option)
{
if (!option) return NULL;
@@ -148,7 +148,7 @@
}
void
-gnc_option_set_widget (GNCOption *option, GncOptionWidgetPtr widget)
+gnc_option_set_widget (GNCOption *option, gpointer widget)
{
g_return_if_fail (option != NULL);
option->widget = widget;
Modified: gnucash/trunk/src/app-utils/option-util.h
===================================================================
--- gnucash/trunk/src/app-utils/option-util.h 2011-01-30 09:24:27 UTC (rev 20203)
+++ gnucash/trunk/src/app-utils/option-util.h 2011-01-30 10:21:48 UTC (rev 20204)
@@ -32,32 +32,6 @@
#include "qof.h"
#include "GNCId.h"
-#if defined(GNOME)
-# include <gtk/gtk.h>
-#endif
-
-/** This is the opaque pointer to this option's widget.
- *
- * Note: This option code is still almost GUI-independent because it
- * does not deal with the UI implementation of the option's widgets,
- * but it stores a pointer to a widget (and incidentally some of the
- * implementation might show an error message through the gtk-specific
- * message box). Hence, the option code just stores a pointer
- * transparently, which is where the GncOptionWidgetPtr typedef comes
- * from. We keep this typedef just in this file to underline that the
- * code of option-utils.[hc] might still be re-usable in a
- * UI-independent usage, even though the only implementation is a gtk
- * one. */
-typedef
-#if defined(GNOME)
-GtkWidget *
-#else
-/* **** No GUI selected *** */
-void *
-#endif
-GncOptionWidgetPtr;
-
-
typedef struct gnc_option GNCOption;
typedef struct gnc_option_section GNCOptionSection;
typedef struct gnc_option_db GNCOptionDB;
@@ -76,9 +50,16 @@
gboolean gnc_option_get_changed (GNCOption *option);
void gnc_option_set_changed (GNCOption *option, gboolean changed);
-GncOptionWidgetPtr gnc_option_get_widget (GNCOption *option);
-void gnc_option_set_widget (GNCOption *option, GncOptionWidgetPtr widget);
+/** Returns an opaque pointer to the widget of this option. The actual
+ * GUI implementation in dialog-options.c will store a GtkWidget* in
+ * here. */
+gpointer gnc_option_get_widget (GNCOption *option);
+/** Store an opaque pointer to the widget of this option. The actual
+ * GUI implementation in dialog-options.c will store a GtkWidget* in
+ * here. */
+void gnc_option_set_widget (GNCOption *option, gpointer widget);
+
SCM gnc_option_get_ui_value(GNCOption *option);
void gnc_option_set_ui_value(GNCOption *option, gboolean use_default);
void gnc_option_set_selectable (GNCOption *option, gboolean selectable);
Modified: gnucash/trunk/src/business/business-gnome/business-options-gnome.c
===================================================================
--- gnucash/trunk/src/business/business-gnome/business-options-gnome.c 2011-01-30 09:24:27 UTC (rev 20203)
+++ gnucash/trunk/src/business/business-gnome/business-options-gnome.c 2011-01-30 10:21:48 UTC (rev 20204)
@@ -149,7 +149,7 @@
owner = &owner_def;
}
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
gnc_owner_set_owner (widget, owner);
return FALSE;
}
@@ -211,7 +211,7 @@
customer = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncCustomer"), 1, 0);
gncOwnerInitCustomer (&owner, customer);
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
gnc_owner_set_owner (widget, &owner);
return FALSE;
}
@@ -270,7 +270,7 @@
vendor = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncVendor"), 1, 0);
gncOwnerInitVendor (&owner, vendor);
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
gnc_owner_set_owner (widget, &owner);
return FALSE;
}
@@ -328,7 +328,7 @@
employee = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncEmployee"), 1, 0);
gncOwnerInitEmployee (&owner, employee);
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
gnc_owner_set_owner (widget, &owner);
return FALSE;
}
@@ -401,7 +401,7 @@
invoice = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncInvoice"), 1, 0);
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
gnc_general_search_set_selected (GNC_GENERAL_SEARCH (widget), invoice);
return FALSE;
}
@@ -476,7 +476,7 @@
taxtable = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncTaxTable"), 1, 0);
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
gnc_ui_optionmenu_set_value (widget, taxtable);
return FALSE;
}
Modified: gnucash/trunk/src/gnome-utils/dialog-options.c
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-options.c 2011-01-30 09:24:27 UTC (rev 20203)
+++ gnucash/trunk/src/gnome-utils/dialog-options.c 2011-01-30 10:21:48 UTC (rev 20204)
@@ -117,6 +117,12 @@
gpointer data);
+GtkWidget *
+gnc_option_get_gtk_widget (GNCOption *option)
+{
+ return (GtkWidget *)gnc_option_get_widget(option);
+}
+
static inline gint
color_d_to_i16 (double d)
{
@@ -165,7 +171,7 @@
{
GtkWidget *widget;
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
gnc_option_changed_widget_cb(widget, option);
}
@@ -177,7 +183,7 @@
GtkWidget *ab_button, *rel_button, *rel_widget, *ab_widget;
GtkWidget *widget;
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
ab_button = g_list_nth_data(widget_list, GNC_RD_WID_AB_BUTTON_POS);
@@ -294,7 +300,7 @@
SCM value;
GNCOptionDef_t *option_def;
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
if (!widget)
return;
@@ -340,7 +346,7 @@
char *type;
GNCOptionDef_t *option_def;
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
if (!widget)
return result;
@@ -378,7 +384,7 @@
{
GtkWidget *widget;
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
if (!widget)
return;
@@ -399,7 +405,7 @@
AccountViewInfo avi;
GncTreeViewAccount *tree_view;
- tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
+ tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_gtk_widget (option));
gnc_tree_view_account_get_view_info (tree_view, &avi);
avi.show_hidden = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
gnc_tree_view_account_set_view_info (tree_view, &avi);
@@ -424,7 +430,7 @@
gint current;
char *type;
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
/* the option menu may be part of a date option widget, so we need to
decomposit the enclosing hbox then */
@@ -471,7 +477,7 @@
gpointer _current, _new_value;
gint current, new_value;
- widget = gnc_option_get_widget (option);
+ widget = gnc_option_get_gtk_widget (option);
_current = g_object_get_data(G_OBJECT(widget), "gnc_radiobutton_index");
current = GPOINTER_TO_INT (_current);
@@ -809,7 +815,7 @@
GncTreeViewAccount *tree_view;
GtkTreeSelection *selection;
- tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
+ tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_gtk_widget (option));
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
gtk_tree_selection_select_all(selection);
gnc_option_changed_widget_cb(widget, option);
@@ -822,7 +828,7 @@
GncTreeViewAccount *tree_view;
GtkTreeSelection *selection;
- tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
+ tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_gtk_widget (option));
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
gtk_tree_selection_unselect_all(selection);
gnc_option_changed_widget_cb(widget, option);
@@ -835,7 +841,7 @@
GncTreeViewAccount *tree_view;
Account *account;
- tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_widget (option));
+ tree_view = GNC_TREE_VIEW_ACCOUNT(gnc_option_get_gtk_widget (option));
account = gnc_tree_view_account_get_cursor_account(tree_view);
if (!account)
return;
@@ -988,7 +994,7 @@
GtkTreeView *view;
GtkTreeSelection *selection;
- view = GTK_TREE_VIEW(gnc_option_get_widget (option));
+ view = GTK_TREE_VIEW(gnc_option_get_gtk_widget (option));
selection = gtk_tree_view_get_selection(view);
gtk_tree_selection_select_all(selection);
gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
@@ -1001,7 +1007,7 @@
GtkTreeView *view;
GtkTreeSelection *selection;
- view = GTK_TREE_VIEW(gnc_option_get_widget (option));
+ view = GTK_TREE_VIEW(gnc_option_get_gtk_widget (option));
selection = gtk_tree_view_get_selection(view);
gtk_tree_selection_unselect_all(selection);
gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
@@ -1864,7 +1870,7 @@
GtkTreeSelection *selection;
*enclosing = gnc_option_create_account_widget(option, name, tooltips);
- value = gnc_option_get_widget (option);
+ value = gnc_option_get_gtk_widget (option);
gtk_tooltips_set_tip(tooltips, *enclosing, documentation, NULL);
@@ -1932,7 +1938,7 @@
GtkWidget *eventbox;
*enclosing = gnc_option_create_list_widget(option, name, tooltips);
- value = gnc_option_get_widget (option);
+ value = gnc_option_get_gtk_widget (option);
/* Pack option widget into an extra eventbox because otherwise the
"documentation" tooltip is not displayed. */
Modified: gnucash/trunk/src/gnome-utils/dialog-options.h
===================================================================
--- gnucash/trunk/src/gnome-utils/dialog-options.h 2011-01-30 09:24:27 UTC (rev 20203)
+++ gnucash/trunk/src/gnome-utils/dialog-options.h 2011-01-30 10:21:48 UTC (rev 20204)
@@ -24,9 +24,13 @@
#define OPTIONS_DIALOG_H
#include <libguile.h>
-
#include "option-util.h"
+#include <gtk/gtk.h>
+/** A simple wrapper that casts the gpointer result of
+ * gnc_option_get_widget() already into a GtkWidget*. */
+GtkWidget *gnc_option_get_gtk_widget (GNCOption *option);
+
typedef struct gnc_option_win GNCOptionWin;
typedef void (* GNCOptionWinCallback)(GNCOptionWin *, gpointer data);
More information about the gnucash-changes
mailing list