Make the GdkScreen font options api public, and add properties

2005-08-26  Matthias Clasen  <mclasen@redhat.com>

	* 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.
This commit is contained in:
Matthias Clasen 2005-08-26 18:49:52 +00:00 committed by Matthias Clasen
parent a4df08a6c7
commit b3a757762c
11 changed files with 177 additions and 63 deletions

View File

@ -1,5 +1,19 @@
2005-08-26 Matthias Clasen <mclasen@redhat.com>
* 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)

View File

@ -1,5 +1,19 @@
2005-08-26 Matthias Clasen <mclasen@redhat.com>
* 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)

View File

@ -1,3 +1,8 @@
2005-08-26 Matthias Clasen <mclasen@redhat.com>
* gdk/gdk-sections.txt: Add font options
API.
2005-08-24 Matthias Clasen <mclasen@redhat.com>
* === Released 2.8.2 ===

View File

@ -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
<SUBSECTION Spawning>
gdk_spawn_on_screen
gdk_spawn_on_screen_with_pipes

View File

@ -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

View File

@ -28,25 +28,12 @@
#define __GDKINTL_H__
#include "config.h"
#include <glib/gi18n-lib.h>
#ifdef ENABLE_NLS
#include<libintl.h>
#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

View File

@ -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;

View File

@ -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_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,6 +95,25 @@ 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:
@ -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.
@ -349,15 +384,16 @@ gdk_screen_height_mm (void)
* 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,
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 != options)
{
if (screen->font_options)
cairo_font_options_destroy (screen->font_options);
@ -365,19 +401,24 @@ gdk_screen_set_font_options_libgtk_only (GdkScreen *screen,
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,
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"

View File

@ -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,
void gdk_screen_set_font_options (GdkScreen *screen,
const cairo_font_options_t *options);
const cairo_font_options_t *gdk_screen_get_font_options_libgtk_only (GdkScreen *screen);
const cairo_font_options_t *gdk_screen_get_font_options (GdkScreen *screen);
void gdk_screen_set_resolution_libgtk_only (GdkScreen *screen,
void gdk_screen_set_resolution (GdkScreen *screen,
gdouble dpi);
gdouble gdk_screen_get_resolution_libgtk_only (GdkScreen *screen);
gdouble gdk_screen_get_resolution (GdkScreen *screen);
G_END_DECLS

View File

@ -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

View File

@ -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));
}
}
}