Back to index

libindicate  12.10.0
server.h
Go to the documentation of this file.
00001 /*
00002 A library to allow applictions to provide simple indications of
00003 information to be displayed to users of the application through the
00004 interface shell.
00005 
00006 Copyright 2009 Canonical Ltd.
00007 
00008 Authors:
00009     Ted Gould <ted@canonical.com>
00010 
00011 This program is free software: you can redistribute it and/or modify it 
00012 under the terms of either or both of the following licenses:
00013 
00014 1) the GNU Lesser General Public License version 3, as published by the 
00015 Free Software Foundation; and/or
00016 2) the GNU Lesser General Public License version 2.1, as published by 
00017 the Free Software Foundation.
00018 
00019 This program is distributed in the hope that it will be useful, but 
00020 WITHOUT ANY WARRANTY; without even the implied warranties of 
00021 MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR 
00022 PURPOSE.  See the applicable version of the GNU Lesser General Public 
00023 License for more details.
00024 
00025 You should have received a copy of both the GNU Lesser General Public 
00026 License version 3 and version 2.1 along with this program.  If not, see 
00027 <http://www.gnu.org/licenses/>
00028 */
00029 
00030 #ifndef INDICATE_SERVER_H_INCLUDED__
00031 #define INDICATE_SERVER_H_INCLUDED__ 1
00032 
00033 #include <glib.h>
00034 #include <glib-object.h>
00035 
00036 #include <libdbusmenu-glib/server.h>
00037 
00038 #include "interests.h"
00039 
00040 G_BEGIN_DECLS
00041 
00042 /* Boilerplate */
00043 #define INDICATE_TYPE_SERVER (indicate_server_get_type ())
00044 #define INDICATE_SERVER(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), INDICATE_TYPE_SERVER, IndicateServer))
00045 #define INDICATE_IS_SERVER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), INDICATE_TYPE_SERVER))
00046 #define INDICATE_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), INDICATE_TYPE_SERVER, IndicateServerClass))
00047 #define INDICATE_IS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), INDICATE_TYPE_SERVER))
00048 #define INDICATE_SERVER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), INDICATE_TYPE_SERVER, IndicateServerClass))
00049 
00050 #define INDICATE_SERVER_INDICATOR_NULL  (0)
00051 
00052 #define INDICATE_SERVER_SIGNAL_INDICATOR_ADDED             "indicator-new"
00053 #define INDICATE_SERVER_SIGNAL_INDICATOR_ADDED_ID          (g_signal_lookup(INDICATE_SERVER_SIGNAL_INDICATOR_ADDED, INDICATE_TYPE_SERVER))
00054 #define INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED           "indicator-delete"
00055 #define INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED_ID        (g_signal_lookup(INDICATE_SERVER_SIGNAL_INDICATOR_REMOVED, INDICATE_TYPE_SERVER))
00056 #define INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED          "indicator-modified"
00057 #define INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED_ID       (g_signal_lookup(INDICATE_SERVER_SIGNAL_INDICATOR_MODIFIED, INDICATE_TYPE_SERVER))
00058 #define INDICATE_SERVER_SIGNAL_SERVER_SHOW                 "server-show"
00059 #define INDICATE_SERVER_SIGNAL_SERVER_SHOW_ID              (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_SHOW, INDICATE_TYPE_SERVER))
00060 #define INDICATE_SERVER_SIGNAL_SERVER_HIDE                 "server-hide"
00061 #define INDICATE_SERVER_SIGNAL_SERVER_HIDE_ID              (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_HIDE, INDICATE_TYPE_SERVER))
00062 #define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY              "server-display"
00063 #define INDICATE_SERVER_SIGNAL_SERVER_DISPLAY_ID           (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_DISPLAY, INDICATE_TYPE_SERVER))
00064 #define INDICATE_SERVER_SIGNAL_INTEREST_ADDED              "interest-added"
00065 #define INDICATE_SERVER_SIGNAL_INTEREST_ADDED_ID           (g_signal_lookup(INDICATE_SERVER_SIGNAL_INTEREST_ADDED, INDICATE_TYPE_SERVER))
00066 #define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED            "interest-removed"
00067 #define INDICATE_SERVER_SIGNAL_INTEREST_REMOVED_ID         (g_signal_lookup(INDICATE_SERVER_SIGNAL_INTEREST_REMOVED, INDICATE_TYPE_SERVER))
00068 #define INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED      "max-indicators-changed"
00069 #define INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED_ID   (g_signal_lookup(INDICATE_SERVER_SIGNAL_MAX_INDICATORS_CHANGED, INDICATE_TYPE_SERVER))
00070 #define INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED        "server-count-changed"
00071 #define INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED_ID     (g_signal_lookup(INDICATE_SERVER_SIGNAL_SERVER_COUNT_CHANGED, INDICATE_TYPE_SERVER))
00072 
00083 typedef struct _IndicateServer IndicateServer;
00084 struct _IndicateServer {
00085        GObject parent;
00086 };
00087 
00088 #include "indicator.h"
00089 
00101 typedef gboolean (*indicate_server_get_indicator_list_slot_t) (IndicateServer * server, GArray ** indicators, GError ** error);
00102 
00115 typedef gboolean (*indicate_server_get_indicator_property_group_slot_t) (IndicateServer * server, guint id, const gchar ** properties, GVariant ** value, GError **error);
00116 
00128 typedef gboolean (*indicate_server_get_indicator_properties_slot_t) (IndicateServer * server, guint id, gchar *** properties, GError **error);
00129 
00176 typedef struct _IndicateServerClass IndicateServerClass;
00177 struct _IndicateServerClass {
00178        GObjectClass parent;
00179 
00180        /* Signals */
00181        void (* indicator_added) (IndicateServer * server, guint id);
00182        void (* indicator_removed) (IndicateServer * server, guint id);
00183        void (* indicator_modified) (IndicateServer * server, guint id, gchar * property);
00184        void (* server_show) (IndicateServer * server, gchar * type);
00185        void (* server_hide) (IndicateServer * server, gchar * type);
00186        void (* server_display) (IndicateServer * server, guint timestamp);
00187        void (* interest_added) (IndicateServer * server, IndicateInterests interest);
00188        void (* interest_removed) (IndicateServer * server, IndicateInterests interest);
00189        void (* max_indicators_changed) (IndicateServer * server, gint max);
00190        void (* server_count_changed) (IndicateServer * server, guint count);
00191 
00192        /* Virtual Functions */
00193        gboolean (*get_indicator_count) (IndicateServer * server, guint * count, GError **error);
00194        indicate_server_get_indicator_list_slot_t get_indicator_list;
00195        gboolean (*get_indicator_property) (IndicateServer * server, guint id, gchar * property, GVariant ** value, GError **error);
00196        indicate_server_get_indicator_property_group_slot_t get_indicator_property_group;
00197        indicate_server_get_indicator_properties_slot_t get_indicator_properties;
00198        gboolean (*show_indicator_to_user) (IndicateServer * server, guint id, guint timestamp, GError ** error);
00199        gboolean (*indicator_displayed) (IndicateServer * server, const gchar * sender, guint id, gboolean displayed, GError ** error);
00200        guint    (*get_next_id) (IndicateServer * server);
00201        gboolean (*show_interest) (IndicateServer * server, const gchar * sender, IndicateInterests interest);
00202        gboolean (*remove_interest) (IndicateServer * server, const gchar * sender, IndicateInterests interest);
00203        gboolean (*check_interest) (IndicateServer * server, IndicateInterests interest);
00204        gboolean (*max_indicators_set) (IndicateServer * server, const gchar * sender, gint max);
00205        gint     (*max_indicators_get) (IndicateServer * server);
00206 
00207        /* Reserver for future use */
00208        void (*indicate_server_reserved1)(void);
00209        void (*indicate_server_reserved2)(void);
00210        void (*indicate_server_reserved3)(void);
00211        void (*indicate_server_reserved4)(void);
00212 };
00213 
00214 GType indicate_server_get_type (void) G_GNUC_CONST;
00215 
00216 /* Gets the server object path. */
00217 const gchar *indicate_server_get_path (IndicateServer *server);
00218 
00219 /* Sets the object.  By default this is /org/freedesktop/indicators */
00220 void indicate_server_set_dbus_object (const gchar * obj);
00221 
00222 /* Sets the desktop file to get data like name and description
00223  * out of */
00224 void indicate_server_set_desktop_file (IndicateServer * server, const gchar * path);
00225 void indicate_server_set_type (IndicateServer * server, const gchar * type);
00226 void indicate_server_set_count (IndicateServer * server, guint count);
00227 
00228 void indicate_server_set_icon_theme (IndicateServer * server, const gchar * name);
00229 
00230 /* Show and hide the server on DBus, this allows for the server to
00231  * be created, change the object, and then shown.  If for some
00232  * reason the app wanted to hide all it's indicators, this is a
00233  * sure fire way to do so.  No idea why, but I'm sure I'll learn. */
00234 void indicate_server_show (IndicateServer * server);
00235 void indicate_server_hide (IndicateServer * server);
00236 
00237 guint indicate_server_get_next_id (IndicateServer * server);
00238 void indicate_server_add_indicator (IndicateServer * server, IndicateIndicator * indicator);
00239 void indicate_server_remove_indicator (IndicateServer * server, IndicateIndicator * indicator);
00240 
00241 IndicateServer * indicate_server_ref_default (void);
00242 void indicate_server_set_default (IndicateServer * server);
00243 
00244 /* Check to see if there is someone, out there, who likes this */
00245 gboolean indicate_server_check_interest (IndicateServer * server, IndicateInterests interest);
00246 /* See how many indicators we can show */
00247 gint indicate_server_get_max_indicators (IndicateServer * server);
00248 
00249 /* Setting a server to use */
00250 void indicate_server_set_menu (IndicateServer * server, DbusmenuServer * menu);
00251 
00252 
00253 
00283 G_END_DECLS
00284 
00285 #endif /* INDICATE_SERVER_H_INCLUDED__ */
00286