]> Pileus Git - ~andy/gtk/commitdiff
do not call gtk_settings_get_default() here as that requires an X
authorjacob berkman <jacob@ximian.com>
Sun, 28 Oct 2001 16:49:56 +0000 (16:49 +0000)
committerJacob Berkman <jberkman@src.gnome.org>
Sun, 28 Oct 2001 16:49:56 +0000 (16:49 +0000)
2001-10-28  jacob berkman  <jacob@ximian.com>

* gtk/gtkcolorsel.c (gtk_color_selection_class_init): do not call
gtk_settings_get_default() here as that requires an X connection
(which breaks doc building with no X connection) and is not
multihead safe
(gtk_color_selection_init): delay palette loading until realize
time
(gtk_color_selection_realize): load the palette, and initialize
the global palette if it hasn't been already

* gtk/gtkpreview.c (gtk_preview_class_init): don't initialize the
visual/cmap fields of klass->info since they are gone
(gtk_preview_get_visual): just return gdk_rgb_get_visual ()
(gtk_preview_get_cmap): just return gdk_rgb_get_colormap ()
(gtk_preview_realize): don't set VISUAL and COLORMAP attributes

* gtk/gtkpreview.h (struct _GtkPreviewInfo): remove visual and
cmap fields
(gtk_preview_get_visual):
(gtk_preview_get_cmap): mark as deprecated

* docs/Changes-2.0.txt: add a little note about the GtkPreviewInfo
changes

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
docs/Changes-2.0.txt
gtk/gtkcolorsel.c
gtk/gtkpreview.c
gtk/gtkpreview.h

index d70b6d271248ba274166d93f9a6a73d4dc77d7ef..7beb37c354264f6627b0855ddfc041c079c312a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2001-10-28  jacob berkman  <jacob@ximian.com>
+
+       * gtk/gtkcolorsel.c (gtk_color_selection_class_init): do not call
+       gtk_settings_get_default() here as that requires an X connection
+       (which breaks doc building with no X connection) and is not
+       multihead safe
+       (gtk_color_selection_init): delay palette loading until realize
+       time
+       (gtk_color_selection_realize): load the palette, and initialize
+       the global palette if it hasn't been already
+
+       * gtk/gtkpreview.c (gtk_preview_class_init): don't initialize the
+       visual/cmap fields of klass->info since they are gone
+       (gtk_preview_get_visual): just return gdk_rgb_get_visual ()
+       (gtk_preview_get_cmap): just return gdk_rgb_get_colormap ()
+       (gtk_preview_realize): don't set VISUAL and COLORMAP attributes
+
+       * gtk/gtkpreview.h (struct _GtkPreviewInfo): remove visual and
+       cmap fields
+       (gtk_preview_get_visual):
+       (gtk_preview_get_cmap): mark as deprecated
+
+       * docs/Changes-2.0.txt: add a little note about the GtkPreviewInfo
+       changes
+
 Sun Oct 28 09:15:39 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimcontext.h (struct _GtkIMContext): Fixed
index d70b6d271248ba274166d93f9a6a73d4dc77d7ef..7beb37c354264f6627b0855ddfc041c079c312a8 100644 (file)
@@ -1,3 +1,28 @@
+2001-10-28  jacob berkman  <jacob@ximian.com>
+
+       * gtk/gtkcolorsel.c (gtk_color_selection_class_init): do not call
+       gtk_settings_get_default() here as that requires an X connection
+       (which breaks doc building with no X connection) and is not
+       multihead safe
+       (gtk_color_selection_init): delay palette loading until realize
+       time
+       (gtk_color_selection_realize): load the palette, and initialize
+       the global palette if it hasn't been already
+
+       * gtk/gtkpreview.c (gtk_preview_class_init): don't initialize the
+       visual/cmap fields of klass->info since they are gone
+       (gtk_preview_get_visual): just return gdk_rgb_get_visual ()
+       (gtk_preview_get_cmap): just return gdk_rgb_get_colormap ()
+       (gtk_preview_realize): don't set VISUAL and COLORMAP attributes
+
+       * gtk/gtkpreview.h (struct _GtkPreviewInfo): remove visual and
+       cmap fields
+       (gtk_preview_get_visual):
+       (gtk_preview_get_cmap): mark as deprecated
+
+       * docs/Changes-2.0.txt: add a little note about the GtkPreviewInfo
+       changes
+
 Sun Oct 28 09:15:39 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimcontext.h (struct _GtkIMContext): Fixed
