aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bzrignore2
-rw-r--r--libindicator/indicator-object.c35
-rw-r--r--libindicator/indicator-object.h2
-rw-r--r--tests/Makefile.am26
-rw-r--r--tests/dummy-indicator-entry-func.c130
-rw-r--r--tests/dummy-indicator-entry-func.h56
-rw-r--r--tests/test-loader.c74
7 files changed, 323 insertions, 2 deletions
diff --git a/.bzrignore b/.bzrignore
index 0874106..7da05f5 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -179,3 +179,5 @@ libindicator/libindicator3_la-gen-indicator-service.xml.lo
tools/indicator-loader3
libindicator-[0-9]*.[0-9]*.[0-9]*
build-aux
+libdummy_indicator_entry_func_la-dummy-indicator-entry-func.lo
+libdummy-indicator-entry-func.la
diff --git a/libindicator/indicator-object.c b/libindicator/indicator-object.c
index bd056f0..7a3e393 100644
--- a/libindicator/indicator-object.c
+++ b/libindicator/indicator-object.c
@@ -99,6 +99,10 @@ indicator_object_class_init (IndicatorObjectClass *klass)
klass->get_entries = get_entries_default;
klass->get_location = NULL;
+ klass->entry_activate = NULL;
+ klass->entry_activate_window = NULL;
+ klass->entry_close = NULL;
+
/**
IndicatorObject::entry-added:
@arg0: The #IndicatorObject object
@@ -539,6 +543,37 @@ indicator_object_get_show_now (IndicatorObject * io, IndicatorObjectEntry * entr
}
/**
+ indicator_object_entry_activate_window:
+ @io: #IndicatorObject to query
+ @entry: The #IndicatorObjectEntry whose entry was shown
+ @windowid: ID of the window that is currently focused (or will
+ be very shortly)
+ @timestamp: The X11 timestamp of the event
+
+ Used to signal to the indicator that the menu on an entry has
+ been clicked on. This can either be an activate or a showing
+ of the menu. Also includes a window ID so that we can know what
+ application is going to be getting focused soon. If there is
+ no override of this function, it is the same as calling
+ indicator_object_entry_activate and in general is preferable
+ if you have that information available.
+*/
+void
+indicator_object_entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp)
+{
+ g_return_if_fail(INDICATOR_IS_OBJECT(io));
+ IndicatorObjectClass * class = INDICATOR_OBJECT_GET_CLASS(io);
+
+ if (class->entry_activate_window != NULL) {
+ return class->entry_activate_window(io, entry, windowid, timestamp);
+ } else {
+ indicator_object_entry_activate(io, entry, timestamp);
+ }
+
+ return;
+}
+
+/**
indicator_object_entry_activate:
@io: #IndicatorObject to query
@entry: The #IndicatorObjectEntry whose entry was shown
diff --git a/libindicator/indicator-object.h b/libindicator/indicator-object.h
index 3a120f5..bbc215a 100644
--- a/libindicator/indicator-object.h
+++ b/libindicator/indicator-object.h
@@ -118,6 +118,7 @@ struct _IndicatorObjectClass {
gboolean (*get_show_now) (IndicatorObject * io, IndicatorObjectEntry * entry);
void (*entry_activate) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp);
+ void (*entry_activate_window) (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp);
void (*entry_close) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp);
/* Signals */
@@ -184,6 +185,7 @@ GList * indicator_object_get_entries (IndicatorObject * io);
guint indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry);
guint indicator_object_get_show_now (IndicatorObject * io, IndicatorObjectEntry * entry);
void indicator_object_entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp);
+void indicator_object_entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp);
void indicator_object_entry_close (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp);
void indicator_object_set_environment (IndicatorObject * io, const GStrv env);
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f11a9d1..c8a9ba7 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -14,7 +14,8 @@ lib_LTLIBRARIES = \
libdummy-indicator-blank.la \
libdummy-indicator-null.la \
libdummy-indicator-signaler.la \
- libdummy-indicator-simple.la
+ libdummy-indicator-simple.la \
+ libdummy-indicator-entry-func.la
DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf
XVFB_RUN=". $(srcdir)/run-xvfb.sh"
@@ -162,6 +163,27 @@ libdummy_indicator_simple_la_LDFLAGS = \
-avoid-version
#############################
+# Dummy Indicator Entry Func
+#############################
+
+libdummy_indicator_entry_func_la_SOURCES = \
+ dummy-indicator-entry-func.c \
+ dummy-indicator-entry-func.h
+
+libdummy_indicator_entry_func_la_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
+
+libdummy_indicator_entry_func_la_LIBADD = \
+ $(LIBINDICATOR_LIBS) \
+ -L$(top_builddir)/libindicator/.libs \
+ $(INDICATOR_LIB)
+
+libdummy_indicator_entry_func_la_LDFLAGS = \
+ -module \
+ -avoid-version
+
+#############################
# Service Shutdown Timeout
#############################
@@ -412,7 +434,7 @@ DISTCLEANFILES += service-manager-connect-nostart-tester
XML_REPORT = loader-check-results.xml
HTML_REPORT = loader-check-results.html
-loader-tester: test-loader libdummy-indicator-null.la libdummy-indicator-simple.la Makefile
+loader-tester: test-loader libdummy-indicator-null.la libdummy-indicator-simple.la libdummy-indicator-entry-func.la Makefile
@echo "#!/bin/bash" > loader-tester
@echo $(XVFB_RUN) >> $@
@echo gtester -k --verbose -o=$(XML_REPORT) ./test-loader >> loader-tester
diff --git a/tests/dummy-indicator-entry-func.c b/tests/dummy-indicator-entry-func.c
new file mode 100644
index 0000000..96e5ad0
--- /dev/null
+++ b/tests/dummy-indicator-entry-func.c
@@ -0,0 +1,130 @@
+/*
+Test for libindicator
+
+Copyright 2012 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+version 3.0 as published by the Free Software Foundation.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License version 3.0 for more details.
+
+You should have received a copy of the GNU General Public
+License along with this library. If not, see
+<http://www.gnu.org/licenses/>.
+*/
+
+#include "dummy-indicator-entry-func.h"
+
+
+GType dummy_indicator_entry_func_get_type (void);
+
+INDICATOR_SET_VERSION
+INDICATOR_SET_TYPE(DUMMY_INDICATOR_ENTRY_FUNC_TYPE)
+
+
+GtkLabel *
+get_label (IndicatorObject * io)
+{
+ return NULL;
+}
+
+GtkImage *
+get_icon (IndicatorObject * io)
+{
+ return NULL;
+}
+
+GtkMenu *
+get_menu (IndicatorObject * io)
+{
+ return NULL;
+}
+const gchar *
+get_accessible_desc (IndicatorObject * io)
+{
+ return NULL;
+}
+
+static void
+entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp)
+{
+ DummyIndicatorEntryFunc * self = DUMMY_INDICATOR_ENTRY_FUNC(io);
+ self->entry_activate_called = TRUE;
+ return;
+}
+
+static void
+entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp)
+{
+ DummyIndicatorEntryFunc * self = DUMMY_INDICATOR_ENTRY_FUNC(io);
+ self->entry_activate_window_called = TRUE;
+ return;
+}
+
+static void
+entry_close (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp)
+{
+ DummyIndicatorEntryFunc * self = DUMMY_INDICATOR_ENTRY_FUNC(io);
+ self->entry_close_called = TRUE;
+ return;
+}
+
+
+static void dummy_indicator_entry_func_class_init (DummyIndicatorEntryFuncClass *klass);
+static void dummy_indicator_entry_func_init (DummyIndicatorEntryFunc *self);
+static void dummy_indicator_entry_func_dispose (GObject *object);
+static void dummy_indicator_entry_func_finalize (GObject *object);
+
+G_DEFINE_TYPE (DummyIndicatorEntryFunc, dummy_indicator_entry_func, INDICATOR_OBJECT_TYPE);
+
+static void
+dummy_indicator_entry_func_class_init (DummyIndicatorEntryFuncClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = dummy_indicator_entry_func_dispose;
+ object_class->finalize = dummy_indicator_entry_func_finalize;
+
+ IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass);
+
+ io_class->get_label = get_label;
+ io_class->get_image = get_icon;
+ io_class->get_menu = get_menu;
+ io_class->get_accessible_desc = get_accessible_desc;
+
+ io_class->entry_activate = entry_activate;
+ io_class->entry_activate_window = entry_activate_window;
+ io_class->entry_close = entry_close;
+
+ return;
+}
+
+static void
+dummy_indicator_entry_func_init (DummyIndicatorEntryFunc *self)
+{
+
+ return;
+}
+
+static void
+dummy_indicator_entry_func_dispose (GObject *object)
+{
+
+ G_OBJECT_CLASS (dummy_indicator_entry_func_parent_class)->dispose (object);
+ return;
+}
+
+static void
+dummy_indicator_entry_func_finalize (GObject *object)
+{
+
+ G_OBJECT_CLASS (dummy_indicator_entry_func_parent_class)->finalize (object);
+ return;
+}
diff --git a/tests/dummy-indicator-entry-func.h b/tests/dummy-indicator-entry-func.h
new file mode 100644
index 0000000..f5c8264
--- /dev/null
+++ b/tests/dummy-indicator-entry-func.h
@@ -0,0 +1,56 @@
+/*
+Test for libindicator
+
+Copyright 2012 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+version 3.0 as published by the Free Software Foundation.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License version 3.0 for more details.
+
+You should have received a copy of the GNU General Public
+License along with this library. If not, see
+<http://www.gnu.org/licenses/>.
+*/
+
+#ifndef __DUMMY_INDICATOR_ENTRY_FUNC__
+#define __DUMMY_INDICATOR_ENTRY_FUNC__
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include "libindicator/indicator.h"
+#include "libindicator/indicator-object.h"
+
+G_BEGIN_DECLS
+
+#define DUMMY_INDICATOR_ENTRY_FUNC_TYPE (dummy_indicator_entry_func_get_type ())
+#define DUMMY_INDICATOR_ENTRY_FUNC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFunc))
+#define DUMMY_INDICATOR_ENTRY_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFuncClass))
+#define IS_DUMMY_INDICATOR_ENTRY_FUNC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE))
+#define IS_DUMMY_INDICATOR_ENTRY_FUNC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_ENTRY_FUNC_TYPE))
+#define DUMMY_INDICATOR_ENTRY_FUNC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_ENTRY_FUNC_TYPE, DummyIndicatorEntryFuncClass))
+
+typedef struct _DummyIndicatorEntryFunc DummyIndicatorEntryFunc;
+typedef struct _DummyIndicatorEntryFuncClass DummyIndicatorEntryFuncClass;
+
+struct _DummyIndicatorEntryFuncClass {
+ IndicatorObjectClass parent_class;
+};
+
+struct _DummyIndicatorEntryFunc {
+ IndicatorObject parent;
+
+ gboolean entry_activate_called;
+ gboolean entry_activate_window_called;
+ gboolean entry_close_called;
+};
+
+#endif /* __DUMMY_INDICATOR_ENTRY_FUNC__ */
diff --git a/tests/test-loader.c b/tests/test-loader.c
index ac9d4e5..2e9cf55 100644
--- a/tests/test-loader.c
+++ b/tests/test-loader.c
@@ -23,6 +23,78 @@ License along with this library. If not, see
#include <gtk/gtk.h>
#include "libindicator/indicator-object.h"
+#include "dummy-indicator-entry-func.h"
+
+void
+entry_func_swap (IndicatorObject * io)
+{
+ static void (*saved_func) (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp) = NULL;
+ IndicatorObjectClass * klass = INDICATOR_OBJECT_GET_CLASS(io);
+
+ if (saved_func == NULL) {
+ saved_func = klass->entry_activate_window;
+ }
+
+ if (klass->entry_activate_window == NULL) {
+ klass->entry_activate_window = saved_func;
+ } else {
+ klass->entry_activate_window = NULL;
+ }
+
+ return;
+}
+
+void
+test_loader_entry_func_window (void)
+{
+ IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-entry-func.so");
+ g_assert(object != NULL);
+
+ DummyIndicatorEntryFunc * entryfunc = (DummyIndicatorEntryFunc *)(object);
+
+ entryfunc->entry_activate_called = FALSE;
+ entryfunc->entry_activate_window_called = FALSE;
+ entryfunc->entry_close_called = FALSE;
+
+ entry_func_swap(object);
+ indicator_object_entry_activate_window(object, NULL, 0, 0);
+ g_assert(entryfunc->entry_activate_called);
+
+ entry_func_swap(object);
+ indicator_object_entry_activate_window(object, NULL, 0, 0);
+ g_assert(entryfunc->entry_activate_window_called);
+
+ g_object_unref(object);
+
+ return;
+}
+
+void
+test_loader_entry_funcs (void)
+{
+ IndicatorObject * object = indicator_object_new_from_file(BUILD_DIR "/.libs/libdummy-indicator-entry-func.so");
+ g_assert(object != NULL);
+
+ DummyIndicatorEntryFunc * entryfunc = (DummyIndicatorEntryFunc *)(object);
+
+ entryfunc->entry_activate_called = FALSE;
+ entryfunc->entry_activate_window_called = FALSE;
+ entryfunc->entry_close_called = FALSE;
+
+ indicator_object_entry_activate(object, NULL, 0);
+ g_assert(entryfunc->entry_activate_called);
+
+ indicator_object_entry_activate_window(object, NULL, 0, 0);
+ g_assert(entryfunc->entry_activate_window_called);
+
+ indicator_object_entry_close(object, NULL, 0);
+ g_assert(entryfunc->entry_close_called);
+
+ g_object_unref(object);
+
+ return;
+}
+
void destroy_cb (gpointer data, GObject * object);
void
@@ -174,6 +246,8 @@ test_loader_creation_deletion_suite (void)
g_test_add_func ("/libindicator/loader/dummy/simple_accessors", test_loader_filename_dummy_simple_accessors);
g_test_add_func ("/libindicator/loader/dummy/simple_location", test_loader_filename_dummy_simple_location);
g_test_add_func ("/libindicator/loader/dummy/signaler", test_loader_filename_dummy_signaler);
+ g_test_add_func ("/libindicator/loader/dummy/entry_funcs", test_loader_entry_funcs);
+ g_test_add_func ("/libindicator/loader/dummy/entry_func_window", test_loader_entry_func_window);
return;
}