2 * font-combo-menu-item.c
3 * Copyright (C) 2009 Jim Evins <evins@snaught.com>.
5 * This file is part of gLabels.
7 * gLabels is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
12 * gLabels is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
23 #include "font-combo-menu-item.h"
25 #include "font-sample.h"
27 #include <glib/gi18n.h>
28 #include <gtk/gtkmenuitem.h>
29 #include <gtk/gtkseparatormenuitem.h>
30 #include <gtk/gtkhbox.h>
31 #include <gtk/gtklabel.h>
35 /*===========================================*/
36 /* Private macros and constants. */
37 /*===========================================*/
43 /*===========================================*/
45 /*===========================================*/
47 struct _glFontComboMenuItemPrivate {
54 /*===========================================*/
56 /*===========================================*/
59 /*===========================================*/
60 /* Local function prototypes */
61 /*===========================================*/
63 static void gl_font_combo_menu_item_finalize (GObject *object);
66 /****************************************************************************/
67 /* Boilerplate Object stuff. */
68 /****************************************************************************/
69 G_DEFINE_TYPE (glFontComboMenuItem, gl_font_combo_menu_item, GTK_TYPE_MENU_ITEM);
72 /*****************************************************************************/
73 /* Class Init Function. */
74 /*****************************************************************************/
76 gl_font_combo_menu_item_class_init (glFontComboMenuItemClass *class)
78 GObjectClass *gobject_class = G_OBJECT_CLASS (class);
80 gl_font_combo_menu_item_parent_class = g_type_class_peek_parent (class);
82 gobject_class->finalize = gl_font_combo_menu_item_finalize;
86 /*****************************************************************************/
87 /* Object Instance Init Function. */
88 /*****************************************************************************/
90 gl_font_combo_menu_item_init (glFontComboMenuItem *this)
92 this->priv = g_new0 (glFontComboMenuItemPrivate, 1);
96 /*****************************************************************************/
97 /* Finalize Method. */
98 /*****************************************************************************/
100 gl_font_combo_menu_item_finalize (GObject *object)
102 glFontComboMenuItem *this = GL_FONT_COMBO_MENU_ITEM (object);
104 g_return_if_fail (object != NULL);
105 g_return_if_fail (GL_IS_FONT_COMBO_MENU_ITEM (object));
107 g_free (this->priv->font_family);
110 G_OBJECT_CLASS (gl_font_combo_menu_item_parent_class)->finalize (object);
114 /*****************************************************************************/
115 /** New Object Generator. */
116 /*****************************************************************************/
118 gl_font_combo_menu_item_new (gchar *font_family)
120 glFontComboMenuItem *this;
126 this = g_object_new (GL_TYPE_FONT_COMBO_MENU_ITEM, NULL);
128 this->priv->font_family = g_strdup (font_family);
130 hbox = gtk_hbox_new (FALSE, 6);
131 gtk_container_add (GTK_CONTAINER (this), hbox);
133 sample = gl_font_sample_new (SAMPLE_W, SAMPLE_H, "Aa", font_family);
134 gtk_box_pack_start (GTK_BOX (hbox), sample, FALSE, FALSE, 0);
136 label = gtk_label_new (font_family);
137 gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
139 markup = g_strdup_printf ("<span font_family=\"%s\" size=\"x-large\">ABCDEFGHIJKLMNOPQRSTUVWXYZ\nabcdefghijklmnopqrstuvwxyz\n0123456789</span>",
141 gtk_widget_set_tooltip_markup (GTK_WIDGET (this), markup);
144 return GTK_WIDGET (this);
148 /*****************************************************************************/
150 /*****************************************************************************/
152 gl_font_combo_menu_item_get_family (glFontComboMenuItem *this)
154 return g_strdup (this->priv->font_family);
160 * Local Variables: -- emacs
162 * c-basic-offset: 8 -- emacs
163 * tab-width: 8 -- emacs
164 * indent-tabs-mode: nil -- emacs