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

Deflickerize.

2000-02-21  Jon K Hellan  <hellan@acm.org>


	* src/dialogs/dialog-cell-sort.c (dialog_cell_sort): Deflickerize.

	* src/dialogs/dialog-cell-comment.c (dialog_cell_comment): Ditto.

	* src/gnumeric-util.c (gnumeric_dialog_show): New function. Pop up
	a dialog without recursive main loop, with a handler to take care
	of parent shell closing.
	(on_parent_close, on_close): New callback functions.
	(connect_to_parent_close): New helper function - connect handler
	for parent shell closing.

	* src/print.c (sheet_print): Use gnumeric_dialog_run.
parent 4a0aadae
2000-02-21 Jon K Hellan <hellan@acm.org>
* src/dialogs/dialog-cell-sort.c (dialog_cell_sort): Deflickerize.
* src/dialogs/dialog-cell-comment.c (dialog_cell_comment): Ditto.
* src/gnumeric-util.c (gnumeric_dialog_show): New function. Pop up
a dialog without recursive main loop, with a handler to take care
of parent shell closing.
(on_parent_close, on_close): New callback functions.
(connect_to_parent_close): New helper function - connect handler
for parent shell closing.
* src/print.c (sheet_print): Use gnumeric_dialog_run.
2000-02-20 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c (cb_back_preview_color) : Hard code
......
2000-02-21 Jon K Hellan <hellan@acm.org>
* src/dialogs/dialog-cell-sort.c (dialog_cell_sort): Deflickerize.
* src/dialogs/dialog-cell-comment.c (dialog_cell_comment): Ditto.
* src/gnumeric-util.c (gnumeric_dialog_show): New function. Pop up
a dialog without recursive main loop, with a handler to take care
of parent shell closing.
(on_parent_close, on_close): New callback functions.
(connect_to_parent_close): New helper function - connect handler
for parent shell closing.
* src/print.c (sheet_print): Use gnumeric_dialog_run.
2000-02-20 Jody Goldberg <jgoldberg@home.com>
* src/dialogs/dialog-cell-format.c (cb_back_preview_color) : Hard code
......
......@@ -40,8 +40,7 @@ dialog_cell_comment (Workbook *wb, Cell *cell)
}
gtk_box_pack_start (GTK_BOX (GNOME_DIALOG (dialog)->vbox), text, TRUE, TRUE, 0);
gtk_widget_show_all (dialog);
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_widget_show (text);
gtk_widget_grab_focus (text);
v = gnumeric_dialog_run (wb, GNOME_DIALOG (dialog));
......
......@@ -609,7 +609,7 @@ dialog_cell_sort (Workbook *inwb, Sheet *sheet)
GTK_SIGNAL_FUNC (dialog_cell_sort_cols_toggled),
&sort_flow);
gtk_widget_show_all (sort_flow.dialog);
gtk_widget_show_all (sort_flow.clause_box);
/* Run the dialog */
cont = TRUE;
......
......@@ -67,8 +67,12 @@ gnumeric_wb_dialog_run (Workbook *wb, GnomeDialog *dialog)
}
/**
* gnumeric_dialog_run : A utility routine to handle the application being closed by
* the window manager while a modal dialog is being displayed.
* gnumeric_dialog_run
*
* Pop up a dialog as child of a workbook.
*
* The number_of_dialogs_displayed counter is maintained to make sure
* that the window manager doesn't close the app underneath us.
*/
gint
gnumeric_dialog_run (Workbook *wb, GnomeDialog *dialog)
......@@ -79,6 +83,100 @@ gnumeric_dialog_run (Workbook *wb, GnomeDialog *dialog)
return gnome_dialog_run (dialog);
}
/**
* Data structure and callbacks for dialogs which do not use recursive
* mainloop. */
typedef struct {
GtkWidget *parent_toplevel;
gint parent_close_id;
} DialogRunInfo;
static gboolean
on_parent_close (GnomeDialog *parent, GnomeDialog *dialog)
{
gnome_dialog_close (dialog);
return FALSE;
}
static gboolean
on_parent_delete (GnomeDialog *parent, GdkEvent *event, GnomeDialog *dialog)
{
return on_parent_close (parent, dialog);
}
static gboolean
on_close (GnomeDialog *dialog,
DialogRunInfo *run_info)
{
gtk_signal_disconnect(GTK_OBJECT (run_info->parent_toplevel),
run_info->parent_close_id);
g_free (run_info);
return FALSE;
}
/**
* connect_to_parent_close
*
* Attach a handler to close if the parent closes.
*/
static void
connect_to_parent_close (GnomeDialog *dialog, DialogRunInfo *run_info)
{
if (GNOME_IS_DIALOG(run_info->parent_toplevel)) {
run_info->parent_close_id =
gtk_signal_connect
(GTK_OBJECT (run_info->parent_toplevel),
"close", (GtkSignalFunc) on_parent_close,
dialog);
} else {
run_info->parent_close_id =
gtk_signal_connect
(GTK_OBJECT (run_info->parent_toplevel),
"delete_event",
(GtkSignalFunc) on_parent_delete,
dialog);
}
gtk_signal_connect (GTK_OBJECT (dialog), "close",
(GtkSignalFunc) on_close, run_info);
}
/**
* gnumeric_dialog_show
* @parent parent widget
* @dialog dialog
* @click_closes close on click
* @closw_with_parent close when parent closes
*
* Pop up a dialog without a recursive main loop
*
* Attach a handler to close if the parent closes.
* The parent widget does not have to be a toplevel shell - we look it
* up here.
*/
void
gnumeric_dialog_show (GtkWidget *parent, GnomeDialog *dialog,
gboolean click_closes, gboolean close_with_parent)
{
DialogRunInfo *run_info = NULL;
g_return_if_fail(GNOME_IS_DIALOG(dialog));
if (parent) {
run_info = g_new0 (DialogRunInfo, 1);
run_info->parent_toplevel
= gtk_widget_get_toplevel (GTK_WIDGET (parent));
gnome_dialog_set_parent
(GNOME_DIALOG (dialog),
GTK_WINDOW (run_info->parent_toplevel));
if (close_with_parent)
connect_to_parent_close (dialog, run_info);
}
gnome_dialog_set_close (GNOME_DIALOG (dialog), click_closes);
if ( ! GTK_WIDGET_VISIBLE(GTK_WIDGET(dialog)) ) /* Pop up the dialog */
gtk_widget_show(GTK_WIDGET(dialog));
}
int
gtk_radio_group_get_selected (GSList *radio_group)
{
......
......@@ -8,6 +8,9 @@ void gnumeric_notice (Workbook *wb, const char *type, const char *str);
void gnumeric_no_modify_array_notice (Workbook *wb);
gint gnumeric_dialog_run (Workbook *wb, GnomeDialog *dialog);
void gnumeric_dialog_show (GtkWidget *parent, GnomeDialog *dialog,
gboolean click_closes,
gboolean close_with_parent);
/* A simple routine for making a popup menu */
int run_popup_menu (GdkEvent *event, int button, char **strings);
......
......@@ -67,8 +67,12 @@ gnumeric_wb_dialog_run (Workbook *wb, GnomeDialog *dialog)
}
/**
* gnumeric_dialog_run : A utility routine to handle the application being closed by
* the window manager while a modal dialog is being displayed.
* gnumeric_dialog_run
*
* Pop up a dialog as child of a workbook.
*
* The number_of_dialogs_displayed counter is maintained to make sure
* that the window manager doesn't close the app underneath us.
*/
gint
gnumeric_dialog_run (Workbook *wb, GnomeDialog *dialog)
......@@ -79,6 +83,100 @@ gnumeric_dialog_run (Workbook *wb, GnomeDialog *dialog)
return gnome_dialog_run (dialog);
}
/**
* Data structure and callbacks for dialogs which do not use recursive
* mainloop. */
typedef struct {
GtkWidget *parent_toplevel;
gint parent_close_id;
} DialogRunInfo;
static gboolean
on_parent_close (GnomeDialog *parent, GnomeDialog *dialog)
{
gnome_dialog_close (dialog);
return FALSE;
}
static gboolean
on_parent_delete (GnomeDialog *parent, GdkEvent *event, GnomeDialog *dialog)
{
return on_parent_close (parent, dialog);
}
static gboolean
on_close (GnomeDialog *dialog,
DialogRunInfo *run_info)
{
gtk_signal_disconnect(GTK_OBJECT (run_info->parent_toplevel),
run_info->parent_close_id);
g_free (run_info);
return FALSE;
}
/**
* connect_to_parent_close
*
* Attach a handler to close if the parent closes.
*/
static void
connect_to_parent_close (GnomeDialog *dialog, DialogRunInfo *run_info)
{
if (GNOME_IS_DIALOG(run_info->parent_toplevel)) {
run_info->parent_close_id =
gtk_signal_connect
(GTK_OBJECT (run_info->parent_toplevel),
"close", (GtkSignalFunc) on_parent_close,
dialog);
} else {
run_info->parent_close_id =
gtk_signal_connect
(GTK_OBJECT (run_info->parent_toplevel),
"delete_event",
(GtkSignalFunc) on_parent_delete,
dialog);
}
gtk_signal_connect (GTK_OBJECT (dialog), "close",
(GtkSignalFunc) on_close, run_info);
}
/**
* gnumeric_dialog_show
* @parent parent widget
* @dialog dialog
* @click_closes close on click
* @closw_with_parent close when parent closes
*
* Pop up a dialog without a recursive main loop
*
* Attach a handler to close if the parent closes.
* The parent widget does not have to be a toplevel shell - we look it
* up here.
*/
void
gnumeric_dialog_show (GtkWidget *parent, GnomeDialog *dialog,
gboolean click_closes, gboolean close_with_parent)
{
DialogRunInfo *run_info = NULL;
g_return_if_fail(GNOME_IS_DIALOG(dialog));
if (parent) {
run_info = g_new0 (DialogRunInfo, 1);
run_info->parent_toplevel
= gtk_widget_get_toplevel (GTK_WIDGET (parent));
gnome_dialog_set_parent
(GNOME_DIALOG (dialog),
GTK_WINDOW (run_info->parent_toplevel));
if (close_with_parent)
connect_to_parent_close (dialog, run_info);
}
gnome_dialog_set_close (GNOME_DIALOG (dialog), click_closes);
if ( ! GTK_WIDGET_VISIBLE(GTK_WIDGET(dialog)) ) /* Pop up the dialog */
gtk_widget_show(GTK_WIDGET(dialog));
}
int
gtk_radio_group_get_selected (GSList *radio_group)
{
......
......@@ -8,6 +8,9 @@ void gnumeric_notice (Workbook *wb, const char *type, const char *str);
void gnumeric_no_modify_array_notice (Workbook *wb);
gint gnumeric_dialog_run (Workbook *wb, GnomeDialog *dialog);
void gnumeric_dialog_show (GtkWidget *parent, GnomeDialog *dialog,
gboolean click_closes,
gboolean close_with_parent);
/* A simple routine for making a popup menu */
int run_popup_menu (GdkEvent *event, int button, char **strings);
......
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