index d70b6d271248ba274166d93f9a6a73d4dc77d7ef..7beb37c354264f6627b0855ddfc041c079c312a8 100644 (file)
@@ -1,3 +1,28 @@
+2001-10-28  jacob berkman  <jacob@ximian.com>
+
+       * gtk/gtkcolorsel.c (gtk_color_selection_class_init): do not call
+       gtk_settings_get_default() here as that requires an X connection
+       (which breaks doc building with no X connection) and is not
+       multihead safe
+       (gtk_color_selection_init): delay palette loading until realize
+       time
+       (gtk_color_selection_realize): load the palette, and initialize
+       the global palette if it hasn't been already
+
+       * gtk/gtkpreview.c (gtk_preview_class_init): don't initialize the
+       visual/cmap fields of klass->info since they are gone
+       (gtk_preview_get_visual): just return gdk_rgb_get_visual ()
+       (gtk_preview_get_cmap): just return gdk_rgb_get_colormap ()
+       (gtk_preview_realize): don't set VISUAL and COLORMAP attributes
+
+       * gtk/gtkpreview.h (struct _GtkPreviewInfo): remove visual and
+       cmap fields
+       (gtk_preview_get_visual):
+       (gtk_preview_get_cmap): mark as deprecated
+
+       * docs/Changes-2.0.txt: add a little note about the GtkPreviewInfo
+       changes
+
 Sun Oct 28 09:15:39 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimcontext.h (struct _GtkIMContext): Fixed
index d70b6d271248ba274166d93f9a6a73d4dc77d7ef..7beb37c354264f6627b0855ddfc041c079c312a8 100644 (file)
@@ -1,3 +1,28 @@
+2001-10-28  jacob berkman  <jacob@ximian.com>
+
+       * gtk/gtkcolorsel.c (gtk_color_selection_class_init): do not call
+       gtk_settings_get_default() here as that requires an X connection
+       (which breaks doc building with no X connection) and is not
+       multihead safe
+       (gtk_color_selection_init): delay palette loading until realize
+       time
+       (gtk_color_selection_realize): load the palette, and initialize
+       the global palette if it hasn't been already
+
+       * gtk/gtkpreview.c (gtk_preview_class_init): don't initialize the
+       visual/cmap fields of klass->info since they are gone
+       (gtk_preview_get_visual): just return gdk_rgb_get_visual ()
+       (gtk_preview_get_cmap): just return gdk_rgb_get_colormap ()
+       (gtk_preview_realize): don't set VISUAL and COLORMAP attributes
+
+       * gtk/gtkpreview.h (struct _GtkPreviewInfo): remove visual and
+       cmap fields
+       (gtk_preview_get_visual):
+       (gtk_preview_get_cmap): mark as deprecated
+
+       * docs/Changes-2.0.txt: add a little note about the GtkPreviewInfo
+       changes
+
 Sun Oct 28 09:15:39 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimcontext.h (struct _GtkIMContext): Fixed
index d70b6d271248ba274166d93f9a6a73d4dc77d7ef..7beb37c354264f6627b0855ddfc041c079c312a8 100644 (file)
@@ -1,3 +1,28 @@
+2001-10-28  jacob berkman  <jacob@ximian.com>
+
+       * gtk/gtkcolorsel.c (gtk_color_selection_class_init): do not call
+       gtk_settings_get_default() here as that requires an X connection
+       (which breaks doc building with no X connection) and is not
+       multihead safe
+       (gtk_color_selection_init): delay palette loading until realize
+       time
+       (gtk_color_selection_realize): load the palette, and initialize
+       the global palette if it hasn't been already
+
+       * gtk/gtkpreview.c (gtk_preview_class_init): don't initialize the
+       visual/cmap fields of klass->info since they are gone
+       (gtk_preview_get_visual): just return gdk_rgb_get_visual ()
+       (gtk_preview_get_cmap): just return gdk_rgb_get_colormap ()
+       (gtk_preview_realize): don't set VISUAL and COLORMAP attributes
+
+       * gtk/gtkpreview.h (struct _GtkPreviewInfo): remove visual and
+       cmap fields
+       (gtk_preview_get_visual):
+       (gtk_preview_get_cmap): mark as deprecated
+
+       * docs/Changes-2.0.txt: add a little note about the GtkPreviewInfo
+       changes
+
 Sun Oct 28 09:15:39 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimcontext.h (struct _GtkIMContext): Fixed
