Commit ccb86658 authored by Jon K Hellan's avatar Jon K Hellan Committed by Jon Kåre Hellan

New callback function. Removes object data from wbcg when dialog is

2001-05-03  Jon K Hellan  <hellan@acm.org>

	* src/gnumeric-util.c (cb_remove_object_data): New callback
	function. Removes object data from wbcg when dialog is destroyed.
	(gnumeric_keyed_dialog): New function. Make dialog a transient
	child of wbcg, attaching to wbcg object data to identify the
	dialog.
	(gnumeric_dialog_raise_if_exists): New function: Raise the dialog
	identified by key if it is registered on the wbcg.

	* src/gnumeric-util.h (gnumeric_dialog_make_unique,
	gnumeric_dialog_raise_if_exists): Declare.

 	* src/about.c (dialog_about): Use gnumeric_keyed_dialog.
	Use gnumeric_dialog_raise_if_exists to ensure that only one sheet
	object config dialog at a time can be displayed for a wbcg.

 	* src/sheet-object-widget.c (sheet_widget_checkbox_user_config):
	Ditto.

2001-05-03  Jon K Hellan  <hellan@acm.org>

	* src/dialogs/dialog-define-names.c (name_guru_init): Use
	gnumeric_keyed_dialog rather than gnumeric_non_modal_dialog.
	(dialog_define_names): Use (gnumeric_dialog_raise_if_exists to
	ensure that only one instance at a time can be displayed for a
	wbcg.
parent 19f217c5
2001-05-03 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.c (cb_remove_object_data): New callback
function. Removes object data from wbcg when dialog is destroyed.
(gnumeric_keyed_dialog): New function. Make dialog a transient
child of wbcg, attaching to wbcg object data to identify the
dialog.
(gnumeric_dialog_raise_if_exists): New function: Raise the dialog
identified by key if it is registered on the wbcg.
* src/gnumeric-util.h (gnumeric_dialog_make_unique,
gnumeric_dialog_raise_if_exists): Declare.
* src/about.c (dialog_about): Use gnumeric_keyed_dialog.
Use gnumeric_dialog_raise_if_exists to ensure that only one sheet
object config dialog at a time can be displayed for a wbcg.
* src/sheet-object-widget.c (sheet_widget_checkbox_user_config):
Ditto.
2001-05-02 Almer S. Tigelaar <almer@gnome.org>
* src/workbook-edit.c (cb_thaw_ui_toolbar): Callback timer
......
2001-05-03 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.c (cb_remove_object_data): New callback
function. Removes object data from wbcg when dialog is destroyed.
(gnumeric_keyed_dialog): New function. Make dialog a transient
child of wbcg, attaching to wbcg object data to identify the
dialog.
(gnumeric_dialog_raise_if_exists): New function: Raise the dialog
identified by key if it is registered on the wbcg.
* src/gnumeric-util.h (gnumeric_dialog_make_unique,
gnumeric_dialog_raise_if_exists): Declare.
* src/about.c (dialog_about): Use gnumeric_keyed_dialog.
Use gnumeric_dialog_raise_if_exists to ensure that only one sheet
object config dialog at a time can be displayed for a wbcg.
* src/sheet-object-widget.c (sheet_widget_checkbox_user_config):
Ditto.
2001-05-02 Almer S. Tigelaar <almer@gnome.org>
* src/workbook-edit.c (cb_thaw_ui_toolbar): Callback timer
......
2001-05-03 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.c (cb_remove_object_data): New callback
function. Removes object data from wbcg when dialog is destroyed.
(gnumeric_keyed_dialog): New function. Make dialog a transient
child of wbcg, attaching to wbcg object data to identify the
dialog.
(gnumeric_dialog_raise_if_exists): New function: Raise the dialog
identified by key if it is registered on the wbcg.
* src/gnumeric-util.h (gnumeric_dialog_make_unique,
gnumeric_dialog_raise_if_exists): Declare.
* src/about.c (dialog_about): Use gnumeric_keyed_dialog.
Use gnumeric_dialog_raise_if_exists to ensure that only one sheet
object config dialog at a time can be displayed for a wbcg.
* src/sheet-object-widget.c (sheet_widget_checkbox_user_config):
Ditto.
2001-05-02 Almer S. Tigelaar <almer@gnome.org>
* src/workbook-edit.c (cb_thaw_ui_toolbar): Callback timer
......
2001-05-03 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.c (cb_remove_object_data): New callback
function. Removes object data from wbcg when dialog is destroyed.
(gnumeric_keyed_dialog): New function. Make dialog a transient
child of wbcg, attaching to wbcg object data to identify the
dialog.
(gnumeric_dialog_raise_if_exists): New function: Raise the dialog
identified by key if it is registered on the wbcg.
* src/gnumeric-util.h (gnumeric_dialog_make_unique,
gnumeric_dialog_raise_if_exists): Declare.
* src/about.c (dialog_about): Use gnumeric_keyed_dialog.
Use gnumeric_dialog_raise_if_exists to ensure that only one sheet
object config dialog at a time can be displayed for a wbcg.
* src/sheet-object-widget.c (sheet_widget_checkbox_user_config):
Ditto.
2001-05-02 Almer S. Tigelaar <almer@gnome.org>
* src/workbook-edit.c (cb_thaw_ui_toolbar): Callback timer
......
2001-05-03 Jon K Hellan <hellan@acm.org>
* src/gnumeric-util.c (cb_remove_object_data): New callback
function. Removes object data from wbcg when dialog is destroyed.
(gnumeric_keyed_dialog): New function. Make dialog a transient
child of wbcg, attaching to wbcg object data to identify the
dialog.
(gnumeric_dialog_raise_if_exists): New function: Raise the dialog
identified by key if it is registered on the wbcg.
* src/gnumeric-util.h (gnumeric_dialog_make_unique,
gnumeric_dialog_raise_if_exists): Declare.
* src/about.c (dialog_about): Use gnumeric_keyed_dialog.
Use gnumeric_dialog_raise_if_exists to ensure that only one sheet
object config dialog at a time can be displayed for a wbcg.
* src/sheet-object-widget.c (sheet_widget_checkbox_user_config):
Ditto.
2001-05-02 Almer S. Tigelaar <almer@gnome.org>
* src/workbook-edit.c (cb_thaw_ui_toolbar): Callback timer
......
......@@ -14,16 +14,6 @@
#define ABOUT_KEY "about-dialog"
/* Object data is to make sure we don't pop up more than one copy. When
closing, we remove the data */
static void
cb_closed (GtkWidget *button, WorkbookControlGUI *wbcg)
{
g_return_if_fail (gtk_object_get_data (GTK_OBJECT (wbcg), ABOUT_KEY) != NULL);
gtk_object_remove_data (GTK_OBJECT (wbcg), ABOUT_KEY);
}
/*
* We need to get rid of that so that we will be able
* to list everybody. Something like guname would be
......@@ -76,11 +66,8 @@ dialog_about (WorkbookControlGUI *wbcg)
}
#endif
/* Ensure we only pop up one copy per workbook */
about = gtk_object_get_data (GTK_OBJECT (wbcg), ABOUT_KEY);
if (about && GNOME_IS_ABOUT (about)) {
gdk_window_raise (about->window);
if (gnumeric_dialog_raise_if_exists (wbcg, ABOUT_KEY))
return;
}
about = gnome_about_new (_("Gnumeric"), VERSION,
_("(C) 1998-2001 Miguel de Icaza"),
......@@ -99,11 +86,7 @@ dialog_about (WorkbookControlGUI *wbcg)
hbox, TRUE, FALSE, 0);
gtk_widget_show_all (hbox);
gtk_object_set_data (GTK_OBJECT (wbcg), ABOUT_KEY, about);
gtk_signal_connect (
GTK_OBJECT (about), "close",
GTK_SIGNAL_FUNC (cb_closed), wbcg);
gnumeric_keyed_dialog (wbcg, GTK_WINDOW (about), ABOUT_KEY);
/* Close on click, close with parent */
gnumeric_dialog_show (wbcg, GNOME_DIALOG (about), TRUE, TRUE);
......
2001-05-03 Jon K Hellan <hellan@acm.org>
* dialog-define-names.c (name_guru_init): Use
gnumeric_keyed_dialog rather than gnumeric_non_modal_dialog.
(dialog_define_names): Use (gnumeric_dialog_raise_if_exists to
ensure that only one instance at a time can be displayed for a
wbcg.
2001-04-29 Almer S. Tigelaar <almer@gnome.org>
* dialog-zoom.c (dialog_zoom_impl): Use cmd_zoom.
......
......@@ -14,16 +14,6 @@
#define ABOUT_KEY "about-dialog"
/* Object data is to make sure we don't pop up more than one copy. When
closing, we remove the data */
static void
cb_closed (GtkWidget *button, WorkbookControlGUI *wbcg)
{
g_return_if_fail (gtk_object_get_data (GTK_OBJECT (wbcg), ABOUT_KEY) != NULL);
gtk_object_remove_data (GTK_OBJECT (wbcg), ABOUT_KEY);
}
/*
* We need to get rid of that so that we will be able
* to list everybody. Something like guname would be
......@@ -76,11 +66,8 @@ dialog_about (WorkbookControlGUI *wbcg)
}
#endif
/* Ensure we only pop up one copy per workbook */
about = gtk_object_get_data (GTK_OBJECT (wbcg), ABOUT_KEY);
if (about && GNOME_IS_ABOUT (about)) {
gdk_window_raise (about->window);
if (gnumeric_dialog_raise_if_exists (wbcg, ABOUT_KEY))
return;
}
about = gnome_about_new (_("Gnumeric"), VERSION,
_("(C) 1998-2001 Miguel de Icaza"),
......@@ -99,11 +86,7 @@ dialog_about (WorkbookControlGUI *wbcg)
hbox, TRUE, FALSE, 0);
gtk_widget_show_all (hbox);
gtk_object_set_data (GTK_OBJECT (wbcg), ABOUT_KEY, about);
gtk_signal_connect (
GTK_OBJECT (about), "close",
GTK_SIGNAL_FUNC (cb_closed), wbcg);
gnumeric_keyed_dialog (wbcg, GTK_WINDOW (about), ABOUT_KEY);
/* Close on click, close with parent */
gnumeric_dialog_show (wbcg, GNOME_DIALOG (about), TRUE, TRUE);
......
......@@ -24,6 +24,7 @@
#include "widgets/gnumeric-expr-entry.h"
#define LIST_KEY "name_list_data"
#define DEFINE_NAMES_KEY "define-names-dialog"
typedef enum {
NAME_GURU_SCOPE_SHEET,
......@@ -631,7 +632,8 @@ name_guru_init (NameGuruState *state, WorkbookControlGUI *wbcg)
GTK_EDITABLE (state->expr_text));
gnumeric_combo_enters (GTK_WINDOW (state->dialog),
state->scope);
gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog));
gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
DEFINE_NAMES_KEY);
gnumeric_expr_entry_set_scg (state->expr_text,
wb_control_gui_cur_sheet (wbcg));
......@@ -653,6 +655,10 @@ dialog_define_names (WorkbookControlGUI *wbcg)
g_return_if_fail (wbcg != NULL);
/* Only pop up one copy per workbook */
if (gnumeric_dialog_raise_if_exists (wbcg, DEFINE_NAMES_KEY))
return;
state = g_new (NameGuruState, 1);
if (name_guru_init (state, wbcg)) {
gnumeric_notice (wbcg, GNOME_MESSAGE_BOX_ERROR,
......
......@@ -244,6 +244,9 @@ gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg, ErrorInfo *error)
*
* Make the window a child of the workbook in the command context, if there is
* one.
* The function duplicates the positioning functionality in
* gnome_dialog_set_parent, but does not require the transient window to be
* a GnomeDialog.
*/
void
gnumeric_set_transient (WorkbookControlGUI *wbcg, GtkWindow *window)
......@@ -284,6 +287,80 @@ gnumeric_set_transient (WorkbookControlGUI *wbcg, GtkWindow *window)
}
}
typedef struct {
WorkbookControlGUI *wbcg;
char *key;
} KeyedDialogContext;
static void
cb_remove_object_data (GtkWidget *w, KeyedDialogContext *ctxt)
{
g_return_if_fail (
gtk_object_get_data (
GTK_OBJECT (ctxt->wbcg), ctxt->key) != NULL);
gtk_object_remove_data (GTK_OBJECT (ctxt->wbcg), ctxt->key);
g_free (ctxt);
}
/**
* gnumeric_keyed_dialog
*
* @wbcg A WorkbookControlGUI
* @dialog A transient window
* @key A key to identify the dialog
*
* Make dialog a transient child of wbcg, attaching to wbcg object data to
* identify the dialog. The object data makes it possible to ensure that
* only one dialog of a kind can be displayed for a wbcg. Deallocation of
* the object data is managed here. */
void
gnumeric_keyed_dialog (WorkbookControlGUI *wbcg, GtkWindow *dialog, char *key)
{
KeyedDialogContext *ctxt;
g_return_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg));
g_return_if_fail (GTK_IS_WINDOW (dialog));
g_return_if_fail (key != NULL);
gnumeric_set_transient (wbcg, dialog);
ctxt = g_new (KeyedDialogContext, 1);
ctxt->wbcg = wbcg;
ctxt->key = key;
gtk_object_set_data (GTK_OBJECT (wbcg), key, dialog);
gtk_signal_connect (
GTK_OBJECT (dialog), "destroy",
GTK_SIGNAL_FUNC (cb_remove_object_data), ctxt);
}
/**
* gnumeric_dialog_raise_if_exists
*
* @wbcg A WorkbookControlGUI
* @key A key to identify the dialog
*
* Raise the dialog identified by key if it is registered on the wbcg.
* Returns TRUE if dialog found, FALSE if not.
*/
gboolean
gnumeric_dialog_raise_if_exists (WorkbookControlGUI *wbcg, char *key)
{
GtkWidget *dialog;
g_return_val_if_fail (wbcg != NULL, FALSE);
g_return_val_if_fail (key != NULL, FALSE);
/* Ensure we only pop up one copy per workbook */
dialog = gtk_object_get_data (GTK_OBJECT (wbcg), key);
if (dialog && GTK_IS_WINDOW (dialog)) {
gdk_window_raise (dialog->window);
return TRUE;
} else
return FALSE;
}
/**
* gnumeric_editable_enters: Make the "activate" signal of an editable click
* the default dialog button.
......
......@@ -11,12 +11,17 @@ void gnumeric_notice (WorkbookControlGUI *wbcg, const char *type, const ch
void gnumeric_non_modal_dialog (WorkbookControlGUI *wbcg, GtkWindow *dialog);
gint gnumeric_dialog_run (WorkbookControlGUI *wbcg, GnomeDialog *dialog);
void gnumeric_dialog_show (WorkbookControlGUI *wbcg, GnomeDialog *dialog,
void gnumeric_dialog_show (WorkbookControlGUI *wbcg,
GnomeDialog *dialog,
gboolean click_closes,
gboolean close_with_parent);
void gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg,
ErrorInfo *error);
void gnumeric_set_transient (WorkbookControlGUI *context, GtkWindow *window);
void gnumeric_keyed_dialog (WorkbookControlGUI *wbcg,
GtkWindow *dialog, char *key);
gboolean gnumeric_dialog_raise_if_exists (WorkbookControlGUI *wbcg,
char *key);
void gnumeric_editable_enters (GtkWindow *window, GtkEditable *editable);
void gnumeric_combo_enters (GtkWindow *window, GtkCombo *combo);
void gnumeric_toolbar_insert_with_eventbox (GtkToolbar *toolbar,
......
......@@ -244,6 +244,9 @@ gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg, ErrorInfo *error)
*
* Make the window a child of the workbook in the command context, if there is
* one.
* The function duplicates the positioning functionality in
* gnome_dialog_set_parent, but does not require the transient window to be
* a GnomeDialog.
*/
void
gnumeric_set_transient (WorkbookControlGUI *wbcg, GtkWindow *window)
......@@ -284,6 +287,80 @@ gnumeric_set_transient (WorkbookControlGUI *wbcg, GtkWindow *window)
}
}
typedef struct {
WorkbookControlGUI *wbcg;
char *key;
} KeyedDialogContext;
static void
cb_remove_object_data (GtkWidget *w, KeyedDialogContext *ctxt)
{
g_return_if_fail (
gtk_object_get_data (
GTK_OBJECT (ctxt->wbcg), ctxt->key) != NULL);
gtk_object_remove_data (GTK_OBJECT (ctxt->wbcg), ctxt->key);
g_free (ctxt);
}
/**
* gnumeric_keyed_dialog
*
* @wbcg A WorkbookControlGUI
* @dialog A transient window
* @key A key to identify the dialog
*
* Make dialog a transient child of wbcg, attaching to wbcg object data to
* identify the dialog. The object data makes it possible to ensure that
* only one dialog of a kind can be displayed for a wbcg. Deallocation of
* the object data is managed here. */
void
gnumeric_keyed_dialog (WorkbookControlGUI *wbcg, GtkWindow *dialog, char *key)
{
KeyedDialogContext *ctxt;
g_return_if_fail (IS_WORKBOOK_CONTROL_GUI (wbcg));
g_return_if_fail (GTK_IS_WINDOW (dialog));
g_return_if_fail (key != NULL);
gnumeric_set_transient (wbcg, dialog);
ctxt = g_new (KeyedDialogContext, 1);
ctxt->wbcg = wbcg;
ctxt->key = key;
gtk_object_set_data (GTK_OBJECT (wbcg), key, dialog);
gtk_signal_connect (
GTK_OBJECT (dialog), "destroy",
GTK_SIGNAL_FUNC (cb_remove_object_data), ctxt);
}
/**
* gnumeric_dialog_raise_if_exists
*
* @wbcg A WorkbookControlGUI
* @key A key to identify the dialog
*
* Raise the dialog identified by key if it is registered on the wbcg.
* Returns TRUE if dialog found, FALSE if not.
*/
gboolean
gnumeric_dialog_raise_if_exists (WorkbookControlGUI *wbcg, char *key)
{
GtkWidget *dialog;
g_return_val_if_fail (wbcg != NULL, FALSE);
g_return_val_if_fail (key != NULL, FALSE);
/* Ensure we only pop up one copy per workbook */
dialog = gtk_object_get_data (GTK_OBJECT (wbcg), key);
if (dialog && GTK_IS_WINDOW (dialog)) {
gdk_window_raise (dialog->window);
return TRUE;
} else
return FALSE;
}
/**
* gnumeric_editable_enters: Make the "activate" signal of an editable click
* the default dialog button.
......
......@@ -11,12 +11,17 @@ void gnumeric_notice (WorkbookControlGUI *wbcg, const char *type, const ch
void gnumeric_non_modal_dialog (WorkbookControlGUI *wbcg, GtkWindow *dialog);
gint gnumeric_dialog_run (WorkbookControlGUI *wbcg, GnomeDialog *dialog);
void gnumeric_dialog_show (WorkbookControlGUI *wbcg, GnomeDialog *dialog,
void gnumeric_dialog_show (WorkbookControlGUI *wbcg,
GnomeDialog *dialog,
gboolean click_closes,
gboolean close_with_parent);
void gnumeric_error_info_dialog_show (WorkbookControlGUI *wbcg,
ErrorInfo *error);
void gnumeric_set_transient (WorkbookControlGUI *context, GtkWindow *window);
void gnumeric_keyed_dialog (WorkbookControlGUI *wbcg,
GtkWindow *dialog, char *key);
gboolean gnumeric_dialog_raise_if_exists (WorkbookControlGUI *wbcg,
char *key);
void gnumeric_editable_enters (GtkWindow *window, GtkEditable *editable);
void gnumeric_combo_enters (GtkWindow *window, GtkCombo *combo);
void gnumeric_toolbar_insert_with_eventbox (GtkToolbar *toolbar,
......
......@@ -39,6 +39,9 @@
#include "workbook-edit.h"
#include "workbook.h"
#include "gnumeric-expr-entry.h"
#include "dialogs.h"
#define SHEET_OBJECT_CONFIG_KEY "sheet-object-config-dialog"
#define SHEET_OBJECT_WIDGET_TYPE (sheet_object_widget_get_type ())
#define SHEET_OBJECT_WIDGET(obj) (GTK_CHECK_CAST((obj), SHEET_OBJECT_WIDGET_TYPE, SheetObjectWidget))
......@@ -779,6 +782,11 @@ sheet_widget_checkbox_user_config (SheetObject *so, SheetControlGUI *scg)
g_return_if_fail (swc != NULL);
/* Only pop up one copy per workbook */
if (gnumeric_dialog_raise_if_exists (scg->wbcg,
SHEET_OBJECT_CONFIG_KEY))
return;
state = g_new (CheckboxConfigState, 1);
state->swc = swc;
state->wbcg = scg->wbcg;
......@@ -810,7 +818,9 @@ sheet_widget_checkbox_user_config (SheetObject *so, SheetControlGUI *scg)
gnumeric_editable_enters (GTK_WINDOW (state->dialog),
GTK_EDITABLE(state->entry));
gnumeric_non_modal_dialog (state->wbcg, GTK_WINDOW (state->dialog));
gnumeric_keyed_dialog (state->wbcg, GTK_WINDOW (state->dialog),
SHEET_OBJECT_CONFIG_KEY);
workbook_edit_attach_guru (state->wbcg, state->dialog);
gtk_window_set_position (GTK_WINDOW (state->dialog), GTK_WIN_POS_MOUSE);
gtk_window_set_focus (GTK_WINDOW (state->dialog),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment