[sysprof/wip/visualizers] zoom: add plumbing for zoom to SpWindow
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sysprof/wip/visualizers] zoom: add plumbing for zoom to SpWindow
- Date: Thu, 29 Sep 2016 01:07:02 +0000 (UTC)
commit 50bfd8db727555628022ed0a78d5335cf0ec265b
Author: Christian Hergert <chergert redhat com>
Date: Wed Sep 28 17:51:48 2016 -0700
zoom: add plumbing for zoom to SpWindow
This uses the new ZoomManager to wire up zoom controls for the
main window. We had to switch away from GMenu to give ourselves
the control we will need for the zoom label of 100% which still
needs to be wired up.
src/resources/gtk/menus.ui | 26 -----------
src/resources/ui/sp-window.ui | 92 +++++++++++++++++++++++++++++++++++++++++
src/sp-window.c | 19 +--------
3 files changed, 94 insertions(+), 43 deletions(-)
---
diff --git a/src/resources/gtk/menus.ui b/src/resources/gtk/menus.ui
index bc31b0a..095f4d3 100644
--- a/src/resources/gtk/menus.ui
+++ b/src/resources/gtk/menus.ui
@@ -28,30 +28,4 @@
</item>
</section>
</menu>
- <menu id="gear-menu">
- <section id="gear-menu-open-section">
- <item>
- <attribute name="label" translatable="yes">Open</attribute>
- <attribute name="action">win.open-capture</attribute>
- </item>
- </section>
- <section id="gear-menu-save-section">
- <item>
- <attribute name="label" translatable="yes">Save As</attribute>
- <attribute name="action">win.save-capture</attribute>
- </item>
- </section>
- <section id="gear-menu-screenshot-section">
- <item>
- <attribute name="label" translatable="yes">Screenshot</attribute>
- <attribute name="action">win.screenshot</attribute>
- </item>
- </section>
- <section id="gear-menu-close-section">
- <item>
- <attribute name="label" translatable="yes">Close</attribute>
- <attribute name="action">win.close-capture</attribute>
- </item>
- </section>
- </menu>
</interface>
diff --git a/src/resources/ui/sp-window.ui b/src/resources/ui/sp-window.ui
index 4d84b3f..f95a93a 100644
--- a/src/resources/ui/sp-window.ui
+++ b/src/resources/ui/sp-window.ui
@@ -72,6 +72,7 @@
</child>
<child>
<object class="GtkMenuButton" id="gear_menu_button">
+ <property name="popover">gear_popover</property>
<property name="visible">true</property>
<style>
<class name="image-button"/>
@@ -203,4 +204,95 @@
</object>
</child>
</template>
+ <object class="SpZoomManager" id="zoom_manager">
+ </object>
+ <object class="GtkPopover" id="gear_popover">
+ <property name="border-width">12</property>
+ <property name="width-request">225</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">vertical</property>
+ <property name="visible">true</property>
+ <child>
+ <object class="GtkBox">
+ <property name="orientation">horizontal</property>
+ <property name="margin-bottom">12</property>
+ <property name="visible">true</property>
+ <style>
+ <class name="linked"/>
+ </style>
+ <child>
+ <object class="GtkButton">
+ <property name="action-name">zoom.zoom-out</property>
+ <property name="hexpand">true</property>
+ <property name="visible">true</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">zoom-out-symbolic</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="action-name">zoom.zoom-one</property>
+ <property name="label" translatable="yes">100%</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton">
+ <property name="action-name">zoom.zoom-in</property>
+ <property name="hexpand">true</property>
+ <property name="visible">true</property>
+ <style>
+ <class name="image-button"/>
+ </style>
+ <child>
+ <object class="GtkImage">
+ <property name="icon-name">zoom-in-symbolic</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton">
+ <property name="action-name">win.open-capture</property>
+ <property name="text" translatable="yes">Open</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton">
+ <property name="action-name">win.save-capture</property>
+ <property name="text" translatable="yes">Save As</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton">
+ <property name="margin-top">12</property>
+ <property name="action-name">win.screenshot</property>
+ <property name="text" translatable="yes">Screenshot</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkModelButton">
+ <property name="margin-top">12</property>
+ <property name="action-name">win.close-capture</property>
+ <property name="text" translatable="yes">Close</property>
+ <property name="visible">true</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
</interface>
diff --git a/src/sp-window.c b/src/sp-window.c
index b8a7d96..f1840a1 100644
--- a/src/sp-window.c
+++ b/src/sp-window.c
@@ -51,6 +51,7 @@ struct _SpWindow
GtkLabel *title;
GtkStack *view_stack;
SpVisualizerView *visualizers;
+ SpZoomManager *zoom_manager;
guint stats_handler;
@@ -796,9 +797,6 @@ sp_window_init (SpWindow *self)
{ "save-capture", sp_window_save_capture },
{ "screenshot", sp_window_screenshot },
};
- GtkApplication *app;
- GtkPopover *popover;
- GMenu *menu;
gtk_widget_init_template (GTK_WIDGET (self));
@@ -843,20 +841,7 @@ sp_window_init (SpWindow *self)
action_entries,
G_N_ELEMENTS (action_entries),
self);
-
- /*
- * Setup our gear (hamburger) menu.
- */
- app = GTK_APPLICATION (g_application_get_default ());
- menu = gtk_application_get_menu_by_id (app, "gear-menu");
- gtk_menu_button_set_menu_model (self->gear_menu_button, G_MENU_MODEL (menu));
-
- /*
- * Set the min-width on the popover for the gear menu, which is rather
- * small by default (since our wording is short).
- */
- popover = gtk_menu_button_get_popover (self->gear_menu_button);
- gtk_widget_set_size_request (GTK_WIDGET (popover), 200, -1);
+ gtk_widget_insert_action_group (GTK_WIDGET (self), "zoom", G_ACTION_GROUP (self->zoom_manager));
/*
* Restore previous window settings.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]