[gnote] Pass IKeybinder as an argument to objects
- From: Aurimas Äernius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Pass IKeybinder as an argument to objects
- Date: Sat, 19 Jan 2013 16:47:49 +0000 (UTC)
commit 19f96c78f04e75e08c23927542b9a0dbb996ab0b
Author: Aurimas Äernius <aurisc4 gmail com>
Date: Sun Jan 6 19:02:27 2013 +0200
Pass IKeybinder as an argument to objects
Avoid call to Gnote method.
src/gnote.cpp | 2 +-
src/prefskeybinder.cpp | 14 +++++++++-----
src/prefskeybinder.hpp | 6 +++---
src/tray.cpp | 23 ++++++++++++-----------
src/tray.hpp | 10 ++++++----
5 files changed, 31 insertions(+), 24 deletions(-)
---
diff --git a/src/gnote.cpp b/src/gnote.cpp
index 39c2a77..30a4a1e 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -244,7 +244,7 @@ namespace gnote {
if(!m_tray_icon) {
// Create the tray icon and run the main loop
- m_tray_icon = Glib::RefPtr<TrayIcon>(new TrayIcon(default_note_manager()));
+ m_tray_icon = Glib::RefPtr<TrayIcon>(new TrayIcon(keybinder(), default_note_manager()));
m_tray = m_tray_icon->tray();
}
diff --git a/src/prefskeybinder.cpp b/src/prefskeybinder.cpp
index 731b5b3..c329956 100644
--- a/src/prefskeybinder.cpp
+++ b/src/prefskeybinder.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011-2012 Aurimas Cernius
+ * Copyright (C) 2011-2013 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -22,12 +22,14 @@
#include "debug.hpp"
#include "gnote.hpp"
+#include "keybinder.hpp"
#include "note.hpp"
#include "notemanager.hpp"
#include "notewindow.hpp"
#include "preferences.hpp"
#include "prefskeybinder.hpp"
#include "recentchanges.hpp"
+#include "tray.hpp"
#define KEYBINDING_SHOW_NOTE_MENU_DEFAULT "<Alt>F12"
@@ -112,8 +114,8 @@ namespace gnote {
}
- PrefsKeybinder::PrefsKeybinder()
- : m_native_keybinder(Gnote::obj().keybinder())
+ PrefsKeybinder::PrefsKeybinder(IKeybinder & keybinder)
+ : m_native_keybinder(keybinder)
{
}
@@ -142,8 +144,10 @@ namespace gnote {
}
- GnotePrefsKeybinder::GnotePrefsKeybinder(NoteManager & manager, IGnoteTray & trayicon)
- : m_manager(manager)
+ GnotePrefsKeybinder::GnotePrefsKeybinder(IKeybinder & keybinder,
+ NoteManager & manager, IGnoteTray & trayicon)
+ : PrefsKeybinder(keybinder)
+ , m_manager(manager)
, m_trayicon(trayicon)
{
Glib::RefPtr<Gio::Settings> settings = Preferences::obj()
diff --git a/src/prefskeybinder.hpp b/src/prefskeybinder.hpp
index 41d2881..81d13a2 100644
--- a/src/prefskeybinder.hpp
+++ b/src/prefskeybinder.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2011 Aurimas Cernius
+ * Copyright (C) 2011,2013 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -40,7 +40,7 @@ class IKeybinder;
class PrefsKeybinder : public sigc::trackable
{
public:
- PrefsKeybinder();
+ PrefsKeybinder(IKeybinder &);
virtual ~PrefsKeybinder();
void bind(const std::string & pref_path, const std::string & default_binding,
const sigc::slot<void> & handler);
@@ -57,7 +57,7 @@ class GnotePrefsKeybinder
: public PrefsKeybinder
{
public:
- GnotePrefsKeybinder(NoteManager & manager, IGnoteTray & trayicon);
+ GnotePrefsKeybinder(IKeybinder & keybinder, NoteManager & manager, IGnoteTray & trayicon);
void enable_keybindings_changed(const Glib::ustring & key);
void enable_disable(bool enable);
private:
diff --git a/src/tray.cpp b/src/tray.cpp
index ad0be9b..d450fd6 100644
--- a/src/tray.cpp
+++ b/src/tray.cpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2012 Aurimas Cernius
+ * Copyright (C) 2010-2013 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -195,10 +195,11 @@ namespace gnote {
return IconManager::obj().get_icon(IconManager::PIN_DOWN, 16);
}
- Tray::Tray(NoteManager & manager, IGnoteTray & trayicon)
+ Tray::Tray(NoteManager & manager, IGnoteTray & trayicon, IKeybinder & keybinder)
: m_manager(manager)
, m_trayicon(trayicon)
, m_menu_added(false)
+ , m_keybinder(keybinder)
{
m_tray_menu = make_tray_notes_menu();
@@ -218,15 +219,15 @@ namespace gnote {
if (enable_keybindings) {
Gtk::MenuItem *item = (Gtk::MenuItem*)am.get_widget("/TrayIconMenu/TrayNewNotePlaceholder/TrayNewNote");
if(item) {
- KeybindingToAccel::add_accelerator(*item, Preferences::KEYBINDING_CREATE_NEW_NOTE);
+ KeybindingToAccel::add_accelerator(m_keybinder, *item, Preferences::KEYBINDING_CREATE_NEW_NOTE);
}
item = (Gtk::MenuItem*)am.get_widget("/TrayIconMenu/ShowSearchAllNotes");
if(item) {
- KeybindingToAccel::add_accelerator(*item, Preferences::KEYBINDING_OPEN_RECENT_CHANGES);
+ KeybindingToAccel::add_accelerator(m_keybinder, *item, Preferences::KEYBINDING_OPEN_RECENT_CHANGES);
}
item = (Gtk::MenuItem*)am.get_widget("/TrayIconMenu/OpenStartHereNote");
if(item) {
- KeybindingToAccel::add_accelerator(*item, Preferences::KEYBINDING_OPEN_START_HERE);
+ KeybindingToAccel::add_accelerator(m_keybinder, *item, Preferences::KEYBINDING_OPEN_START_HERE);
}
}
@@ -367,7 +368,7 @@ namespace gnote {
bool enable_keybindings = Preferences::obj().get_schema_settings(
Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::ENABLE_KEYBINDINGS);
if (enable_keybindings) {
- KeybindingToAccel::add_accelerator(*item, Preferences::KEYBINDING_OPEN_START_HERE);
+ KeybindingToAccel::add_accelerator(m_keybinder, *item, Preferences::KEYBINDING_OPEN_START_HERE);
}
}
@@ -393,10 +394,10 @@ namespace gnote {
m_recent_notes.push_back(separator);
}
- TrayIcon::TrayIcon(NoteManager & manager)
+ TrayIcon::TrayIcon(IKeybinder & keybinder, NoteManager & manager)
: Gtk::StatusIcon()
- , m_tray(new Tray(manager, *this))
- , m_keybinder(new GnotePrefsKeybinder(manager, *this))
+ , m_tray(new Tray(manager, *this, keybinder))
+ , m_keybinder(new GnotePrefsKeybinder(keybinder, manager, *this))
, m_context_menu(NULL)
{
gtk_status_icon_set_tooltip_text(gobj(),
@@ -586,12 +587,12 @@ namespace gnote {
return "";
}
- void KeybindingToAccel::add_accelerator (Gtk::MenuItem & item, const std::string & key)
+ void KeybindingToAccel::add_accelerator(IKeybinder & keybinder, Gtk::MenuItem & item, const std::string & key)
{
guint keyval;
Gdk::ModifierType mods;
- if(Gnote::obj().keybinder().get_accel_keys(key, keyval, mods)) {
+ if(keybinder.get_accel_keys(key, keyval, mods)) {
item.add_accelerator ("activate",
get_accel_group(),
keyval,
diff --git a/src/tray.hpp b/src/tray.hpp
index 57d7a1a..29e797c 100644
--- a/src/tray.hpp
+++ b/src/tray.hpp
@@ -1,7 +1,7 @@
/*
* gnote
*
- * Copyright (C) 2010-2012 Aurimas Cernius
+ * Copyright (C) 2010-2013 Aurimas Cernius
* Copyright (C) 2009 Hubert Figuiere
*
* This program is free software: you can redistribute it and/or modify
@@ -26,6 +26,7 @@
#include <gtkmm/statusicon.h>
#include <gtkmm/imagemenuitem.h>
+#include "keybinder.hpp"
#include "note.hpp"
namespace gnote {
@@ -71,7 +72,7 @@ class Tray
{
public:
typedef std::tr1::shared_ptr<Tray> Ptr;
- Tray(NoteManager &, IGnoteTray &);
+ Tray(NoteManager &, IGnoteTray &, IKeybinder &);
Gtk::Menu * make_tray_notes_menu();
Gtk::Menu * tray_menu()
@@ -85,6 +86,7 @@ private:
Gtk::Menu *m_tray_menu;
bool m_menu_added;
std::list<Gtk::MenuItem*> m_recent_notes;
+ IKeybinder & m_keybinder;
};
@@ -93,7 +95,7 @@ class TrayIcon
, public IGnoteTray
{
public:
- TrayIcon(NoteManager & manager);
+ TrayIcon(IKeybinder & keybinder, NoteManager & manager);
~TrayIcon();
Tray::Ptr tray() const
@@ -124,7 +126,7 @@ class KeybindingToAccel
{
public:
static std::string get_shortcut (const std::string & key);
- static void add_accelerator (Gtk::MenuItem & item, const std::string & key);
+ static void add_accelerator(IKeybinder & keybinder, Gtk::MenuItem & item, const std::string & key);
static Glib::RefPtr<Gtk::AccelGroup> get_accel_group();
private:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]