[glom/glom-1-20] Add simple clipboard handlers to App_WithDoc_Gtk



commit 1539ae43a1a7523fe7d747f5bfa5393cd454ce5c
Author: David King <davidk openismus com>
Date:   Fri Dec 23 14:13:31 2011 +0100

    Add simple clipboard handlers to App_WithDoc_Gtk
    
    * glom/bakery/app_withdoc_gtk.[cc|h]: Add simple clipboard handlers to
    fix bug 518315.

 ChangeLog                      |    7 +++++++
 glom/bakery/app_withdoc_gtk.cc |   37 ++++++++++++++++++++++++++++++++++---
 glom/bakery/app_withdoc_gtk.h  |    3 +++
 3 files changed, 44 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 10a75e1..214613c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-12-27  David King  <davidk openismus com>
+
+	Add simple clipboard handlers to App_WithDoc_Gtk
+
+	* glom/bakery/app_withdoc_gtk.[cc|h]: Add simple clipboard handlers to
+	fix bug 518315.
+
 2011-12-24  Murray Cumming  <murrayc murrayc com>
 
 	Choices: Make sure related choices are sorted.
diff --git a/glom/bakery/app_withdoc_gtk.cc b/glom/bakery/app_withdoc_gtk.cc
index d4ca478..1e3f14d 100644
--- a/glom/bakery/app_withdoc_gtk.cc
+++ b/glom/bakery/app_withdoc_gtk.cc
@@ -25,6 +25,7 @@
 #include <gtkmm/recentchoosermenu.h>
 #include <gtkmm/messagedialog.h>
 #include <gtkmm/filechooserdialog.h>
+#include <gtkmm/editable.h>
 #include <giomm/file.h>
 #include <algorithm>
 #include <iostream>
@@ -281,9 +282,12 @@ void App_WithDoc_Gtk::init_menus_edit()
   m_refEditActionGroup = ActionGroup::create("BakeryEditActions");
   m_refEditActionGroup->add(Action::create("BakeryAction_Menu_Edit", _("_Edit")));
   
-  m_refEditActionGroup->add(Action::create("BakeryAction_Edit_Cut", Gtk::Stock::CUT));
-  m_refEditActionGroup->add(Action::create("BakeryAction_Edit_Copy", Gtk::Stock::COPY));
-  m_refEditActionGroup->add(Action::create("BakeryAction_Edit_Paste", Gtk::Stock::PASTE));
+  m_refEditActionGroup->add(Action::create("BakeryAction_Edit_Cut", Gtk::Stock::CUT),
+                        sigc::mem_fun((App_WithDoc_Gtk&)*this, &App_WithDoc_Gtk::on_menu_edit_cut_activate));
+  m_refEditActionGroup->add(Action::create("BakeryAction_Edit_Copy", Gtk::Stock::COPY),
+                        sigc::mem_fun((App_WithDoc_Gtk&)*this, &App_WithDoc_Gtk::on_menu_edit_copy_activate));
+  m_refEditActionGroup->add(Action::create("BakeryAction_Edit_Paste", Gtk::Stock::PASTE),
+                        sigc::mem_fun((App_WithDoc_Gtk&)*this, &App_WithDoc_Gtk::on_menu_edit_paste_activate));
   m_refEditActionGroup->add(Action::create("BakeryAction_Edit_Clear", Gtk::Stock::CLEAR));
 
   m_refUIManager->insert_action_group(m_refEditActionGroup);
@@ -567,6 +571,33 @@ void App_WithDoc_Gtk::document_history_remove(const Glib::ustring& file_uri)
   }
 }
 
+void App_WithDoc_Gtk::on_menu_edit_copy_activate()
+{
+  GtkEditable* editable_gobj = (GtkEditable *)this->get_focus()->gobj();
+  Glib::RefPtr<Gtk::Editable> editable = Glib::RefPtr<Gtk::Editable>::cast_dynamic(Glib::wrap(editable_gobj, true));
+
+  if(editable)
+    editable->copy_clipboard();
+}
+
+void App_WithDoc_Gtk::on_menu_edit_cut_activate()
+{
+  GtkEditable* editable_gobj = (GtkEditable *)this->get_focus()->gobj();
+  Glib::RefPtr<Gtk::Editable> editable = Glib::RefPtr<Gtk::Editable>::cast_dynamic(Glib::wrap(editable_gobj, true));
+
+  if(editable)
+    editable->cut_clipboard();
+}
+
+void App_WithDoc_Gtk::on_menu_edit_paste_activate()
+{
+  GtkEditable* editable_gobj = (GtkEditable *)this->get_focus()->gobj();
+  Glib::RefPtr<Gtk::Editable> editable = Glib::RefPtr<Gtk::Editable>::cast_dynamic(Glib::wrap(editable_gobj, true));
+
+  if(editable)
+    editable->paste_clipboard();
+}
+
 void App_WithDoc_Gtk::on_recent_files_activate(Gtk::RecentChooser& chooser)
 {
   const Glib::ustring uri = chooser.get_current_uri();
diff --git a/glom/bakery/app_withdoc_gtk.h b/glom/bakery/app_withdoc_gtk.h
index a1e80a2..5f70b8f 100644
--- a/glom/bakery/app_withdoc_gtk.h
+++ b/glom/bakery/app_withdoc_gtk.h
@@ -103,6 +103,9 @@ protected:
 
   virtual bool on_delete_event(GdkEventAny* event); //override
 
+  void on_menu_edit_copy_activate();
+  void on_menu_edit_cut_activate();
+  void on_menu_edit_paste_activate();
   void on_recent_files_activate(Gtk::RecentChooser& recent_chooser);
 
   //UIManager and Actions



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