From 366cfa34733d4058e24b84f1fbc1e40c9ab7f4c9 Mon Sep 17 00:00:00 2001 From: Přemysl Janouch Date: Tue, 9 Oct 2012 07:05:32 +0200 Subject: Show diagram zoom in the main window. --- src/ld-window-main.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ld-window-main.c b/src/ld-window-main.c index a12655c..8b83852 100644 --- a/src/ld-window-main.c +++ b/src/ld-window-main.c @@ -40,6 +40,7 @@ struct _LdWindowMainPrivate LdDiagramView *view; GtkWidget *statusbar; + GtkWidget *zoom_label; guint statusbar_symbol_context_id; guint statusbar_menu_context_id; guint statusbar_hint_context_id; @@ -341,9 +342,6 @@ ld_window_main_init (LdWindowMain *self) ld_diagram_view_set_diagram (priv->view, priv->diagram); ld_diagram_view_set_library (priv->view, priv->library); - g_signal_connect (priv->view, "notify::zoom", - G_CALLBACK (on_view_zoom_changed), self); - ld_category_view_set_category (LD_CATEGORY_VIEW (priv->library_view), ld_library_get_root (priv->library)); @@ -358,6 +356,15 @@ ld_window_main_init (LdWindowMain *self) (GTK_STATUSBAR (priv->statusbar), priv->statusbar_hint_context_id, _("Drag symbols from the library pane to add them to the diagram.")); + priv->zoom_label = gtk_label_new (""); + gtk_label_set_single_line_mode (GTK_LABEL (priv->zoom_label), TRUE); + gtk_box_pack_end (GTK_BOX (gtk_statusbar_get_message_area + (GTK_STATUSBAR (priv->statusbar))), priv->zoom_label, FALSE, FALSE, 0); + + g_signal_connect (priv->view, "notify::zoom", + G_CALLBACK (on_view_zoom_changed), self); + g_object_notify (G_OBJECT (priv->view), "zoom"); + action_set_sensitive (self, "Undo", FALSE); action_set_sensitive (self, "Redo", FALSE); action_set_sensitive (self, "Delete", FALSE); @@ -901,12 +908,19 @@ static void on_view_zoom_changed (LdDiagramView *view, GParamSpec *pspec, LdWindowMain *self) { + gchar *zoom; + action_set_sensitive (self, "ZoomIn", ld_diagram_view_can_zoom_in (self->priv->view)); action_set_sensitive (self, "ZoomOut", ld_diagram_view_can_zoom_out (self->priv->view)); action_set_sensitive (self, "NormalSize", ld_diagram_view_get_zoom (self->priv->view) != 1); + + zoom = g_strdup_printf (_("%d%%"), + (gint) (ld_diagram_view_get_zoom (self->priv->view) * 100 + 0.5)); + gtk_label_set_text (GTK_LABEL (self->priv->zoom_label), zoom); + g_free (zoom); } static void -- cgit v1.2.3-70-g09d2