Re: gtk_type_init() with no X connection [was: Re: horrible things]



jacob berkman <jacob ximian com> writes:

> On Wed, 2001-10-24 at 21:15, Owen Taylor wrote:
> > 
> > > > jacob berkman <jacob ximian com> writes:
> > > > 
> > > > > this patch allows the gtk docs to build w/o an X connection.
> > 
> > Looks like its definitely heading in the right direction. But
> > there is a much simpler solution for GtkPreview - just let it
> > use the default visual and colormap for the widget instead of setting 
> > something different:
> > 
> >  - The GdkRGB visual/colormap are the default now
> >  - GdkRGB can render into any visual/colormap now
> > 
> > I think it should be possible to fix GtkPreview with a '-' only
> > patch.
> 
> ok - this patch does that, but i'm not sure it's the right thing.
> 
> there is currently code (mostly in gimp) which does:
> 
> gtk_widget_push_colormap (gtk_preview_get_colormap ());
> 
> this could be safely removed - since you don't need to push the colormap
> / visual any more.  with this patch, gtk_preview_get_colormap () would
> return NULL, and you'd get failed assertions.
> 
> so, that could either be left in such that people should remove the
> push/pop, or _get_colormap() could return gdk_rgb_get_colormap().
> 
> (maybe the visual / colormap fields should be removed if the former?)
> 
> i also fixed up colorsel per your suggestions.

Returning NULL here is not a good at all since it will just
segfault programs. Why don't you:

 - Remove the cmap and visual fields from GtkPreviewInfo
 - Add a quick entry to Changes-2.0.txt mentioning that
 - Make gtk_preview_get_cmap/visual return 
   gdk_rgb_get_colormap(), gdk_rgb_get_visual().
 - Deprecate gtk_preview_get_cmap/visual.

> +static void
> +gtk_color_selection_realize (GtkWidget *widget)
> +{
> +  GtkColorSelection *colorsel = GTK_COLOR_SELECTION (widget);
> +  ColorSelectionPrivate *priv = colorsel->private_data;
> +  gchar *palette;
> +
> +  g_object_get (G_OBJECT (gtk_settings_get_default ()),
> +                "gtk-color-palette",
> +                &palette,
> +                NULL);
> +  
> +  fill_palette_from_string (palette);
> +  g_free (palette);
> +
> +  if (!change_palette_hook)
> +    {
> +      change_palette_hook = default_change_palette_func;
> +  
> +      g_signal_connect (gtk_settings_get_default (),
> +			"notify::gtk-color-palette",
> +			G_CALLBACK (palette_change_notify_class),
> +			NULL);
> +    }

This doesn't work, does it? gtk_color_selection_set_change_palette_hook()
could be (and probably will be) called before the first colorsell
is realized.

Seems to me the assiugnment to '= default_change_palette_func'
should be done as a static initializer, adn then you
should have something like:

 static gboolean init = FALSE;

 if (!init)
   {
     gchar *palette;

     init = TRUE;

     g_object_get (G_OBJECT (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);
   }

Thanks,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]