Back to index

libindicator  12.10.0
dummy-indicator-simple.c
Go to the documentation of this file.
00001 /*
00002 Test for libindicator
00003 
00004 Copyright 2009 Canonical Ltd.
00005 
00006 Authors:
00007     Ted Gould <ted@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_SIMPLE_TYPE            (dummy_indicator_simple_get_type ())
00030 #define DUMMY_INDICATOR_SIMPLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), DUMMY_INDICATOR_SIMPLE_TYPE, DummyIndicatorSimple))
00031 #define DUMMY_INDICATOR_SIMPLE_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), DUMMY_INDICATOR_SIMPLE_TYPE, DummyIndicatorSimpleClass))
00032 #define IS_DUMMY_INDICATOR_SIMPLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DUMMY_INDICATOR_SIMPLE_TYPE))
00033 #define IS_DUMMY_INDICATOR_SIMPLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DUMMY_INDICATOR_SIMPLE_TYPE))
00034 #define DUMMY_INDICATOR_SIMPLE_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), DUMMY_INDICATOR_SIMPLE_TYPE, DummyIndicatorSimpleClass))
00035 
00036 typedef struct _DummyIndicatorSimple      DummyIndicatorSimple;
00037 typedef struct _DummyIndicatorSimpleClass DummyIndicatorSimpleClass;
00038 
00039 struct _DummyIndicatorSimpleClass {
00040        IndicatorObjectClass parent_class;
00041 };
00042 
00043 struct _DummyIndicatorSimple {
00044        IndicatorObject parent;
00045 };
00046 
00047 GType dummy_indicator_simple_get_type (void);
00048 
00049 INDICATOR_SET_VERSION
00050 INDICATOR_SET_TYPE(DUMMY_INDICATOR_SIMPLE_TYPE)
00051 
00052 GtkLabel *
00053 get_label (IndicatorObject * io)
00054 {
00055        return GTK_LABEL(gtk_label_new("Simple 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 "Simple Item";
00079 }
00080 
00081 static void dummy_indicator_simple_class_init (DummyIndicatorSimpleClass *klass);
00082 static void dummy_indicator_simple_init       (DummyIndicatorSimple *self);
00083 static void dummy_indicator_simple_dispose    (GObject *object);
00084 static void dummy_indicator_simple_finalize   (GObject *object);
00085 
00086 G_DEFINE_TYPE (DummyIndicatorSimple, dummy_indicator_simple, INDICATOR_OBJECT_TYPE);
00087 
00088 static void
00089 dummy_indicator_simple_class_init (DummyIndicatorSimpleClass *klass)
00090 {
00091        GObjectClass *object_class = G_OBJECT_CLASS (klass);
00092 
00093        object_class->dispose = dummy_indicator_simple_dispose;
00094        object_class->finalize = dummy_indicator_simple_finalize;
00095 
00096        IndicatorObjectClass * io_class = INDICATOR_OBJECT_CLASS(klass);
00097 
00098        io_class->get_label = get_label;
00099        io_class->get_image = get_icon;
00100        io_class->get_menu = get_menu;
00101        io_class->get_accessible_desc = get_accessible_desc;
00102 
00103        return;
00104 }
00105 
00106 static void
00107 dummy_indicator_simple_init (DummyIndicatorSimple *self)
00108 {
00109 
00110        return;
00111 }
00112 
00113 static void
00114 dummy_indicator_simple_dispose (GObject *object)
00115 {
00116 
00117        G_OBJECT_CLASS (dummy_indicator_simple_parent_class)->dispose (object);
00118        return;
00119 }
00120 
00121 static void
00122 dummy_indicator_simple_finalize (GObject *object)
00123 {
00124 
00125        G_OBJECT_CLASS (dummy_indicator_simple_parent_class)->finalize (object);
00126        return;
00127 }