mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Collapse common option dialog handling. Tweak args to option dialog
creation. Use g_signal_connect to set up signal handlers. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9155 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -22,18 +22,6 @@
|
||||
#include "dialog-invoice.h"
|
||||
#include "guile-mappings.h"
|
||||
|
||||
static int
|
||||
option_changed_cb (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
GNCOption *option = data;
|
||||
|
||||
gnc_option_set_changed (option, TRUE);
|
||||
gnc_option_call_option_widget_changed_proc (option);
|
||||
gnc_options_dialog_changed_internal (widget);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
create_owner_widget (GNCOption *option, GncOwnerType type, GtkWidget *hbox)
|
||||
{
|
||||
@@ -61,8 +49,8 @@ create_owner_widget (GNCOption *option, GncOwnerType type, GtkWidget *hbox)
|
||||
gnc_get_current_book (), &owner);
|
||||
gnc_option_set_widget (option, widget);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (widget), "changed",
|
||||
GTK_SIGNAL_FUNC (option_changed_cb), option);
|
||||
g_signal_connect (G_OBJECT (widget), "changed",
|
||||
G_CALLBACK (gnc_option_changed_option_cb), option);
|
||||
|
||||
return widget;
|
||||
}
|
||||
@@ -357,8 +345,8 @@ create_invoice_widget (GNCOption *option, GtkWidget *hbox)
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
|
||||
gnc_option_set_widget (option, widget);
|
||||
gtk_signal_connect (GTK_OBJECT (widget), "changed",
|
||||
GTK_SIGNAL_FUNC (option_changed_cb), option);
|
||||
g_signal_connect (G_OBJECT (widget), "changed",
|
||||
G_CALLBACK (gnc_option_changed_option_cb), option);
|
||||
|
||||
return widget;
|
||||
}
|
||||
@@ -432,7 +420,7 @@ create_taxtable_widget (GNCOption *option, GtkWidget *hbox)
|
||||
gnc_option_set_widget (option, widget);
|
||||
|
||||
gnc_ui_optionmenu_set_changed_callback (widget,
|
||||
(void(*)(GtkWidget*,gpointer))option_changed_cb,
|
||||
(void(*)(GtkWidget*,gpointer))gnc_option_changed_option_cb,
|
||||
option);
|
||||
|
||||
return widget;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -36,7 +36,8 @@ typedef struct gnc_option_win GNCOptionWin;
|
||||
|
||||
typedef void (* GNCOptionWinCallback)(GNCOptionWin *, gpointer data);
|
||||
|
||||
GNCOptionWin * gnc_options_dialog_new(gboolean make_toplevel, gchar *title);
|
||||
GNCOptionWin * gnc_options_dialog_new(gchar *title);
|
||||
GNCOptionWin * gnc_options_dialog_new_w_dialog(gchar *title, GtkWidget *dialog);
|
||||
void gnc_options_dialog_destroy(GNCOptionWin * win);
|
||||
void gnc_options_register_stocks (void);
|
||||
|
||||
@@ -44,6 +45,8 @@ GtkWidget * gnc_options_dialog_widget(GNCOptionWin * win);
|
||||
GtkWidget * gnc_options_dialog_notebook(GNCOptionWin * win);
|
||||
|
||||
void gnc_options_dialog_changed (GNCOptionWin *win);
|
||||
void gnc_option_changed_widget_cb(GtkWidget *widget, GNCOption *option);
|
||||
void gnc_option_changed_option_cb(GtkWidget *dummy, GNCOption *option);
|
||||
|
||||
void gnc_options_dialog_set_apply_cb(GNCOptionWin * win,
|
||||
GNCOptionWinCallback thunk,
|
||||
@@ -99,11 +102,7 @@ typedef struct gnc_option_def {
|
||||
|
||||
|
||||
/* Register a new option type in the UI */
|
||||
void gnc_options_ui_initialize (void);
|
||||
void gnc_options_ui_register_option (GNCOptionDef_t *option);
|
||||
GNCOptionDef_t * gnc_options_ui_get_option (const char *option_name);
|
||||
|
||||
/* For option definitions outside the main module only */
|
||||
void gnc_options_dialog_changed_internal (GtkWidget *widget);
|
||||
|
||||
#endif /* OPTIONS_DIALOG_H */
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
(define (gnc:kvp-option-dialog id-type slots title changed_cb)
|
||||
(let* ((options (gnc:make-kvp-options id-type))
|
||||
(optiondb (gnc:option-db-new options))
|
||||
(optionwin (gnc:option-dialog-new #t title)))
|
||||
(optionwin (gnc:option-dialog-new title)))
|
||||
|
||||
(define (apply-cb)
|
||||
(gnc:options-scm->kvp options slots gnc:*kvp-option-path* #t)
|
||||
|
||||
@@ -98,7 +98,7 @@
|
||||
'gnc:option-dialog-new
|
||||
'<gnc:OptionWin*>
|
||||
"gnc_options_dialog_new"
|
||||
'((<gw:bool> make-toplevel) ((<gw:mchars> caller-owned) title))
|
||||
'(((<gw:mchars> caller-owned) title))
|
||||
"Create a new option dialog")
|
||||
|
||||
(gw:wrap-function
|
||||
|
||||
@@ -1109,7 +1109,8 @@ gnc_acct_tree_window_create_menu(GNCAcctTreeWin * main_info,
|
||||
static void
|
||||
gnc_acct_tree_window_select_cb(GNCMainWinAccountTree *tree,
|
||||
Account *account,
|
||||
GNCAcctTreeWin * win) {
|
||||
GNCAcctTreeWin * win)
|
||||
{
|
||||
gboolean sensitive;
|
||||
|
||||
account = gnc_mainwin_account_tree_get_current_account(tree);
|
||||
@@ -1121,7 +1122,8 @@ gnc_acct_tree_window_select_cb(GNCMainWinAccountTree *tree,
|
||||
|
||||
|
||||
Account *
|
||||
gnc_acct_tree_window_get_current_account(GNCAcctTreeWin * win) {
|
||||
gnc_acct_tree_window_get_current_account(GNCAcctTreeWin * win)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
@@ -1138,7 +1140,8 @@ gnc_acct_tree_window_get_current_account(GNCAcctTreeWin * win) {
|
||||
|
||||
|
||||
static void
|
||||
gnc_acct_tree_window_options_new(GNCAcctTreeWin * win) {
|
||||
gnc_acct_tree_window_options_new(GNCAcctTreeWin * win)
|
||||
{
|
||||
SCM func = scm_c_eval_string("gnc:make-new-acct-tree-window");
|
||||
SCM opts_and_id = scm_call_0(func);
|
||||
|
||||
@@ -1149,7 +1152,8 @@ gnc_acct_tree_window_options_new(GNCAcctTreeWin * win) {
|
||||
}
|
||||
|
||||
void
|
||||
gnc_acct_tree_window_destroy(GNCAcctTreeWin * win) {
|
||||
gnc_acct_tree_window_destroy(GNCAcctTreeWin * win)
|
||||
{
|
||||
SCM free_tree = scm_c_eval_string("gnc:free-acct-tree-window");
|
||||
gnc_unregister_option_change_callback_id
|
||||
(win->euro_change_callback_id);
|
||||
@@ -1199,7 +1203,8 @@ gnc_acct_tree_button_press_cb (GtkWidget *widget,
|
||||
}
|
||||
|
||||
GNCAcctTreeWin *
|
||||
gnc_acct_tree_window_new(const gchar * url) {
|
||||
gnc_acct_tree_window_new(const gchar * url)
|
||||
{
|
||||
GNCAcctTreeWin * treewin = g_new0(GNCAcctTreeWin, 1);
|
||||
EggMenuMerge *merge;
|
||||
EggActionGroup *action_group;
|
||||
@@ -1325,17 +1330,20 @@ gnc_acct_tree_window_new(const gchar * url) {
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gnc_acct_tree_window_get_widget(GNCAcctTreeWin * win) {
|
||||
gnc_acct_tree_window_get_widget(GNCAcctTreeWin * win)
|
||||
{
|
||||
return GTK_WIDGET (win->account_tree_view);
|
||||
}
|
||||
|
||||
SCM
|
||||
gnc_acct_tree_window_get_options(GNCAcctTreeWin * w) {
|
||||
gnc_acct_tree_window_get_options(GNCAcctTreeWin * w)
|
||||
{
|
||||
return w->options;
|
||||
}
|
||||
|
||||
int
|
||||
gnc_acct_tree_window_get_id(GNCAcctTreeWin * w) {
|
||||
gnc_acct_tree_window_get_id(GNCAcctTreeWin * w)
|
||||
{
|
||||
return w->options_id;
|
||||
}
|
||||
|
||||
@@ -1345,7 +1353,8 @@ gnc_acct_tree_window_get_id(GNCAcctTreeWin * w) {
|
||||
|
||||
static void
|
||||
gnc_options_dialog_apply_cb(GNCOptionWin * propertybox,
|
||||
gpointer user_data) {
|
||||
gpointer user_data)
|
||||
{
|
||||
GNCAcctTreeWin * win = user_data;
|
||||
if(!win) return;
|
||||
|
||||
@@ -1371,7 +1380,8 @@ gnc_options_dialog_help_cb(GNCOptionWin * propertybox,
|
||||
|
||||
static void
|
||||
gnc_options_dialog_close_cb(GNCOptionWin * propertybox,
|
||||
gpointer user_data) {
|
||||
gpointer user_data)
|
||||
{
|
||||
GNCAcctTreeWin * win = user_data;
|
||||
gnc_options_dialog_destroy(win->editor_dialog);
|
||||
win->editor_dialog = NULL;
|
||||
@@ -1379,7 +1389,8 @@ gnc_options_dialog_close_cb(GNCOptionWin * propertybox,
|
||||
|
||||
|
||||
void
|
||||
gnc_acct_tree_window_toolbar_options_cb(GtkWidget * widget, gpointer data) {
|
||||
gnc_acct_tree_window_toolbar_options_cb(GtkWidget * widget, gpointer data)
|
||||
{
|
||||
GNCAcctTreeWin * win = data;
|
||||
|
||||
if(win->editor_dialog) {
|
||||
@@ -1387,7 +1398,7 @@ gnc_acct_tree_window_toolbar_options_cb(GtkWidget * widget, gpointer data) {
|
||||
(gnc_options_dialog_widget(win->editor_dialog)));
|
||||
}
|
||||
else {
|
||||
win->editor_dialog = gnc_options_dialog_new(TRUE, NULL);
|
||||
win->editor_dialog = gnc_options_dialog_new(NULL);
|
||||
gnc_build_options_dialog_contents(win->editor_dialog,
|
||||
win->odb);
|
||||
|
||||
|
||||
@@ -231,7 +231,7 @@ gnc_column_view_edit_options(SCM options, SCM view) {
|
||||
gnc_column_view_edit * r = g_new0(gnc_column_view_edit, 1);
|
||||
GladeXML *xml;
|
||||
|
||||
r->optwin = gnc_options_dialog_new(TRUE, NULL);
|
||||
r->optwin = gnc_options_dialog_new(NULL);
|
||||
|
||||
xml = gnc_glade_xml_new ("report.glade", "view_contents_hbox");
|
||||
|
||||
|
||||
@@ -93,7 +93,8 @@ row_data_destroy_cb(gpointer data) {
|
||||
|
||||
|
||||
static void
|
||||
gnc_style_sheet_dialog_fill(StyleSheetDialog * ss, SCM selected) {
|
||||
gnc_style_sheet_dialog_fill(StyleSheetDialog * ss, SCM selected)
|
||||
{
|
||||
SCM stylesheets = scm_c_eval_string("(gnc:get-html-style-sheets)");
|
||||
SCM get_options = scm_c_eval_string("gnc:html-style-sheet-options");
|
||||
SCM get_name = scm_c_eval_string("gnc:html-style-sheet-name");
|
||||
@@ -109,7 +110,7 @@ gnc_style_sheet_dialog_fill(StyleSheetDialog * ss, SCM selected) {
|
||||
char * c_name;
|
||||
|
||||
/* make the options DB and dialog, but don't parent it yet */
|
||||
ssinfo->odialog = gnc_options_dialog_new(FALSE, NULL);
|
||||
ssinfo->odialog = gnc_options_dialog_new(NULL);
|
||||
ssinfo->odb = gnc_option_db_new(scm_options);
|
||||
ssinfo->stylesheet = SCM_CAR(stylesheets);
|
||||
|
||||
@@ -147,7 +148,8 @@ gnc_style_sheet_dialog_fill(StyleSheetDialog * ss, SCM selected) {
|
||||
|
||||
|
||||
static void
|
||||
gnc_style_sheet_new_cb(GtkWidget * w, gpointer user_data) {
|
||||
gnc_style_sheet_new_cb(GtkWidget * w, gpointer user_data)
|
||||
{
|
||||
StyleSheetDialog * ssd = user_data;
|
||||
SCM make_ss = scm_c_eval_string("gnc:make-html-style-sheet");
|
||||
SCM templates = scm_c_eval_string("(gnc:get-html-templates)");
|
||||
@@ -223,7 +225,8 @@ gnc_style_sheet_dialog_close_cb(GtkWidget * w, GdkEventAny * ev,
|
||||
}
|
||||
|
||||
static StyleSheetDialog *
|
||||
gnc_style_sheet_dialog_create() {
|
||||
gnc_style_sheet_dialog_create()
|
||||
{
|
||||
StyleSheetDialog * ss = g_new0(StyleSheetDialog, 1);
|
||||
GtkWidget * new_button=NULL;
|
||||
GtkWidget * delete_button=NULL;
|
||||
|
||||
@@ -1091,7 +1091,7 @@ gnc_report_window_default_params_editor(SCM options, SCM report)
|
||||
if (ptr != SCM_BOOL_F) {
|
||||
title = gh_scm2newstr(ptr, NULL);
|
||||
}
|
||||
prm->win = gnc_options_dialog_new(TRUE, title);
|
||||
prm->win = gnc_options_dialog_new(title);
|
||||
|
||||
if (title) {
|
||||
free(title);
|
||||
|
||||
Reference in New Issue
Block a user