summaryrefslogtreecommitdiffhomepage
path: root/mixgtk/mixgtk_colorsel.c
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2001-05-24 00:38:38 +0000
committerJose Antonio Ortega Ruiz <jao@gnu.org>2001-05-24 00:38:38 +0000
commitb21ee3c2ea317e4ac503330ac195f0be1cbfad1a (patch)
treeb6b79fd6994a01da477015a3a6c7eb44f49c4b5c /mixgtk/mixgtk_colorsel.c
parentc3773eaf619976d302a05d3b6a02158b6f5ce9cc (diff)
downloadmdk-b21ee3c2ea317e4ac503330ac195f0be1cbfad1a.tar.gz
mdk-b21ee3c2ea317e4ac503330ac195f0be1cbfad1a.tar.bz2
deferred dialog creation
Diffstat (limited to 'mixgtk/mixgtk_colorsel.c')
-rw-r--r--mixgtk/mixgtk_colorsel.c32
1 files changed, 15 insertions, 17 deletions
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)