[empathy: 14/28] Use the same font-setting utility for empathy-theme-adium
- From: Danielle Madeley <daniellem src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy: 14/28] Use the same font-setting utility for empathy-theme-adium
- Date: Thu, 18 Aug 2011 00:35:58 +0000 (UTC)
commit 356bb4555e3d1eacd8115cb8a8f0c91483055a52
Author: Danielle Madeley <danielle madeley collabora co uk>
Date: Tue Aug 9 11:50:33 2011 +1000
Use the same font-setting utility for empathy-theme-adium
libempathy-gtk/empathy-theme-adium.c | 77 +++++++---------------------------
1 files changed, 15 insertions(+), 62 deletions(-)
---
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c
index 874f559..e5227f5 100644
--- a/libempathy-gtk/empathy-theme-adium.c
+++ b/libempathy-gtk/empathy-theme-adium.c
@@ -65,7 +65,10 @@ typedef struct {
* marker for when we lose focus. */
GQueue acked_messages;
GtkWidget *inspector_window;
+
GSettings *gsettings_chat;
+ GSettings *gsettings_desktop;
+
gboolean has_focus;
gboolean has_unread_message;
gboolean allow_scrolling;
@@ -1463,7 +1466,9 @@ theme_adium_finalize (GObject *object)
EmpathyThemeAdiumPriv *priv = GET_PRIV (object);
empathy_adium_data_unref (priv->data);
+
g_object_unref (priv->gsettings_chat);
+ g_object_unref (priv->gsettings_desktop);
G_OBJECT_CLASS (empathy_theme_adium_parent_class)->finalize (object);
}
@@ -1560,64 +1565,6 @@ theme_adium_inspect_web_view_cb (WebKitWebInspector *inspector,
return NULL;
}
-static PangoFontDescription *
-theme_adium_get_default_font (void)
-{
- GSettings *gsettings;
- PangoFontDescription *pango_fd;
- gchar *font_family;
-
- gsettings = g_settings_new (EMPATHY_PREFS_DESKTOP_INTERFACE_SCHEMA);
-
- font_family = g_settings_get_string (gsettings,
- EMPATHY_PREFS_DESKTOP_INTERFACE_DOCUMENT_FONT_NAME);
-
- if (font_family == NULL)
- return NULL;
-
- pango_fd = pango_font_description_from_string (font_family);
- g_free (font_family);
- g_object_unref (gsettings);
- return pango_fd;
-}
-
-static void
-theme_adium_set_webkit_font (WebKitWebSettings *w_settings,
- const gchar *name,
- gint size)
-{
- g_object_set (w_settings, "default-font-family", name, NULL);
- g_object_set (w_settings, "default-font-size", size, NULL);
-}
-
-static void
-theme_adium_set_default_font (WebKitWebSettings *w_settings)
-{
- PangoFontDescription *default_font_desc;
- GdkScreen *current_screen;
- gdouble dpi = 0;
- gint pango_font_size = 0;
-
- default_font_desc = theme_adium_get_default_font ();
- if (default_font_desc == NULL)
- return ;
- pango_font_size = pango_font_description_get_size (default_font_desc)
- / PANGO_SCALE ;
- if (pango_font_description_get_size_is_absolute (default_font_desc)) {
- current_screen = gdk_screen_get_default ();
- if (current_screen != NULL) {
- dpi = gdk_screen_get_resolution (current_screen);
- } else {
- dpi = BORING_DPI_DEFAULT;
- }
- pango_font_size = (gint) (pango_font_size / (dpi / 72));
- }
- theme_adium_set_webkit_font (w_settings,
- pango_font_description_get_family (default_font_desc),
- pango_font_size);
- pango_font_description_free (default_font_desc);
-}
-
static void
theme_adium_constructed (GObject *object)
{
@@ -1625,18 +1572,21 @@ theme_adium_constructed (GObject *object)
const gchar *font_family = NULL;
gint font_size = 0;
WebKitWebView *webkit_view = WEBKIT_WEB_VIEW (object);
- WebKitWebSettings *webkit_settings;
WebKitWebInspector *webkit_inspector;
/* Set default settings */
font_family = tp_asv_get_string (priv->data->info, "DefaultFontFamily");
font_size = tp_asv_get_int32 (priv->data->info, "DefaultFontSize", NULL);
- webkit_settings = webkit_web_view_get_settings (webkit_view);
if (font_family && font_size) {
- theme_adium_set_webkit_font (webkit_settings, font_family, font_size);
+ g_object_set (webkit_web_view_get_settings (webkit_view),
+ "default-font-family", font_family,
+ "default-font-size", font_size,
+ NULL);
} else {
- theme_adium_set_default_font (webkit_settings);
+ empathy_webkit_bind_font_setting (webkit_view,
+ priv->gsettings_desktop,
+ EMPATHY_PREFS_DESKTOP_INTERFACE_DOCUMENT_FONT_NAME);
}
/* Setup webkit inspector */
@@ -1758,6 +1708,9 @@ empathy_theme_adium_init (EmpathyThemeAdium *theme)
NULL);
priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+ priv->gsettings_desktop = g_settings_new (
+ EMPATHY_PREFS_DESKTOP_INTERFACE_SCHEMA);
+
g_signal_connect (priv->gsettings_chat,
"changed::" EMPATHY_PREFS_CHAT_WEBKIT_DEVELOPER_TOOLS,
G_CALLBACK (theme_adium_notify_enable_webkit_developer_tools_cb),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]