From 79d94105efbbc9f5a1d66678f0e016018e7377ca Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Dec 2009 15:35:52 -0600 Subject: Fixing function documentation. --- src/libappindicator/app-indicator.c | 37 +++++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) (limited to 'src/libappindicator/app-indicator.c') diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index bd72499..ab95ee5 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -549,7 +549,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, @@ -565,9 +570,17 @@ app_indicator_new (const gchar *id, return indicator; } +/** + 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 +601,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 +627,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) @@ -678,6 +695,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 +725,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 +741,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 +757,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 +773,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 +789,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. -- cgit v1.2.3 From 284188bb81f79d5fc98b01206a129ab6ccfc8f13 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Tue, 8 Dec 2009 16:34:01 -0600 Subject: Beefed up and stuff. --- src/libappindicator/app-indicator.c | 65 ++++++++++++++++++++++++++++++++++--- 1 file changed, 61 insertions(+), 4 deletions(-) (limited to 'src/libappindicator/app-indicator.c') diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index bd72499..6f4a6fd 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -640,18 +640,75 @@ activate_menuitem (DbusmenuMenuitem *mi, gpointer user_data) gtk_menu_item_activate (GTK_MENU_ITEM (widget)); } +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; + gboolean label_set = FALSE; + + label = gtk_menu_item_get_label (GTK_MENU_ITEM (widget)); 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_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); -- cgit v1.2.3 From 6cb0e1a6708ea0aae9b07cb08e49f06220fceeb4 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Wed, 9 Dec 2009 22:10:40 -0600 Subject: Add support for separator menuitems --- src/libappindicator/app-indicator.c | 42 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'src/libappindicator/app-indicator.c') diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index 6f4a6fd..f73369d 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 #include +#include #include "libappindicator/app-indicator.h" #include "libappindicator/app-indicator-enum-types.h" @@ -660,33 +661,42 @@ container_iterate (GtkWidget *widget, { DbusmenuMenuitem *root = (DbusmenuMenuitem *)data; DbusmenuMenuitem *child; - const gchar *label; + const gchar *label = NULL; gboolean label_set = FALSE; - label = gtk_menu_item_get_label (GTK_MENU_ITEM (widget)); - child = dbusmenu_menuitem_new (); - if (GTK_IS_IMAGE_MENU_ITEM (widget)) + if (GTK_IS_SEPARATOR_MENU_ITEM (widget)) + { + dbusmenu_menuitem_property_set (child, + "type", + DBUSMENU_CLIENT_TYPES_SEPARATOR); + } + else { - GtkWidget *image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget)); + label = gtk_menu_item_get_label (GTK_MENU_ITEM (widget)); - if (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_STOCK) + if (GTK_IS_IMAGE_MENU_ITEM (widget)) { - GtkStockItem stock; + GtkWidget *image = gtk_image_menu_item_get_image (GTK_IMAGE_MENU_ITEM (widget)); - gtk_stock_lookup (GTK_IMAGE (image)->data.stock.stock_id, &stock); + if (gtk_image_get_storage_type (GTK_IMAGE (image)) == GTK_IMAGE_STOCK) + { + GtkStockItem stock; - dbusmenu_menuitem_property_set (child, - DBUSMENU_MENUITEM_PROP_ICON, - GTK_IMAGE (image)->data.stock.stock_id); + gtk_stock_lookup (GTK_IMAGE (image)->data.stock.stock_id, &stock); - if (stock.label != NULL) - { dbusmenu_menuitem_property_set (child, - DBUSMENU_MENUITEM_PROP_LABEL, - stock.label); - label_set = TRUE; + 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; + } } } } -- cgit v1.2.3