]> git.sur5r.net Git - glabels/commitdiff
2009-09-08 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Wed, 9 Sep 2009 02:16:13 +0000 (02:16 +0000)
committerJim Evins <evins@snaught.com>
Wed, 9 Sep 2009 02:16:13 +0000 (02:16 +0000)
* src/font-util.c: (gl_font_util_validate_family):
* src/font-util.h:
Added gl_font_util_validate_family().
* src/font-combo.c: (gl_font_combo_class_init),
(gl_font_combo_new), (gl_font_combo_set_family):
Use gl_font_util_validate_family() when setting family.
* src/label-text.c: (set_font_family):
* src/prefs-dialog.c: (construct_object_page),
(update_object_page_from_prefs):
* src/ui-property-bar.c: (gl_ui_property_bar_construct),
(reset_to_default_properties):
* src/object-editor-text-page.c:
(gl_object_editor_prepare_text_page),
(gl_object_editor_set_font_family):
Removed code obsoleted by the addition of gl_font_util_validate_family().
* src/color-swatch.c: (gl_color_swatch_class_init), (style_set_cb),
(draw_swatch):
* src/font-sample.c: (gl_font_sample_class_init), (style_set_cb),
(draw_sample):
Added handler for style_set event.
* src/color-combo-button.c: (gl_color_combo_button_class_init):
* src/color-combo-color-menu-item.c:
(gl_color_combo_color_menu_item_class_init):
* src/color-combo-history.c: (gl_color_combo_history_class_init):
* src/color-combo-menu.c: (map_event_cb):
* src/color-combo.c: (gl_color_combo_class_init),
(gl_color_combo_new):
* src/font-combo-menu-item.c: (gl_font_combo_menu_item_class_init):
* src/font-combo-menu.c: (gl_font_combo_menu_class_init):
* src/wdgt-rotate-label.c: (create_pixbuf):
Various cleanups -- mostly removing unused variables.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@877 f5e0f49d-192f-0410-a22d-a8d8700d0965

18 files changed:
glabels2/ChangeLog
glabels2/src/color-combo-button.c
glabels2/src/color-combo-color-menu-item.c
glabels2/src/color-combo-history.c
glabels2/src/color-combo-menu.c
glabels2/src/color-combo.c
glabels2/src/color-swatch.c
glabels2/src/font-combo-menu-item.c
glabels2/src/font-combo-menu.c
glabels2/src/font-combo.c
glabels2/src/font-sample.c
glabels2/src/font-util.c
glabels2/src/font-util.h
glabels2/src/label-text.c
glabels2/src/object-editor-text-page.c
glabels2/src/prefs-dialog.c
glabels2/src/ui-property-bar.c
glabels2/src/wdgt-rotate-label.c

index dcaaac4d79130ed9eaec1778af5122cbf6304319..60c7bf89c86b6233438c470ff46b40971fe030ef 100644 (file)
@@ -1,3 +1,37 @@
+2009-09-08  Jim Evins  <evins@snaught.com>
+
+       * src/font-util.c: (gl_font_util_validate_family):
+       * src/font-util.h:
+               Added gl_font_util_validate_family().
+       * src/font-combo.c: (gl_font_combo_class_init),
+       (gl_font_combo_new), (gl_font_combo_set_family):
+               Use gl_font_util_validate_family() when setting family.
+       * src/label-text.c: (set_font_family):
+       * src/prefs-dialog.c: (construct_object_page),
+       (update_object_page_from_prefs):
+       * src/ui-property-bar.c: (gl_ui_property_bar_construct),
+       (reset_to_default_properties):
+       * src/object-editor-text-page.c:
+       (gl_object_editor_prepare_text_page),
+       (gl_object_editor_set_font_family):
+               Removed code obsoleted by the addition of gl_font_util_validate_family().
+       * src/color-swatch.c: (gl_color_swatch_class_init), (style_set_cb),
+       (draw_swatch):
+       * src/font-sample.c: (gl_font_sample_class_init), (style_set_cb),
+       (draw_sample):
+               Added handler for style_set event.
+       * src/color-combo-button.c: (gl_color_combo_button_class_init):
+       * src/color-combo-color-menu-item.c:
+       (gl_color_combo_color_menu_item_class_init):
+       * src/color-combo-history.c: (gl_color_combo_history_class_init):
+       * src/color-combo-menu.c: (map_event_cb):
+       * src/color-combo.c: (gl_color_combo_class_init),
+       (gl_color_combo_new):
+       * src/font-combo-menu-item.c: (gl_font_combo_menu_item_class_init):
+       * src/font-combo-menu.c: (gl_font_combo_menu_class_init):
+       * src/wdgt-rotate-label.c: (create_pixbuf):
+               Various cleanups -- mostly removing unused variables.
+
 2009-09-07  Jim Evins  <evins@snaught.com>
 
        Created new glFontCombo widget family subsystem + minor refinements to glColorCombo
