[gnote] Make X conditional dependency
- From: Aurimas Černius <aurimasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnote] Make X conditional dependency
- Date: Fri, 5 Jul 2013 22:44:19 +0000 (UTC)
commit febe434f3c3461233ac0d956b083fcec20d8b86f
Author: Aurimas Černius <aurisc4 gmail com>
Date: Sat Jul 6 01:41:50 2013 +0300
Make X conditional dependency
Add configure option --with-x11-support.
When built without this option, X is not required to build and run, so
it's possible to run Gnote on environments like Wayland.
Makefile.am | 8 ++++++--
configure.ac | 6 ++++++
src/Makefile.am | 19 +++++++++++++------
src/gnote.cpp | 17 +++++++++++++++--
src/gnote.hpp | 11 +++++++++--
src/notewindow.cpp | 1 -
src/preferencesdialog.cpp | 2 ++
src/tray.cpp | 35 ++++++++++++++++++++++++++++++-----
src/tray.hpp | 22 ++++++++++++++++++++--
src/utils.hpp | 7 +++++++
10 files changed, 108 insertions(+), 20 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index d2c82d7..8dfacc0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,9 +11,13 @@ DISTCLEANFILES = intltool-extract \
intltool-update \
po/.intltool-merge-cache
-SUBDIRS = data libtomboy src po help
+if HAVE_X11_SUPPORT
+LIBTOMBOYDIR = libtomboy
+endif
-DISTCHECK_CONFIGURE_FLAGS = --disable-schemas-install --disable-scrollkeeper
+SUBDIRS = data $(LIBTOMBOYDIR) src po help
+
+DISTCHECK_CONFIGURE_FLAGS = --disable-schemas-install --disable-scrollkeeper --with-x11-support
# Ignore scrollkeeper issues for now. @#*$& scrollkeeper (from Evince)
diff --git a/configure.ac b/configure.ac
index fffd307..da6ec37 100644
--- a/configure.ac
+++ b/configure.ac
@@ -131,6 +131,11 @@ else
fi
AC_SUBST(DBUS_SERVICE_DIR)
+AC_ARG_WITH(x11_support, [ --with-x11-support Compile with X11 support.],
+ [with_x11_support=yes;AC_DEFINE(HAVE_X11_SUPPORT, [1], [Define to 1 to include X11 support.])],
+ [with_x11_support=no])
+AM_CONDITIONAL(HAVE_X11_SUPPORT, test "x$with_x11_support" != "x")
+
IT_PROG_INTLTOOL([0.35.0])
@@ -186,5 +191,6 @@ echo "
Options:
Spellchecking support: ${FIXED_GTKSPELL}
+ X11 support: ${with_x11_support}
"
diff --git a/src/Makefile.am b/src/Makefile.am
index 82fc378..f31985c 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -2,8 +2,7 @@
SUBDIRS = addins
-INCLUDES = -I$(top_srcdir)
-AM_CPPFLAGS= LIBGTKMM_CFLAGS@ @LIBGLIBMM_CFLAGS@ \
+AM_CPPFLAGS= -I$(top_srcdir) @LIBGTKMM_CFLAGS@ @LIBGLIBMM_CFLAGS@ \
@GTK_CFLAGS@ \
@GTKSPELL_CFLAGS@ @LIBXML_CFLAGS@ \
@LIBXSLT_CFLAGS@ \
@@ -14,7 +13,11 @@ AM_CPPFLAGS= LIBGTKMM_CFLAGS@ @LIBGLIBMM_CFLAGS@ \
AM_LDFLAGS=-export-dynamic
-LIBGNOTE_LIBS = $(top_builddir)/libtomboy/libtomboy.la \
+if HAVE_X11_SUPPORT
+LIBTOMBOY_LIBS = $(top_builddir)/libtomboy/libtomboy.la
+endif
+
+LIBGNOTE_LIBS = $(LIBTOMBOY_LIBS)\
@LIBGLIBMM_LIBS@ @LIBGTKMM_LIBS@ \
@LIBXSLT_LIBS@ \
@GTKSPELL_LIBS@ @GTK_LIBS@ \
@@ -65,6 +68,12 @@ DBUS_SOURCES=remotecontrolproxy.hpp remotecontrolproxy.cpp \
dbus/searchprovider.hpp dbus/searchprovider.cpp \
$(NULL)
+if HAVE_X11_SUPPORT
+KEYBINDER_SOURCES=keybinder.hpp \
+ prefskeybinder.hpp prefskeybinder.cpp \
+ xkeybinder.hpp xkeybinder.cpp
+endif
+
libgnote_la_LDFLAGS = -release @LIBGNOTE_RELEASE@ -version-info @LIBGNOTE_VERSION_INFO@
libgnote_la_LIBADD = $(LIBGNOTE_LIBS)
libgnote_la_SOURCES = \
@@ -148,20 +157,18 @@ gnote_SOURCES = \
sharp/addinstreemodel.hpp sharp/addinstreemodel.cpp \
actionmanager.hpp actionmanager.cpp \
gnote.cpp gnote.hpp \
- keybinder.hpp \
preferencesdialog.hpp preferencesdialog.cpp \
- prefskeybinder.hpp prefskeybinder.cpp \
recentchanges.hpp recentchanges.cpp \
searchnoteswidget.hpp searchnoteswidget.cpp \
tagmanager.hpp tagmanager.cpp \
tray.hpp tray.cpp \
- xkeybinder.hpp xkeybinder.cpp \
notebooks/notebookstreeview.hpp notebooks/notebookstreeview.cpp \
synchronization/gnotesyncclient.hpp synchronization/gnotesyncclient.cpp \
synchronization/silentui.hpp synchronization/silentui.cpp \
synchronization/syncdialog.hpp synchronization/syncdialog.cpp \
synchronization/syncmanager.hpp synchronization/syncmanager.cpp \
$(DBUS_SOURCES) \
+ $(KEYBINDER_SOURCES) \
main.cpp \
$(NULL)
diff --git a/src/gnote.cpp b/src/gnote.cpp
index 37ebede..a852a48 100644
--- a/src/gnote.cpp
+++ b/src/gnote.cpp
@@ -49,7 +49,6 @@
#include "remotecontrolproxy.hpp"
#include "utils.hpp"
#include "tagmanager.hpp"
-#include "xkeybinder.hpp"
#include "dbus/remotecontrol.hpp"
#include "dbus/remotecontrolclient.hpp"
#include "sharp/streamreader.hpp"
@@ -57,15 +56,21 @@
#include "notebooks/notebookmanager.hpp"
#include "synchronization/syncmanager.hpp"
+#ifdef HAVE_X11_SUPPORT
+#include "xkeybinder.hpp"
+#endif
+
namespace gnote {
Gnote::Gnote()
: Gtk::Application("org.gnome.Gnote", Gio::APPLICATION_HANDLES_COMMAND_LINE)
, m_manager(NULL)
- , m_keybinder(NULL)
, m_is_background(false)
, m_prefsdlg(NULL)
+#ifdef HAVE_X11_SUPPORT
+ , m_keybinder(NULL)
+#endif
{
}
@@ -73,7 +78,9 @@ namespace gnote {
{
delete m_prefsdlg;
delete m_manager;
+#ifdef HAVE_X11_SUPPORT
delete m_keybinder;
+#endif
}
@@ -151,7 +158,9 @@ namespace gnote {
new Preferences;
m_manager = new NoteManager(note_path);
new notebooks::NotebookManager(default_note_manager());
+#ifdef HAVE_X11_SUPPORT
m_keybinder = new XKeybinder();
+#endif
new ActionManager;
sync::SyncManager::init(default_note_manager());
@@ -244,7 +253,11 @@ namespace gnote {
if(!m_tray_icon) {
// Create the tray icon and run the main loop
+#ifdef HAVE_X11_SUPPORT
m_tray_icon = Glib::RefPtr<TrayIcon>(new TrayIcon(keybinder(), default_note_manager()));
+#else
+ m_tray_icon = Glib::RefPtr<TrayIcon>(new TrayIcon(default_note_manager()));
+#endif
m_tray = m_tray_icon->tray();
}
diff --git a/src/gnote.hpp b/src/gnote.hpp
index 8a16da8..2a1a402 100644
--- a/src/gnote.hpp
+++ b/src/gnote.hpp
@@ -33,11 +33,14 @@
#include "actionmanager.hpp"
#include "ignote.hpp"
-#include "keybinder.hpp"
#include "remotecontrolproxy.hpp"
#include "tray.hpp"
#include "synchronization/syncdialog.hpp"
+#ifdef HAVE_X11_SUPPORT
+#include "keybinder.hpp"
+#endif
+
namespace gnote {
class PreferencesDialog;
@@ -113,10 +116,12 @@ public:
{
return *m_manager;
}
+#ifdef HAVE_X11_SUPPORT
IKeybinder & keybinder()
{
return *m_keybinder;
}
+#endif
void setup_global_actions();
void start_tray_icon();
@@ -172,7 +177,6 @@ private:
void register_object();
NoteManager *m_manager;
- IKeybinder *m_keybinder;
Glib::RefPtr<Gtk::IconTheme> m_icon_theme;
Glib::RefPtr<TrayIcon> m_tray_icon;
Tray::Ptr m_tray;
@@ -180,6 +184,9 @@ private:
PreferencesDialog *m_prefsdlg;
GnoteCommandLine cmd_line;
sync::SyncDialog::Ptr m_sync_dlg;
+#ifdef HAVE_X11_SUPPORT
+ IKeybinder *m_keybinder;
+#endif
};
diff --git a/src/notewindow.cpp b/src/notewindow.cpp
index 436e91c..b05d85b 100644
--- a/src/notewindow.cpp
+++ b/src/notewindow.cpp
@@ -29,7 +29,6 @@
#include <gtkmm/separatortoolitem.h>
#include <gtkmm/separatormenuitem.h>
-#include "libtomboy/tomboyutil.h"
#include "debug.hpp"
#include "iconmanager.hpp"
#include "note.hpp"
diff --git a/src/preferencesdialog.cpp b/src/preferencesdialog.cpp
index 4bd5c74..382b69f 100644
--- a/src/preferencesdialog.cpp
+++ b/src/preferencesdialog.cpp
@@ -120,8 +120,10 @@ namespace gnote {
notebook->append_page (*manage(make_editing_pane()),
_("General"));
+#ifdef HAVE_X11_SUPPORT
notebook->append_page (*manage(make_hotkeys_pane()),
_("Hotkeys"));
+#endif
// }
notebook->append_page(*manage(make_sync_pane()),
_("Synchronization"));
diff --git a/src/tray.cpp b/src/tray.cpp
index f26504c..cf34a3d 100644
--- a/src/tray.cpp
+++ b/src/tray.cpp
@@ -52,14 +52,16 @@ namespace gnote {
std::string tray_util_get_tooltip_text()
{
std::string tip_text = _("Take notes");
-
+
+#ifdef HAVE_X11_SUPPORT
if (Preferences::obj().get_schema_settings(
Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::ENABLE_KEYBINDINGS)) {
std::string shortcut = KeybindingToAccel::get_shortcut(Preferences::KEYBINDING_SHOW_NOTE_MENU);
if (!shortcut.empty())
tip_text += str(boost::format(" (%1%)") % shortcut);
}
-
+#endif
+
return tip_text;
}
@@ -196,15 +198,24 @@ namespace gnote {
return IconManager::obj().get_icon(IconManager::PIN_DOWN, 16);
}
+#ifdef HAVE_X11_SUPPORT
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();
}
+#else
+ Tray::Tray(NoteManager & manager, IGnoteTray & trayicon)
+ : m_manager(manager)
+ , m_trayicon(trayicon)
+ , m_menu_added(false)
+ {
+ m_tray_menu = make_tray_notes_menu();
+ }
+#endif
Gtk::Menu * Tray::make_tray_notes_menu()
{
@@ -228,13 +239,15 @@ namespace gnote {
m_search_notes_item->signal_activate()
.connect(sigc::mem_fun(*this, &Tray::on_search_notes_activate));
menu->insert(*m_search_notes_item, -1);
-
+
+#ifdef HAVE_X11_SUPPORT
bool enable_keybindings = Preferences::obj().get_schema_settings(
Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::ENABLE_KEYBINDINGS);
if (enable_keybindings) {
KeybindingToAccel::add_accelerator(m_keybinder, *m_new_note_item,
Preferences::KEYBINDING_CREATE_NEW_NOTE);
KeybindingToAccel::add_accelerator(m_keybinder, *m_search_notes_item,
Preferences::KEYBINDING_OPEN_RECENT_CHANGES);
}
+#endif
return menu;
}
@@ -322,11 +335,13 @@ namespace gnote {
m_tray_menu->insert(*item, -1);
list_size++;
+#ifdef HAVE_X11_SUPPORT
bool enable_keybindings = Preferences::obj().get_schema_settings(
Preferences::SCHEMA_GNOTE)->get_boolean(Preferences::ENABLE_KEYBINDINGS);
if (enable_keybindings) {
KeybindingToAccel::add_accelerator(m_keybinder, *item, Preferences::KEYBINDING_OPEN_START_HERE);
}
+#endif
}
bool menuOpensUpward = m_trayicon.menu_opens_upward();
@@ -360,11 +375,18 @@ namespace gnote {
}
+#ifdef HAVE_X11_SUPPORT
TrayIcon::TrayIcon(IKeybinder & keybinder, NoteManager & manager)
: Gtk::StatusIcon()
, m_tray(new Tray(manager, *this, keybinder))
+ , m_context_menu(NULL)
, m_keybinder(new GnotePrefsKeybinder(keybinder, manager, *this))
+#else
+ TrayIcon::TrayIcon(NoteManager & manager)
+ : Gtk::StatusIcon()
+ , m_tray(new Tray(manager, *this))
, m_context_menu(NULL)
+#endif
{
gtk_status_icon_set_tooltip_text(gobj(),
tray_util_get_tooltip_text().c_str());
@@ -391,7 +413,9 @@ namespace gnote {
TrayIcon::~TrayIcon()
{
delete m_context_menu;
+#ifdef HAVE_X11_SUPPORT
delete m_keybinder;
+#endif
}
void TrayIcon::on_activate()
@@ -511,6 +535,7 @@ namespace gnote {
return Gtk::StatusIcon::on_size_changed(size);
}
+#ifdef HAVE_X11_SUPPORT
//
// This is a helper to take the XKeybinding string from GConf, and
// convert it to a widget accelerator label, so note menu items can
@@ -566,6 +591,6 @@ namespace gnote {
Gtk::ACCEL_VISIBLE);
}
}
-
+#endif
}
diff --git a/src/tray.hpp b/src/tray.hpp
index 30dd0fd..3381ede 100644
--- a/src/tray.hpp
+++ b/src/tray.hpp
@@ -26,9 +26,12 @@
#include <gtkmm/statusicon.h>
#include <gtkmm/imagemenuitem.h>
-#include "keybinder.hpp"
#include "note.hpp"
+#ifdef HAVE_X11_SUPPORT
+#include "keybinder.hpp"
+#endif
+
namespace gnote {
class TrayIcon;
@@ -72,7 +75,11 @@ class Tray
{
public:
typedef std::tr1::shared_ptr<Tray> Ptr;
+#ifdef HAVE_X11_SUPPORT
Tray(NoteManager &, IGnoteTray &, IKeybinder &);
+#else
+ Tray(NoteManager &, IGnoteTray &);
+#endif
Gtk::Menu * make_tray_notes_menu();
Gtk::Menu * tray_menu()
@@ -89,7 +96,9 @@ private:
Gtk::ImageMenuItem *m_new_note_item;
Gtk::ImageMenuItem *m_search_notes_item;
bool m_menu_added;
+#ifdef HAVE_X11_SUPPORT
IKeybinder & m_keybinder;
+#endif
};
@@ -98,7 +107,11 @@ class TrayIcon
, public IGnoteTray
{
public:
+#ifdef HAVE_X11_SUPPORT
TrayIcon(IKeybinder & keybinder, NoteManager & manager);
+#else
+ explicit TrayIcon(NoteManager & manager);
+#endif
~TrayIcon();
Tray::Ptr tray() const
@@ -121,10 +134,14 @@ protected:
virtual bool on_size_changed(int size);
private:
Tray::Ptr m_tray;
- PrefsKeybinder *m_keybinder;
Gtk::Menu *m_context_menu;
+#ifdef HAVE_X11_SUPPORT
+ PrefsKeybinder *m_keybinder;
+#endif
};
+
+#ifdef HAVE_X11_SUPPORT
class KeybindingToAccel
{
public:
@@ -135,6 +152,7 @@ public:
private:
static Glib::RefPtr<Gtk::AccelGroup> s_accel_group;
};
+#endif
diff --git a/src/utils.hpp b/src/utils.hpp
index 9c191d4..3f4a253 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -40,7 +40,10 @@
#include "sharp/exception.hpp"
#include "sharp/uri.hpp"
+
+#ifdef HAVE_X11_SUPPORT
#include "libtomboy/tomboyutil.h"
+#endif
namespace sharp {
class DateTime;
@@ -220,7 +223,11 @@ namespace gnote {
void present()
{
+#ifdef HAVE_X11_SUPPORT
::tomboy_window_present_hardcore(GTK_WINDOW(gobj()));
+#else
+ Gtk::ApplicationWindow::present();
+#endif
}
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]