]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkfontbutton.c
Change FSF Address
[~andy/gtk] / gtk / gtkfontbutton.c
index 5e65fb619a9539c22186ee5e1c00cc4502f49644..f65b905b2d45a8e1fda13b49f8ba9a40ecf87374 100644 (file)
@@ -16,8 +16,7 @@
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 /*
  * Modified by the GTK+ Team and others 2003.  See the AUTHORS
@@ -275,9 +274,9 @@ gtk_font_button_set_show_preview_entry (GtkFontButton *font_button,
   GtkFontButtonPrivate *priv = font_button->priv;
 
   if (priv->font_dialog)
-    return gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (priv->font_dialog), show);
-
-  priv->show_preview_entry = show != FALSE;
+    gtk_font_chooser_set_show_preview_entry (GTK_FONT_CHOOSER (priv->font_dialog), show);
+  else
+    priv->show_preview_entry = show != FALSE;
 }
 
 static PangoFontFamily *
@@ -794,12 +793,9 @@ gtk_font_button_set_use_font (GtkFontButton *font_button,
     {
       font_button->priv->use_font = use_font;
 
-      if (use_font)
-        gtk_font_button_label_use_font (font_button);
-      else
-       gtk_widget_set_style (font_button->priv->font_label, NULL);
+      gtk_font_button_label_use_font (font_button);
  
-     g_object_notify (G_OBJECT (font_button), "use-font");
+      g_object_notify (G_OBJECT (font_button), "use-font");
     }
 } 
 
@@ -842,8 +838,7 @@ gtk_font_button_set_use_size (GtkFontButton *font_button,
     {
       font_button->priv->use_size = use_size;
 
-      if (font_button->priv->use_font)
-        gtk_font_button_label_use_font (font_button);
+      gtk_font_button_label_use_font (font_button);
 
       g_object_notify (G_OBJECT (font_button), "use-size");
     }
@@ -1147,17 +1142,20 @@ gtk_font_button_label_use_font (GtkFontButton *font_button)
 {
   PangoFontDescription *desc;
 
-  if (!font_button->priv->use_font)
-    return;
-
-  desc = pango_font_description_copy (font_button->priv->font_desc);
+  if (font_button->priv->use_font)
+    {
+      desc = pango_font_description_copy (font_button->priv->font_desc);
 
-  if (!font_button->priv->use_size)
-    pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
+      if (!font_button->priv->use_size)
+        pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
+    }
+  else
+    desc = NULL;
 
-  gtk_widget_modify_font (font_button->priv->font_label, desc);
+  gtk_widget_override_font (font_button->priv->font_label, desc);
 
-  pango_font_description_free (desc);
+  if (desc)
+    pango_font_description_free (desc);
 }
 
 static void
@@ -1168,29 +1166,26 @@ gtk_font_button_update_font_info (GtkFontButton *font_button)
 
   g_assert (priv->font_desc != NULL);
 
-  if (priv->show_style &&
-      priv->font_family != NULL &&
-      priv->font_face != NULL &&
-      g_ascii_strcasecmp (pango_font_face_get_face_name (priv->font_face), "Regular") != 0)
+  if (priv->show_style)
     {
-      family_style = g_strdup_printf ("%s %s",
-                                      pango_font_family_get_name (priv->font_family),
-                                      pango_font_face_get_face_name (priv->font_face));
-  
+      PangoFontDescription *desc = pango_font_description_copy_static (priv->font_desc);
 
+      pango_font_description_unset_fields (desc, PANGO_FONT_MASK_SIZE);
+      family_style = pango_font_description_to_string (desc);
+      pango_font_description_free (desc);
     }
-  else if (priv->font_family != NULL)
-    family_style = g_strdup (pango_font_family_get_name (priv->font_family));
   else
-    family_style = g_strdup ("");
+    family_style = g_strdup (pango_font_description_get_family (priv->font_desc));
 
   gtk_label_set_text (GTK_LABEL (font_button->priv->font_label), family_style);
   g_free (family_style);
 
   if (font_button->priv->show_size) 
     {
-      gchar *size = g_strdup_printf ("%g",
-                                     pango_font_description_get_size (priv->font_desc) / (double)PANGO_SCALE);
+      /* mirror Pango, which doesn't translate this either */
+      gchar *size = g_strdup_printf ("%g%s",
+                                     pango_font_description_get_size (priv->font_desc) / (double)PANGO_SCALE,
+                                     pango_font_description_get_size_is_absolute (priv->font_desc) ? "px" : "");
       
       gtk_label_set_text (GTK_LABEL (font_button->priv->size_label), size);