From b21ee3c2ea317e4ac503330ac195f0be1cbfad1a Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Thu, 24 May 2001 00:38:38 +0000 Subject: deferred dialog creation --- mixgtk/mixgtk_colorsel.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'mixgtk/mixgtk_colorsel.c') diff --git a/mixgtk/mixgtk_colorsel.c b/mixgtk/mixgtk_colorsel.c index c1f5a3d..b40f6d2 100644 --- a/mixgtk/mixgtk_colorsel.c +++ b/mixgtk/mixgtk_colorsel.c @@ -49,10 +49,7 @@ typedef struct static area_id_t areas_[LNO_][ZNO_]; static area_id_t *current_ = NULL; -#define COLORSEL_DLG_NAME_ "colorsel_dialog" static GtkWidget *colorseldlg_ = NULL; - - static void set_area_color_ (GtkWidget *area, const GdkColor *color) { @@ -78,39 +75,39 @@ set_area_color_ (GtkWidget *area, const GdkColor *color) static gint area_event_(GtkWidget *widget, GdkEvent *event, gpointer areaid) { - gint handled = FALSE; /* Check if we've received a button pressed event */ if (event->type == GDK_BUTTON_PRESS) { -/* handled = TRUE; */ current_ = (area_id_t *)areaid; /* Show the dialog */ gtk_widget_show (colorseldlg_); } - return handled; + return FALSE; } /* initialise the color selection dialog */ -gboolean -mixgtk_colorsel_init (void) +static void +init_colorsel_ (void) { int i, j; - color_dialog_ = mixgtk_widget_factory_get (MIXGTK_WIDGET_COLORSEL_DIALOG); - g_return_val_if_fail (color_dialog_ != NULL, FALSE); - colorseldlg_ = mixgtk_widget_factory_get_by_name (COLORSEL_DLG_NAME_); - g_return_val_if_fail (colorseldlg_ != NULL, FALSE); + color_dialog_ = mixgtk_widget_factory_get_dialog (MIXGTK_COLOR_DIALOG); + g_assert (color_dialog_ != NULL); + colorseldlg_ = mixgtk_widget_factory_get_dialog (MIXGTK_COLORSEL_DIALOG); + g_assert (colorseldlg_ != NULL); for (i = 0; i < LNO_; ++i) for (j = 0; j < ZNO_; ++j) { - areas_[i][j].area = mixgtk_widget_factory_get_by_name (anames_[i][j]); - g_return_val_if_fail (areas_[i][j].area != NULL, FALSE); + areas_[i][j].area = + mixgtk_widget_factory_get_child_by_name + (MIXGTK_COLOR_DIALOG, anames_[i][j]); + g_assert (areas_[i][j].area != NULL); areas_[i][j].changed = FALSE; gtk_widget_set_events (areas_[i][j].area, GDK_BUTTON_PRESS_MASK); - gtk_signal_connect (GTK_OBJECT(areas_[i][j].area), "event", - (GtkSignalFunc)area_event_, (gpointer)&areas_[i][j]); + gtk_signal_connect (GTK_OBJECT(areas_[i][j].area), "event", + (GtkSignalFunc)area_event_, + (gpointer)&areas_[i][j]); } - return TRUE; } /* gtk callbacks */ @@ -120,6 +117,7 @@ on_colors_activate (GtkWidget *w, gpointer p) int i, j; /* must show widget before changing its colors */ + if (!color_dialog_) init_colorsel_ (); gtk_widget_show (color_dialog_); for (i = 0; i < LNO_; ++i) -- cgit v1.2.3