index c444ee881f9e1ecc5d81a160a6814950d146f730..f32bbf2dbba97a1a7b1a5f8e7784602f12fe3ae8 100644 (file)
@@ -110,8 +110,6 @@ static void
 gl_color_combo_button_class_init (glColorComboButtonClass *class)
 {
         GObjectClass            *gobject_class = (GObjectClass *) class;
-        GtkWidgetClass          *widget_class  = (GtkWidgetClass *) class;
-        glColorComboButtonClass *object_class  = (glColorComboButtonClass *) class;
 
         gl_color_combo_button_parent_class = g_type_class_peek_parent (class);
 
index 9fc6c79d13fb39bc07eb175405e35df25350d5a7..2ffc1cbcebba4f3dd4624a09bdb031f79ecf3801 100644 (file)
@@ -62,11 +62,6 @@ struct _glColorComboColorMenuItemPrivate {
 
 static void gl_color_combo_color_menu_item_finalize    (GObject                *object);
 
-static GdkPixbuf *
-create_color_pixbuf (gdouble         w,
-                     gdouble         h,
-                     guint           color);
-
 
 /****************************************************************************/
 /* Boilerplate Object stuff.                                                */
@@ -81,7 +76,6 @@ static void
 gl_color_combo_color_menu_item_class_init (glColorComboColorMenuItemClass *class)
 {
        GObjectClass   *gobject_class = G_OBJECT_CLASS (class);
-       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
 
         gl_color_combo_color_menu_item_parent_class = g_type_class_peek_parent (class);
 
index fa62c0d8dc41d91088031b739ce5bc271569dc16..decc99e4a7ebd9568bc78ffeff17d99dc2522f26 100644 (file)
@@ -65,7 +65,6 @@ static void
 gl_color_combo_history_class_init (glColorComboHistoryClass *class)
 {
         GObjectClass              *gobject_class = (GObjectClass *) class;
-        glColorComboHistoryClass  *object_class  = (glColorComboHistoryClass *) class;
 
         gl_color_combo_history_parent_class = g_type_class_peek_parent (class);
 
index c34252732131b33fb2f460abe3e161ff2c29d6c3..c96573e0d539a8665ec00fb5f019551b1ddb2e49 100644 (file)
@@ -337,6 +337,8 @@ map_event_cb (GtkWidget    *widget,
         glColorComboMenu *this = GL_COLOR_COMBO_MENU (widget);
 
         load_custom_color_history (this);
+
+        return FALSE;
 }
 
 
index 172f2e206b31c568d4d002f816788b261fe0ff53..02008b2e9980fb58bb06096458edd1b2ef5e4806 100644 (file)
@@ -100,8 +100,6 @@ static void
 gl_color_combo_class_init (glColorComboClass *class)
 {
         GObjectClass       *gobject_class = (GObjectClass *) class;
-        GtkWidgetClass     *widget_class  = (GtkWidgetClass *) class;
-        glColorComboClass  *object_class  = (glColorComboClass *) class;
 
         gl_color_combo_parent_class = g_type_class_peek_parent (class);
 
@@ -172,8 +170,6 @@ gl_color_combo_new (const gchar  *default_label,
                     guint         color)
 {
         glColorCombo *this;
-        GdkPixbuf    *pixbuf;
-        GtkWidget    *wimage;
 
         this = g_object_new (TYPE_GL_COLOR_COMBO, NULL);
 
index ae72e3dcb990dbf51374da0a733c9094be9dad9a..8a413462ac2340f53b44aa118670b19164c28f29 100644 (file)
@@ -53,6 +53,9 @@ struct _glColorSwatchPrivate {
 
 static void       gl_color_swatch_finalize    (GObject        *object);
 
+static void       style_set_cb                (GtkWidget      *widget,
+                                               GtkStyle       *previous_style);
+
 static void       redraw                      (glColorSwatch  *this);
 
 static gboolean   expose_event_cb             (GtkWidget      *widget,
@@ -83,6 +86,7 @@ gl_color_swatch_class_init (glColorSwatchClass *class)
        gobject_class->finalize    = gl_color_swatch_finalize;
 
         widget_class->expose_event = expose_event_cb;
+        widget_class->style_set    = style_set_cb;
 }
 
 
@@ -148,6 +152,17 @@ gl_color_swatch_set_color (glColorSwatch *this,
 }
 
 
+/*--------------------------------------------------------------------------*/
+/* Style set handler (updates colors when style/theme changes).             */
+/*--------------------------------------------------------------------------*/
+static void
+style_set_cb (GtkWidget        *widget,
+              GtkStyle         *previous_style)
+{
+        redraw (GL_COLOR_SWATCH (widget));
+}
+
+
 /*****************************************************************************/
 /* Request redraw.                                                           */
 /*****************************************************************************/
@@ -199,7 +214,6 @@ static void
 draw_swatch (glColorSwatch *this,
              cairo_t       *cr)
 {
-        GdkPixbuf *pixbuf;
         GtkStyle  *style;
         gdouble    w, h;
         guint      fill_color, line_color;
index bbaafb28aed77d1d0ebf74982d3755161a934192..5c16ffae93da2185d4344cb40785adf4e8e346f8 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "font-combo-menu-item.h"
 
+#include "font-sample.h"
 #include "marshal.h"
 #include <glib/gi18n.h>
 #include <gtk/gtkmenuitem.h>
@@ -75,7 +76,6 @@ static void
 gl_font_combo_menu_item_class_init (glFontComboMenuItemClass *class)
 {
        GObjectClass   *gobject_class = G_OBJECT_CLASS (class);
-       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
 
         gl_font_combo_menu_item_parent_class = g_type_class_peek_parent (class);
 
index cf263702b1e7780b4aa876d2718bbe6bf4363129..87c1ece752403dfe8f178d5667eac3e4e10b73b6 100644 (file)
@@ -83,7 +83,6 @@ static void
 gl_font_combo_menu_class_init (glFontComboMenuClass *class)
 {
        GObjectClass   *gobject_class = G_OBJECT_CLASS (class);
-       GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
 
         gl_font_combo_menu_parent_class = g_type_class_peek_parent (class);
 
index 44dfc396280857a54d7013540d76dec431068f6e..f77d5ad20ec4ed5ee592d8da34a9ec06c7f551ec 100644 (file)
@@ -23,6 +23,7 @@
 #include "font-combo.h"
 
 #include "font-combo-menu.h"
+#include "font-util.h"
 #include <glib/gi18n.h>
 #include <gtk/gtkhbox.h>
 #include <gtk/gtklabel.h>
@@ -91,8 +92,6 @@ static void
 gl_font_combo_class_init (glFontComboClass *class)
 {
         GObjectClass      *gobject_class = (GObjectClass *) class;
-        GtkWidgetClass    *widget_class  = (GtkWidgetClass *) class;
-        glFontComboClass  *object_class  = (glFontComboClass *) class;
 
         gl_font_combo_parent_class = g_type_class_peek_parent (class);
 
@@ -165,9 +164,9 @@ gl_font_combo_new (const gchar  *font_family)
 
         this = g_object_new (TYPE_GL_FONT_COMBO, NULL);
 
-        this->priv->font_family = g_strdup (font_family);
+        this->priv->font_family = gl_font_util_validate_family (font_family);
 
-        gtk_label_set_text (GTK_LABEL (this->priv->label), font_family);
+        gtk_label_set_text (GTK_LABEL (this->priv->label), this->priv->font_family);
 
         this->priv->menu = gl_font_combo_menu_new ();
 
@@ -201,9 +200,9 @@ gl_font_combo_set_family (glFontCombo  *this,
                           const gchar  *font_family)
 {
 
-        this->priv->font_family = g_strdup (font_family);
+        this->priv->font_family = gl_font_util_validate_family (font_family);
 
-        gtk_label_set_text (GTK_LABEL (this->priv->label), font_family);
+        gtk_label_set_text (GTK_LABEL (this->priv->label), this->priv->font_family);
 }
 
 
index 299b9ba85caa86ee1d7f00747dbdad04436d0444..da2c13aa3b70662e93ec109fe9d1654e3c35015f 100644 (file)
@@ -56,6 +56,9 @@ struct _glFontSamplePrivate {
 
 static void       gl_font_sample_finalize     (GObject        *object);
 
+static void       style_set_cb                (GtkWidget      *widget,
+                                               GtkStyle       *previous_style);
+
 static void       redraw                      (glFontSample   *this);
 
 static gboolean   expose_event_cb             (GtkWidget      *widget,
@@ -86,6 +89,7 @@ gl_font_sample_class_init (glFontSampleClass *class)
        gobject_class->finalize    = gl_font_sample_finalize;
 
         widget_class->expose_event = expose_event_cb;
+        widget_class->style_set    = style_set_cb;
 }
 
 
@@ -142,6 +146,17 @@ gl_font_sample_new (gint         w,
 }
 
 
+/*--------------------------------------------------------------------------*/
+/* Style set handler (updates colors when style/theme changes).             */
+/*--------------------------------------------------------------------------*/
+static void
+style_set_cb (GtkWidget        *widget,
+              GtkStyle         *previous_style)
+{
+        redraw (GL_FONT_SAMPLE (widget));
+}
+
+
 /*****************************************************************************/
 /* Request redraw.                                                           */
 /*****************************************************************************/
@@ -193,7 +208,6 @@ static void
 draw_sample (glFontSample *this,
              cairo_t       *cr)
 {
-        GdkPixbuf            *pixbuf;
         GtkStyle             *style;
         gdouble               w, h;
         guint                 fill_color, line_color;
@@ -211,7 +225,7 @@ draw_sample (glFontSample *this,
         style = gtk_widget_get_style (GTK_WIDGET (this));
         if ( GTK_WIDGET_IS_SENSITIVE (GTK_WIDGET (this)) )
         {
-                fill_color = GL_COLOR_WHITE;
+                fill_color = gl_color_from_gdk_color (&style->light[GTK_STATE_NORMAL]);
                 line_color = gl_color_from_gdk_color (&style->fg[GTK_STATE_NORMAL]);
         }
         else
index 15555f5ad10dedcf5841cd802c07285b0603906a..1bb54b77aa0609cce49b1d69f1d92b02543d6021 100644 (file)
@@ -148,6 +148,42 @@ gl_font_util_get_fixed_width_families (void)
 }
 
 
+/****************************************************************************/
+/* Make sure we have a valid font.  If not provide a good default.          */
+/****************************************************************************/
+gchar *
+gl_font_util_validate_family (const gchar *family)
+{
+        const GList *installed_families;
+        gchar       *good_family;
+
+        installed_families = gl_font_util_get_all_families ();
+
+        if (g_list_find_custom ((GList *)installed_families,
+                                family,
+                                (GCompareFunc)g_utf8_collate))
+        {
+                good_family = g_strdup (family);
+        }
+        else if (g_list_find_custom ((GList *)installed_families,
+                                     "Sans",
+                                     (GCompareFunc)g_utf8_collate))
+        {
+                good_family = g_strdup ("Sans");
+        }
+        else if (installed_families != NULL)
+        {
+                good_family = g_strdup (installed_families->data); /* 1st entry */
+        }
+        else
+        {
+                good_family = NULL;
+        }
+
+        return good_family;
+}
+
+
 
 /*
  * Local Variables:       -- emacs
index 38541f776428459cd139f18899654c1515a516e5..7060d117d64a98094968c6606519170904a133b4 100644 (file)
@@ -29,6 +29,8 @@ const GList *gl_font_util_get_all_families          (void);
 const GList *gl_font_util_get_proportional_families (void);
 const GList *gl_font_util_get_fixed_width_families  (void);
 
+gchar       *gl_font_util_validate_family           (const gchar *family);
+
 G_END_DECLS
 
 #endif /* __FONT_UTIL_H__ */
index 118af190b19d6c3a9cf9cc6070fe407b60fe3219..1e38f7ead279a5f969abb4aa83b9594702c98b27 100644 (file)
@@ -459,7 +459,6 @@ set_font_family (glLabelObject *object,
                 const gchar   *font_family)
 {
        glLabelText    *ltext = (glLabelText *)object;
-       GList          *family_names;
        gchar          *good_font_family;
 
        gl_debug (DEBUG_LABEL, "START");
@@ -467,16 +466,7 @@ set_font_family (glLabelObject *object,
        g_return_if_fail (ltext && GL_IS_LABEL_TEXT (ltext));
        g_return_if_fail (font_family);
 
-       family_names = gl_font_util_get_all_families ();
-       if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) {
-               good_font_family = g_strdup (font_family);
-       } else {
-               if (family_names != NULL) {
-                       good_font_family = g_strdup (family_names->data); /* 1st entry */
-               } else {
-                       good_font_family = g_strdup (font_family);
-               }
-       }
+        good_font_family = gl_font_util_validate_family (font_family);
 
        if (ltext->priv->font_family) {
                if (strcmp (ltext->priv->font_family, good_font_family) == 0) {
index ee4280eff5ab367775bffa5d5cc3ea8646797f48..6160668132387c060bb8e4ab3268dafe6810f385 100644 (file)
@@ -70,8 +70,6 @@ static void text_radio_toggled_cb              (glObjectEditor        *editor);
 void
 gl_object_editor_prepare_text_page (glObjectEditor       *editor)
 {
-       GList        *family_names = NULL;
-
        gl_debug (DEBUG_EDITOR, "START");
 
        /* Extract widgets from XML tree. */
@@ -225,9 +223,7 @@ void
 gl_object_editor_set_font_family (glObjectEditor      *editor,
                                  const gchar         *font_family)
 {
-        GList    *family_names;
        gchar    *old_font_family;
-       gchar    *good_font_family;
 
        gl_debug (DEBUG_EDITOR, "START");
 
@@ -237,20 +233,8 @@ gl_object_editor_set_font_family (glObjectEditor      *editor,
 
         if ( !old_font_family || g_utf8_collate( old_font_family, font_family ) )
         {
-
-                /* Make sure we have a valid font family.  if not provide a good default. */
-                family_names = gl_font_util_get_all_families ();
-                if (g_list_find_custom (family_names, font_family, (GCompareFunc)g_utf8_collate)) {
-                        good_font_family = g_strdup (font_family);
-                } else {
-                        if (family_names != NULL) {
-                                good_font_family = g_strdup (family_names->data); /* 1st entry */
-                        } else {
-                                good_font_family = NULL;
-                        }
-                }
-                gl_font_combo_set_family (GL_FONT_COMBO (editor->priv->text_family_combo), good_font_family);
-                g_free (good_font_family);
+                gl_font_combo_set_family (GL_FONT_COMBO (editor->priv->text_family_combo),
+                                          font_family);
         }
 
         g_free (old_font_family);
index b263e522c08401a19427c8003ef44c718e79c18c..3c76bc1d89e7877999d6a77a4f18df08ec590fcc 100644 (file)
@@ -322,8 +322,6 @@ construct_locale_page (glPrefsDialog *dialog)
 static void
 construct_object_page (glPrefsDialog *dialog)
 {
-        GList    *family_names;
-
         gl_util_get_builder_widgets (dialog->priv->builder,
                                      "text_family_hbox",       &dialog->priv->text_family_hbox,
                                      "text_size_spin",         &dialog->priv->text_size_spin,
@@ -517,34 +515,11 @@ update_locale_page_from_prefs (glPrefsDialog *dialog)
 static void
 update_object_page_from_prefs (glPrefsDialog *dialog)
 {
-        const GList *family_names;
-        gchar       *good_font_family;
  
        dialog->priv->stop_signals = TRUE;
 
-
-        /* Make sure we have a valid font family.  if not provide a good default. */
-        family_names = gl_font_util_get_all_families ();
-        if (g_list_find_custom ((GList *)family_names,
-                               gl_prefs->default_font_family,
-                               (GCompareFunc)g_utf8_collate))
-        {
-                good_font_family = g_strdup (gl_prefs->default_font_family);
-        }
-        else
-        {
-                if (family_names != NULL)
-                {
-                        good_font_family = g_strdup (family_names->data); /* 1st entry */
-                }
-                else
-                {
-                        good_font_family = NULL;
-                }
-        }
        gl_font_combo_set_family (GL_FONT_COMBO (dialog->priv->text_family_combo),
-                                  good_font_family);
-        g_free (good_font_family);
+                                  gl_prefs->default_font_family);
 
         gtk_spin_button_set_value (GTK_SPIN_BUTTON (dialog->priv->text_size_spin),
                                    gl_prefs->default_font_size);
index 6ed7ed28fbf4319ee847e1cba002846c63e59b17..d2bb94c48286fb29f0cb94aea90b1daf1c46d005 100644 (file)
@@ -237,8 +237,6 @@ gl_ui_property_bar_construct (glUIPropertyBar   *this)
                                         "adjustment1", "adjustment2",
                                         NULL };
         GError        *error = NULL;
-       GList         *family_names = NULL;
-       GList         *family_node;
        GdkPixbuf     *pixbuf = NULL;
 
        gl_debug (DEBUG_PROPERTY_BAR, "START");
@@ -391,34 +389,12 @@ gl_ui_property_bar_construct (glUIPropertyBar   *this)
 /* Fill widgets with default values.                                        */
 /****************************************************************************/
 static void
-reset_to_default_properties (glView *view,
+reset_to_default_properties (glView          *view,
                             glUIPropertyBar *this)
 {
-       GList     *family_names;
-       gchar     *good_font_family;
-
-       /* Make sure we have a valid font.  if not provide a good default. */
-       family_names = gl_font_util_get_all_families ();
-       if (g_list_find_custom (family_names,
-                               view->default_font_family,
-                               (GCompareFunc)g_utf8_collate))
-        {
-               good_font_family = g_strdup (view->default_font_family);
-       }
-        else
-        {
-               if (family_names != NULL)
-                {
-                       good_font_family = g_strdup (family_names->data); /* 1st entry */
-               }
-                else
-                {
-                       good_font_family = NULL;
-               }
-       }
+
        gl_font_combo_set_family (GL_FONT_COMBO (this->priv->font_family_combo),
-                                  good_font_family);
-       g_free (good_font_family);
+                                  view->default_font_family);
 
        gtk_spin_button_set_value (GTK_SPIN_BUTTON(this->priv->font_size_spin),
                                   view->default_font_size);
index 993eab20f780317f2add8001ea77a0eaa43a3e5c..4a924280e1b35ffdcaf8accbea3fbf8b34e2c27c 100644 (file)
@@ -215,7 +215,6 @@ create_pixbuf (lglTemplate    *template,
         cairo_surface_t           *surface;
        const lglTemplateFrame    *frame;
        gdouble                    m, m_canvas, w, h, scale;
-       GtkStyle                  *style;
        cairo_t                   *cr;
 
         /* Create pixbuf and cairo context. */