aboutsummaryrefslogtreecommitdiff
path: root/tests/dummy-indicator-visible.c
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2012-01-23 05:39:50 -0600
committerCharles Kerr <charles.kerr@canonical.com>2012-01-23 05:39:50 -0600
commit4f4190f71f8495e5bcf6779d73157931572e42ac (patch)
treef580039098edc4be81bd39305f052013d18e8d38 /tests/dummy-indicator-visible.c
parent8cb8b9f16b2f24dd99e7e4d86cb46415bfa99cd9 (diff)
downloadlibayatana-indicator-4f4190f71f8495e5bcf6779d73157931572e42ac.tar.gz
libayatana-indicator-4f4190f71f8495e5bcf6779d73157931572e42ac.tar.bz2
libayatana-indicator-4f4190f71f8495e5bcf6779d73157931572e42ac.zip
another iteration of the indicator-object visibility support patch, incorporating ideas from discussion with ted
- some functions were public when they should have been private - the hide/show handler is now a virtual function & is documented in indicator-object.h - added unit tests - the GSettings monitor has been removed
Diffstat (limited to 'tests/dummy-indicator-visible.c')
-rw-r--r--tests/dummy-indicator-visible.c139
1 files changed, 139 insertions, 0 deletions
diff --git a/tests/dummy-indicator-visible.c b/tests/dummy-indicator-visible.c
new file mode 100644
index 0000000..0bb9e89
--- /dev/null
+++ b/tests/dummy-indicator-visible.c
@@ -0,0 +1,139 @@
+/*
+Test for libindicator
+
+Copyright 2012 Canonical Ltd.
+
+Authors:
+ Charles Kerr <charles.kerr@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 <glib.h>
+#include <glib-object.h>
+
+#include "libindicator/indicator.h"
+#include "libindicator/indicator-object.h"
+
+#define DUMMY_INDICATOR_VISIBLE_TYPE (dummy_indicator_visible_get_type ())
+#define DUMMY_INDICATOR_VISIBLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_VISIBLE_TYPE, DummyIndicatorVisible))
+#define DUMMY_INDICATOR_VISIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_VISIBLE_TYPE, DummyIndicatorVisibleClass))
+#define IS_DUMMY_INDICATOR_VISIBLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_VISIBLE_TYPE))
+#define IS_DUMMY_INDICATOR_VISIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_VISIBLE_TYPE))
+#define DUMMY_INDICATOR_VISIBLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_VISIBLE_TYPE, DummyIndicatorVisibleClass))
+
+typedef struct _DummyIndicatorVisible DummyIndicatorVisible;
+typedef struct _DummyIndicatorVisibleClass DummyIndicatorVisibleClass;
+
+struct _DummyIndicatorVisibleClass {
+ IndicatorObjectClass parent_class;
+};
+
+struct _DummyIndicatorVisible {
+ IndicatorObject parent;
+};
+
+GType dummy_indicator_visible_get_type (void);
+
+INDICATOR_SET_VERSION
+INDICATOR_SET_TYPE(DUMMY_INDICATOR_VISIBLE_TYPE)
+
+GtkLabel *
+get_label (IndicatorObject * io)
+{
+ return GTK_LABEL(gtk_label_new("Visible Item"));
+}
+
+GtkImage *
+get_icon (IndicatorObject * io)
+{
+ return GTK_IMAGE(gtk_image_new());
+}
+
+GtkMenu *
+get_menu (IndicatorObject * io)
+{
+ GtkMenu * main_menu = GTK_MENU(gtk_menu_new());
+ GtkWidget * loading_item = gtk_menu_item_new_with_label("Loading...");
+ gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), loading_item);
+ gtk_widget_show(GTK_WIDGET(loading_item));
+
+ return main_menu;
+}
+
+const gchar *
+get_accessible_desc (IndicatorObject * io)
+{
+ return "Visible Item";
+}
+
+static void dummy_indicator_visible_class_init (DummyIndicatorVisibleClass *klass);
+static void dummy_indicator_visible_init (DummyIndicatorVisible *self);
+static void dummy_indicator_visible_dispose (GObject *object);
+static void dummy_indicator_visible_finalize (GObject *object);
+
+G_DEFINE_TYPE (DummyIndicatorVisible, dummy_indicator_visible, INDICATOR_OBJECT_TYPE);
+
+static void
+dummy_indicator_entry_being_removed (IndicatorObject * io, IndicatorObjectEntry * entry)
+{
+ g_object_set_data(G_OBJECT(entry->label), "is-hidden", GINT_TO_POINTER(1));
+
+ INDICATOR_OBJECT_CLASS(dummy_indicator_visible_parent_class)->entry_being_removed (io, entry);
+}
+
+static void
+dummy_indicator_entry_was_added (IndicatorObject * io, IndicatorObjectEntry * entry)
+{
+ g_object_steal_data(G_OBJECT(entry->label), "is-hidden");
+
+ INDICATOR_OBJECT_CLASS(dummy_indicator_visible_parent_class)->entry_was_added (io, entry);
+}
+
+static void
+dummy_indicator_visible_class_init (DummyIndicatorVisibleClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = dummy_indicator_visible_dispose;
+ object_class->finalize = dummy_indicator_visible_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_being_removed = dummy_indicator_entry_being_removed;
+ io_class->entry_was_added = dummy_indicator_entry_was_added;
+}
+
+static void
+dummy_indicator_visible_init (DummyIndicatorVisible *self)
+{
+}
+
+static void
+dummy_indicator_visible_dispose (GObject *object)
+{
+
+ G_OBJECT_CLASS (dummy_indicator_visible_parent_class)->dispose (object);
+}
+
+static void
+dummy_indicator_visible_finalize (GObject *object)
+{
+
+ G_OBJECT_CLASS (dummy_indicator_visible_parent_class)->finalize (object);
+}