1 /* 2 An object to represent loadable indicator modules to make loading 3 them easy and objectified. 4 5 Copyright 2009 Canonical Ltd. 6 7 Authors: 8 Ted Gould <ted@canonical.com> 9 10 This library is free software; you can redistribute it and/or 11 modify it under the terms of the GNU General Public License 12 version 3.0 as published by the Free Software Foundation. 13 14 This library is distributed in the hope that it will be useful, 15 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 GNU General Public License version 3.0 for more details. 18 19 You should have received a copy of the GNU General Public 20 License along with this library. If not, see 21 <http://www.gnu.org/licenses/>. 22 */ 23 24 #ifndef __INDICATOR_OBJECT_H__ 25 #define __INDICATOR_OBJECT_H__ 26 27 #include <gtk/gtk.h> 28 29 G_BEGIN_DECLS 30 31 typedef enum 32 { 33 INDICATOR_OBJECT_SCROLL_UP, 34 INDICATOR_OBJECT_SCROLL_DOWN, 35 INDICATOR_OBJECT_SCROLL_LEFT, 36 INDICATOR_OBJECT_SCROLL_RIGHT 37 } IndicatorScrollDirection; 38 39 #define INDICATOR_OBJECT_TYPE (indicator_object_get_type ()) 40 #define INDICATOR_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), INDICATOR_OBJECT_TYPE, IndicatorObject)) 41 #define INDICATOR_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), INDICATOR_OBJECT_TYPE, IndicatorObjectClass)) 42 #define INDICATOR_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), INDICATOR_OBJECT_TYPE)) 43 #define INDICATOR_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_OBJECT_TYPE)) 44 #define INDICATOR_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_OBJECT_TYPE, IndicatorObjectClass)) 45 46 #define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED "entry-added" 47 #define INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, INDICATOR_OBJECT_TYPE)) 48 #define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED "entry-removed" 49 #define INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, INDICATOR_OBJECT_TYPE)) 50 #define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED "entry-moved" 51 #define INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, INDICATOR_OBJECT_TYPE)) 52 #define INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED "entry-scrolled" 53 #define INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ENTRY_SCROLLED, INDICATOR_OBJECT_TYPE)) 54 #define INDICATOR_OBJECT_SIGNAL_MENU_SHOW "menu-show" 55 #define INDICATOR_OBJECT_SIGNAL_MENU_SHOW_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_MENU_SHOW, INDICATOR_OBJECT_TYPE)) 56 #define INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED "show-now-changed" 57 #define INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_SHOW_NOW_CHANGED, INDICATOR_OBJECT_TYPE)) 58 #define INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE "accessible-desc-update" 59 #define INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, INDICATOR_OBJECT_TYPE)) 60 #define INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE "secondary-activate" 61 #define INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE_ID (g_signal_lookup(INDICATOR_OBJECT_SIGNAL_SECONDARY_ACTIVATE, INDICATOR_OBJECT_TYPE)) 62 63 /* the name of the property to decide whether or not entries are visible by default */ 64 #define INDICATOR_OBJECT_DEFAULT_VISIBILITY "indicator-object-default-visibility" 65 66 typedef struct _IndicatorObject IndicatorObject; 67 typedef struct _IndicatorObjectClass IndicatorObjectClass; 68 typedef struct _IndicatorObjectPrivate IndicatorObjectPrivate; 69 typedef struct _IndicatorObjectEntry IndicatorObjectEntry; 70 71 /** 72 IndicatorObjectClass: 73 @parent_class: #GObjectClass 74 @get_label: Gets the label for this object. Should be set 75 to #NULL if @get_entries is set. Should NOT ref the 76 object. 77 @get_image: Gets the image for this object. Should be set 78 to #NULL if @get_entries is set. Should NOT ref the 79 object. 80 @get_menu: Gets the image for this object. Should be set 81 to #NULL if @get_entries is set. Should NOT ref the 82 object. 83 @get_accessible_desc: Gets the accessible descriptionfor this 84 object. 85 @get_name_hint: Gets the hint of the type of indicator that this 86 is for the caller. 87 @get_entries: Gets all of the entires for this object returning 88 a #GList of #IndicatorObjectEntries. The list should be 89 under the ownership of the caller but the entires will 90 not be. 91 @get_location: Returns the location that a particular entry 92 should be placed in. This is really only relevant for 93 indicators that have more than one entry. 94 @get_show_now: Returns whether the entry is requesting to 95 be shown "right now" in that it has something important 96 to tell the user. 97 @entry_being_removed: Called before an entry is removed. 98 The default implementation is to ref and unparent the 99 entry's widgets so that they can be re-added later. 100 @entry_was_added: Called after an entry is added. 101 The default implementation is to unref the entry's widgets if 102 previously reffed by entry_being_removed's default impementation 103 @entry_activate: Should be called when the menus for a given 104 entry are shown to the user. 105 @entry_close: Called when the menu is closed. 106 @entry_added: Slot for #IndicatorObject::entry-added 107 @entry_removed: Slot for #IndicatorObject::entry-removed 108 @entry_moved: Slot for #IndicatorObject::entry-moved 109 @menu_show: Slot for #IndicatorObject::menu-show 110 @entry_scrolled: Slot for #IndicatorObject::entry-scrolled 111 @show_now_changed: Slot for #IndicatorObject::show-now-changed 112 @accessible_desc_update: Slot for #IndicatorObject::accessible-desc-update 113 @secondary_activate: Slot for #IndicatorObject::secondary-activate 114 */ 115 struct _IndicatorObjectClass { 116 GObjectClass parent_class; 117 118 /* Virtual Functions */ 119 GtkLabel * (*get_label) (IndicatorObject * io); 120 GtkImage * (*get_image) (IndicatorObject * io); 121 GtkMenu * (*get_menu) (IndicatorObject * io); 122 const gchar * (*get_accessible_desc) (IndicatorObject * io); 123 const gchar * (*get_name_hint) (IndicatorObject * io); 124 125 GList * (*get_entries) (IndicatorObject * io); 126 guint (*get_location) (IndicatorObject * io, IndicatorObjectEntry * entry); 127 gboolean (*get_show_now) (IndicatorObject * io, IndicatorObjectEntry * entry); 128 129 void (*entry_being_removed) (IndicatorObject * io, IndicatorObjectEntry * entry); 130 void (*entry_was_added) (IndicatorObject * io, IndicatorObjectEntry * entry); 131 132 void (*entry_activate) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); 133 void (*entry_activate_window) (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp); 134 void (*entry_close) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); 135 136 /* Signals */ 137 void (*entry_added) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data); 138 void (*entry_removed) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data); 139 void (*entry_moved) (IndicatorObject * io, IndicatorObjectEntry * entry, guint old_pos, guint new_pos, gpointer user_data); 140 void (*entry_scrolled) (IndicatorObject * io, IndicatorObjectEntry * entry, gint delta, IndicatorScrollDirection direction); 141 void (*menu_show) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data); 142 void (*show_now_changed) (IndicatorObject * io, IndicatorObjectEntry * entry, gboolean show_now_state, gpointer user_data); 143 void (*accessible_desc_update) (IndicatorObject * io, IndicatorObjectEntry * entry, gpointer user_data); 144 void (*secondary_activate) (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp, gpointer user_data); 145 146 /* Reserved */ 147 void (*reserved1) (void); 148 void (*reserved2) (void); 149 void (*reserved3) (void); 150 void (*reserved4) (void); 151 void (*reserved5) (void); 152 }; 153 154 /** 155 IndicatorObject: 156 @parent: #GObject 157 @priv: A cached reference to the private data for the 158 instance. 159 */ 160 struct _IndicatorObject { 161 GObject parent; 162 IndicatorObjectPrivate * priv; 163 }; 164 165 /** 166 IndicatorObjectEntry: 167 @parent_object: The #IndicatorObject that created this entry 168 @label: The label to be shown on the panel 169 @image: The image to be shown on the panel 170 @menu: The menu to be added to the menubar 171 @accessible_desc: The accessible description 172 of the indicator 173 @name_hint: A name to describe the indicator being placed to allow 174 the caller to be more aware of the individual entries. 175 176 @reserved1: Reserved for future use 177 @reserved2: Reserved for future use 178 @reserved3: Reserved for future use 179 @reserved4: Reserved for future use 180 */ 181 struct _IndicatorObjectEntry { 182 IndicatorObject * parent_object; 183 GtkLabel * label; 184 GtkImage * image; 185 GtkMenu * menu; 186 const gchar * accessible_desc; 187 const gchar * name_hint; 188 189 void (*reserved1) (void); 190 void (*reserved2) (void); 191 void (*reserved3) (void); 192 void (*reserved4) (void); 193 }; 194 195 GType indicator_object_get_type (void); 196 IndicatorObject * indicator_object_new_from_file (const gchar * file); 197 198 GList * indicator_object_get_entries (IndicatorObject * io); 199 guint indicator_object_get_location (IndicatorObject * io, IndicatorObjectEntry * entry); 200 guint indicator_object_get_show_now (IndicatorObject * io, IndicatorObjectEntry * entry); 201 void indicator_object_set_visible (IndicatorObject * io, gboolean visible); 202 void indicator_object_entry_activate (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); 203 void indicator_object_entry_activate_window (IndicatorObject * io, IndicatorObjectEntry * entry, guint windowid, guint timestamp); 204 void indicator_object_entry_close (IndicatorObject * io, IndicatorObjectEntry * entry, guint timestamp); 205 206 void indicator_object_set_environment (IndicatorObject * io, GStrv env); 207 GStrv indicator_object_get_environment (IndicatorObject * io); 208 gboolean indicator_object_check_environment (IndicatorObject * io, const gchar * env); 209 210 G_END_DECLS 211 212 #endif 213