[gnote] Update replace title addin for popover



commit aee634da9cc77f7242afa88657e0ca5ab4221a52
Author: Aurimas Černius <aurisc4 gmail com>
Date:   Sun Jan 3 22:02:36 2016 +0200

    Update replace title addin for popover

 src/addins/replacetitle/replacetitle.desktop.in.in |    4 +-
 src/addins/replacetitle/replacetitlenoteaddin.cpp  |   46 +++++---------------
 src/addins/replacetitle/replacetitlenoteaddin.hpp  |    6 +-
 3 files changed, 17 insertions(+), 39 deletions(-)
---
diff --git a/src/addins/replacetitle/replacetitle.desktop.in.in 
b/src/addins/replacetitle/replacetitle.desktop.in.in
index ba9524d..251bdcb 100644
--- a/src/addins/replacetitle/replacetitle.desktop.in.in
+++ b/src/addins/replacetitle/replacetitle.desktop.in.in
@@ -4,8 +4,10 @@ _Name=Replace title
 _Description=Replace title with selection.
 _Authors=Pierre-Yves Luyten
 Category=Tools
-Version=0.2
+Version=0.3
 DefaultEnabled=true
 Module=replacetitle
 LibgnoteRelease= LIBGNOTE_RELEASE@
 LibgnoteVersionInfo= LIBGNOTE_VERSION_INFO@
+[Actions]
+actions_void=replacetitle-replace
diff --git a/src/addins/replacetitle/replacetitlenoteaddin.cpp 
b/src/addins/replacetitle/replacetitlenoteaddin.cpp
index 63d8875..4ac3431 100644
--- a/src/addins/replacetitle/replacetitlenoteaddin.cpp
+++ b/src/addins/replacetitle/replacetitlenoteaddin.cpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2013 Aurimas Cernius
+ * Copyright (C) 2011-2013,2016 Aurimas Cernius
  *
  * 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
@@ -18,7 +18,6 @@
  */
 
 #include <glibmm/i18n.h>
-#include <gtkmm/stock.h>
 #include <gtkmm/clipboard.h>
 
 #include "iactionmanager.hpp"
@@ -28,35 +27,6 @@
 
 namespace replacetitle {
 
-  namespace {
-    class ReplaceTitleAction
-      : public Gtk::Action
-    {
-    public:
-      static Glib::RefPtr<Gtk::Action> create(gnote::NoteWindow *note_window)
-        {
-          return Glib::RefPtr<Gtk::Action>(new ReplaceTitleAction(note_window));
-        }
-    protected:
-      virtual Gtk::Widget *create_menu_item_vfunc()
-        {
-          Gtk::ImageMenuItem *menu_item = new Gtk::ImageMenuItem;
-          menu_item->add_accelerator("activate", m_note_window->get_accel_group(),
-                                     GDK_KEY_R, Gdk::CONTROL_MASK, Gtk::ACCEL_VISIBLE);
-          return menu_item;
-        }
-    private:
-      ReplaceTitleAction(gnote::NoteWindow *note_window)
-        : Gtk::Action("ReplaceTitleAction", Gtk::Stock::FIND_AND_REPLACE,
-                      _("Replace title"), _("Replace title"))
-        , m_note_window(note_window)
-        {}
-
-      gnote::NoteWindow *m_note_window;
-    };
-  }
-
-
 ReplaceTitleModule::ReplaceTitleModule()
 {
   ADD_INTERFACE_IMPL(ReplaceTitleNoteAddin);
@@ -73,13 +43,19 @@ void ReplaceTitleNoteAddin::shutdown()
 
 void ReplaceTitleNoteAddin::on_note_opened()
 {
-  Glib::RefPtr<Gtk::Action> action = ReplaceTitleAction::create(get_window());
-  action->signal_activate().connect(
+  register_main_window_action_callback("replacetitle-replace",
     sigc::mem_fun(*this, &ReplaceTitleNoteAddin::replacetitle_button_clicked));
-  add_note_action(action, gnote::REPLACE_TITLE_ORDER);
 }
 
-void ReplaceTitleNoteAddin::replacetitle_button_clicked()
+std::map<int, Gtk::Widget*> ReplaceTitleNoteAddin::get_actions_popover_widgets() const
+{
+  auto widgets = NoteAddin::get_actions_popover_widgets();
+  auto button = gnote::utils::create_popover_button("win.replacetitle-replace", _("Replace title"));
+  gnote::utils::add_item_to_ordered_map(widgets, gnote::REPLACE_TITLE_ORDER, button);
+  return widgets;
+}
+
+void ReplaceTitleNoteAddin::replacetitle_button_clicked(const Glib::VariantBase&)
 {
   // unix primary clipboard
   Glib::RefPtr<Gtk::Clipboard> refClipboard = Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
diff --git a/src/addins/replacetitle/replacetitlenoteaddin.hpp 
b/src/addins/replacetitle/replacetitlenoteaddin.hpp
index fed905d..1e2443f 100644
--- a/src/addins/replacetitle/replacetitlenoteaddin.hpp
+++ b/src/addins/replacetitle/replacetitlenoteaddin.hpp
@@ -1,7 +1,7 @@
 /*
  * gnote
  *
- * Copyright (C) 2011-2013 Aurimas Cernius
+ * Copyright (C) 2011-2013,2016 Aurimas Cernius
  *
  * 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
@@ -21,7 +21,6 @@
 #ifndef _REPLACETITLE_ADDIN_HPP_
 #define _REPLACETITLE_ADDIN_HPP_
 
-#include "base/macros.hpp"
 #include "sharp/dynamicmodule.hpp"
 #include "note.hpp"
 #include "noteaddin.hpp"
@@ -48,8 +47,9 @@ public:
   virtual void initialize() override;
   virtual void shutdown() override;
   virtual void on_note_opened() override;
+  virtual std::map<int, Gtk::Widget*> get_actions_popover_widgets() const override;
 private:
-  void replacetitle_button_clicked();
+  void replacetitle_button_clicked(const Glib::VariantBase&);
 };
 
 


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