diff options
author | Ted Gould <ted@gould.cx> | 2010-01-07 17:06:38 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-01-07 17:06:38 -0600 |
commit | b1ffef34b05cecbad73a0278dcfe67b4c3a22f90 (patch) | |
tree | d2ab38c259eef60f4d26c6a342f83e0af38904c3 /src | |
parent | 2cc15ba2a7ce9f141068ee8e348906bfd867f9f5 (diff) | |
parent | ad8ca0d507d627da2221d39cd45c78e760623598 (diff) | |
download | ayatana-indicator-application-b1ffef34b05cecbad73a0278dcfe67b4c3a22f90.tar.gz ayatana-indicator-application-b1ffef34b05cecbad73a0278dcfe67b4c3a22f90.tar.bz2 ayatana-indicator-application-b1ffef34b05cecbad73a0278dcfe67b4c3a22f90.zip |
Merging in the icon_path branch to start to handle conflicts from there.
Diffstat (limited to 'src')
-rw-r--r-- | src/application-service-appstore.c | 18 | ||||
-rw-r--r-- | src/application-service-marshal.list | 2 | ||||
-rw-r--r-- | src/application-service.xml | 1 | ||||
-rw-r--r-- | src/indicator-application.c | 19 | ||||
-rw-r--r-- | src/libappindicator/app-indicator.c | 58 | ||||
-rw-r--r-- | src/libappindicator/app-indicator.h | 4 | ||||
-rw-r--r-- | src/notification-item.xml | 1 |
7 files changed, 97 insertions, 6 deletions
diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c index 02b8faf..a712d30 100644 --- a/src/application-service-appstore.c +++ b/src/application-service-appstore.c @@ -40,6 +40,7 @@ static gboolean _application_service_server_get_applications (ApplicationService #define NOTIFICATION_ITEM_PROP_STATUS "Status" #define NOTIFICATION_ITEM_PROP_ICON_NAME "IconName" #define NOTIFICATION_ITEM_PROP_AICON_NAME "AttentionIconName" +#define NOTIFICATION_ITEM_PROP_ICON_PATH "IconPath" #define NOTIFICATION_ITEM_PROP_MENU "Menu" #define NOTIFICATION_ITEM_SIG_NEW_ICON "NewIcon" @@ -76,6 +77,7 @@ struct _Application { gchar * icon; gchar * aicon; gchar * menu; + gchar * icon_path; }; #define APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(o) \ @@ -116,8 +118,8 @@ application_service_appstore_class_init (ApplicationServiceAppstoreClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (ApplicationServiceAppstore, application_added), NULL, NULL, - _application_service_marshal_VOID__STRING_INT_STRING_STRING, - G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); + _application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING, + G_TYPE_NONE, 5, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_NONE); signals[APPLICATION_REMOVED] = g_signal_new ("application-removed", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, @@ -214,6 +216,13 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err app->aicon = g_value_dup_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_NAME)); } + gpointer icon_path_data = g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_ICON_PATH); + if (icon_path_data != NULL) { + app->icon_path = g_value_dup_string((GValue *)icon_path_data); + } else { + app->icon_path = g_strdup(""); + } + apply_status(app, string_to_status(g_value_get_string(g_hash_table_lookup(properties, NOTIFICATION_ITEM_PROP_STATUS)))); return; @@ -268,6 +277,9 @@ application_free (Application * app) if (app->menu != NULL) { g_free(app->menu); } + if (app->icon_path != NULL) { + g_free(app->icon_path); + } g_free(app); return; @@ -333,6 +345,7 @@ apply_status (Application * app, ApplicationStatus status) 0, /* Position */ app->dbus_name, app->menu, + app->icon_path, TRUE); } else { /* Icon update */ @@ -498,6 +511,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst app->icon = NULL; app->aicon = NULL; app->menu = NULL; + app->icon_path = NULL; /* Get the DBus proxy for the NotificationItem interface */ GError * error = NULL; diff --git a/src/application-service-marshal.list b/src/application-service-marshal.list index 99d13c0..4ac8398 100644 --- a/src/application-service-marshal.list +++ b/src/application-service-marshal.list @@ -16,5 +16,5 @@ # # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. -VOID: STRING, INT, STRING, STRING +VOID: STRING, INT, STRING, STRING, STRING VOID: INT, STRING diff --git a/src/application-service.xml b/src/application-service.xml index 57d429b..d74aaa9 100644 --- a/src/application-service.xml +++ b/src/application-service.xml @@ -35,6 +35,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. <arg type="i" name="position" direction="out" /> <arg type="s" name="dbusaddress" direction="out" /> <arg type="o" name="dbusobject" direction="out" /> + <arg type="s" name="iconpath" direction="out" /> </signal> <signal name="ApplicationRemoved"> <arg type="i" name="position" direction="out" /> diff --git a/src/indicator-application.c b/src/indicator-application.c index 221be04..c330645 100644 --- a/src/indicator-application.c +++ b/src/indicator-application.c @@ -80,6 +80,7 @@ struct _IndicatorApplicationPrivate { typedef struct _ApplicationEntry ApplicationEntry; struct _ApplicationEntry { IndicatorObjectEntry entry; + gchar * icon_path; }; #define INDICATOR_APPLICATION_GET_PRIVATE(o) \ @@ -91,7 +92,7 @@ static void indicator_application_dispose (GObject *object); static void indicator_application_finalize (GObject *object); static GList * get_entries (IndicatorObject * io); static void connected (IndicatorServiceManager * sm, gboolean connected, IndicatorApplication * application); -static void application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, IndicatorApplication * application); +static void application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, IndicatorApplication * application); static void application_removed (DBusGProxy * proxy, gint position , IndicatorApplication * application); static void application_icon_changed (DBusGProxy * proxy, gint position, const gchar * iconname, IndicatorApplication * application); static void get_applications (DBusGProxy *proxy, GPtrArray *OUT_applications, GError *error, gpointer userdata); @@ -112,12 +113,13 @@ indicator_application_class_init (IndicatorApplicationClass *klass) io_class->get_entries = get_entries; - dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_INT_STRING_STRING, + dbus_g_object_register_marshaller(_application_service_marshal_VOID__STRING_INT_STRING_STRING_STRING, G_TYPE_NONE, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INVALID); dbus_g_object_register_marshaller(_application_service_marshal_VOID__INT_STRING, G_TYPE_NONE, @@ -217,6 +219,7 @@ connected (IndicatorServiceManager * sm, gboolean connected, IndicatorApplicatio G_TYPE_INT, G_TYPE_STRING, G_TYPE_STRING, + G_TYPE_STRING, G_TYPE_INVALID); dbus_g_proxy_add_signal(priv->service_proxy, "ApplicationRemoved", @@ -283,12 +286,19 @@ get_entries (IndicatorObject * io) ApplicationEntry and signaling the indicator host that we've got a new indicator. */ static void -application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, IndicatorApplication * application) +application_added (DBusGProxy * proxy, const gchar * iconname, gint position, const gchar * dbusaddress, const gchar * dbusobject, const gchar * icon_path, IndicatorApplication * application) { g_debug("Building new application entry: %s with icon: %s", dbusaddress, iconname); IndicatorApplicationPrivate * priv = INDICATOR_APPLICATION_GET_PRIVATE(application); ApplicationEntry * app = g_new(ApplicationEntry, 1); + app->icon_path = NULL; + if (icon_path != NULL && icon_path[0] != '\0') { + app->icon_path = g_strdup(icon_path); + g_debug("\tAppending search path: %s", app->icon_path); + gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), app->icon_path); + } + app->entry.image = GTK_IMAGE(gtk_image_new_from_icon_name(iconname, GTK_ICON_SIZE_MENU)); app->entry.label = NULL; app->entry.menu = GTK_MENU(dbusmenu_gtkmenu_new((gchar *)dbusaddress, (gchar *)dbusobject)); @@ -318,6 +328,9 @@ application_removed (DBusGProxy * proxy, gint position, IndicatorApplication * a priv->applications = g_list_remove(priv->applications, app); g_signal_emit(G_OBJECT(application), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED_ID, 0, &(app->entry), TRUE); + if (app->icon_path != NULL) { + g_free(app->icon_path); + } if (app->entry.image != NULL) { g_object_unref(G_OBJECT(app->entry.image)); } diff --git a/src/libappindicator/app-indicator.c b/src/libappindicator/app-indicator.c index bb68cb2..d22161c 100644 --- a/src/libappindicator/app-indicator.c +++ b/src/libappindicator/app-indicator.c @@ -63,6 +63,7 @@ struct _AppIndicatorPrivate { AppIndicatorStatus status; gchar *icon_name; gchar *attention_icon_name; + gchar * icon_path; DbusmenuServer *menuservice; GtkWidget *menu; @@ -91,6 +92,7 @@ enum { PROP_STATUS, PROP_ICON_NAME, PROP_ATTENTION_ICON_NAME, + PROP_ICON_PATH, PROP_MENU, PROP_CONNECTED }; @@ -101,6 +103,7 @@ enum { #define PROP_STATUS_S "status" #define PROP_ICON_NAME_S "icon-name" #define PROP_ATTENTION_ICON_NAME_S "attention-icon-name" +#define PROP_ICON_PATH_S "icon-path" #define PROP_MENU_S "menu" #define PROP_CONNECTED_S "connected" @@ -179,6 +182,14 @@ app_indicator_class_init (AppIndicatorClass *klass) NULL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property(object_class, + PROP_ICON_PATH, + g_param_spec_string (PROP_ICON_PATH_S, + "An additional path for custom icons.", + "An additional place to look for icon names that may be installed by the application.", + NULL, + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY)); + g_object_class_install_property(object_class, PROP_MENU, g_param_spec_string (PROP_MENU_S, @@ -277,6 +288,7 @@ app_indicator_init (AppIndicator *self) priv->status = APP_INDICATOR_STATUS_PASSIVE; priv->icon_name = NULL; priv->attention_icon_name = NULL; + priv->icon_path = NULL; priv->menu = NULL; priv->menuservice = NULL; @@ -355,6 +367,11 @@ app_indicator_finalize (GObject *object) priv->attention_icon_name = NULL; } + if (priv->icon_path != NULL) { + g_free(priv->icon_path); + priv->icon_path = NULL; + } + G_OBJECT_CLASS (app_indicator_parent_class)->finalize (object); return; } @@ -423,6 +440,13 @@ app_indicator_set_property (GObject * object, guint prop_id, const GValue * valu g_value_get_string (value)); break; + case PROP_ICON_PATH: + if (priv->icon_path != NULL) { + g_free(priv->icon_path); + } + priv->icon_path = g_value_dup_string(value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -462,6 +486,10 @@ app_indicator_get_property (GObject * object, guint prop_id, GValue * value, GPa g_value_set_string (value, priv->attention_icon_name); break; + case PROP_ICON_PATH: + g_value_set_string (value, priv->icon_path); + break; + case PROP_MENU: if (G_VALUE_HOLDS_STRING(value)) { if (priv->menuservice != NULL) { @@ -573,6 +601,36 @@ app_indicator_new (const gchar *id, } /** + app_indicator_new_with_path: + @id: The unique id of the indicator to create. + @icon_name: The icon name for this indicator + @category: The category of indicator. + @icon_path: A custom path for finding icons. + + Creates a new #AppIndicator setting the properties: + #AppIndicator::id with @id, #AppIndicator::category + with @category, #AppIndicator::icon-name with + @icon_name and #AppIndicator::icon-path with @icon_path. + + Return value: A pointer to a new #AppIndicator object. + */ +AppIndicator * +app_indicator_new_with_path (const gchar *id, + const gchar *icon_name, + AppIndicatorCategory category, + const gchar *icon_path) +{ + AppIndicator *indicator = g_object_new (APP_INDICATOR_TYPE, + "id", id, + "category", category_from_enum (category), + "icon-name", icon_name, + "icon-path", icon_path, + NULL); + + return indicator; +} + +/** app_indicator_get_type: Generates or returns the unique #GType for #AppIndicator. diff --git a/src/libappindicator/app-indicator.h b/src/libappindicator/app-indicator.h index e966a49..52438f6 100644 --- a/src/libappindicator/app-indicator.h +++ b/src/libappindicator/app-indicator.h @@ -202,6 +202,10 @@ GType app_indicator_get_type (void) G_GNUC_C AppIndicator *app_indicator_new (const gchar *id, const gchar *icon_name, AppIndicatorCategory category); +AppIndicator *app_indicator_new_with_path (const gchar *id, + const gchar *icon_name, + AppIndicatorCategory category, + const gchar *icon_path); /* Set properties */ void app_indicator_set_status (AppIndicator *self, diff --git a/src/notification-item.xml b/src/notification-item.xml index c28cc54..b671e38 100644 --- a/src/notification-item.xml +++ b/src/notification-item.xml @@ -8,6 +8,7 @@ <property name="Status" type="s" access="read" /> <property name="IconName" type="s" access="read" /> <property name="AttentionIconName" type="s" access="read" /> + <property name="IconPath" type="s" access="read" /> <property name="Menu" type="o" access="read" /> <!-- Methods --> |