diff options
Diffstat (limited to 'src/libappindicator')
-rw-r--r-- | src/libappindicator/app-indicator.c | 112 | ||||
-rw-r--r-- | src/libappindicator/app-indicator.h | 72 | ||||
-rw-r--r-- | src/libappindicator/appindicator-0.1.pc.in | 14 |
3 files changed, 186 insertions, 12 deletions
diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index bd72499..791f9ff 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -33,6 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see #include <dbus/dbus-glib.h> #include <libdbusmenu-glib/server.h> +#include <libdbusmenu-gtk/client.h> #include "libappindicator/app-indicator.h" #include "libappindicator/app-indicator-enum-types.h" @@ -549,7 +550,12 @@ category_from_enum (AppIndicatorCategory category) @icon_name: The icon name for this indicator @category: The category of indicator. - @returns: A pointer to a new #AppIndicator object. + Creates a new #AppIndicator setting the properties: + #AppIndicator::id with @id, #AppIndicator::category + with @category and #AppIndicator::icon-name with + @icon_name. + + Return value: A pointer to a new #AppIndicator object. */ AppIndicator * app_indicator_new (const gchar *id, @@ -566,8 +572,16 @@ app_indicator_new (const gchar *id, } /** + app_indicator_get_type: + + Generates or returns the unique #GType for #AppIndicator. + + Return value: A unique #GType for #AppIndicator objects. +*/ + +/** app_indicator_set_status: - @ci: The #AppIndicator object to use + @self: The #AppIndicator object to use @status: The status to set for this indicator Wrapper function for property #AppIndicator::status. @@ -588,7 +602,7 @@ app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status) /** app_indicator_set_attention_icon: - @ci: The #AppIndicator object to use + @self: The #AppIndicator object to use @icon_name: The name of the attention icon to set for this indicator Wrapper function for property #AppIndicator::attention-icon. @@ -614,6 +628,10 @@ app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name) app_indicator_set_icon: @self: The #AppIndicator object to use @icon_name: The icon name to set. + + Sets the default icon to use when the status is active but + not set to attention. In most cases, this should be the + application icon for the program. **/ void app_indicator_set_icon (AppIndicator *self, const gchar *icon_name) @@ -641,17 +659,83 @@ activate_menuitem (DbusmenuMenuitem *mi, gpointer user_data) } static void +menuitem_iterate (GtkWidget *widget, + gpointer data) +{ + if (GTK_IS_LABEL (widget)) + { + DbusmenuMenuitem *child = (DbusmenuMenuitem *)data; + + dbusmenu_menuitem_property_set (child, + DBUSMENU_MENUITEM_PROP_LABEL, + gtk_label_get_text (GTK_LABEL (widget))); + } +} + +static void container_iterate (GtkWidget *widget, gpointer data) { DbusmenuMenuitem *root = (DbusmenuMenuitem *)data; DbusmenuMenuitem *child; + const gchar *label = NULL; + gboolean label_set = FALSE; child = dbusmenu_menuitem_new (); - dbusmenu_menuitem_property_set (child, - DBUSMENU_MENUITEM_PROP_LABEL, - gtk_menu_item_get_label (GTK_MENU_ITEM (widget))); - g_signal_connect (G_OBJECT(child), + + if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) + { + dbusmenu_menuitem_property_set (child, + "type", + DBUSMENU_CLIENT_TYPES_SEPARATOR); + } + else + { + label = gtk_menu_item_get_label (GTK_MENU_ITEM (widget)); + + if (GTK_IS_IMAGE_MENU_ITEM (widget)) + { + GtkWidget *image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget)); + + if (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_STOCK) + { + GtkStockItem stock; + + gtk_stock_lookup (GTK_IMAGE (image)->data.stock.stock_id, &stock); + + dbusmenu_menuitem_property_set (child, + DBUSMENU_MENUITEM_PROP_ICON, + GTK_IMAGE (image)->data.stock.stock_id); + + if (stock.label != NULL) + { + dbusmenu_menuitem_property_set (child, + DBUSMENU_MENUITEM_PROP_LABEL, + stock.label); + label_set = TRUE; + } + } + } + } + + if (!label_set) + { + if (label != NULL) + { + dbusmenu_menuitem_property_set (child, + DBUSMENU_MENUITEM_PROP_LABEL, + label); + } + else + { + /* find label child widget */ + gtk_container_forall (GTK_CONTAINER (widget), + menuitem_iterate, + child); + } + } + + g_signal_connect (G_OBJECT (child), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK (activate_menuitem), widget); dbusmenu_menuitem_child_append (root, child); @@ -678,6 +762,10 @@ setup_dbusmenu (AppIndicator *self) app_indicator_set_menu: @self: The #AppIndicator @menu: A #GtkMenu to set + + Sets the menu that should be shown when the Application Indicator + is clicked on in the panel. An application indicator will not + be rendered unless it has a menu. **/ void app_indicator_set_menu (AppIndicator *self, GtkMenu *menu) @@ -704,7 +792,7 @@ app_indicator_set_menu (AppIndicator *self, GtkMenu *menu) /** app_indicator_get_id: - @ci: The #AppIndicator object to use + @self: The #AppIndicator object to use Wrapper function for property #AppIndicator::id. @@ -720,7 +808,7 @@ app_indicator_get_id (AppIndicator *self) /** app_indicator_get_category: - @ci: The #AppIndicator object to use + @self: The #AppIndicator object to use Wrapper function for property #AppIndicator::category. @@ -736,7 +824,7 @@ app_indicator_get_category (AppIndicator *self) /** app_indicator_get_status: - @ci: The #AppIndicator object to use + @self: The #AppIndicator object to use Wrapper function for property #AppIndicator::status. @@ -752,7 +840,7 @@ app_indicator_get_status (AppIndicator *self) /** app_indicator_get_icon: - @ci: The #AppIndicator object to use + @self: The #AppIndicator object to use Wrapper function for property #AppIndicator::icon-name. @@ -768,7 +856,7 @@ app_indicator_get_icon (AppIndicator *self) /** app_indicator_get_attention_icon: - @ci: The #AppIndicator object to use + @self: The #AppIndicator object to use Wrapper function for property #AppIndicator::attention-icon-name. diff --git a/src/libappindicator/app-indicator.h b/src/libappindicator/app-indicator.h index 6a961fe..e966a49 100644 --- a/src/libappindicator/app-indicator.h +++ b/src/libappindicator/app-indicator.h @@ -34,6 +34,41 @@ License version 3 and version 2.1 along with this program. If not, see G_BEGIN_DECLS +/** + APP_INDICATOR_TYPE: + + Get the #GType for a #AppIndicator. +*/ +/** + APP_INDICATOR: + @obj: The object to convert + + Safely convert a #GObject into an #AppIndicator. +*/ +/** + APP_INDICATOR_CLASS: + @klass: #GObjectClass based class to convert. + + Safely convert a #GObjectClass into a #AppIndicatorClass. +*/ +/** + IS_APP_INDICATOR: + @obj: An #GObject to check + + Checks to see if @obj is in the object hierarchy of #AppIndicator. +*/ +/** + IS_APP_INDICATOR_CLASS: + @klass: An #GObjectClass to check + + Checks to see if @klass is in the object class hierarchy of #AppIndicatorClass. +*/ +/** + APP_INDICATOR_GET_CLASS: + @obj: A #GObject in the class hierarchy of #AppIndicator. + + Gets a pointer to the #AppIndicatorClass for the object @obj. +*/ #define APP_INDICATOR_TYPE (app_indicator_get_type ()) #define APP_INDICATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APP_INDICATOR_TYPE, AppIndicator)) #define APP_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APP_INDICATOR_TYPE, AppIndicatorClass)) @@ -41,6 +76,26 @@ G_BEGIN_DECLS #define IS_APP_INDICATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APP_INDICATOR_TYPE)) #define APP_INDICATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APP_INDICATOR_TYPE, AppIndicatorClass)) +/** + APP_INDICATOR_SIGNAL_NEW_ICON: + + String identifier for the #AppIndicator::new-icon signal. +*/ +/** + APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON: + + String identifier for the #AppIndicator::new-attention-icon signal. +*/ +/** + APP_INDICATOR_SIGNAL_NEW_STATUS: + + String identifier for the #AppIndicator::new-status signal. +*/ +/** + APP_INDICATOR_SIGNAL_CONNECTION_CHANGED: + + String identifier for the #AppIndicator::connection-changed signal. +*/ #define APP_INDICATOR_SIGNAL_NEW_ICON "new-icon" #define APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON "new-attention-icon" #define APP_INDICATOR_SIGNAL_NEW_STATUS "new-status" @@ -167,4 +222,21 @@ const gchar * app_indicator_get_attention_icon (AppIndicator * G_END_DECLS +/** + SECTION:app-indicator + @short_description: An object to put application information + into the panel. + @stability: Unstable + @include: libappindicator/app-indicator.h + + An application indicator is a way for an application to put + a menu into the panel on the user's screen. This allows the + user to interact with the application even though it might + not be visible to the user at the time. In most cases this + is not a good solution as there are other ways to inform the + user. It should only be use if persistence is a desired + feature for the user (not for your marketing purpose of + having your logo in the panel). +*/ + #endif diff --git a/src/libappindicator/appindicator-0.1.pc.in b/src/libappindicator/appindicator-0.1.pc.in new file mode 100644 index 0000000..b80fded --- /dev/null +++ b/src/libappindicator/appindicator-0.1.pc.in @@ -0,0 +1,14 @@ +prefix=@prefix@ +exec_prefix=@exec_prefix@ +libdir=@libdir@ +bindir=@bindir@ +includedir=@includedir@ + +Cflags: -I${includedir}/libappindicator-0.1 +Requires: dbusmenu-glib gtk+-2.0 +Libs: -L${libdir} -lappindicator + +Name: appindicator-0.1 +Description: Application indicators +Version: @VERSION@ + |