index d70b6d271248ba274166d93f9a6a73d4dc77d7ef..7beb37c354264f6627b0855ddfc041c079c312a8 100644 (file)
@@ -1,3 +1,28 @@
+2001-10-28  jacob berkman  <jacob@ximian.com>
+
+       * gtk/gtkcolorsel.c (gtk_color_selection_class_init): do not call
+       gtk_settings_get_default() here as that requires an X connection
+       (which breaks doc building with no X connection) and is not
+       multihead safe
+       (gtk_color_selection_init): delay palette loading until realize
+       time
+       (gtk_color_selection_realize): load the palette, and initialize
+       the global palette if it hasn't been already
+
+       * gtk/gtkpreview.c (gtk_preview_class_init): don't initialize the
+       visual/cmap fields of klass->info since they are gone
+       (gtk_preview_get_visual): just return gdk_rgb_get_visual ()
+       (gtk_preview_get_cmap): just return gdk_rgb_get_colormap ()
+       (gtk_preview_realize): don't set VISUAL and COLORMAP attributes
+
+       * gtk/gtkpreview.h (struct _GtkPreviewInfo): remove visual and
+       cmap fields
+       (gtk_preview_get_visual):
+       (gtk_preview_get_cmap): mark as deprecated
+
+       * docs/Changes-2.0.txt: add a little note about the GtkPreviewInfo
+       changes
+
 Sun Oct 28 09:15:39 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimcontext.h (struct _GtkIMContext): Fixed
index d70b6d271248ba274166d93f9a6a73d4dc77d7ef..7beb37c354264f6627b0855ddfc041c079c312a8 100644 (file)
@@ -1,3 +1,28 @@
+2001-10-28  jacob berkman  <jacob@ximian.com>
+
+       * gtk/gtkcolorsel.c (gtk_color_selection_class_init): do not call
+       gtk_settings_get_default() here as that requires an X connection
+       (which breaks doc building with no X connection) and is not
+       multihead safe
+       (gtk_color_selection_init): delay palette loading until realize
+       time
+       (gtk_color_selection_realize): load the palette, and initialize
+       the global palette if it hasn't been already
+
+       * gtk/gtkpreview.c (gtk_preview_class_init): don't initialize the
+       visual/cmap fields of klass->info since they are gone
+       (gtk_preview_get_visual): just return gdk_rgb_get_visual ()
+       (gtk_preview_get_cmap): just return gdk_rgb_get_colormap ()
+       (gtk_preview_realize): don't set VISUAL and COLORMAP attributes
+
+       * gtk/gtkpreview.h (struct _GtkPreviewInfo): remove visual and
+       cmap fields
+       (gtk_preview_get_visual):
+       (gtk_preview_get_cmap): mark as deprecated
+
+       * docs/Changes-2.0.txt: add a little note about the GtkPreviewInfo
+       changes
+
 Sun Oct 28 09:15:39 2001  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkimcontext.h (struct _GtkIMContext): Fixed
index 5b79890799a750dbc1206a240bc479bb97f3cb1c..b8ee4f6274c0529bf6562797c6276cd769ed7052 100644 (file)
@@ -502,3 +502,9 @@ Incompatible Changes from GTK+-1.2 to GTK+-2.0:
 
   If you aren't using GDK and GTK+ functions from multiple threads,
   there is no reason to call gdk_threads_init().
+
+* The GtkPreviewInfo struct has had its visual and colormap fields
+  removed.  Also, gtk_preview_get_cmap() and gtk_preview_get_visual()
+  are deprecated, as GdkRgb works on any colormap and visual.  You no
+  longer need to gtk_widget_push_cmap (gtk_preview_get_cmap ()) in
+  your code.
index dda756b38ffb32eec509c8bd92418f006d543e1f..b337357de93e02921ad67cc3ef596ed6f7224a5a 100644 (file)
@@ -143,6 +143,7 @@ static void gtk_color_selection_init                (GtkColorSelection       *colorsel);
 static void gtk_color_selection_class_init     (GtkColorSelectionClass  *klass);
 static void gtk_color_selection_destroy                (GtkObject               *object);
 static void gtk_color_selection_finalize        (GObject                *object);
