Back to index

libindicator  12.10.0
dummy-indicator-visible.c
Go to the documentation of this file.
00001 /*
00002 Test for libindicator
00003 
00004 Copyright 2012 Canonical Ltd.
00005 
00006 Authors:
00007     Charles Kerr <charles.kerr@canonical.com>
00008 
00009 This library is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 version 3.0 as published by the Free Software Foundation.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 GNU General Public License version 3.0 for more details.
00017 
00018 You should have received a copy of the GNU General Public
00019 License along with this library. If not, see
00020 <http://www.gnu.org/licenses/>.
00021 */
00022 
00023 #include <glib.h>
00024 #include <glib-object.h>
00025 
00026 #include "libindicator/indicator.h"
00027 #include "libindicator/indicator-object.h"
00028 
00029 #define DUMMY_INDICATOR_VISIBLE_TYPE            (dummy_indicator_visible_get_type ())
00030 #define DUMMY_INDICATOR_VISIBLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_VISIBLE_TYPE, DummyIndicatorVisible))
00031 #define DUMMY_INDICATOR_VISIBLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_VISIBLE_TYPE, DummyIndicatorVisibleClass))
00032 #define IS_DUMMY_INDICATOR_VISIBLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_VISIBLE_TYPE))
00033 #define IS_DUMMY_INDICATOR_VISIBLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_VISIBLE_TYPE))
00034 #define DUMMY_INDICATOR_VISIBLE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_VISIBLE_TYPE, DummyIndicatorVisibleClass))
00035 
00036 typedef struct _DummyIndicatorVisible      DummyIndicatorVisible;
00037 typedef struct _DummyIndicatorVisibleClass DummyIndicatorVisibleClass;
00038 
00039 struct _DummyIndicatorVisibleClass {
00040        IndicatorObjectClass parent_class;
00041 };
00042 
00043 struct _DummyIndicatorVisible {
00044        IndicatorObject parent;
00045 };
00046 
00047 GType dummy_indicator_visible_get_type (void);
00048 
00049 INDICATOR_SET_VERSION
00050 INDICATOR_SET_TYPE(DUMMY_INDICATOR_VISIBLE_TYPE)
00051 
00052 GtkLabel *
00053 get_label (IndicatorObject * io)
00054 {
00055        return GTK_LABEL(gtk_label_new("Visible Item"));
00056 }
00057 
00058 GtkImage *
00059 get_icon (IndicatorObject * io)
00060 {
00061        return GTK_IMAGE(gtk_image_new());
00062 }
00063 
00064 GtkMenu *
00065 get_menu (IndicatorObject * io)
00066 {
00067        GtkMenu * main_menu = GTK_MENU(gtk_menu_new());
00068        GtkWidget * loading_item = gtk_menu_item_new_with_label("Loading...");
00069        gtk_menu_shell_append(GTK_MENU_SHELL(main_menu), loading_item);
00070        gtk_widget_show(GTK_WIDGET(loading_item));
00071 
00072        return main_menu;
00073 }
00074 
00075 const gchar *
00076 get_accessible_desc (IndicatorObject * io)
00077 {
00078        return "Visible Item";
00079 }
00080 
00081 static void dummy_indicator_visible_class_init (DummyIndicatorVisibleClass *klass);
00082 static void dummy_indicator_visible_init       (DummyIndicatorVisible *self);
00083 static void dummy_indicator_visible_dispose    (GObject *object);
00084 static void dummy_indicator_visible_finalize   (GObject *object);
00085 
00086 G_DEFINE_TYPE (DummyIndicatorVisible, dummy_indicator_visible, INDICATOR_OBJECT_TYPE);
00087 
00088 static void
00089 dummy_indicator_entry_being_removed (IndicatorObject * io, IndicatorObjectEntry * entry)
00090 {
00091        g_object_set_data(G_OBJECT(entry->label), "is-hidden", GINT_TO_POINTER(1));
00092 
00093         INDICATOR_OBJECT_CLASS(dummy_indicator_visible_parent_class)->entry_being_removed (io, entry);
00094 }
00095 
00096 static void
00097 dummy_indicator_entry_was_added (IndicatorObject * io, IndicatorObjectEntry * entry)
00098 {
00099        g_object_steal_data(G_OBJECT(entry->label), "is-hidden");
00100 
00101         INDICATOR_OBJECT_CLASS(dummy_indicator_visible_parent_class)->entry_was_added (io, entry);
00102 }
00103 
00104 static void
00105 dummy_indicator_visible_class_init (DummyIndicatorVisibleClass *klass)
00106 {
00107        GObjectClass *object_class = G_OBJECT_CLASS (klass);
00108 
00109        object_class->dispose = dummy_indicator_visible_dispose;
00110        object_class->finalize = dummy_indicator_visible_finalize;
00111 
00112        IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass);
00113 
00114        io_class->get_label = get_label;
00115        io_class->get_image = get_icon;
00116        io_class->get_menu = get_menu;
00117        io_class->get_accessible_desc = get_accessible_desc;
00118        io_class->entry_being_removed = dummy_indicator_entry_being_removed;
00119        io_class->entry_was_added = dummy_indicator_entry_was_added;
00120 }
00121 
00122 static void
00123 dummy_indicator_visible_init (DummyIndicatorVisible *self)
00124 {
00125 }
00126 
00127 static void
00128 dummy_indicator_visible_dispose (GObject *object)
00129 {
00130 
00131        G_OBJECT_CLASS (dummy_indicator_visible_parent_class)->dispose (object);
00132 }
00133 
00134 static void
00135 dummy_indicator_visible_finalize (GObject *object)
00136 {
00137 
00138        G_OBJECT_CLASS (dummy_indicator_visible_parent_class)->finalize (object);
00139 }