forked from AuroraMiddleware/gtk
New functions to set the colormap or visual of an existing widget. These
Mon Jan 25 20:05:22 1999 Owen Taylor <otaylor@redhat.com> * gtk/gtkwidget.c (gtk_widget_set_{visual,colormap}): New functions to set the colormap or visual of an existing widget. These functions should not be called on a widget that has previosly been realized. * gtk/gtkcolorsel.c (gtk_color_selection_dialog_init): Set the visual and colormap on the toplevel dialog, then push them for the child widgets. As opposed to push/pop in _new(), this way, things will work properly with gtk_widget_new().
This commit is contained in:
parent
65dd58ffa3
commit
df403d5908
@ -1615,6 +1615,12 @@ gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
|
||||
{
|
||||
GtkWidget *action_area, *frame;
|
||||
|
||||
gtk_widget_set_visual (GTK_WIDGET (colorseldiag), gdk_rgb_get_visual ());
|
||||
gtk_widget_set_colormap (GTK_WIDGET (colorseldiag), gdk_rgb_get_cmap ());
|
||||
|
||||
gtk_widget_push_visual (gdk_rgb_get_visual ());
|
||||
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
|
||||
|
||||
colorseldiag->main_vbox = gtk_vbox_new (FALSE, 10);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (colorseldiag), 10);
|
||||
gtk_container_add (GTK_CONTAINER (colorseldiag), colorseldiag->main_vbox);
|
||||
@ -1650,6 +1656,9 @@ gtk_color_selection_dialog_init (GtkColorSelectionDialog *colorseldiag)
|
||||
GTK_WIDGET_SET_FLAGS (colorseldiag->help_button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (action_area), colorseldiag->help_button, TRUE, TRUE, 0);
|
||||
gtk_widget_show (colorseldiag->help_button);
|
||||
|
||||
gtk_widget_pop_colormap ();
|
||||
gtk_widget_pop_visual ();
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
@ -1657,14 +1666,8 @@ gtk_color_selection_dialog_new (const gchar *title)
|
||||
{
|
||||
GtkColorSelectionDialog *colorseldiag;
|
||||
|
||||
gtk_widget_push_visual (gdk_rgb_get_visual ());
|
||||
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
|
||||
|
||||
colorseldiag = gtk_type_new (gtk_color_selection_dialog_get_type ());
|
||||
gtk_window_set_title (GTK_WINDOW (colorseldiag), title);
|
||||
|
||||
gtk_widget_pop_colormap ();
|
||||
gtk_widget_pop_visual ();
|
||||
|
||||
return GTK_WIDGET (colorseldiag);
|
||||
}
|
||||
|
@ -1015,19 +1015,11 @@ gtk_widget_init (GtkWidget *widget)
|
||||
colormap = gtk_widget_peek_colormap ();
|
||||
visual = gtk_widget_peek_visual ();
|
||||
|
||||
/* XXX - should we ref the colormap and visual, too? */
|
||||
|
||||
if (colormap != gtk_widget_get_default_colormap ())
|
||||
{
|
||||
/* gdk_colormap_ref (colormap); */
|
||||
gtk_object_set_data (GTK_OBJECT (widget), colormap_key, colormap);
|
||||
}
|
||||
gtk_widget_set_colormap (widget, colormap);
|
||||
|
||||
if (visual != gtk_widget_get_default_visual ())
|
||||
{
|
||||
/* gdk_visual_ref (visual); */
|
||||
gtk_object_set_data (GTK_OBJECT (widget), visual_key, visual);
|
||||
}
|
||||
gtk_widget_set_visual (widget, visual);
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
@ -3912,6 +3904,59 @@ gtk_widget_get_visual (GtkWidget *widget)
|
||||
return gtk_widget_get_default_visual ();
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_set_colormap:
|
||||
* Set the colormap for the widget to the given
|
||||
* value. Widget must not have been previously
|
||||
* realized. This probably should only be used
|
||||
* from an init() function.
|
||||
* arguments:
|
||||
* widget:
|
||||
* colormap:
|
||||
* results:
|
||||
*****************************************/
|
||||
|
||||
void
|
||||
gtk_widget_set_colormap (GtkWidget *widget, GdkColormap *colormap)
|
||||
{
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
|
||||
g_return_if_fail (colormap != NULL);
|
||||
|
||||
/* FIXME: reference count the colormap.
|
||||
*/
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (widget),
|
||||
colormap_key,
|
||||
colormap);
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_set_visual:
|
||||
* Set the colormap for the widget to the given
|
||||
* value. Widget must not have been previously
|
||||
* realized. This probably should only be used
|
||||
* from an init() function.
|
||||
* arguments:
|
||||
* widget:
|
||||
* visual:
|
||||
* results:
|
||||
*****************************************/
|
||||
|
||||
void
|
||||
gtk_widget_set_visual (GtkWidget *widget, GdkVisual *visual)
|
||||
{
|
||||
g_return_if_fail (widget != NULL);
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
g_return_if_fail (!GTK_WIDGET_REALIZED (widget));
|
||||
g_return_if_fail (visual != NULL);
|
||||
|
||||
gtk_object_set_data (GTK_OBJECT (widget),
|
||||
visual_key,
|
||||
visual);
|
||||
}
|
||||
|
||||
/*****************************************
|
||||
* gtk_widget_get_events:
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user