[simple-scan] Move action bar code out of .ui file - Glade doesn't handle it
- From: Robert Ancell <rancell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [simple-scan] Move action bar code out of .ui file - Glade doesn't handle it
- Date: Sat, 20 May 2017 02:03:55 +0000 (UTC)
commit f3d0ba498a5f4ecff8cb595bcd8d9bf233c1bf51
Author: Robert Ancell <robert ancell canonical com>
Date: Sat May 20 14:03:37 2017 +1200
Move action bar code out of .ui file - Glade doesn't handle it
src/app-window.ui | 143 +--------------------------------------------------
src/app-window.vala | 82 +++++++++++++++++++++--------
2 files changed, 61 insertions(+), 164 deletions(-)
---
diff --git a/src/app-window.ui b/src/app-window.ui
index ec84592..4154251 100644
--- a/src/app-window.ui
+++ b/src/app-window.ui
@@ -576,150 +576,9 @@
<placeholder/>
</child>
<child>
- <object class="GtkActionBar">
+ <object class="GtkActionBar" id="action_bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <child>
- <object class="GtkButton" id="new_toolbutton">
- <property name="label" translatable="yes" comments="Label on new document button">Start
Again…</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltip for new document
button">Start a new document</property>
- <signal name="clicked" handler="new_button_clicked_cb" swapped="no"/>
- <style>
- <class name="text-button"/>
- </style>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child type="center">
- <object class="GtkBox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">center</property>
- <property name="spacing">10</property>
- <child>
- <object class="GtkBox" id="rotate_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="valign">center</property>
- <child>
- <object class="GtkButton" id="rotate_right_button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltip for rotate right
(clockwise) button">Rotate the page to the right (clockwise)</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="rotate_right_button_clicked_cb" swapped="no"/>
- <child>
- <object class="GtkImage" id="objectrotateright-button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">object-rotate-right-symbolic</property>
- <property name="icon_size">1</property>
- </object>
- </child>
- <style>
- <class name="image-button"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="rotate_left_button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltip for rotate left
(counter-clockwise) button">Rotate the page to the left (counter-clockwise)</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="rotate_left_button_clicked_cb" swapped="no"/>
- <child>
- <object class="GtkImage" id="objectrotateleft-button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">object-rotate-left-symbolic</property>
- <property name="icon_size">1</property>
- </object>
- </child>
- <style>
- <class name="image-button"/>
- </style>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="pack_type">end</property>
- <property name="position">1</property>
- </packing>
- </child>
- <style>
- <class name="linked"/>
- </style>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkToggleButton" id="crop_button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltip for crop button">Crop
the selected page</property>
- <property name="use_underline">True</property>
- <signal name="toggled" handler="crop_button_toggled_cb" swapped="no"/>
- <child>
- <object class="GtkImage" id="objectcrop-button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">edit-cut-symbolic</property>
- <property name="icon_size">1</property>
- </object>
- </child>
- <style>
- <class name="image-button"/>
- </style>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="delete_button">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="receives_default">False</property>
- <property name="tooltip_text" translatable="yes" comments="Tooltip for delete
button">Delete the selected page</property>
- <property name="use_underline">True</property>
- <signal name="clicked" handler="delete_button_clicked_cb" swapped="no"/>
- <child>
- <object class="GtkImage">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="icon_name">edit-delete-symbolic</property>
- <property name="icon_size">1</property>
- </object>
- </child>
- <style>
- <class name="image-button"/>
- </style>
- </object>
- <packing>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/src/app-window.vala b/src/app-window.vala
index ee6f4c5..2b16b67 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -88,13 +88,13 @@ public class AppWindow : Gtk.ApplicationWindow
[GtkChild]
private Gtk.ToolButton stop_toolbutton;
[GtkChild]
- private Gtk.ToggleButton crop_button;
- [GtkChild]
- private Gtk.Button delete_button;
- [GtkChild]
private Gtk.Button stop_button;
[GtkChild]
private Gtk.Button scan_button;
+ [GtkChild]
+ private Gtk.ActionBar action_bar;
+ private Gtk.ToggleButton crop_button;
+ private Gtk.Button delete_button;
[GtkChild]
private Gtk.RadioMenuItem text_button_menuitem;
@@ -880,24 +880,6 @@ public class AppWindow : Gtk.ApplicationWindow
}
[GtkCallback]
- private void crop_button_toggled_cb (Gtk.ToggleButton widget)
- {
- if (updating_page_menu)
- return;
-
- if (widget.active)
- custom_crop_menuitem.active = true;
- else
- no_crop_menuitem.active = true;
- }
-
- [GtkCallback]
- private void delete_button_clicked_cb (Gtk.Button widget)
- {
- book_view.book.delete_page (book_view.selected_page);
- }
-
- [GtkCallback]
private void four_by_six_menuitem_toggled_cb (Gtk.CheckMenuItem widget)
{
if (widget.active)
@@ -1710,6 +1692,62 @@ public class AppWindow : Gtk.ApplicationWindow
info_bar_install_button = info_bar.add_button (/* Button in error infobar to prompt user to install
drivers */
_("_Install Drivers"), 2) as Gtk.Button;
+ /* Populate ActionBar (not supported in Glade) */
+ var button = new Gtk.Button.with_label (/* Label on new document button */
+ _("Start Again…"));
+ button.visible = true;
+ button.clicked.connect (new_button_clicked_cb);
+ action_bar.pack_start (button);
+
+ var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 10);
+ box.visible = true;
+ action_bar.set_center_widget (box);
+
+ var rotate_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+ rotate_box.get_style_context ().add_class (Gtk.STYLE_CLASS_LINKED);
+ rotate_box.visible = true;
+ box.pack_start (rotate_box, false, true, 0);
+
+ button = new Gtk.Button.from_icon_name ("object-rotate-left-symbolic");
+ button.visible = true;
+ /* Tooltip for rotate left (counter-clockwise) button */
+ button.tooltip_text = _("Rotate the page to the left (counter-clockwise)");
+ button.clicked.connect (rotate_left_button_clicked_cb);
+ rotate_box.pack_start (button, false, true, 0);
+
+ button = new Gtk.Button.from_icon_name ("object-rotate-right-symbolic");
+ button.visible = true;
+ /* Tooltip for rotate right (clockwise) button */
+ button.tooltip_text = _("Rotate the page to the right (clockwise)");
+ button.clicked.connect (rotate_right_button_clicked_cb);
+ rotate_box.pack_start (button, false, true, 0);
+
+ crop_button = new Gtk.ToggleButton ();
+ crop_button.visible = true;
+ var image = new Gtk.Image.from_icon_name ("edit-cut-symbolic", Gtk.IconSize.BUTTON);
+ image.visible = true;
+ crop_button.add (image);
+ /* Tooltip for crop button */
+ crop_button.tooltip_text = _("Crop the selected page");
+ crop_button.toggled.connect ((widget) =>
+ {
+ if (updating_page_menu)
+ return;
+
+ if (widget.active)
+ custom_crop_menuitem.active = true;
+ else
+ no_crop_menuitem.active = true;
+ });
+ box.pack_start (crop_button, false, true, 0);
+
+ delete_button = new Gtk.Button.from_icon_name ("user-trash-symbolic");
+ delete_button.visible = true;
+ /* Tooltip for delete button */
+ delete_button.tooltip_text = _("Delete the selected page");
+ delete_button.clicked.connect (() => { book_view.book.delete_page (book_view.selected_page); });
+ box.pack_start (delete_button, false, true, 0);
+
var document_type = settings.get_string ("document-type");
if (document_type != null)
set_document_hint (document_type);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]