diff --git a/ChangeLog b/ChangeLog index 04b55dc997..a400d9b596 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2005-08-26 Matthias Clasen + * gdk/gdk.symbols: + * gdk/gdkscreen.h: + * gdk/gdkscreen.c: Make the GdkScreen font options api + public, and add properties GdkScreen::font-options and + GdkScreen::resolution. (#314004) + + * gdk/gdkpango.c: + * gtk/gtksettings.c: + * gtk/gtkwidget.c: Adjust all callers. + + * gdk/gdkintl.h: Simplify and use glib/gi18n-lib.h. + * gdk/gdkpango.c: Include gdkintl.h, not gtkintl.h. + * gdk/gdkscreen.c: Include gdkintl.h. + * gtk/gtkicontheme.c (theme_lookup_icon): Avoid an uninitialized variable warning, pointed out by Colin Walters. (#314585) diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 04b55dc997..a400d9b596 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,19 @@ 2005-08-26 Matthias Clasen + * gdk/gdk.symbols: + * gdk/gdkscreen.h: + * gdk/gdkscreen.c: Make the GdkScreen font options api + public, and add properties GdkScreen::font-options and + GdkScreen::resolution. (#314004) + + * gdk/gdkpango.c: + * gtk/gtksettings.c: + * gtk/gtkwidget.c: Adjust all callers. + + * gdk/gdkintl.h: Simplify and use glib/gi18n-lib.h. + * gdk/gdkpango.c: Include gdkintl.h, not gtkintl.h. + * gdk/gdkscreen.c: Include gdkintl.h. + * gtk/gtkicontheme.c (theme_lookup_icon): Avoid an uninitialized variable warning, pointed out by Colin Walters. (#314585) diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 53cb38422e..5c84db9f46 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,8 @@ +2005-08-26 Matthias Clasen + + * gdk/gdk-sections.txt: Add font options + API. + 2005-08-24 Matthias Clasen * === Released 2.8.2 === diff --git a/docs/reference/gdk/gdk-sections.txt b/docs/reference/gdk/gdk-sections.txt index 2c6ca0667a..85263d33d4 100644 --- a/docs/reference/gdk/gdk-sections.txt +++ b/docs/reference/gdk/gdk-sections.txt @@ -215,6 +215,10 @@ gdk_screen_get_monitor_at_point gdk_screen_get_monitor_at_window gdk_screen_broadcast_client_message gdk_screen_get_setting +gdk_screen_get_font_options +gdk_screen_set_font_options +gdk_screen_get_resolution +gdk_screen_set_resolution gdk_spawn_on_screen gdk_spawn_on_screen_with_pipes diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index c8c25e88c9..8b3f48b271 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -962,10 +962,10 @@ gdk_draw_rgb_image_dithalign gdk_screen_get_type G_GNUC_CONST gdk_screen_get_monitor_at_point gdk_screen_get_monitor_at_window -gdk_screen_set_font_options_libgtk_only -gdk_screen_get_font_options_libgtk_only -gdk_screen_set_resolution_libgtk_only -gdk_screen_get_resolution_libgtk_only +gdk_screen_set_font_options +gdk_screen_get_font_options +gdk_screen_set_resolution +gdk_screen_get_resolution #endif #endif diff --git a/gdk/gdkintl.h b/gdk/gdkintl.h index cfcda9d390..9bd7b267dc 100644 --- a/gdk/gdkintl.h +++ b/gdk/gdkintl.h @@ -28,25 +28,12 @@ #define __GDKINTL_H__ #include "config.h" +#include #ifdef ENABLE_NLS -#include -#define _(String) dgettext(GETTEXT_PACKAGE,String) #define P_(String) dgettext(GETTEXT_PACKAGE "-properties",String) -#ifdef gettext_noop -#define N_(String) gettext_noop(String) #else -#define N_(String) (String) -#endif -#else /* NLS is disabled */ -#define _(String) (String) #define P_(String) (String) -#define N_(String) (String) -#define textdomain(String) (String) -#define gettext(String) (String) -#define dgettext(Domain,String) (String) -#define dcgettext(Domain,String,Type) (String) -#define bindtextdomain(Domain,Directory) (Domain) #endif #endif diff --git a/gdk/gdkpango.c b/gdk/gdkpango.c index 4adc04ac4e..4ddec897c5 100644 --- a/gdk/gdkpango.c +++ b/gdk/gdkpango.c @@ -30,8 +30,7 @@ #include "gdkscreen.h" #include "gdkalias.h" -/* This is for P_() ... a bit non-kosher, but works fine */ -#include "gtk/gtkintl.h" +#include "gdkintl.h" #define GDK_INFO_KEY "gdk-info" @@ -1384,10 +1383,10 @@ gdk_pango_context_get_for_screen (GdkScreen *screen) context = pango_cairo_font_map_create_context (PANGO_CAIRO_FONT_MAP (fontmap)); - options = gdk_screen_get_font_options_libgtk_only (screen); + options = gdk_screen_get_font_options (screen); pango_cairo_context_set_font_options (context, options); - dpi = gdk_screen_get_resolution_libgtk_only (screen); + dpi = gdk_screen_get_resolution (screen); pango_cairo_context_set_resolution (context, dpi); return context; diff --git a/gdk/gdkscreen.c b/gdk/gdkscreen.c index 482361615f..949a9d22ea 100644 --- a/gdk/gdkscreen.c +++ b/gdk/gdkscreen.c @@ -26,12 +26,28 @@ #include "gdkcolor.h" #include "gdkwindow.h" #include "gdkscreen.h" +#include "gdkintl.h" #include "gdkalias.h" -static void gdk_screen_class_init (GdkScreenClass *klass); -static void gdk_screen_init (GdkScreen *screen); -static void gdk_screen_dispose (GObject *object); -static void gdk_screen_finalize (GObject *object); +static void gdk_screen_class_init (GdkScreenClass *klass); +static void gdk_screen_init (GdkScreen *screen); +static void gdk_screen_dispose (GObject *object); +static void gdk_screen_finalize (GObject *object); +static void gdk_screen_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec); +static void gdk_screen_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + +enum +{ + PROP_0, + PROP_FONT_OPTIONS, + PROP_RESOLUTION +}; enum { @@ -79,7 +95,26 @@ gdk_screen_class_init (GdkScreenClass *klass) object_class->dispose = gdk_screen_dispose; object_class->finalize = gdk_screen_finalize; + object_class->set_property = gdk_screen_set_property; + object_class->get_property = gdk_screen_get_property; + g_object_class_install_property (object_class, + PROP_FONT_OPTIONS, + g_param_spec_pointer ("font-options", + P_("Font options"), + P_("The default font options for the screen"), + G_PARAM_READWRITE)); + + g_object_class_install_property (object_class, + PROP_RESOLUTION, + g_param_spec_double ("resolution", + P_("Font resolution"), + P_("The resolution for fonts on the screen"), + -G_MAXDOUBLE, + G_MAXDOUBLE, + -1.0, + G_PARAM_READWRITE)); + /** * GdkScreen::size-changed: * @screen: the object on which the signal is emitted @@ -338,7 +373,7 @@ gdk_screen_height_mm (void) } /** - * gdk_screen_set_font_options_libgtk_only: + * gdk_screen_set_font_options: * @screen: a #GdkScreen * @options: a #cairo_font_options_t, or %NULL to unset any * previously set default font options. @@ -348,36 +383,42 @@ gdk_screen_height_mm (void) * with gdk_pango_context_get_for_screen(). Changing the * default set of font options does not affect contexts that * have already been created. - * - * This function is not part of the GDK public API and is only - * for use by GTK+. + * + * Since: 2.10 **/ void -gdk_screen_set_font_options_libgtk_only (GdkScreen *screen, - const cairo_font_options_t *options) +gdk_screen_set_font_options (GdkScreen *screen, + const cairo_font_options_t *options) { g_return_if_fail (GDK_IS_SCREEN (screen)); - if (screen->font_options) - cairo_font_options_destroy (screen->font_options); - - if (options) - screen->font_options = cairo_font_options_copy (options); - else - screen->font_options = NULL; + if (screen->font_options != options) + { + if (screen->font_options) + cairo_font_options_destroy (screen->font_options); + + if (options) + screen->font_options = cairo_font_options_copy (options); + else + screen->font_options = NULL; + + g_object_notify (G_OBJECT (screen), "font-options"); + } } /** - * gdk_screen_get_font_options_libgtk_only: + * gdk_screen_get_font_options: * @screen: a #GdkScreen * - * Gets any options previously set with gdk_screen_set_font_options_libgtk_only(). + * Gets any options previously set with gdk_screen_set_font_options(). * * Return value: the current font options, or %NULL if no default * font options have been set. + * + * Since: 2.10 **/ const cairo_font_options_t * -gdk_screen_get_font_options_libgtk_only (GdkScreen *screen) +gdk_screen_get_font_options (GdkScreen *screen) { g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); @@ -385,7 +426,7 @@ gdk_screen_get_font_options_libgtk_only (GdkScreen *screen) } /** - * gdk_screen_set_resolution_libgtk_only: + * gdk_screen_set_resolution: * @screen: a #GdkScreen * @dpi: the resolution in "dots per inch". (Physical inches aren't actually * involved; the terminology is conventional.) @@ -395,38 +436,88 @@ gdk_screen_get_font_options_libgtk_only (GdkScreen *screen) * and cairo units. The default value is 96, meaning that a 10 point * font will be 13 units high. (10 * 96. / 72. = 13.3). * - * This function is not part of the GDK public API and is only - * for use by GTK+. + * Since: 2.10 **/ void -gdk_screen_set_resolution_libgtk_only (GdkScreen *screen, - gdouble dpi) +gdk_screen_set_resolution (GdkScreen *screen, + gdouble dpi) { g_return_if_fail (GDK_IS_SCREEN (screen)); - if (dpi >= 0) + if (dpi < 0) + dpi = -1.0; + + if (screen->resolution != dpi) + { screen->resolution = dpi; - else - screen->resolution = -1.; + + g_object_notify (G_OBJECT (screen), "resolution"); + } } /** - * gdk_screen_get_resolution_libgtk_only: + * gdk_screen_get_resolution: * @screen: a #GdkScreen * * Gets the resolution for font handling on the screen; see - * gdk_screen_set_resolution_libgtk_only() for full details. + * gdk_screen_set_resolution() for full details. * * Return value: the current resolution, or -1 if no resolution * has been set. + * + * Since: 2.10 **/ gdouble -gdk_screen_get_resolution_libgtk_only (GdkScreen *screen) +gdk_screen_get_resolution (GdkScreen *screen) { g_return_val_if_fail (GDK_IS_SCREEN (screen), -1.); return screen->resolution; } +static void +gdk_screen_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GdkScreen *screen = GDK_SCREEN (object); + + switch (prop_id) + { + case PROP_FONT_OPTIONS: + g_value_set_pointer (value, gdk_screen_get_font_options (screen)); + break; + case PROP_RESOLUTION: + g_value_set_double (value, gdk_screen_get_resolution (screen)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gdk_screen_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GdkScreen *screen = GDK_SCREEN (object); + + switch (prop_id) + { + case PROP_FONT_OPTIONS: + gdk_screen_set_font_options (screen, g_value_get_pointer (value)); + break; + case PROP_RESOLUTION: + gdk_screen_set_resolution (screen, g_value_get_double (value)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + #define __GDK_SCREEN_C__ #include "gdkaliasdef.c" diff --git a/gdk/gdkscreen.h b/gdk/gdkscreen.h index 2d93a41944..620fca71ce 100644 --- a/gdk/gdkscreen.h +++ b/gdk/gdkscreen.h @@ -102,13 +102,13 @@ gboolean gdk_screen_get_setting (GdkScreen *screen, const gchar *name, GValue *value); -void gdk_screen_set_font_options_libgtk_only (GdkScreen *screen, - const cairo_font_options_t *options); -const cairo_font_options_t *gdk_screen_get_font_options_libgtk_only (GdkScreen *screen); +void gdk_screen_set_font_options (GdkScreen *screen, + const cairo_font_options_t *options); +const cairo_font_options_t *gdk_screen_get_font_options (GdkScreen *screen); -void gdk_screen_set_resolution_libgtk_only (GdkScreen *screen, - gdouble dpi); -gdouble gdk_screen_get_resolution_libgtk_only (GdkScreen *screen); +void gdk_screen_set_resolution (GdkScreen *screen, + gdouble dpi); +gdouble gdk_screen_get_resolution (GdkScreen *screen); G_END_DECLS diff --git a/gtk/gtksettings.c b/gtk/gtksettings.c index acdd0518fb..65e21a3606 100644 --- a/gtk/gtksettings.c +++ b/gtk/gtksettings.c @@ -1448,7 +1448,7 @@ settings_update_font_options (GtkSettings *settings) cairo_font_options_set_antialias (options, antialias_mode); - gdk_screen_set_font_options_libgtk_only (settings->screen, options); + gdk_screen_set_font_options (settings->screen, options); cairo_font_options_destroy (options); } @@ -1468,7 +1468,7 @@ settings_update_resolution (GtkSettings *settings) else dpi = -1.; - gdk_screen_set_resolution_libgtk_only (settings->screen, dpi); + gdk_screen_set_resolution (settings->screen, dpi); } #endif diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 4125db0889..a24a101339 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5218,9 +5218,9 @@ gtk_widget_update_pango_context (GtkWidget *widget) if (screen) { pango_cairo_context_set_resolution (context, - gdk_screen_get_resolution_libgtk_only (screen)); + gdk_screen_get_resolution (screen)); pango_cairo_context_set_font_options (context, - gdk_screen_get_font_options_libgtk_only (screen)); + gdk_screen_get_font_options (screen)); } } }