* 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
+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
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);
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. */
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);
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);
glColorComboMenu *this = GL_COLOR_COMBO_MENU (widget);
load_custom_color_history (this);
+
+ return FALSE;
}
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);
guint color)
{
glColorCombo *this;
- GdkPixbuf *pixbuf;
- GtkWidget *wimage;
this = g_object_new (TYPE_GL_COLOR_COMBO, NULL);
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,
gobject_class->finalize = gl_color_swatch_finalize;
widget_class->expose_event = expose_event_cb;
+ widget_class->style_set = style_set_cb;
}
}
+/*--------------------------------------------------------------------------*/
+/* 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. */
/*****************************************************************************/
draw_swatch (glColorSwatch *this,
cairo_t *cr)
{
- GdkPixbuf *pixbuf;
GtkStyle *style;
gdouble w, h;
guint fill_color, line_color;
#include "font-combo-menu-item.h"
+#include "font-sample.h"
#include "marshal.h"
#include <glib/gi18n.h>
#include <gtk/gtkmenuitem.h>
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);
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);
#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>
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);
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 ();
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);
}
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,
gobject_class->finalize = gl_font_sample_finalize;
widget_class->expose_event = expose_event_cb;
+ widget_class->style_set = style_set_cb;
}
}
+/*--------------------------------------------------------------------------*/
+/* 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. */
/*****************************************************************************/
draw_sample (glFontSample *this,
cairo_t *cr)
{
- GdkPixbuf *pixbuf;
GtkStyle *style;
gdouble w, h;
guint fill_color, line_color;
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
}
+/****************************************************************************/
+/* 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
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__ */
const gchar *font_family)
{
glLabelText *ltext = (glLabelText *)object;
- GList *family_names;
gchar *good_font_family;
gl_debug (DEBUG_LABEL, "START");
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) {
void
gl_object_editor_prepare_text_page (glObjectEditor *editor)
{
- GList *family_names = NULL;
-
gl_debug (DEBUG_EDITOR, "START");
/* Extract widgets from XML tree. */
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");
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);
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,
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);
"adjustment1", "adjustment2",
NULL };
GError *error = NULL;
- GList *family_names = NULL;
- GList *family_node;
GdkPixbuf *pixbuf = NULL;
gl_debug (DEBUG_PROPERTY_BAR, "START");
/* 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);
cairo_surface_t *surface;
const lglTemplateFrame *frame;
gdouble m, m_canvas, w, h, scale;
- GtkStyle *style;
cairo_t *cr;
/* Create pixbuf and cairo context. */