[niepce] Issue 12 - Add toolbar to the gridview



commit 69d270ba215e3013098f709837b027bded2be219
Author: Hubert Figuière <hub figuiere net>
Date:   Fri Aug 10 23:23:12 2018 -0400

    Issue 12 - Add toolbar to the gridview
    
    https://gitlab.gnome.org/GNOME/niepce/issues/12

 build.rs                                       |  1 +
 src/Makefile.am                                |  1 +
 src/niepce/modules/darkroom/darkroommodule.cpp | 34 +++------------
 src/niepce/ui/gridviewmodule.cpp               | 12 +++++-
 src/niepce/ui/imagetoolbar.rs                  | 59 ++++++++++++++++++++++++++
 src/niepce/ui/mod.rs                           |  1 +
 6 files changed, 77 insertions(+), 31 deletions(-)
---
diff --git a/build.rs b/build.rs
index f96314c..9c2bb29 100644
--- a/build.rs
+++ b/build.rs
@@ -67,6 +67,7 @@ fn main() {
             .with_parse_deps(true)
             .with_parse_exclude(&["exempi", "chrono"])
             .exclude_item("GtkWindow")
+            .exclude_item("GtkToolbar")
             .with_crate(&crate_dir);
 
         if let Ok(bindings) = cbuilder.generate() {
diff --git a/src/Makefile.am b/src/Makefile.am
index 2a09fd2..35aac27 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,6 +42,7 @@ RUST_SOURCES = \
        @top_srcdir@/src/libraryclient/mod.rs \
        @top_srcdir@/src/niepce/mod.rs \
        @top_srcdir@/src/niepce/ui/mod.rs \
+       @top_srcdir@/src/niepce/ui/imagetoolbar.rs \
        @top_srcdir@/src/niepce/ui/dialogs/mod.rs \
        @top_srcdir@/src/niepce/ui/dialogs/confirm.rs \
        @top_srcdir@/src/niepce/ui/dialogs/requestnewfolder.rs \
diff --git a/src/niepce/modules/darkroom/darkroommodule.cpp b/src/niepce/modules/darkroom/darkroommodule.cpp
index 5d81fa6..c5b91bd 100644
--- a/src/niepce/modules/darkroom/darkroommodule.cpp
+++ b/src/niepce/modules/darkroom/darkroommodule.cpp
@@ -18,7 +18,8 @@
  */
 
 #include <gdkmm/pixbuf.h>
-#include <gtkmm/toolbar.h>
+
+#include "rust_bindings.hpp"
 
 #include "fwk/base/debug.hpp"
 #include "fwk/toolkit/application.hpp"
@@ -111,34 +112,9 @@ Gtk::Widget * DarkroomModule::buildWidget()
     m_imagecanvas->set_image(m_image);
 
     // build the toolbar.
-    auto toolbar = Gtk::manage(new Gtk::Toolbar);
-
-    Glib::RefPtr<Gio::Action> an_action;
-    auto tool_item = new Gtk::ToolButton();
-    gtk_actionable_set_action_name(GTK_ACTIONABLE(tool_item->gobj()),
-                                   "shell.PrevImage");
-    tool_item->set_icon_name("go-previous-symbolic");
-    toolbar->append(*manage(tool_item));
-
-    tool_item = new Gtk::ToolButton();
-    gtk_actionable_set_action_name(GTK_ACTIONABLE(tool_item->gobj()),
-                                   "shell.NextImage");
-    tool_item->set_icon_name("go-next-symbolic");
-    toolbar->append(*manage(tool_item));
-
-    tool_item = new Gtk::ToolButton();
-    gtk_actionable_set_action_name(GTK_ACTIONABLE(tool_item->gobj()),
-                                   "shell.RotateLeft");
-    tool_item->set_icon_name("object-rotate-left-symbolic");
-    toolbar->append(*manage(tool_item));
-
-    tool_item = new Gtk::ToolButton();
-    gtk_actionable_set_action_name(GTK_ACTIONABLE(tool_item->gobj()),
-                                   "shell.RotateRight");
-    tool_item->set_icon_name("object-rotate-right-symbolic");
-    toolbar->append(*manage(tool_item));
-
-    m_vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
+    auto toolbar = ffi::image_toolbar_new();
+    gtk_box_pack_start(m_vbox.gobj(), GTK_WIDGET(toolbar), false, false, 0);
+
     m_dr_splitview.pack1(m_vbox, Gtk::EXPAND);
     m_dock = Gtk::manage(new fwk::Dock());
     m_dr_splitview.pack2(*m_dock, Gtk::SHRINK);
diff --git a/src/niepce/ui/gridviewmodule.cpp b/src/niepce/ui/gridviewmodule.cpp
index 63f595b..353ff83 100644
--- a/src/niepce/ui/gridviewmodule.cpp
+++ b/src/niepce/ui/gridviewmodule.cpp
@@ -24,6 +24,8 @@
 
 #include <exempi/xmpconsts.h>
 
+#include "rust_bindings.hpp"
+
 #include "fwk/base/debug.hpp"
 #include "fwk/toolkit/application.hpp"
 #include "fwk/toolkit/configdatabinder.hpp"
@@ -32,7 +34,6 @@
 #include "moduleshell.hpp"
 #include "librarycellrenderer.hpp"
 
-
 namespace ui {
 
 
@@ -121,7 +122,14 @@ Gtk::Widget * GridViewModule::buildWidget()
   m_scrollview.add(*m_librarylistview);
   m_scrollview.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
   m_lib_splitview.set_wide_handle(true);
-  m_lib_splitview.pack1(m_scrollview);
+
+  // build the toolbar
+  auto box = Gtk::manage(new Gtk::Box(Gtk::ORIENTATION_VERTICAL));
+  box->pack_start(m_scrollview);
+  auto toolbar = ffi::image_toolbar_new();
+  gtk_box_pack_end(box->gobj(), GTK_WIDGET(toolbar), false, false, 0);
+  m_lib_splitview.pack1(*box);
+
   m_dock = new fwk::Dock();
   m_metapanecontroller = MetaDataPaneController::Ptr(new MetaDataPaneController);
   m_metapanecontroller->signal_metadata_changed.connect(
diff --git a/src/niepce/ui/imagetoolbar.rs b/src/niepce/ui/imagetoolbar.rs
new file mode 100644
index 0000000..dd36713
--- /dev/null
+++ b/src/niepce/ui/imagetoolbar.rs
@@ -0,0 +1,59 @@
+/*
+ * niepce - ui/imagetoolbar.rs
+ *
+ * Copyright (C) 2018 Hubert Figuiere
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+use glib::translate::*;
+use gtk::prelude::*;
+use gtk;
+use gtk_sys;
+
+#[no_mangle]
+pub extern "C" fn image_toolbar_new() -> *mut gtk_sys::GtkToolbar {
+    let toolbar = gtk::Toolbar::new();
+
+    let icon = gtk::Image::new_from_icon_name(
+        "go-previous-symbolic", gtk::IconSize::SmallToolbar.into());
+    let tool_item = gtk::ToolButton::new(Some(&icon), None);
+    tool_item.set_action_name("shell.PrevImage");
+    toolbar.add(&tool_item);
+
+    let icon = gtk::Image::new_from_icon_name(
+        "go-next-symbolic", gtk::IconSize::SmallToolbar.into());
+    let tool_item = gtk::ToolButton::new(Some(&icon), None);
+    tool_item.set_action_name("shell.NextImage");
+    toolbar.add(&tool_item);
+
+    let separator = gtk::SeparatorToolItem::new();
+    toolbar.add(&separator);
+
+    let icon = gtk::Image::new_from_icon_name(
+        "object-rotate-left-symbolic", gtk::IconSize::SmallToolbar.into());
+    let tool_item = gtk::ToolButton::new(Some(&icon), None);
+    tool_item.set_action_name("shell.RotateLeft");
+    toolbar.add(&tool_item);
+
+    let icon = gtk::Image::new_from_icon_name(
+        "object-rotate-right-symbolic", gtk::IconSize::SmallToolbar.into());
+    let tool_item = gtk::ToolButton::new(Some(&icon), None);
+    tool_item.set_action_name("shell.RotateRight");
+    toolbar.add(&tool_item);
+
+
+    toolbar.to_glib_full()
+}
diff --git a/src/niepce/ui/mod.rs b/src/niepce/ui/mod.rs
index 3f3da9c..45d37c6 100644
--- a/src/niepce/ui/mod.rs
+++ b/src/niepce/ui/mod.rs
@@ -1,3 +1,4 @@
 
 
 pub mod dialogs;
+pub mod imagetoolbar;


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