+static void gtk_color_selection_realize         (GtkWidget               *widget);
 static void update_color                       (GtkColorSelection       *colorsel);
 static void gtk_color_selection_set_property    (GObject                 *object,
                                                 guint                    prop_id,
@@ -162,13 +163,15 @@ static void     gtk_color_selection_set_palette_color   (GtkColorSelection *colo
                                                          GdkColor          *color);
 static void     gtk_color_selection_unset_palette_color (GtkColorSelection *colorsel,
                                                          gint               index);
+static void     default_change_palette_func             (const GdkColor    *colors,
+                                                        gint               n_colors);
 
 static gpointer parent_class = NULL;
 static guint color_selection_signals[LAST_SIGNAL] = { 0 };
 
 static gchar* default_colors = "black:white:gray50:red:purple:blue:light blue:green:yellow:orange:lavender:brown:goldenrod4:dodger blue:pink:light green:gray10:gray30:gray75:gray90";
 
-static GtkColorSelectionChangePaletteFunc change_palette_hook = NULL;
+static GtkColorSelectionChangePaletteFunc change_palette_hook = default_change_palette_func;
 
 static GdkColor current_colors[GTK_CUSTOM_PALETTE_WIDTH * GTK_CUSTOM_PALETTE_HEIGHT];
 
@@ -1648,10 +1651,11 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
 {
   GtkObjectClass *object_class;
   GObjectClass *gobject_class;
-  gchar *palette;
+  GtkWidgetClass *widget_class;
   
   object_class = GTK_OBJECT_CLASS (klass);
   gobject_class = G_OBJECT_CLASS (klass);
+  widget_class = GTK_WIDGET_CLASS (klass);
   
   parent_class = gtk_type_class (GTK_TYPE_VBOX);
   
@@ -1661,6 +1665,8 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
   gobject_class->set_property = gtk_color_selection_set_property;
   gobject_class->get_property = gtk_color_selection_get_property;
   
+  widget_class->realize = gtk_color_selection_realize;
+
   g_object_class_install_property (gobject_class,
                                    PROP_HAS_OPACITY_CONTROL,
                                    g_param_spec_boolean ("has_opacity_control",
@@ -1703,21 +1709,6 @@ gtk_color_selection_class_init (GtkColorSelectionClass *klass)
                                                       _("Palette to use in the color selector"),
                                                       default_colors,
                                                       G_PARAM_READWRITE));
-
-  g_object_get (G_OBJECT (gtk_settings_get_default ()),
-                "gtk-color-palette",
-                &palette,
-                NULL);
-  
-  fill_palette_from_string (palette);
-  g_free (palette);
-
-  change_palette_hook = default_change_palette_func;
-  
-  g_signal_connect_data (G_OBJECT (gtk_settings_get_default ()),
-                         "notify::gtk-color-palette",
-                         G_CALLBACK (palette_change_notify_class),
-                         NULL, NULL, 0);
 }
 
 /* widget functions */
@@ -1875,16 +1866,6 @@ gtk_color_selection_init (GtkColorSelection *colorsel)
   
   gtk_widget_show_all (top_hbox);
 
-  /* Set default colors */
-
-  update_palette (colorsel);
-
-  priv->settings_connection = 
-    g_signal_connect_data (G_OBJECT (gtk_settings_get_default ()),
-                           "notify::gtk-color-palette",
-                           G_CALLBACK (palette_change_notify_instance),
-                           colorsel, NULL, 0);
-  
   /* hide unused stuff */
   
   if (priv->has_opacity == FALSE)
@@ -1942,6 +1923,43 @@ gtk_color_selection_finalize (GObject *object)
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
 
+static void
+gtk_color_selection_realize (GtkWidget *widget)
+{
+  GtkColorSelection *colorsel = GTK_COLOR_SELECTION (widget);
+  ColorSelectionPrivate *priv = colorsel->private_data;
+  gchar *palette;
+  static gboolean initialized = FALSE;
+
+  if (!initialized)
+    {
+      g_object_get (gtk_settings_get_default (),
+                   "gtk-color-palette", &palette,
+                   NULL);
+      
+      fill_palette_from_string (palette);
+      g_free (palette);
+
+      g_signal_connect (gtk_settings_get_default (),
+                       "notify::gtk-color-palette",
+                       G_CALLBACK (palette_change_notify_class),
+                       NULL);
+
+      initialized = TRUE;
+    }
+  
+  /* Set default colors */
+
+  update_palette (colorsel);
+  priv->settings_connection =
+    g_signal_connect (gtk_settings_get_default (),
+                     "notify::gtk-color-palette",
+                     G_CALLBACK (palette_change_notify_instance),
+                     colorsel);
+
+  if (GTK_WIDGET_CLASS (parent_class)->realize)
+    GTK_WIDGET_CLASS (parent_class)->realize (widget);
+}
 
 /**
  * gtk_color_selection_new:
index 62f9a3e6bd4ba74b7ef1df420ec3b1da43a291d9..a429d6ad6601aa8e6fadb31865fe3df7213f8843 100644 (file)
@@ -117,16 +117,11 @@ gtk_preview_class_init (GtkPreviewClass *klass)
   widget_class->size_allocate = gtk_preview_size_allocate;
   widget_class->expose_event = gtk_preview_expose;
 
-  klass->info.visual = NULL;
-  klass->info.cmap = NULL;
-
   klass->info.lookup = NULL;
 
   klass->info.gamma = 1.0;
 
   gdk_rgb_init ();
-  klass->info.cmap = gdk_rgb_get_cmap ();
-  klass->info.visual = gdk_rgb_get_visual ();
 
   g_object_class_install_property (gobject_class,
                                    PROP_EXPAND,
@@ -313,7 +308,6 @@ gtk_preview_draw_row (GtkPreview *preview,
 
   g_return_if_fail (GTK_IS_PREVIEW (preview));
   g_return_if_fail (data != NULL);
-  g_return_if_fail (preview_class->info.visual != NULL);
   
   bpp = (preview->type == GTK_PREVIEW_COLOR ? 3 : 1);
   rowstride = (preview->buffer_width * bpp + 3) & -4;
@@ -422,19 +416,13 @@ gtk_preview_set_dither (GtkPreview      *preview,
 GdkVisual*
 gtk_preview_get_visual (void)
 {
-  if (!preview_class)
-    preview_class = gtk_type_class (gtk_preview_get_type ());
-
-  return preview_class->info.visual;
+  return gdk_rgb_get_visual ();
 }
 
 GdkColormap*
 gtk_preview_get_cmap (void)
 {
-  if (!preview_class)
-    preview_class = gtk_type_class (gtk_preview_get_type ());
-
-  return preview_class->info.cmap;
+  return gdk_rgb_get_colormap ();
 }
 
 GtkPreviewInfo*
@@ -491,10 +479,8 @@ gtk_preview_realize (GtkWidget *widget)
   attributes.y = widget->allocation.y + (widget->allocation.height - attributes.height) / 2;;
 
   attributes.wclass = GDK_INPUT_OUTPUT;
-  attributes.visual = preview_class->info.visual;
-  attributes.colormap = preview_class->info.cmap;
   attributes.event_mask = gtk_widget_get_events (widget) | GDK_EXPOSURE_MASK;
-  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+  attributes_mask = GDK_WA_X | GDK_WA_Y;
 
   widget->window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask);
   gdk_window_set_user_data (widget->window, widget);
index 0dd5d7fdeb63b058676495bf1c4a99667b96122e..032cc3c693efff8361f036b0327db05a4d4ec94d 100644 (file)
@@ -70,9 +70,6 @@ struct _GtkPreview
 
 struct _GtkPreviewInfo
 {
-  GdkVisual *visual;
-  GdkColormap *cmap;
-
   guchar *lookup;
 
   gdouble gamma;
@@ -125,8 +122,10 @@ void            gtk_preview_set_install_cmap   (gint             install_cmap);
 void            gtk_preview_set_reserved       (gint             nreserved);
 void            gtk_preview_set_dither         (GtkPreview      *preview,
                                                GdkRgbDither     dither);
+#ifndef GTK_DISABLE_DEPRECATED
 GdkVisual*      gtk_preview_get_visual         (void);
 GdkColormap*    gtk_preview_get_cmap           (void);
+#endif
 GtkPreviewInfo* gtk_preview_get_info           (void);
 
 /* This function reinitializes the preview colormap and visual from