[gnumeric] GUI: Add vertical version of the font button.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnumeric] GUI: Add vertical version of the font button.
- Date: Thu, 18 Apr 2013 01:08:51 +0000 (UTC)
commit 0675901fd060267408a7355fb9bbeef15d01e98f
Author: Morten Welinder <terra gnome org>
Date: Wed Apr 17 21:08:31 2013 -0400
GUI: Add vertical version of the font button.
ChangeLog | 6 +++
NEWS | 1 +
src/GNOME_Gnumeric-gtk.xml.in | 1 +
src/wbc-gtk-impl.h | 2 +-
src/wbc-gtk.c | 109 ++++++++++++++++++++++++++++++++----------
5 files changed, 92 insertions(+), 27 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index be2cf10..acbadc5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2013-04-17 Morten Welinder <terra gnome org>
+ * src/wbc-gtk.c (wbc_gtk_init): Add also a vertical font chooser
+ button.
+
+ * src/wbc-gtk-impl.h (_WBCGtk): Rename font_name member to
+ font_name_haction.
+
* src/wbc-gtk.c (wbc_gtk_init_font_name): Show the font button
only for horizontal toolbars.
diff --git a/NEWS b/NEWS
index 75471dd..68b8f3a 100644
--- a/NEWS
+++ b/NEWS
@@ -49,6 +49,7 @@ Morten:
* Fix database criterias "=" and "<>" for emptiness test. [#686156]
* Enable context menu for graph sheet tabs. [#685446]
* Fix bad interaction between save-as and GtkFileChooser. [#695839]
+ * Fix vertical toolbar's font button.
--------------------------------------------------------------------------
Gnumeric 1.12.1
diff --git a/src/GNOME_Gnumeric-gtk.xml.in b/src/GNOME_Gnumeric-gtk.xml.in
index 54955e0..c9c71c3 100644
--- a/src/GNOME_Gnumeric-gtk.xml.in
+++ b/src/GNOME_Gnumeric-gtk.xml.in
@@ -359,6 +359,7 @@
</toolbar>
<toolbar _name="FormatToolbar">
<toolitem action="FontName"/>
+ <toolitem action="VFontName"/>
<toolitem action="FontBold"/>
<toolitem action="FontItalic"/>
<toolitem action="FontUnderline"/>
diff --git a/src/wbc-gtk-impl.h b/src/wbc-gtk-impl.h
index 1eb748d..c8c581b 100644
--- a/src/wbc-gtk-impl.h
+++ b/src/wbc-gtk-impl.h
@@ -113,7 +113,7 @@ struct _WBCGtk {
GOActionComboStack *undo_haction, *redo_haction;
GtkAction *undo_vaction, *redo_vaction;
GOActionComboColor *fore_color, *back_color;
- GtkAction *font_name;
+ GtkAction *font_name_haction, *font_name_vaction;
GOActionComboText *zoom_haction;
GtkAction *zoom_vaction;
GOActionComboPixmaps *borders, *halignment, *valignment;
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index 243345d..51dfb8c 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -3390,7 +3390,7 @@ typedef struct { GtkAction base; } GnmFontAction;
typedef struct { GtkActionClass base; } GnmFontActionClass;
static PangoFontDescription *
-gnm_font_action_get_font_desc (GnmFontAction *act)
+gnm_font_action_get_font_desc (GtkAction *act)
{
PangoFontDescription *desc =
g_object_get_data (G_OBJECT (act), "font-data");
@@ -3398,7 +3398,7 @@ gnm_font_action_get_font_desc (GnmFontAction *act)
}
static void
-gnm_font_action_set_font_desc (GnmFontAction *act, PangoFontDescription *desc)
+gnm_font_action_set_font_desc (GtkAction *act, PangoFontDescription *desc)
{
PangoFontDescription *old_desc;
GSList *p;
@@ -3412,7 +3412,7 @@ gnm_font_action_set_font_desc (GnmFontAction *act, PangoFontDescription *desc)
}
pango_font_description_merge (old_desc, desc, TRUE);
- for (p = gtk_action_get_proxies (GTK_ACTION (act)); p; p = p->next) {
+ for (p = gtk_action_get_proxies (act); p; p = p->next) {
GtkWidget *w = p->data;
GtkWidget *child;
GtkFontChooser *chooser;
@@ -3430,12 +3430,12 @@ gnm_font_action_set_font_desc (GnmFontAction *act, PangoFontDescription *desc)
}
static void
-cb_font_set (GtkFontChooser *chooser, GnmFontAction *act)
+cb_font_set (GtkFontChooser *chooser, GtkAction *act)
{
PangoFontDescription *desc = gtk_font_chooser_get_font_desc (chooser);
gnm_font_action_set_font_desc (act, desc);
pango_font_description_free (desc);
- gtk_action_activate (GTK_ACTION (act));
+ gtk_action_activate (act);
}
static void
@@ -3533,7 +3533,7 @@ GSF_CLASS (GnmFontAction, gnm_font_action,
#define GNM_FONT_ACTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), gnm_font_action_get_type(), GnmFontAction))
static void
-cb_font_changed (GnmFontAction *act, WBCGtk *gtk)
+cb_font_changed (GtkAction *act, WBCGtk *gtk)
{
PangoFontDescription *desc = gnm_font_action_get_font_desc (act);
const char *family = pango_font_description_get_family (desc);
@@ -3567,11 +3567,52 @@ cb_font_changed (GnmFontAction *act, WBCGtk *gtk)
}
static void
+cb_font_name_vaction_response (GtkDialog *dialog,
+ gint response_id,
+ GtkAction *act)
+{
+ WBCGtk *wbcg = g_object_get_data (G_OBJECT (act), "wbcg");
+
+ if (response_id == GTK_RESPONSE_OK) {
+ PangoFontDescription *desc = gtk_font_chooser_get_font_desc
+ (GTK_FONT_CHOOSER (dialog));
+ gnm_font_action_set_font_desc (act, desc);
+ pango_font_description_free (desc);
+ cb_font_changed (act, wbcg);
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+}
+
+
+static void
+cb_font_name_vaction_clicked (GtkAction *act, WBCGtk *wbcg)
+{
+ GtkFontChooser *font_dialog;
+ const char *key = "font-name-dialog";
+
+ if (gnumeric_dialog_raise_if_exists (wbcg, key))
+ return;
+
+ font_dialog = g_object_new (GO_TYPE_FONT_SEL_DIALOG, NULL);
+ gtk_font_chooser_set_font_desc (font_dialog,
+ gnm_font_action_get_font_desc (act));
+ g_signal_connect (font_dialog, "response",
+ G_CALLBACK (cb_font_name_vaction_response),
+ act);
+
+ gtk_window_present (GTK_WINDOW (font_dialog));
+
+ gnumeric_keyed_dialog (wbcg, GTK_WINDOW (font_dialog), key);
+}
+
+
+static void
set_font_name_feedback (GtkAction *act, const char *family)
{
PangoFontDescription *desc = pango_font_description_new ();
pango_font_description_set_family (desc, family);
- gnm_font_action_set_font_desc (GNM_FONT_ACTION (act), desc);
+ gnm_font_action_set_font_desc (act, desc);
pango_font_description_free (desc);
}
@@ -3580,26 +3621,34 @@ set_font_size_feedback (GtkAction *act, double size)
{
PangoFontDescription *desc = pango_font_description_new ();
pango_font_description_set_size (desc, size * PANGO_SCALE);
- gnm_font_action_set_font_desc (GNM_FONT_ACTION (act), desc);
+ gnm_font_action_set_font_desc (act, desc);
pango_font_description_free (desc);
}
-static void
-wbc_gtk_init_font_name (WBCGtk *gtk)
+static GtkAction *
+wbc_gtk_init_font_name (WBCGtk *gtk, gboolean horiz)
{
- gtk->font_name = g_object_new
- (gnm_font_action_get_type (),
- "visible-vertical", FALSE,
- "name", "FontName",
+ GtkAction *act = g_object_new
+ (horiz ? gnm_font_action_get_type () : GTK_TYPE_ACTION,
+ "visible-vertical", !horiz,
+ "visible-horizontal", horiz,
+ "name", (horiz ? "FontName" : "VFontName"),
"tooltip", _("Change font"),
+ "stock-id", GTK_STOCK_SELECT_FONT,
NULL);
- g_object_set_data (G_OBJECT (gtk->font_name), "wbcg", gtk);
- g_signal_connect (G_OBJECT (gtk->font_name),
- "activate",
- G_CALLBACK (cb_font_changed), gtk);
- gtk_action_group_add_action (gtk->font_actions,
- GTK_ACTION (gtk->font_name));
+ g_object_set_data (G_OBJECT (act), "wbcg", gtk);
+
+ g_signal_connect (G_OBJECT (act),
+ "activate",
+ (horiz
+ ? G_CALLBACK (cb_font_changed)
+ : G_CALLBACK (cb_font_name_vaction_clicked)),
+ gtk);
+
+ gtk_action_group_add_action (gtk->font_actions, act);
+
+ return act;
}
/****************************************************************************/
@@ -3692,13 +3741,19 @@ wbc_gtk_style_feedback_real (WorkbookControl *wbc, GnmStyle const *changes)
go_action_combo_pixmaps_select_id (wbcg->valignment, align);
}
- if (gnm_style_is_element_set (changes, MSTYLE_FONT_SIZE))
- set_font_size_feedback (wbcg->font_name,
+ if (gnm_style_is_element_set (changes, MSTYLE_FONT_SIZE)) {
+ set_font_size_feedback (wbcg->font_name_haction,
gnm_style_get_font_size (changes));
+ set_font_size_feedback (wbcg->font_name_vaction,
+ gnm_style_get_font_size (changes));
+ }
- if (gnm_style_is_element_set (changes, MSTYLE_FONT_NAME))
- set_font_name_feedback (wbcg->font_name,
+ if (gnm_style_is_element_set (changes, MSTYLE_FONT_NAME)) {
+ set_font_name_feedback (wbcg->font_name_haction,
gnm_style_get_font_name (changes));
+ set_font_name_feedback (wbcg->font_name_vaction,
+ gnm_style_get_font_name (changes));
+ }
wbcg_ui_update_end (WBC_GTK (wbc));
}
@@ -5060,7 +5115,8 @@ wbc_gtk_finalize (GObject *obj)
g_clear_object (&wbcg->borders);
g_clear_object (&wbcg->fore_color);
g_clear_object (&wbcg->back_color);
- g_clear_object (&wbcg->font_name);
+ g_clear_object (&wbcg->font_name_haction);
+ g_clear_object (&wbcg->font_name_vaction);
g_clear_object (&wbcg->redo_haction);
g_clear_object (&wbcg->redo_vaction);
g_clear_object (&wbcg->undo_haction);
@@ -5596,7 +5652,8 @@ wbc_gtk_init (GObject *obj)
wbc_gtk_init_undo_redo (wbcg);
wbc_gtk_init_color_fore (wbcg);
wbc_gtk_init_color_back (wbcg);
- wbc_gtk_init_font_name (wbcg);
+ wbcg->font_name_haction = wbc_gtk_init_font_name (wbcg, TRUE);
+ wbcg->font_name_vaction = wbc_gtk_init_font_name (wbcg, FALSE);
wbc_gtk_init_zoom (wbcg);
wbc_gtk_init_borders (wbcg);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]