[gnumeric] GUI: Put zoom action on vertical toolbar too.



commit 74b852b96964e7a51f14fb562d4235f5a5c781bc
Author: Morten Welinder <terra gnome org>
Date:   Fri Sep 18 11:13:01 2009 -0400

    GUI: Put zoom action on vertical toolbar too.

 ChangeLog                     |    7 +++
 NEWS                          |    1 +
 src/GNOME_Gnumeric-gtk.xml.in |    1 +
 src/wbc-gtk-impl.h            |    3 +-
 src/wbc-gtk.c                 |   95 ++++++++++++++++++++++++++--------------
 5 files changed, 73 insertions(+), 34 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index bac78e1..301fc0d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-09-18  Morten Welinder  <terra gnome org>
+
+	* src/wbc-gtk-impl.h (struct _WBCGtk): Rename zoom to zoom_haction
+	and add zoom_vaction.
+
+	* src/wbc-gtk.c (wbc_gtk_init_zoom): Setup zoom_vaction.
+
 2009-09-17  Morten Welinder  <terra gnome org>
 
 	* src/item-edit.c (item_edit_class_init): Don't set ::dispose.
diff --git a/NEWS b/NEWS
index 26374f1..678829c 100644
--- a/NEWS
+++ b/NEWS
@@ -11,6 +11,7 @@ Morten:
 	* Limit memory usage for rendered values.
 	* Fix auto-format.
 	* Fix API installation problem.  [#595317]
+	* Put zoom action on vertical toolbars too.  [#590889]
 
 --------------------------------------------------------------------------
 Gnumeric 1.9.12
diff --git a/src/GNOME_Gnumeric-gtk.xml.in b/src/GNOME_Gnumeric-gtk.xml.in
index b0dc620..8f33cfb 100644
--- a/src/GNOME_Gnumeric-gtk.xml.in
+++ b/src/GNOME_Gnumeric-gtk.xml.in
@@ -268,6 +268,7 @@
     <separator name="std-sep5"/>
     <toolitem action="ChartGuru" />
     <toolitem action="Zoom"/>
+    <toolitem action="VZoom"/>
   </toolbar>
   <toolbar _name="FormatToolbar">
     <toolitem action="FontName"/>
diff --git a/src/wbc-gtk-impl.h b/src/wbc-gtk-impl.h
index 9bb7b2d..478f59d 100644
--- a/src/wbc-gtk-impl.h
+++ b/src/wbc-gtk-impl.h
@@ -116,7 +116,8 @@ struct _WBCGtk {
 	GOActionComboStack	*undo_haction, *redo_haction;
 	GtkAction		*undo_vaction, *redo_vaction;
 	GOActionComboColor	*fore_color, *back_color;
-	GOActionComboText	*font_name, *font_size, *zoom;
+	GOActionComboText	*font_name, *font_size, *zoom_haction;
+	GtkAction               *zoom_vaction;
 	GOActionComboPixmaps	*borders, *halignment, *valignment;
 	struct {
 		GtkToggleAction	 *bold, *italic, *underline, *d_underline;
diff --git a/src/wbc-gtk.c b/src/wbc-gtk.c
index c8d0a69..5ed5a93 100644
--- a/src/wbc-gtk.c
+++ b/src/wbc-gtk.c
@@ -814,7 +814,7 @@ cb_zoom_change (Sheet *sheet,
 	if (wbcg_ui_update_begin (wbcg)) {
 		int pct = sheet->last_zoom_factor_used * 100 + .5;
 		char *label = g_strdup_printf ("%d%%", pct);
-		go_action_combo_text_set_entry (wbcg->zoom, label,
+		go_action_combo_text_set_entry (wbcg->zoom_haction, label,
 			GO_ACTION_COMBO_SEARCH_CURRENT);
 		g_free (label);
 		wbcg_ui_update_end (wbcg);
@@ -2487,11 +2487,27 @@ wbcg_view_changed (WBCGtk *wbcg,
 
 /*****************************************************************************/
 
+static void
+cb_chain_sensitivity (GtkAction *src, G_GNUC_UNUSED GParamSpec *pspec,
+		      GtkAction *action)
+{
+	gboolean old_val = gtk_action_get_sensitive (action);
+	gboolean new_val = gtk_action_get_sensitive (src);
+	if ((new_val != 0) == (old_val != 0))
+		return;
+	if (new_val)
+		gtk_action_connect_accelerator (action);
+	else
+		gtk_action_disconnect_accelerator (action);
+	g_object_set (action, "sensitive", new_val, NULL);
+}
+
+
 static GNM_ACTION_DEF (cb_zoom_activated)
 {
 	WorkbookControl *wbc = (WorkbookControl *)wbcg;
 	Sheet *sheet = wb_control_cur_sheet (wbc);
-	char const *new_zoom = go_action_combo_text_get_entry (wbcg->zoom);
+	char const *new_zoom = go_action_combo_text_get_entry (wbcg->zoom_haction);
 	int factor;
 	char *end;
 
@@ -2508,6 +2524,11 @@ static GNM_ACTION_DEF (cb_zoom_activated)
 		cmd_zoom (wbc, g_slist_append (NULL, sheet), factor / 100.);
 }
 
+static GNM_ACTION_DEF (cb_vzoom_activated)
+{
+	dialog_zoom (wbcg, wbcg_cur_sheet (wbcg));
+}
+
 static void
 wbc_gtk_init_zoom (WBCGtk *wbcg)
 {
@@ -2523,28 +2544,50 @@ wbc_gtk_init_zoom (WBCGtk *wbcg)
 	};
 	int i;
 
-	wbcg->zoom = g_object_new (go_action_combo_text_get_type (),
-				  "name", "Zoom",
-				  "label", _("_Zoom"),
-				  "visible-vertical", FALSE,
-				  "tooltip", _("Zoom"),
-				  "stock-id", GTK_STOCK_ZOOM_IN,
-				  NULL);
+	/* ----- horizontal ----- */
+
+	wbcg->zoom_haction =
+		g_object_new (go_action_combo_text_get_type (),
+			      "name", "Zoom",
+			      "label", _("_Zoom"),
+			      "visible-vertical", FALSE,
+			      "tooltip", _("Zoom"),
+			      "stock-id", GTK_STOCK_ZOOM_IN,
+			      NULL);
+	go_action_combo_text_set_width (wbcg->zoom_haction,
 #ifdef GNM_USE_HILDON
-	go_action_combo_text_set_width (wbcg->zoom,  "100000000%");
+					"100000000%"
 #else
-	go_action_combo_text_set_width (wbcg->zoom,  "10000%");
+					"10000%"
 #endif
+					);
 	for (i = 0; preset_zoom[i] != NULL ; ++i)
-		go_action_combo_text_add_item (wbcg->zoom, preset_zoom[i]);
+		go_action_combo_text_add_item (wbcg->zoom_haction,
+					       preset_zoom[i]);
 
-#if 0
-	gnm_combo_box_set_title (GO_COMBO_BOX (fore_combo), _("Foreground"));
-#endif
-	g_signal_connect (G_OBJECT (wbcg->zoom),
+	g_signal_connect (G_OBJECT (wbcg->zoom_haction),
 		"activate",
 		G_CALLBACK (cb_zoom_activated), wbcg);
-	gtk_action_group_add_action (wbcg->actions, GTK_ACTION (wbcg->zoom));
+	gtk_action_group_add_action (wbcg->actions,
+				     GTK_ACTION (wbcg->zoom_haction));
+
+	/* ----- vertical ----- */
+
+	wbcg->zoom_vaction = gtk_action_new ("VZoom", NULL, _("Zoom"),
+					     GTK_STOCK_ZOOM_IN);
+	g_object_set (G_OBJECT (wbcg->zoom_vaction),
+		      "visible-horizontal", FALSE,
+		      NULL);
+	g_signal_connect (G_OBJECT (wbcg->zoom_vaction),
+			  "activate",
+			  G_CALLBACK (cb_vzoom_activated), wbcg);
+	gtk_action_group_add_action (wbcg->actions,
+				     GTK_ACTION (wbcg->zoom_vaction));
+
+	/* ----- chain ----- */
+
+	g_signal_connect (G_OBJECT (wbcg->zoom_haction), "notify::sensitive",
+		G_CALLBACK (cb_chain_sensitivity), wbcg->zoom_vaction);
 }
 
 /****************************************************************************/
@@ -2701,21 +2744,6 @@ wbc_gtk_undo_redo_push (WorkbookControl *wbc, gboolean is_undo,
 }
 
 static void
-cb_chain_sensitivity (GtkAction *src, G_GNUC_UNUSED GParamSpec *pspec,
-		      GtkAction *action)
-{
-	gboolean old_val = gtk_action_get_sensitive (action);
-	gboolean new_val = gtk_action_get_sensitive (src);
-	if ((new_val != 0) == (old_val != 0))
-		return;
-	if (new_val)
-		gtk_action_connect_accelerator (action);
-	else
-		gtk_action_disconnect_accelerator (action);
-	g_object_set (action, "sensitive", new_val, NULL);
-}
-
-static void
 create_undo_redo (GOActionComboStack **haction, char const *hname,
 		  GCallback hcb,
 		  GtkAction **vaction, char const *vname,
@@ -4512,7 +4540,8 @@ wbc_gtk_finalize (GObject *obj)
 
 	g_hash_table_destroy (wbcg->custom_uis);
 
-	UNREF_OBJ (zoom);
+	UNREF_OBJ (zoom_vaction);
+	UNREF_OBJ (zoom_haction);
 	UNREF_OBJ (borders);
 	UNREF_OBJ (fore_color);
 	UNREF_OBJ (back_color);



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