mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
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. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20204 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
5cb52dbdb5
commit
47032f3687
@ -56,7 +56,7 @@ struct gnc_option
|
|||||||
gboolean changed;
|
gboolean changed;
|
||||||
|
|
||||||
/* The widget which is holding this option */
|
/* The widget which is holding this option */
|
||||||
GncOptionWidgetPtr widget;
|
gpointer widget;
|
||||||
|
|
||||||
/* The option db which holds this option */
|
/* The option db which holds this option */
|
||||||
GNCOptionDB *odb;
|
GNCOptionDB *odb;
|
||||||
@ -140,7 +140,7 @@ gnc_option_set_changed (GNCOption *option, gboolean changed)
|
|||||||
option->changed = changed;
|
option->changed = changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
GncOptionWidgetPtr
|
gpointer
|
||||||
gnc_option_get_widget (GNCOption *option)
|
gnc_option_get_widget (GNCOption *option)
|
||||||
{
|
{
|
||||||
if (!option) return NULL;
|
if (!option) return NULL;
|
||||||
@ -148,7 +148,7 @@ gnc_option_get_widget (GNCOption *option)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gnc_option_set_widget (GNCOption *option, GncOptionWidgetPtr widget)
|
gnc_option_set_widget (GNCOption *option, gpointer widget)
|
||||||
{
|
{
|
||||||
g_return_if_fail (option != NULL);
|
g_return_if_fail (option != NULL);
|
||||||
option->widget = widget;
|
option->widget = widget;
|
||||||
|
@ -32,32 +32,6 @@
|
|||||||
#include "qof.h"
|
#include "qof.h"
|
||||||
#include "GNCId.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 GNCOption;
|
||||||
typedef struct gnc_option_section GNCOptionSection;
|
typedef struct gnc_option_section GNCOptionSection;
|
||||||
typedef struct gnc_option_db GNCOptionDB;
|
typedef struct gnc_option_db GNCOptionDB;
|
||||||
@ -76,8 +50,15 @@ typedef void (*GNCOptionChangeCallback) (gpointer user_data);
|
|||||||
gboolean gnc_option_get_changed (GNCOption *option);
|
gboolean gnc_option_get_changed (GNCOption *option);
|
||||||
void gnc_option_set_changed (GNCOption *option, gboolean changed);
|
void gnc_option_set_changed (GNCOption *option, gboolean changed);
|
||||||
|
|
||||||
GncOptionWidgetPtr gnc_option_get_widget (GNCOption *option);
|
/** Returns an opaque pointer to the widget of this option. The actual
|
||||||
void gnc_option_set_widget (GNCOption *option, GncOptionWidgetPtr widget);
|
* 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);
|
SCM gnc_option_get_ui_value(GNCOption *option);
|
||||||
void gnc_option_set_ui_value(GNCOption *option, gboolean use_default);
|
void gnc_option_set_ui_value(GNCOption *option, gboolean use_default);
|
||||||
|
@ -149,7 +149,7 @@ owner_set_value (GNCOption *option, gboolean use_default,
|
|||||||
owner = &owner_def;
|
owner = &owner_def;
|
||||||
}
|
}
|
||||||
|
|
||||||
widget = gnc_option_get_widget (option);
|
widget = gnc_option_get_gtk_widget (option);
|
||||||
gnc_owner_set_owner (widget, owner);
|
gnc_owner_set_owner (widget, owner);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ customer_set_value (GNCOption *option, gboolean use_default,
|
|||||||
customer = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncCustomer"), 1, 0);
|
customer = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncCustomer"), 1, 0);
|
||||||
gncOwnerInitCustomer (&owner, customer);
|
gncOwnerInitCustomer (&owner, customer);
|
||||||
|
|
||||||
widget = gnc_option_get_widget (option);
|
widget = gnc_option_get_gtk_widget (option);
|
||||||
gnc_owner_set_owner (widget, &owner);
|
gnc_owner_set_owner (widget, &owner);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -270,7 +270,7 @@ vendor_set_value (GNCOption *option, gboolean use_default,
|
|||||||
vendor = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncVendor"), 1, 0);
|
vendor = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncVendor"), 1, 0);
|
||||||
gncOwnerInitVendor (&owner, vendor);
|
gncOwnerInitVendor (&owner, vendor);
|
||||||
|
|
||||||
widget = gnc_option_get_widget (option);
|
widget = gnc_option_get_gtk_widget (option);
|
||||||
gnc_owner_set_owner (widget, &owner);
|
gnc_owner_set_owner (widget, &owner);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -328,7 +328,7 @@ employee_set_value (GNCOption *option, gboolean use_default,
|
|||||||
employee = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncEmployee"), 1, 0);
|
employee = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncEmployee"), 1, 0);
|
||||||
gncOwnerInitEmployee (&owner, employee);
|
gncOwnerInitEmployee (&owner, employee);
|
||||||
|
|
||||||
widget = gnc_option_get_widget (option);
|
widget = gnc_option_get_gtk_widget (option);
|
||||||
gnc_owner_set_owner (widget, &owner);
|
gnc_owner_set_owner (widget, &owner);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -401,7 +401,7 @@ invoice_set_value (GNCOption *option, gboolean use_default,
|
|||||||
|
|
||||||
invoice = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncInvoice"), 1, 0);
|
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);
|
gnc_general_search_set_selected (GNC_GENERAL_SEARCH (widget), invoice);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -476,7 +476,7 @@ taxtable_set_value (GNCOption *option, gboolean use_default,
|
|||||||
|
|
||||||
taxtable = SWIG_MustGetPtr(value, SWIG_TypeQuery("_p__gncTaxTable"), 1, 0);
|
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);
|
gnc_ui_optionmenu_set_value (widget, taxtable);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -117,6 +117,12 @@ void gnc_options_dialog_list_select_cb(GtkWidget * list, GtkWidget * item,
|
|||||||
gpointer data);
|
gpointer data);
|
||||||
|
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gnc_option_get_gtk_widget (GNCOption *option)
|
||||||
|
{
|
||||||
|
return (GtkWidget *)gnc_option_get_widget(option);
|
||||||
|
}
|
||||||
|
|
||||||
static inline gint
|
static inline gint
|
||||||
color_d_to_i16 (double d)
|
color_d_to_i16 (double d)
|
||||||
{
|
{
|
||||||
@ -165,7 +171,7 @@ gnc_option_changed_option_cb(GtkWidget *dummy, GNCOption *option)
|
|||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
|
||||||
widget = gnc_option_get_widget (option);
|
widget = gnc_option_get_gtk_widget (option);
|
||||||
gnc_option_changed_widget_cb(widget, option);
|
gnc_option_changed_widget_cb(widget, option);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +183,7 @@ gnc_date_option_set_select_method(GNCOption *option, gboolean use_absolute,
|
|||||||
GtkWidget *ab_button, *rel_button, *rel_widget, *ab_widget;
|
GtkWidget *ab_button, *rel_button, *rel_widget, *ab_widget;
|
||||||
GtkWidget *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));
|
widget_list = gtk_container_get_children(GTK_CONTAINER(widget));
|
||||||
ab_button = g_list_nth_data(widget_list, GNC_RD_WID_AB_BUTTON_POS);
|
ab_button = g_list_nth_data(widget_list, GNC_RD_WID_AB_BUTTON_POS);
|
||||||
@ -294,7 +300,7 @@ gnc_option_set_ui_value_internal (GNCOption *option, gboolean use_default)
|
|||||||
SCM value;
|
SCM value;
|
||||||
GNCOptionDef_t *option_def;
|
GNCOptionDef_t *option_def;
|
||||||
|
|
||||||
widget = gnc_option_get_widget (option);
|
widget = gnc_option_get_gtk_widget (option);
|
||||||
if (!widget)
|
if (!widget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -340,7 +346,7 @@ gnc_option_get_ui_value_internal (GNCOption *option)
|
|||||||
char *type;
|
char *type;
|
||||||
GNCOptionDef_t *option_def;
|
GNCOptionDef_t *option_def;
|
||||||
|
|
||||||
widget = gnc_option_get_widget (option);
|
widget = gnc_option_get_gtk_widget (option);
|
||||||
if (!widget)
|
if (!widget)
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
@ -378,7 +384,7 @@ gnc_option_set_selectable_internal (GNCOption *option, gboolean selectable)
|
|||||||
{
|
{
|
||||||
GtkWidget *widget;
|
GtkWidget *widget;
|
||||||
|
|
||||||
widget = gnc_option_get_widget (option);
|
widget = gnc_option_get_gtk_widget (option);
|
||||||
if (!widget)
|
if (!widget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -399,7 +405,7 @@ gnc_option_show_hidden_toggled_cb(GtkWidget *widget, GNCOption* option)
|
|||||||
AccountViewInfo avi;
|
AccountViewInfo avi;
|
||||||
GncTreeViewAccount *tree_view;
|
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);
|
gnc_tree_view_account_get_view_info (tree_view, &avi);
|
||||||
avi.show_hidden = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
avi.show_hidden = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
|
||||||
gnc_tree_view_account_set_view_info (tree_view, &avi);
|
gnc_tree_view_account_set_view_info (tree_view, &avi);
|
||||||
@ -424,7 +430,7 @@ gnc_option_multichoice_cb(GtkWidget *w, gint index, gpointer data)
|
|||||||
gint current;
|
gint current;
|
||||||
char *type;
|
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
|
/* the option menu may be part of a date option widget, so we need to
|
||||||
decomposit the enclosing hbox then */
|
decomposit the enclosing hbox then */
|
||||||
@ -471,7 +477,7 @@ gnc_option_radiobutton_cb(GtkWidget *w, gpointer data)
|
|||||||
gpointer _current, _new_value;
|
gpointer _current, _new_value;
|
||||||
gint 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 = g_object_get_data(G_OBJECT(widget), "gnc_radiobutton_index");
|
||||||
current = GPOINTER_TO_INT (_current);
|
current = GPOINTER_TO_INT (_current);
|
||||||
@ -809,7 +815,7 @@ gnc_option_account_select_all_cb(GtkWidget *widget, gpointer data)
|
|||||||
GncTreeViewAccount *tree_view;
|
GncTreeViewAccount *tree_view;
|
||||||
GtkTreeSelection *selection;
|
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));
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
|
||||||
gtk_tree_selection_select_all(selection);
|
gtk_tree_selection_select_all(selection);
|
||||||
gnc_option_changed_widget_cb(widget, option);
|
gnc_option_changed_widget_cb(widget, option);
|
||||||
@ -822,7 +828,7 @@ gnc_option_account_clear_all_cb(GtkWidget *widget, gpointer data)
|
|||||||
GncTreeViewAccount *tree_view;
|
GncTreeViewAccount *tree_view;
|
||||||
GtkTreeSelection *selection;
|
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));
|
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
|
||||||
gtk_tree_selection_unselect_all(selection);
|
gtk_tree_selection_unselect_all(selection);
|
||||||
gnc_option_changed_widget_cb(widget, option);
|
gnc_option_changed_widget_cb(widget, option);
|
||||||
@ -835,7 +841,7 @@ gnc_option_account_select_children_cb(GtkWidget *widget, gpointer data)
|
|||||||
GncTreeViewAccount *tree_view;
|
GncTreeViewAccount *tree_view;
|
||||||
Account *account;
|
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);
|
account = gnc_tree_view_account_get_cursor_account(tree_view);
|
||||||
if (!account)
|
if (!account)
|
||||||
return;
|
return;
|
||||||
@ -988,7 +994,7 @@ gnc_option_list_select_all_cb(GtkWidget *widget, gpointer data)
|
|||||||
GtkTreeView *view;
|
GtkTreeView *view;
|
||||||
GtkTreeSelection *selection;
|
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);
|
selection = gtk_tree_view_get_selection(view);
|
||||||
gtk_tree_selection_select_all(selection);
|
gtk_tree_selection_select_all(selection);
|
||||||
gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
|
gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
|
||||||
@ -1001,7 +1007,7 @@ gnc_option_list_clear_all_cb(GtkWidget *widget, gpointer data)
|
|||||||
GtkTreeView *view;
|
GtkTreeView *view;
|
||||||
GtkTreeSelection *selection;
|
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);
|
selection = gtk_tree_view_get_selection(view);
|
||||||
gtk_tree_selection_unselect_all(selection);
|
gtk_tree_selection_unselect_all(selection);
|
||||||
gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
|
gnc_option_changed_widget_cb(GTK_WIDGET(view), option);
|
||||||
@ -1864,7 +1870,7 @@ gnc_option_set_ui_widget_account_list (GNCOption *option, GtkBox *page_box,
|
|||||||
GtkTreeSelection *selection;
|
GtkTreeSelection *selection;
|
||||||
|
|
||||||
*enclosing = gnc_option_create_account_widget(option, name, tooltips);
|
*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);
|
gtk_tooltips_set_tip(tooltips, *enclosing, documentation, NULL);
|
||||||
|
|
||||||
@ -1932,7 +1938,7 @@ gnc_option_set_ui_widget_list (GNCOption *option, GtkBox *page_box,
|
|||||||
GtkWidget *eventbox;
|
GtkWidget *eventbox;
|
||||||
|
|
||||||
*enclosing = gnc_option_create_list_widget(option, name, tooltips);
|
*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
|
/* Pack option widget into an extra eventbox because otherwise the
|
||||||
"documentation" tooltip is not displayed. */
|
"documentation" tooltip is not displayed. */
|
||||||
|
@ -24,8 +24,12 @@
|
|||||||
#define OPTIONS_DIALOG_H
|
#define OPTIONS_DIALOG_H
|
||||||
|
|
||||||
#include <libguile.h>
|
#include <libguile.h>
|
||||||
|
|
||||||
#include "option-util.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 struct gnc_option_win GNCOptionWin;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user