port of the font capplet to gtk_font_button and some cleanup,

patch from paolo borelli <pborelli@katamail.com> (Closes: #160016).
This commit is contained in:
Sebastien Bacher 2005-05-22 15:11:44 +00:00
parent 31ba399378
commit b63d084a0f
6 changed files with 309 additions and 454 deletions

View file

@ -1,3 +1,11 @@
2005-05-22 Sebastien Bacher <seb128@debian.org>
* gconf-property-editor.c: (peditor_font_value_changed),
(peditor_font_widget_changed), (gconf_peditor_new_font):
* gconf-property-editor.h:
port of the font capplet to gtk_font_button and some cleanup,
patch from paolo borelli <pborelli@katamail.com> (Closes: #160016).
2005-05-22 Sebastien Bacher <seb128@debian.org>
* theme-thumbnail.c: (create_image): fix the theme preview crasher with

View file

@ -1256,131 +1256,44 @@ gconf_value_float_to_int (GConfPropertyEditor *ignored, const GConfValue *value)
return new_value;
}
static gint
peditor_font_get_size (const gchar *font_str)
{
PangoFontDescription *desc;
int size;
g_return_val_if_fail (font_str != NULL, -1);
desc = pango_font_description_from_string (font_str);
size = pango_font_description_get_size (desc);
pango_font_description_free (desc);
return size / PANGO_SCALE;
}
static gchar*
peditor_font_get_name (const gchar *font_str)
{
PangoFontDescription *desc;
gchar *name;
g_return_val_if_fail (font_str != NULL, NULL);
desc = pango_font_description_from_string (font_str);
pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
name = pango_font_description_to_string (desc);
pango_font_description_free (desc);
return name;
}
static void
peditor_font_merge_setting (GnomeFontPicker *font_picker, GConfValue *value, GConfPEditorFontType font_type)
{
PangoFontDescription *desc;
gchar *font_str;
g_return_if_fail (GNOME_IS_FONT_PICKER (font_picker));
g_return_if_fail (value != NULL);
desc = pango_font_description_from_string (gnome_font_picker_get_font_name (font_picker));
if (font_type == PEDITOR_FONT_SIZE)
{
pango_font_description_set_size (desc, gconf_value_get_int (value) * PANGO_SCALE);
}
else
{
PangoFontDescription *new_desc;
new_desc = pango_font_description_from_string (gconf_value_get_string (value));
if (font_type == PEDITOR_FONT_NAME)
pango_font_description_set_size (new_desc, pango_font_description_get_size (desc));
pango_font_description_free (desc);
desc = new_desc;
}
font_str = pango_font_description_to_string (desc);
g_object_set (G_OBJECT (font_picker),
"font_name", font_str,
"label-font-size", pango_font_description_get_size (desc) / PANGO_SCALE,
NULL);
g_free (font_str);
pango_font_description_free (desc);
}
static void
peditor_font_value_changed (GConfClient *client,
guint cnxn_id,
GConfEntry *entry,
GConfPropertyEditor *peditor)
guint cnxn_id,
GConfEntry *entry,
GConfPropertyEditor *peditor)
{
GConfValue *value, *value_wid;
GConfPEditorFontType font_type;
if (peditor->p->changeset != NULL)
gconf_change_set_remove (peditor->p->changeset, peditor->p->key);
font_type = GPOINTER_TO_UINT (peditor->p->data);
value = gconf_entry_get_value (entry);
if (value != NULL) {
const gchar *font;
value_wid = peditor->p->conv_to_widget_cb (peditor, value);
peditor_font_merge_setting (GNOME_FONT_PICKER (peditor->p->ui_control), value_wid, font_type);
font = gconf_value_get_string (value_wid);
gtk_font_button_set_font_name (GTK_FONT_BUTTON (peditor->p->ui_control),
font);
gconf_value_free (value_wid);
}
}
static void
peditor_font_widget_changed (GConfPropertyEditor *peditor,
gchar *font_str,
GnomeFontPicker *font_picker)
GtkFontButton *font_button)
{
const gchar *font_name;
GConfValue *value, *value_wid = NULL;
GConfPEditorFontType font_type;
gchar *font_name;
int font_size;
if (!peditor->p->inited) return;
if (!peditor->p->inited)
return;
font_type = GPOINTER_TO_UINT (peditor->p->data);
font_name = gtk_font_button_get_font_name (font_button);
value_wid = gconf_value_new (GCONF_VALUE_STRING);
gconf_value_set_string (value_wid, font_name);
font_size = peditor_font_get_size (font_str);
g_object_set (G_OBJECT (peditor->p->ui_control),
"label-font-size", font_size,
NULL);
switch (font_type)
{
case PEDITOR_FONT_NAME:
value_wid = gconf_value_new (GCONF_VALUE_STRING);
font_name = peditor_font_get_name (font_str);
gconf_value_set_string (value_wid, font_name);
g_free (font_name);
break;
case PEDITOR_FONT_SIZE:
value_wid = gconf_value_new (GCONF_VALUE_INT);
gconf_value_set_int (value_wid, font_size);
break;
case PEDITOR_FONT_COMBINED:
value_wid = gconf_value_new (GCONF_VALUE_STRING);
gconf_value_set_string (value_wid, font_str);
break;
}
value = peditor->p->conv_from_widget_cb (peditor, value_wid);
peditor_set_gconf_value (peditor, peditor->p->key, value);
@ -1393,8 +1306,7 @@ peditor_font_widget_changed (GConfPropertyEditor *peditor,
GObject *
gconf_peditor_new_font (GConfChangeSet *changeset,
gchar *key,
GtkWidget *font_picker,
GConfPEditorFontType font_type,
GtkWidget *font_button,
gchar *first_property_name,
...)
{
@ -1402,24 +1314,21 @@ gconf_peditor_new_font (GConfChangeSet *changeset,
va_list var_args;
g_return_val_if_fail (key != NULL, NULL);
g_return_val_if_fail (font_picker != NULL, NULL);
g_return_val_if_fail (GNOME_IS_FONT_PICKER (font_picker), NULL);
g_return_val_if_fail (GTK_IS_FONT_BUTTON (font_button), NULL);
va_start (var_args, first_property_name);
peditor = gconf_peditor_new
(key,
(GConfClientNotifyFunc) peditor_font_value_changed,
changeset,
G_OBJECT (font_picker),
first_property_name,
var_args,
"data", GUINT_TO_POINTER (font_type),
NULL);
peditor = gconf_peditor_new (key,
(GConfClientNotifyFunc) peditor_font_value_changed,
changeset,
G_OBJECT (font_button),
first_property_name,
var_args,
NULL);
va_end (var_args);
g_signal_connect_swapped (G_OBJECT (font_picker), "font_set",
g_signal_connect_swapped (font_button, "font_set",
(GCallback) peditor_font_widget_changed, peditor);
return peditor;

View file

@ -41,13 +41,6 @@ typedef struct _GConfPropertyEditorPrivate GConfPropertyEditorPrivate;
typedef GConfValue *(*GConfPEditorValueConvFn) (GConfPropertyEditor *peditor, const GConfValue *);
typedef int (*GConfPEditorGetValueFn) (GConfPropertyEditor *peditor, gpointer data);
typedef enum
{
PEDITOR_FONT_NAME,
PEDITOR_FONT_SIZE,
PEDITOR_FONT_COMBINED
} GConfPEditorFontType;
struct _GConfPropertyEditor
{
GObject parent;
@ -142,8 +135,7 @@ GObject *gconf_peditor_new_numeric_range (GConfChangeSet *changeset,
GObject *gconf_peditor_new_font (GConfChangeSet *changeset,
gchar *key,
GtkWidget *font_picker,
GConfPEditorFontType font_type,
GtkWidget *font_button,
gchar *first_property_name,
...);

View file

@ -1,3 +1,11 @@
2005-05-22 Sebastien Bacher <seb128@debian.org>
* font-properties.glade:
* main.c: (application_font_to_gconf), (application_font_changed),
(setup_dialog), (cb_show_details), (main):
port of the font capplet to gtk_font_button and some cleanup,
patch from paolo borelli <pborelli@katamail.com> (Closes: #160016).
2005-01-02 Sebastien Bacher <seb128@debian.org>
* font-properties.glade:

View file

@ -12,6 +12,11 @@
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
@ -33,6 +38,7 @@
<property name="label">gtk-help</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-11</property>
</widget>
</child>
@ -45,6 +51,7 @@
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-7</property>
</widget>
</child>
@ -98,25 +105,6 @@
</packing>
</child>
<child>
<widget class="GnomeFontPicker" id="application_font">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Set the font for applications</property>
<property name="can_focus">True</property>
<property name="mode">GNOME_FONT_PICKER_MODE_FONT_INFO</property>
<property name="show_size">True</property>
<property name="use_font_in_label">True</property>
<property name="label_font_size">14</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
@ -142,26 +130,6 @@
</packing>
</child>
<child>
<widget class="GnomeFontPicker" id="desktop_font">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Set the font for the icons on the desktop</property>
<property name="can_focus">True</property>
<property name="mode">GNOME_FONT_PICKER_MODE_FONT_INFO</property>
<property name="show_size">True</property>
<property name="use_font_in_label">True</property>
<property name="label_font_size">14</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label12">
<property name="visible">True</property>
@ -187,25 +155,6 @@
</packing>
</child>
<child>
<widget class="GnomeFontPicker" id="window_title_font">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="mode">GNOME_FONT_PICKER_MODE_FONT_INFO</property>
<property name="show_size">True</property>
<property name="use_font_in_label">True</property>
<property name="label_font_size">14</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label13">
<property name="visible">True</property>
@ -232,21 +181,77 @@
</child>
<child>
<widget class="GnomeFontPicker" id="monospace_font">
<widget class="GtkFontButton" id="application_font">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Set the monospace font for terminals and similar applications</property>
<property name="can_focus">True</property>
<property name="mode">GNOME_FONT_PICKER_MODE_FONT_INFO</property>
<property name="show_style">True</property>
<property name="show_size">True</property>
<property name="use_font_in_label">True</property>
<property name="label_font_size">14</property>
<property name="use_font">True</property>
<property name="use_size">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkFontButton" id="desktop_font">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_style">True</property>
<property name="show_size">True</property>
<property name="use_font">True</property>
<property name="use_size">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkFontButton" id="window_title_font">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_style">True</property>
<property name="show_size">True</property>
<property name="use_font">True</property>
<property name="use_size">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkFontButton" id="monospace_font">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_style">True</property>
<property name="show_size">True</property>
<property name="use_font">True</property>
<property name="use_size">False</property>
<property name="focus_on_click">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">3</property>
<property name="bottom_attach">4</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
@ -334,6 +339,7 @@
<property name="label" translatable="yes">_Monochrome</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -352,6 +358,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="monochrome_sample">
@ -381,6 +391,10 @@
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkButton" id="details_button">
@ -389,6 +403,7 @@
<property name="label" translatable="yes">D_etails...</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
</widget>
</child>
</widget>
@ -415,6 +430,7 @@
<property name="label" translatable="yes">Best _shapes</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -434,6 +450,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="best_shapes_sample">
@ -469,6 +489,7 @@
<property name="label" translatable="yes">Best co_ntrast</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -488,6 +509,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="best_contrast_sample">
@ -523,6 +548,7 @@
<property name="label" translatable="yes">Sub_pixel smoothing (LCDs)</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -542,6 +568,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="subpixel_sample">
@ -603,6 +633,11 @@
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="decorated">True</property>
<property name="skip_taskbar_hint">False</property>
<property name="skip_pager_hint">False</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
@ -624,6 +659,7 @@
<property name="label">gtk-help</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-11</property>
</widget>
</child>
@ -636,6 +672,7 @@
<property name="label" translatable="yes">Go _to font folder</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">1</property>
</widget>
</child>
@ -648,6 +685,7 @@
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="response_id">-7</property>
</widget>
</child>
@ -674,6 +712,10 @@
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkHBox" id="hbox1">
@ -801,6 +843,7 @@
<property name="label" translatable="yes">_None</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -820,6 +863,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="antialias_none_sample">
@ -856,6 +903,7 @@
<property name="label" translatable="yes">Gra_yscale</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -876,6 +924,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="antialias_grayscale_sample">
@ -912,6 +964,7 @@
<property name="label" translatable="yes">Sub_pixel (LCDs)</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -932,6 +985,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="antialias_subpixel_sample">
@ -1018,6 +1075,7 @@
<property name="label" translatable="yes">N_one</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -1037,6 +1095,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="hint_none_sample">
@ -1072,6 +1134,7 @@
<property name="label" translatable="yes">_Slight</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -1092,6 +1155,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="hint_slight_sample">
@ -1128,6 +1195,7 @@
<property name="label" translatable="yes">_Medium</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -1148,6 +1216,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="hint_medium_sample">
@ -1184,6 +1256,7 @@
<property name="label" translatable="yes">_Full</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -1204,6 +1277,10 @@
<property name="yalign">0.5</property>
<property name="xscale">1</property>
<property name="yscale">1</property>
<property name="top_padding">0</property>
<property name="bottom_padding">0</property>
<property name="left_padding">0</property>
<property name="right_padding">0</property>
<child>
<widget class="GtkDrawingArea" id="hint_full_sample">
@ -1291,6 +1368,7 @@
<property name="label" translatable="yes">_RGB</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -1338,6 +1416,7 @@
<property name="label" translatable="yes">_BGR</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -1387,6 +1466,7 @@
<property name="label" translatable="yes">_VRGB</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -1436,6 +1516,7 @@
<property name="label" translatable="yes">VB_GR</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
@ -1497,166 +1578,4 @@
</child>
</widget>
<widget class="GtkDialog" id="font_size_warning_dialog">
<property name="title" translatable="yes"></property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_NONE</property>
<property name="modal">False</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">False</property>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox4">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area4">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="button4">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="has_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="button5">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">1</property>
<child>
<widget class="GtkAlignment" id="alignment14">
<property name="visible">True</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xscale">0</property>
<property name="yscale">0</property>
<child>
<widget class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">2</property>
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-ok</property>
<property name="icon_size">4</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="label" translatable="yes">_Use Font</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox8">
<property name="border_width">12</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">12</property>
<child>
<widget class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="stock">gtk-dialog-warning</property>
<property name="icon_size">6</property>
<property name="xalign">0.5</property>
<property name="yalign">0</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="font_size_warning_label">
<property name="visible">True</property>
<property name="label" translatable="yes"></property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

View file

@ -46,16 +46,6 @@ static gchar *old_font = NULL;
#define MAX_FONT_POINT_WITHOUT_WARNING 32
#define MAX_FONT_SIZE_WITHOUT_WARNING MAX_FONT_POINT_WITHOUT_WARNING*1024
#define PICKER_DIALOG_DATA_STRING "picker-dialog-data-string"
static GladeXML *
create_dialog (void)
{
GladeXML *dialog;
dialog = glade_xml_new (GLADEDIR "/font-properties.glade", "font_dialog", NULL);
return dialog;
}
static void
cb_dialog_response (GtkDialog *dialog, gint response_id)
@ -447,8 +437,6 @@ metacity_changed (GConfClient *client,
metacity_titlebar_load_sensitivity (client, user_data);
}
/* returns 0 if the font is safe, otherwise returns the size in points. */
static gint
new_font_dangerous (const char *new_font)
@ -477,14 +465,11 @@ application_font_to_gconf (GConfPropertyEditor *peditor,
{
GConfValue *new_value;
const char *new_font;
GtkWidget *font_picker;
GladeXML *dialog;
GtkWidget *font_button;
gint danger_level;
font_picker = (GtkWidget *) gconf_property_editor_get_ui_control (peditor);
g_assert (font_picker);
dialog = glade_xml_new (GLADEDIR "/font-properties.glade", "font_size_warning_dialog", NULL);
font_button = GTK_WIDGET (gconf_property_editor_get_ui_control (peditor));
g_return_val_if_fail (font_button != NULL, NULL);
new_value = gconf_value_new (GCONF_VALUE_STRING);
new_font = gconf_value_get_string (value);
@ -496,34 +481,58 @@ application_font_to_gconf (GConfPropertyEditor *peditor,
danger_level = new_font_dangerous (new_font);
if (danger_level) {
GtkWidget *font_size_warning_dialog;
GtkWidget *warning_dialog;
gchar *warning_label;
gchar *warning_label2;
font_size_warning_dialog = WID ("font_size_warning_dialog");
warning_label = g_strdup (_("Font may be too large"));
if (danger_level > MAX_FONT_POINT_WITHOUT_WARNING) {
warning_label = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
_("Font may be too large"),
ngettext ("The font selected is %d point large, and may make it difficult to effectively use the computer. It is recommended that you select a size smaller than %d.",
"The font selected is %d points large, and may make it difficult to effectively use the computer. It is recommended that you select a size smaller than %d.",
danger_level));
warning_label2 = g_strdup_printf (warning_label, danger_level, MAX_FONT_POINT_WITHOUT_WARNING);
warning_label2 = g_strdup_printf (ngettext (
"The font selected is %d point large, "
"and may make it difficult to effectively "
"use the computer. It is recommended that "
"you select a size smaller than %d.",
"The font selected is %d points large, "
"and may make it difficult to effectively "
"use the computer. It is recommended that "
"you select a size smaller than %d.",
danger_level),
danger_level,
MAX_FONT_POINT_WITHOUT_WARNING);
} else {
warning_label = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n\n%s",
_("Font may be too large"),
ngettext ("The font selected is %d point large, and may make it difficult to effectively use the computer. It is recommended that you select a smaller sized font.",
"The font selected is %d points large, and may make it difficult to effectively use the computer. It is recommended that you select a smaller sized font.",
danger_level));
warning_label2 = g_strdup_printf (warning_label, danger_level);
warning_label2 = g_strdup_printf (ngettext (
"The font selected is %d point large, "
"and may make it difficult to effectively "
"use the computer. It is recommended that "
"you select a smaller sized font.",
"The font selected is %d points large, "
"and may make it difficult to effectively "
"use the computer. It is recommended that "
"you select a smaller sized font.",
danger_level),
danger_level);
}
gtk_label_set_markup (GTK_LABEL (WID ("font_size_warning_label")), warning_label2);
if (gtk_dialog_run (GTK_DIALOG (font_size_warning_dialog)) == 1) {
warning_dialog = gtk_message_dialog_new (NULL,
GTK_DIALOG_MODAL,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK_CANCEL,
warning_label);
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (warning_dialog),
warning_label2);
g_free (warning_label);
g_free (warning_label2);
if (gtk_dialog_run (GTK_DIALOG (warning_dialog)) == GTK_RESPONSE_OK) {
gconf_value_set_string (new_value, new_font);
} else {
gconf_value_set_string (new_value, old_font);
gnome_font_picker_set_font_name (GNOME_FONT_PICKER (font_picker), old_font);
gtk_font_button_set_font_name (GTK_FONT_BUTTON (font_button), old_font);
}
gtk_widget_destroy (font_size_warning_dialog);
gtk_widget_destroy (warning_dialog);
} else {
gconf_value_set_string (new_value, new_font);
}
@ -532,86 +541,92 @@ application_font_to_gconf (GConfPropertyEditor *peditor,
}
static void
application_font_changed (GtkWidget *font_picker)
application_font_changed (GtkWidget *font_button)
{
const gchar *font;
font = gnome_font_picker_get_font_name (GNOME_FONT_PICKER (font_picker));
font = gtk_font_button_get_font_name (GTK_FONT_BUTTON (font_button));
g_free (old_font);
old_font = g_strdup (font);
}
static void
setup_dialog (GladeXML *dialog)
setup_dialog (void)
{
GConfClient *client;
GtkWidget *widget;
GObject *peditor;
GladeXML *dialog;
GConfClient *client;
GtkWidget *widget;
GObject *peditor;
client = gconf_client_get_default ();
dialog = glade_xml_new (GLADEDIR "/font-properties.glade", "font_dialog", NULL);
if (!dialog) {
g_warning ("could not load font-properties.glade");
return;
}
gconf_client_add_dir (client, "/desktop/gnome/interface", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_add_dir (client, "/apps/nautilus/preferences", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_add_dir (client, METACITY_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
client = gconf_client_get_default ();
gconf_client_add_dir (client, "/desktop/gnome/interface", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_add_dir (client, "/apps/nautilus/preferences", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_add_dir (client, METACITY_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
#ifdef HAVE_XFT2
gconf_client_add_dir (client, FONT_RENDER_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
gconf_client_add_dir (client, FONT_RENDER_DIR, GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
#endif /* HAVE_XFT2 */
g_object_set_data (G_OBJECT (WID ("application_font")), PICKER_DIALOG_DATA_STRING, dialog);
peditor = gconf_peditor_new_font (NULL, GTK_FONT_KEY,
WID ("application_font"),
PEDITOR_FONT_COMBINED,
"conv-from-widget-cb", application_font_to_gconf,
NULL);
g_signal_connect_swapped (G_OBJECT (peditor), "value-changed", (GCallback) application_font_changed, WID ("application_font"));
application_font_changed (WID ("application_font"));
peditor = gconf_peditor_new_font (NULL, DESKTOP_FONT_KEY,
WID ("desktop_font"),
PEDITOR_FONT_COMBINED, NULL);
peditor = gconf_peditor_new_font (NULL, GTK_FONT_KEY,
WID ("application_font"),
"conv-from-widget-cb", application_font_to_gconf,
NULL);
g_signal_connect_swapped (peditor, "value-changed",
G_CALLBACK (application_font_changed), WID ("application_font"));
application_font_changed (WID ("application_font"));
peditor = gconf_peditor_new_font (NULL, WINDOW_TITLE_FONT_KEY,
WID ("window_title_font"),
PEDITOR_FONT_COMBINED, NULL);
peditor = gconf_peditor_new_font (NULL, DESKTOP_FONT_KEY,
WID ("desktop_font"),
NULL);
peditor = gconf_peditor_new_font (NULL, MONOSPACE_FONT_KEY,
WID ("monospace_font"),
PEDITOR_FONT_COMBINED, NULL);
peditor = gconf_peditor_new_font (NULL, WINDOW_TITLE_FONT_KEY,
WID ("window_title_font"),
NULL);
gconf_client_notify_add (client, METACITY_DIR,
metacity_changed,
dialog, NULL, NULL);
peditor = gconf_peditor_new_font (NULL, MONOSPACE_FONT_KEY,
WID ("monospace_font"),
NULL);
metacity_titlebar_load_sensitivity (client, dialog);
gconf_client_notify_add (client, METACITY_DIR,
metacity_changed,
dialog, NULL, NULL);
widget = WID ("font_dialog");
capplet_set_icon (widget, "gnome-settings-font");
metacity_titlebar_load_sensitivity (client, dialog);
widget = WID ("font_dialog");
capplet_set_icon (widget, "gnome-settings-font");
#ifdef HAVE_XFT2
setup_font_pair (WID ("monochrome_radio"), WID ("monochrome_sample"), ANTIALIAS_NONE, HINT_FULL);
setup_font_pair (WID ("best_shapes_radio"), WID ("best_shapes_sample"), ANTIALIAS_GRAYSCALE, HINT_MEDIUM);
setup_font_pair (WID ("best_contrast_radio"), WID ("best_contrast_sample"), ANTIALIAS_GRAYSCALE, HINT_FULL);
setup_font_pair (WID ("subpixel_radio"), WID ("subpixel_sample"), ANTIALIAS_RGBA, HINT_FULL);
setup_font_pair (WID ("monochrome_radio"), WID ("monochrome_sample"), ANTIALIAS_NONE, HINT_FULL);
setup_font_pair (WID ("best_shapes_radio"), WID ("best_shapes_sample"), ANTIALIAS_GRAYSCALE, HINT_MEDIUM);
setup_font_pair (WID ("best_contrast_radio"), WID ("best_contrast_sample"), ANTIALIAS_GRAYSCALE, HINT_FULL);
setup_font_pair (WID ("subpixel_radio"), WID ("subpixel_sample"), ANTIALIAS_RGBA, HINT_FULL);
font_render_load ();
font_render_load ();
gconf_client_notify_add (client, FONT_RENDER_DIR,
font_render_changed,
NULL, NULL, NULL);
gconf_client_notify_add (client, FONT_RENDER_DIR,
font_render_changed,
NULL, NULL, NULL);
g_signal_connect (WID ("details_button"),
"clicked",
G_CALLBACK (cb_show_details), widget);
g_signal_connect (WID ("details_button"), "clicked",
G_CALLBACK (cb_show_details), widget);
#else /* !HAVE_XFT2 */
gtk_widget_hide (WID ("font_render_frame"));
gtk_widget_hide (WID ("font_render_frame"));
#endif /* HAVE_XFT2 */
g_signal_connect (G_OBJECT (widget),
"response",
G_CALLBACK (cb_dialog_response), NULL);
g_signal_connect (widget, "response",
G_CALLBACK (cb_dialog_response), NULL);
gtk_widget_show (widget);
gtk_widget_show (widget);
g_object_unref (client);
g_object_unref (dialog);
g_object_unref (client);
}
#ifdef HAVE_XFT2
@ -808,12 +823,18 @@ cb_show_details (GtkWidget *button,
if (!details_dialog) {
GConfClient *client = gconf_client_get_default ();
GladeXML *dialog = glade_xml_new (GLADEDIR "/font-properties.glade", "render_details", NULL);
GladeXML *dialog;
GtkWidget *dpi_spinner;
GnomeVFSURI *uri;
int dpi;
GtkAdjustment *adjustment;
dialog = glade_xml_new (GLADEDIR "/font-properties.glade", "render_details", NULL);
if (!dialog) {
g_warning ("could not load font-properties.glade");
return;
}
details_dialog = WID ("render_details");
uri = gnome_vfs_uri_new ("fonts:///");
if (uri == NULL) {
@ -888,6 +909,7 @@ cb_show_details (GtkWidget *button,
"delete_event",
G_CALLBACK (gtk_true), NULL);
g_object_unref (dialog);
g_object_unref (client);
}
@ -898,23 +920,20 @@ cb_show_details (GtkWidget *button,
int
main (int argc, char *argv[])
{
GladeXML *dialog;
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
gnome_program_init ("gnome-font-properties", VERSION,
LIBGNOMEUI_MODULE, argc, argv,
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
NULL);
gnome_program_init ("gnome-font-properties", VERSION,
LIBGNOMEUI_MODULE, argc, argv,
GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
NULL);
activate_settings_daemon ();
activate_settings_daemon ();
setup_dialog ();
dialog = create_dialog ();
setup_dialog (dialog);
gtk_main ();
gtk_main ();
return 0;
return 0;
}