[gnome-font-viewer] font-view: match the font face when getting an iter to update the button



commit 09a6285b7978296bf6af439b898327934d5584da
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu May 3 13:27:42 2012 -0400

    font-view: match the font face when getting an iter to update the button
    
    Instead of matching the file name, match the font face (i.e. its
    family/style names).
    Since we refresh the button appearance when installing a font over to
    ~/.fonts, the file path will not match at that point, since the preview
    will still be showing the old uninstalled file.

 src/font-view.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/src/font-view.c b/src/font-view.c
index cc695b6..b275095 100644
--- a/src/font-view.c
+++ b/src/font-view.c
@@ -284,23 +284,21 @@ static void
 install_button_refresh_appearance (FontViewApplication *self,
                                    GError *error)
 {
-    gchar *path;
+    FT_Face face;
 
     if (error != NULL) {
         gtk_button_set_label (GTK_BUTTON (self->install_button), _("Install Failed"));
         gtk_widget_set_sensitive (self->install_button, FALSE);
     } else {
-        path = g_file_get_path (self->font_file);
+        face = sushi_font_widget_get_ft_face (SUSHI_FONT_WIDGET (self->font_widget));
 
-        if (font_view_model_get_iter_for_file (FONT_VIEW_MODEL (self->model), path, NULL)) {
+        if (font_view_model_get_iter_for_face (FONT_VIEW_MODEL (self->model), face, NULL)) {
             gtk_button_set_label (GTK_BUTTON (self->install_button), _("Installed"));
             gtk_widget_set_sensitive (self->install_button, FALSE);
         } else {
             gtk_button_set_label (GTK_BUTTON (self->install_button), _("Install"));
             gtk_widget_set_sensitive (self->install_button, TRUE);
         }
-
-        g_free (path);
     }
 }
 
@@ -313,9 +311,10 @@ font_install_finished_cb (GObject      *source_object,
     GError *err = NULL;
 
     g_file_copy_finish (G_FILE (source_object), res, &err);
-    install_button_refresh_appearance (self, err);
 
     if (err != NULL) {
+        install_button_refresh_appearance (self, err);
+
         g_debug ("Install failed: %s", err->message);
         g_error_free (err);
     }
@@ -392,6 +391,7 @@ font_widget_loaded_cb (SushiFontWidget *font_widget,
 
     gd_main_toolbar_set_labels (GD_MAIN_TOOLBAR (self->toolbar),
                                 face->family_name, face->style_name);
+    install_button_refresh_appearance (self, NULL);
 }
 
 static void
@@ -443,7 +443,6 @@ font_view_application_do_open (FontViewApplication *self)
     self->install_button = gd_main_toolbar_add_button (GD_MAIN_TOOLBAR (self->toolbar),
                                                        NULL, _("Install"), 
                                                        FALSE);
-    install_button_refresh_appearance (self, NULL);
     g_signal_connect (self->install_button, "clicked",
                       G_CALLBACK (install_button_clicked_cb), self);
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]