summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Karapetsas <[email protected]>2014-01-30 15:58:17 +0100
committerStefano Karapetsas <[email protected]>2014-01-30 15:58:17 +0100
commitc8a85a6aa040c1d2505b957af4cfb4bd39466504 (patch)
tree1d60e06e4504a25bf00918a3ee81e847af72bce1
parentd15349379583695063e692010bdb44e9974c3f18 (diff)
downloadmate-applets-c8a85a6aa040c1d2505b957af4cfb4bd39466504.tar.bz2
mate-applets-c8a85a6aa040c1d2505b957af4cfb4bd39466504.tar.xz
stickynotes: Add undo/redo feature
Using GtkSourceView instead of GtkTextView This adds new dependency to package to build this applet Closes #17 https://github.com/mate-desktop/mate-applets/issues/17
-rw-r--r--configure.ac11
-rw-r--r--stickynotes/Makefile.am2
-rw-r--r--stickynotes/stickynotes.c10
-rw-r--r--stickynotes/stickynotes.h9
-rw-r--r--stickynotes/stickynotes.ui6
5 files changed, 34 insertions, 4 deletions
diff --git a/configure.ac b/configure.ac
index 1e5e882c..02318101 100644
--- a/configure.ac
+++ b/configure.ac
@@ -432,9 +432,14 @@ AM_CONDITIONAL(BUILD_BATTSTAT_APPLET, test x$build_battstat_applet = xyes)
dnl ***************************************************************************
dnl *** Stickynotes specific checks ***
dnl ***************************************************************************
-# AC_ARG_ENABLE(stickynotes, [ --enable-stickynotes build stickynotes
-# [@<:@default: no, transparent upgrade to Tomboy@:>@]], enable_stickynotes="yes", enable_stickynotes="no")
-enable_stickynotes="yes"
+AC_ARG_ENABLE([stickynotes],
+ AC_HELP_STRING([--enable-stickynotes], [Enable stickynotes applet.]),
+ enable_stickynotes=$enableval,
+ enable_stickynotes=yes)
+if test "x$enable_stickynotes" = "xyes"; then
+ PKG_CHECK_MODULES(STICKYNOTES, gtksourceview-$GTK_API_VERSION,
+ enable_stickynotes=yes, enable_stickynotes=no)
+fi
AM_CONDITIONAL(BUILD_STICKYNOTES_APPLET, test "x$enable_stickynotes" = "xyes")
dnl ***************************************************************************
diff --git a/stickynotes/Makefile.am b/stickynotes/Makefile.am
index 1444451f..df6f8292 100644
--- a/stickynotes/Makefile.am
+++ b/stickynotes/Makefile.am
@@ -12,6 +12,7 @@ if BUILD_STICKYNOTES_APPLET
AM_CPPFLAGS = \
-I. \
-I$(srcdir) \
+ $(STICKYNOTES_CFLAGS) \
$(MATE_APPLETS4_CFLAGS) \
$(LIBWNCK_CFLAGS) \
$(XML2_CFLAGS) \
@@ -33,6 +34,7 @@ stickynotes_applet_SOURCES = \
stickynotes_applet_callbacks.c
stickynotes_applet_LDADD = \
+ $(STICKYNOTES_LIBS) \
$(MATE_APPLETS4_LIBS) \
$(LIBWNCK_LIBS) \
$(XML2_LIBS) \
diff --git a/stickynotes/stickynotes.c b/stickynotes/stickynotes.c
index d38aee3f..bb80dcf3 100644
--- a/stickynotes/stickynotes.c
+++ b/stickynotes/stickynotes.c
@@ -21,10 +21,18 @@
#include <libxml/parser.h>
#include <X11/Xatom.h>
#include <gdk/gdkx.h>
+#include <gtk/gtk.h>
#define WNCK_I_KNOW_THIS_IS_UNSTABLE 1
#include <libwnck/libwnck.h>
#include <string.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gtksourceview/gtksource.h>
+#else
+#include <gtksourceview/gtksourceview.h>
+#include <gtksourceview/gtksourcebuffer.h>
+#endif
+
#include "stickynotes.h"
#include "stickynotes_callbacks.h"
#include "util.h"
@@ -122,6 +130,8 @@ stickynote_new_aux (GdkScreen *screen, gint x, gint y, gint w, gint h)
note->w_lock = GTK_WIDGET (gtk_builder_get_object (builder, "lock_button"));
gtk_widget_add_events (note->w_lock, GDK_BUTTON_PRESS_MASK);
+ note->buffer = GTK_SOURCE_BUFFER(gtk_text_view_get_buffer(GTK_TEXT_VIEW(note->w_body)));
+
note->w_close = GTK_WIDGET (gtk_builder_get_object (builder, "close_button"));
gtk_widget_add_events (note->w_close, GDK_BUTTON_PRESS_MASK);
note->w_resize_se = GTK_WIDGET (gtk_builder_get_object (builder, "resize_se_box"));
diff --git a/stickynotes/stickynotes.h b/stickynotes/stickynotes.h
index 4073c42e..85574df1 100644
--- a/stickynotes/stickynotes.h
+++ b/stickynotes/stickynotes.h
@@ -24,6 +24,13 @@
#include <libwnck/libwnck.h>
#include <stickynotes_applet.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gtksourceview/gtksource.h>
+#else
+#include <gtksourceview/gtksourceview.h>
+#include <gtksourceview/gtksourcebuffer.h>
+#endif
+
typedef struct
{
GtkWidget *w_window; /* Sticky Note window */
@@ -48,6 +55,8 @@ typedef struct
GtkWidget *w_resize_se; /* Sticky Note resize button (south east) */
GtkWidget *w_resize_sw; /* Sticky Note resize button (south west) */
+ GtkSourceBuffer *buffer; /* Sticky Note text buffer for undo/redo */
+
GtkToggleAction *ta_lock_toggle_item; /* Lock item in the popup menu */
GtkImage *img_lock; /* Lock image */
diff --git a/stickynotes/stickynotes.ui b/stickynotes/stickynotes.ui
index 14bcdf3f..cc98a1e4 100644
--- a/stickynotes/stickynotes.ui
+++ b/stickynotes/stickynotes.ui
@@ -775,6 +775,9 @@
<action-widget response="-5">button4</action-widget>
</action-widgets>
</object>
+ <object class="GtkSourceBuffer" id="body_buffer">
+ <property name="max_undo_levels">-1</property>
+ </object>
<object class="GtkWindow" id="stickynote_window">
<property name="title" translatable="yes">Sticky Note</property>
<child>
@@ -846,12 +849,13 @@
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">never</property>
<child>
- <object class="GtkTextView" id="body_text">
+ <object class="GtkSourceView" id="body_text">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="wrap_mode">word</property>
<property name="left_margin">4</property>
<property name="right_margin">4</property>
+ <property name="buffer">body_buffer</property>
</object>
</child>
</object>