aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am113
-rw-r--r--src/app-indicator-enum-types.c.in (renamed from src/libappindicator/app-indicator-enum-types.gen.c.in)9
-rw-r--r--src/app-indicator-enum-types.h.in (renamed from src/libappindicator/app-indicator-enum-types.h.in)7
-rw-r--r--src/app-indicator.c (renamed from src/libappindicator/app-indicator.c)119
-rw-r--r--src/app-indicator.h (renamed from src/libappindicator/app-indicator.h)16
-rw-r--r--src/appindicator-0.1.pc.in (renamed from src/libappindicator/appindicator-0.1.pc.in)0
-rw-r--r--src/application-service-appstore.c57
7 files changed, 212 insertions, 109 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 9f2771e..787ba2f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,7 +1,7 @@
CLEANFILES =
DISTCLEANFILES =
BUILT_SOURCES =
-EXTRA_DIST = libappindicator/appindicator-0.1.pc.in
+EXTRA_DIST = appindicator-0.1.pc.in
include $(top_srcdir)/Makefile.am.enum
include $(top_srcdir)/Makefile.am.marshal
@@ -32,27 +32,32 @@ libapplication_la_LDFLAGS = -module -avoid-version
libexec_PROGRAMS = indicator-application-service
+BUILT_SOURCES += \
+ application-service-server.h \
+ application-service-marshal.h \
+ application-service-marshal.c \
+ dbus-properties-client.h \
+ notification-item-client.h \
+ notification-watcher-server.h
+
indicator_application_service_SOURCES = \
application-service.c \
application-service-appstore.h \
application-service-appstore.c \
application-service-lru-file.h \
application-service-lru-file.c \
- application-service-marshal.h \
application-service-marshal.c \
- application-service-server.h \
application-service-watcher.h \
application-service-watcher.c \
- dbus-properties-client.h \
- dbus-shared.h \
- notification-item-client.h \
- notification-watcher-server.h
+ app-indicator-enum-types.c \
+ dbus-shared.h
indicator_application_service_CFLAGS = \
$(INDICATOR_CFLAGS) \
-Wall -Werror \
-DG_LOG_DOMAIN=\"indicator-application-service\"
indicator_application_service_LDADD = \
- $(INDICATOR_LIBS)
+ $(INDICATOR_LIBS) \
+ libappindicator.la
glib_marshal_list = application-service-marshal.list
glib_marshal_prefix = _application_service_marshal
@@ -61,24 +66,14 @@ glib_marshal_prefix = _application_service_marshal
# Library
##################################
-pkgconfig_DATA = libappindicator/appindicator-0.1.pc
+pkgconfig_DATA = appindicator-0.1.pc
pkgconfigdir = $(libdir)/pkgconfig
-glib_enum_h = libappindicator/app-indicator-enum-types.h
-glib_enum_c = libappindicator/app-indicator-enum-types.gen.c
-glib_enum_headers = $(libappindicator_headers)
-
-libappindicator/app-indicator-enum-types.c: libappindicator/app-indicator-enum-types.gen.c
- sed -e "s|\"passive\"|\"Passive\"|" \
- -e "s|\"active\"|\"Active\"|" \
- -e "s|\"attention\"|\"NeedsAttention\"|" \
- -e "s|\"application-status\"|\"ApplicationStatus\"|" \
- -e "s|\"communications\"|\"Communications\"|" \
- -e "s|\"system-services\"|\"SystemServices\"|" \
- -e "s|\"hardware\"|\"Hardware\"|" \
- -e "s|\"other\"|\"Other\"|" \
- $< > $@
-DISTCLEANFILES += libappindicator/app-indicator-enum-types.c
+glib_enum_h = app-indicator-enum-types.h
+glib_enum_c = app-indicator-enum-types.c
+glib_enum_headers = $(addprefix $(srcdir)/, $(libappindicator_headers))
+
+DISTCLEANFILES += app-indicator-enum-types.c
lib_LTLIBRARIES = \
libappindicator.la
@@ -86,18 +81,20 @@ lib_LTLIBRARIES = \
libappindicatorincludedir=$(includedir)/libappindicator-0.1/libappindicator
libappindicator_headers = \
- $(srcdir)/libappindicator/app-indicator.h
+ app-indicator.h
libappindicatorinclude_HEADERS = \
$(libappindicator_headers) \
$(glib_enum_h)
+BUILT_SOURCES += \
+ notification-watcher-client.h \
+ notification-item-server.h
+
libappindicator_la_SOURCES = \
$(libappindicator_headers) \
- libappindicator/app-indicator-enum-types.c \
- notification-watcher-client.h \
- notification-item-server.h \
- libappindicator/app-indicator.c
+ app-indicator-enum-types.c \
+ app-indicator.c
libappindicator_la_LDFLAGS = \
-version-info 0:0:0 \
@@ -117,6 +114,7 @@ libappindicator_la_LIBADD = \
##################################
DBUS_SPECS = \
+ dbus-properties.xml \
application-service.xml \
notification-item.xml \
notification-watcher.xml
@@ -142,3 +140,60 @@ BUILT_SOURCES += \
CLEANFILES += $(BUILT_SOURCES)
EXTRA_DIST += $(DBUS_SPECS)
+
+#########################
+# GObject Introsepction
+#########################
+
+-include $(INTROSPECTION_MAKEFILE)
+INTROSPECTION_GIRS =
+INTROSPECTION_SCANNER_ARGS = \
+ --add-include-path=$(srcdir) \
+ $(addprefix --c-include=libappindicator/, $(introspection_sources))
+INTROSPECTION_COMPILER_ARGS = --includedir=$(builddir)
+
+if HAVE_INTROSPECTION
+
+introspection_sources = \
+ $(addprefix $(srcdir)/,$(libappindicator_headers)) \
+ $(addprefix $(top_builddir)/src/, $(glib_enum_h))
+
+AppIndicator-0.1.gir: libappindicator.la $(glib_enum_h)
+AppIndicator_0_1_gir_INCLUDES = \
+ GObject-2.0 \
+ Gtk-2.0
+AppIndicator_0_1_gir_CFLAGS = $(INDICATOR_CFLAGS) -I$(srcdir) -I$(top_builddir)/src
+AppIndicator_0_1_gir_LIBS = libappindicator.la
+AppIndicator_0_1_gir_FILES = $(introspection_sources)
+
+INTROSPECTION_GIRS += AppIndicator-0.1.gir
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibdir = $(libdir)/girepository-1.0
+typelib_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+CLEANFILES += $(gir_DATA) $(typelib_DATA)
+
+endif
+
+#########################
+# VAPI Files
+#########################
+
+if HAVE_INTROSPECTION
+
+vapidir = $(datadir)/vala/vapi
+vapi_DATA = AppIndicator-0.1.vapi
+
+AppIndicator-0.1.vapi: AppIndicator-0.1.gir Makefile.am
+ $(VALA_API_GEN) --library=AppIndicator-0.1 \
+ --pkg gtk+-2.0 \
+ --vapidir=$(top_builddir)/src \
+ $<
+
+CLEANFILES += $(vapi_DATA)
+
+endif
+
diff --git a/src/libappindicator/app-indicator-enum-types.gen.c.in b/src/app-indicator-enum-types.c.in
index 449f3fc..e200396 100644
--- a/src/libappindicator/app-indicator-enum-types.gen.c.in
+++ b/src/app-indicator-enum-types.c.in
@@ -27,7 +27,7 @@ License version 3 and version 2.1 along with this program. If not, see
<http://www.gnu.org/licenses/>
*/
-#include "libappindicator/app-indicator-enum-types.h"
+#include "app-indicator-enum-types.h"
/*** END file-header ***/
@@ -36,6 +36,13 @@ License version 3 and version 2.1 along with this program. If not, see
/*** END file-production ***/
/*** BEGIN value-header ***/
+/**
+ @enum_name@_get_type:
+
+ Builds a GLib type for the #@EnumName@ enumeration.
+
+ Return value: A unique #GType for the #@EnumName@ enum.
+*/
GType
@enum_name@_get_type (void)
{
diff --git a/src/libappindicator/app-indicator-enum-types.h.in b/src/app-indicator-enum-types.h.in
index da3bf98..a055d71 100644
--- a/src/libappindicator/app-indicator-enum-types.h.in
+++ b/src/app-indicator-enum-types.h.in
@@ -48,13 +48,6 @@ G_END_DECLS
/*** END file-production ***/
/*** BEGIN value-header ***/
-/**
- @enum_name@_get_type:
-
- Builds a glib type for the @EnumName@ enumeration.
-
- Return value: A registered type for the enum
-*/
GType @enum_name@_get_type (void) G_GNUC_CONST;
#define APP_INDICATOR_TYPE_@ENUMSHORT@ (@enum_name@_get_type())
diff --git a/src/libappindicator/app-indicator.c b/src/app-indicator.c
index 03819ca..32f512f 100644
--- a/src/libappindicator/app-indicator.c
+++ b/src/app-indicator.c
@@ -35,8 +35,8 @@ License version 3 and version 2.1 along with this program. If not, see
#include <libdbusmenu-glib/server.h>
#include <libdbusmenu-gtk/client.h>
-#include "libappindicator/app-indicator.h"
-#include "libappindicator/app-indicator-enum-types.h"
+#include "app-indicator.h"
+#include "app-indicator-enum-types.h"
#include "notification-item-server.h"
#include "notification-watcher-client.h"
@@ -52,13 +52,13 @@ License version 3 and version 2.1 along with this program. If not, see
application indicator.
*/
/* Private Fields
- @id: The ID of the indicator. Maps to AppIndicator::id.
- @category: Which category the indicator is. Maps to AppIndicator::category.
- @status: The status of the indicator. Maps to AppIndicator::status.
- @icon_name: The name of the icon to use. Maps to AppIndicator::icon-name.
- @attention_icon_name: The name of the attention icon to use. Maps to AppIndicator::attention-icon-name.
- @menu: The menu for this indicator. Maps to AppIndicator::menu
- @watcher_proxy: The proxy connection to the watcher we're connected to. If we're not connected to one this will be #NULL.
+ @id: The ID of the indicator. Maps to AppIndicator:id.
+ @category: Which category the indicator is. Maps to AppIndicator:category.
+ @status: The status of the indicator. Maps to AppIndicator:status.
+ @icon_name: The name of the icon to use. Maps to AppIndicator:icon-name.
+ @attention_icon_name: The name of the attention icon to use. Maps to AppIndicator:attention-icon-name.
+ @menu: The menu for this indicator. Maps to AppIndicator:menu
+ @watcher_proxy: The proxy connection to the watcher we're connected to. If we're not connected to one this will be %NULL.
*/
struct _AppIndicatorPrivate {
/*< Private >*/
@@ -175,38 +175,68 @@ app_indicator_class_init (AppIndicatorClass *klass)
klass->unfallback = unfallback;
/* Properties */
+
+ /**
+ AppIndicator:id:
+
+ The ID for this indicator, which should be unique, but used consistently
+ by this program and its indicator.
+ */
g_object_class_install_property (object_class,
PROP_ID,
g_param_spec_string(PROP_ID_S,
"The ID for this indicator",
- "An ID that should be unique, but used consistently by this program and it's indicator.",
+ "An ID that should be unique, but used consistently by this program and its indicator.",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY));
+ /**
+ AppIndicator:category:
+
+ The type of indicator that this represents. Please don't use 'Other'.
+ Defaults to 'ApplicationStatus'.
+ */
g_object_class_install_property (object_class,
PROP_CATEGORY,
g_param_spec_string (PROP_CATEGORY_S,
"Indicator Category",
- "The type of indicator that this represents. Please don't use 'other'. Defaults to 'Application Status'.",
+ "The type of indicator that this represents. Please don't use 'other'. Defaults to 'ApplicationStatus'.",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY));
+ /**
+ AppIndicator:status:
+
+ Whether the indicator is shown or requests attention. Defaults to
+ 'Passive'.
+ */
g_object_class_install_property (object_class,
PROP_STATUS,
g_param_spec_string (PROP_STATUS_S,
"Indicator Status",
- "Whether the indicator is shown or requests attention. Defaults to 'off'.",
+ "Whether the indicator is shown or requests attention. Defaults to 'Passive'.",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ /**
+ AppIndicator:icon-name:
+
+ The name of the regular icon that is shown for the indicator.
+ */
g_object_class_install_property(object_class,
- PROP_ICON_NAME,
+ PROP_ICON_NAME,
g_param_spec_string (PROP_ICON_NAME_S,
"An icon for the indicator",
"The default icon that is shown for the indicator.",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ /**
+ AppIndicator:attention-icon-name:
+
+ If the indicator sets it's status to %APP_INDICATOR_STATUS_ATTENTION
+ then this icon is shown.
+ */
g_object_class_install_property (object_class,
PROP_ATTENTION_ICON_NAME,
g_param_spec_string (PROP_ATTENTION_ICON_NAME_S,
@@ -214,7 +244,12 @@ app_indicator_class_init (AppIndicatorClass *klass)
"If the indicator sets it's status to 'attention' then this icon is shown.",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
+ /**
+ AppIndicator:icon-theme-path:
+
+ An additional place to look for icon names that may be installed by the
+ application.
+ */
g_object_class_install_property(object_class,
PROP_ICON_THEME_PATH,
g_param_spec_string (PROP_ICON_THEME_PATH_S,
@@ -222,8 +257,13 @@ app_indicator_class_init (AppIndicatorClass *klass)
"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,
+
+ /**
+ AppIndicator:menu:
+
+ A method for getting the menu path as a string for DBus.
+ */
+ g_object_class_install_property(object_class,
PROP_MENU,
g_param_spec_boxed (PROP_MENU_S,
"The object path of the menu on DBus.",
@@ -231,6 +271,12 @@ app_indicator_class_init (AppIndicatorClass *klass)
DBUS_TYPE_G_OBJECT_PATH,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ /**
+ AppIndicator:connected:
+
+ Pretty simple, %TRUE if we have a reasonable expectation of being
+ displayed through this object. You should hide your TrayIcon if so.
+ */
g_object_class_install_property (object_class,
PROP_CONNECTED,
g_param_spec_boolean (PROP_CONNECTED_S,
@@ -246,8 +292,7 @@ app_indicator_class_init (AppIndicatorClass *klass)
AppIndicator::new-icon:
@arg0: The #AppIndicator object
- Signaled when there is a new icon set for the
- object.
+ Emitted when #AppIndicator:icon-name is changed
*/
signals[NEW_ICON] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_ICON,
G_TYPE_FROM_CLASS(klass),
@@ -261,8 +306,7 @@ app_indicator_class_init (AppIndicatorClass *klass)
AppIndicator::new-attention-icon:
@arg0: The #AppIndicator object
- Signaled when there is a new attention icon set for the
- object.
+ Emitted when #AppIndicator:attention-icon-name is changed
*/
signals[NEW_ATTENTION_ICON] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_ATTENTION_ICON,
G_TYPE_FROM_CLASS(klass),
@@ -277,7 +321,7 @@ app_indicator_class_init (AppIndicatorClass *klass)
@arg0: The #AppIndicator object
@arg1: The string value of the #AppIndicatorStatus enum.
- Signaled when the status of the indicator changes.
+ Emitted when #AppIndicator:status is changed
*/
signals[NEW_STATUS] = g_signal_new (APP_INDICATOR_SIGNAL_NEW_STATUS,
G_TYPE_FROM_CLASS(klass),
@@ -293,8 +337,7 @@ app_indicator_class_init (AppIndicatorClass *klass)
@arg0: The #AppIndicator object
@arg1: Whether we're connected or not
- Signaled when we connect to a watcher, or when it drops
- away.
+ Signaled when we connect to a watcher, or when it drops away.
*/
signals[CONNECTION_CHANGED] = g_signal_new (APP_INDICATOR_SIGNAL_CONNECTION_CHANGED,
G_TYPE_FROM_CLASS(klass),
@@ -957,8 +1000,8 @@ append_panel_icon_suffix (const gchar *icon_name)
@category: The category of indicator.
Creates a new #AppIndicator setting the properties:
- #AppIndicator::id with @id, #AppIndicator::category
- with @category and #AppIndicator::icon-name with
+ #AppIndicator:id with @id, #AppIndicator:category
+ with @category and #AppIndicator:icon-name with
@icon_name.
Return value: A pointer to a new #AppIndicator object.
@@ -985,9 +1028,9 @@ app_indicator_new (const gchar *id,
@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-theme-path with @icon_path.
+ #AppIndicator:id with @id, #AppIndicator:category
+ with @category, #AppIndicator:icon-name with
+ @icon_name and #AppIndicator:icon-theme-path with @icon_path.
Return value: A pointer to a new #AppIndicator object.
*/
@@ -1020,7 +1063,7 @@ app_indicator_new_with_path (const gchar *id,
@self: The #AppIndicator object to use
@status: The status to set for this indicator
- Wrapper function for property #AppIndicator::status.
+ Wrapper function for property #AppIndicator:status.
*/
void
app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status)
@@ -1041,7 +1084,7 @@ app_indicator_set_status (AppIndicator *self, AppIndicatorStatus status)
@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.
+ Wrapper function for property #AppIndicator:attention-icon-name.
*/
void
app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name)
@@ -1070,6 +1113,7 @@ app_indicator_set_attention_icon (AppIndicator *self, const gchar *icon_name)
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.
+ Wrapper function for property #AppIndicator:icon-name.
**/
void
app_indicator_set_icon (AppIndicator *self, const gchar *icon_name)
@@ -1481,6 +1525,8 @@ client_menu_changed (GtkWidget *widget,
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.
+
+ Wrapper function for property #AppIndicator:menu.
**/
void
app_indicator_set_menu (AppIndicator *self, GtkMenu *menu)
@@ -1519,7 +1565,7 @@ app_indicator_set_menu (AppIndicator *self, GtkMenu *menu)
app_indicator_get_id:
@self: The #AppIndicator object to use
- Wrapper function for property #AppIndicator::id.
+ Wrapper function for property #AppIndicator:id.
Return value: The current ID
*/
@@ -1535,7 +1581,7 @@ app_indicator_get_id (AppIndicator *self)
app_indicator_get_category:
@self: The #AppIndicator object to use
- Wrapper function for property #AppIndicator::category.
+ Wrapper function for property #AppIndicator:category.
Return value: The current category.
*/
@@ -1551,7 +1597,7 @@ app_indicator_get_category (AppIndicator *self)
app_indicator_get_status:
@self: The #AppIndicator object to use
- Wrapper function for property #AppIndicator::status.
+ Wrapper function for property #AppIndicator:status.
Return value: The current status.
*/
@@ -1567,7 +1613,7 @@ app_indicator_get_status (AppIndicator *self)
app_indicator_get_icon:
@self: The #AppIndicator object to use
- Wrapper function for property #AppIndicator::icon-name.
+ Wrapper function for property #AppIndicator:icon-name.
Return value: The current icon name.
*/
@@ -1583,7 +1629,7 @@ app_indicator_get_icon (AppIndicator *self)
app_indicator_get_attention_icon:
@self: The #AppIndicator object to use
- Wrapper function for property #AppIndicator::attention-icon-name.
+ Wrapper function for property #AppIndicator:attention-icon-name.
Return value: The current attention icon name.
*/
@@ -1600,8 +1646,9 @@ app_indicator_get_attention_icon (AppIndicator *self)
@self: The #AppIndicator object to use
Gets the menu being used for this application indicator.
+ Wrapper function for property #AppIndicator:menu.
- Return value: A menu object or #NULL if one hasn't been set.
+ Return value: A #GtkMenu object or %NULL if one hasn't been set.
*/
GtkMenu *
app_indicator_get_menu (AppIndicator *self)
diff --git a/src/libappindicator/app-indicator.h b/src/app-indicator.h
index 549ab35..e37abd4 100644
--- a/src/libappindicator/app-indicator.h
+++ b/src/app-indicator.h
@@ -113,11 +113,11 @@ G_BEGIN_DECLS
users can find indicators that are similar together.
*/
typedef enum { /*< prefix=APP_INDICATOR_CATEGORY >*/
- APP_INDICATOR_CATEGORY_APPLICATION_STATUS,
- APP_INDICATOR_CATEGORY_COMMUNICATIONS,
- APP_INDICATOR_CATEGORY_SYSTEM_SERVICES,
- APP_INDICATOR_CATEGORY_HARDWARE,
- APP_INDICATOR_CATEGORY_OTHER
+ APP_INDICATOR_CATEGORY_APPLICATION_STATUS, /*< nick=ApplicationStatus >*/
+ APP_INDICATOR_CATEGORY_COMMUNICATIONS, /*< nick=Communications >*/
+ APP_INDICATOR_CATEGORY_SYSTEM_SERVICES, /*< nick=SystemServices >*/
+ APP_INDICATOR_CATEGORY_HARDWARE, /*< nick=Hardware >*/
+ APP_INDICATOR_CATEGORY_OTHER /*< nick=Other >*/
} AppIndicatorCategory;
/**
@@ -132,9 +132,9 @@ typedef enum { /*< prefix=APP_INDICATOR_CATEGORY >*/
shown by setting it to @APP_INDICATOR_STATUS_ACTIVE.
*/
typedef enum { /*< prefix=APP_INDICATOR_STATUS >*/
- APP_INDICATOR_STATUS_PASSIVE,
- APP_INDICATOR_STATUS_ACTIVE,
- APP_INDICATOR_STATUS_ATTENTION
+ APP_INDICATOR_STATUS_PASSIVE, /*< nick=Passive >*/
+ APP_INDICATOR_STATUS_ACTIVE, /*< nick=Active >*/
+ APP_INDICATOR_STATUS_ATTENTION /*< nick=NeedsAttention >*/
} AppIndicatorStatus;
typedef struct _AppIndicator AppIndicator;
diff --git a/src/libappindicator/appindicator-0.1.pc.in b/src/appindicator-0.1.pc.in
index b80fded..b80fded 100644
--- a/src/libappindicator/appindicator-0.1.pc.in
+++ b/src/appindicator-0.1.pc.in
diff --git a/src/application-service-appstore.c b/src/application-service-appstore.c
index b189a45..15abea3 100644
--- a/src/application-service-appstore.c
+++ b/src/application-service-appstore.c
@@ -25,6 +25,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#endif
#include <dbus/dbus-glib.h>
+#include "app-indicator.h"
+#include "app-indicator-enum-types.h"
#include "application-service-appstore.h"
#include "application-service-marshal.h"
#include "dbus-properties-client.h"
@@ -55,17 +57,6 @@ struct _ApplicationServiceAppstorePrivate {
AppLruFile * lrufile;
};
-#define APP_STATUS_PASSIVE_STR "Passive"
-#define APP_STATUS_ACTIVE_STR "Active"
-#define APP_STATUS_ATTENTION_STR "NeedsAttention"
-
-typedef enum _ApplicationStatus ApplicationStatus;
-enum _ApplicationStatus {
- APP_STATUS_PASSIVE,
- APP_STATUS_ACTIVE,
- APP_STATUS_ATTENTION
-};
-
typedef struct _Application Application;
struct _Application {
gchar * id;
@@ -76,7 +67,7 @@ struct _Application {
DBusGProxy * dbus_proxy;
DBusGProxy * prop_proxy;
gboolean validated; /* Whether we've gotten all the parameters and they look good. */
- ApplicationStatus status;
+ AppIndicatorStatus status;
gchar * icon;
gchar * aicon;
gchar * menu;
@@ -102,8 +93,8 @@ static void application_service_appstore_class_init (ApplicationServiceAppstoreC
static void application_service_appstore_init (ApplicationServiceAppstore *self);
static void application_service_appstore_dispose (GObject *object);
static void application_service_appstore_finalize (GObject *object);
-static ApplicationStatus string_to_status(const gchar * status_string);
-static void apply_status (Application * app, ApplicationStatus status);
+static AppIndicatorStatus string_to_status(const gchar * status_string);
+static void apply_status (Application * app, AppIndicatorStatus status);
G_DEFINE_TYPE (ApplicationServiceAppstore, application_service_appstore, G_TYPE_OBJECT);
@@ -249,14 +240,24 @@ get_all_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * err
}
/* Simple translation function -- could be optimized */
-static ApplicationStatus
+static AppIndicatorStatus
string_to_status(const gchar * status_string)
{
- if (!g_strcmp0(status_string, APP_STATUS_ACTIVE_STR))
- return APP_STATUS_ACTIVE;
- if (!g_strcmp0(status_string, APP_STATUS_ATTENTION_STR))
- return APP_STATUS_ATTENTION;
- return APP_STATUS_PASSIVE;
+ GEnumClass * klass = G_ENUM_CLASS(g_type_class_ref(APP_INDICATOR_TYPE_INDICATOR_STATUS));
+ g_return_val_if_fail(klass != NULL, APP_INDICATOR_STATUS_PASSIVE);
+
+ AppIndicatorStatus retval = APP_INDICATOR_STATUS_PASSIVE;
+
+ GEnumValue * val = g_enum_get_value_by_nick(klass, status_string);
+ if (val == NULL) {
+ g_warning("Unrecognized status '%s' assuming passive.", status_string);
+ } else {
+ retval = (AppIndicatorStatus)val->value;
+ }
+
+ g_type_class_unref(klass);
+
+ return retval;
}
/* A small helper function to get the position of an application
@@ -330,7 +331,7 @@ application_removed_cb (DBusGProxy * proxy, gpointer userdata)
Application * app = (Application *)userdata;
/* Remove from the panel */
- apply_status(app, APP_STATUS_PASSIVE);
+ apply_status(app, APP_INDICATOR_STATUS_PASSIVE);
/* Destroy the data */
application_free(app);
@@ -375,7 +376,7 @@ app_sort_func (gconstpointer a, gconstpointer b, gpointer userdata)
it removes it from the panel. If we're coming online, then
it add it to the panel. Otherwise it changes the icon. */
static void
-apply_status (Application * app, ApplicationStatus status)
+apply_status (Application * app, AppIndicatorStatus status)
{
if (app->status == status) {
return;
@@ -386,7 +387,7 @@ apply_status (Application * app, ApplicationStatus status)
ApplicationServiceAppstorePrivate * priv = APPLICATION_SERVICE_APPSTORE_GET_PRIVATE(appstore);
/* This means we're going off line */
- if (status == APP_STATUS_PASSIVE) {
+ if (status == APP_INDICATOR_STATUS_PASSIVE) {
gint position = get_position(app);
if (position == -1) return;
@@ -397,12 +398,12 @@ apply_status (Application * app, ApplicationStatus status)
} else {
/* Figure out which icon we should be using */
gchar * newicon = app->icon;
- if (status == APP_STATUS_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') {
+ if (status == APP_INDICATOR_STATUS_ATTENTION && app->aicon != NULL && app->aicon[0] != '\0') {
newicon = app->aicon;
}
/* Determine whether we're already shown or not */
- if (app->status == APP_STATUS_PASSIVE) {
+ if (app->status == APP_INDICATOR_STATUS_PASSIVE) {
if (can_add_application (priv->applications, app)) {
/* Put on panel */
priv->applications = g_list_insert_sorted_with_data (priv->applications, app, app_sort_func, priv->lrufile);
@@ -457,7 +458,7 @@ new_icon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdata
if (app->icon != NULL) g_free(app->icon);
app->icon = g_strdup(newicon);
- if (app->status == APP_STATUS_ACTIVE) {
+ if (app->status == APP_INDICATOR_STATUS_ACTIVE) {
gint position = get_position(app);
if (position == -1) return;
@@ -495,7 +496,7 @@ new_aicon_cb (DBusGProxy * proxy, GValue value, GError * error, gpointer userdat
if (app->aicon != NULL) g_free(app->aicon);
app->aicon = g_strdup(newicon);
- if (app->status == APP_STATUS_ATTENTION) {
+ if (app->status == APP_INDICATOR_STATUS_ATTENTION) {
gint position = get_position(app);
if (position == -1) return;
@@ -576,7 +577,7 @@ application_service_appstore_application_add (ApplicationServiceAppstore * appst
app->dbus_name = g_strdup(dbus_name);
app->dbus_object = g_strdup(dbus_object);
app->appstore = appstore;
- app->status = APP_STATUS_PASSIVE;
+ app->status = APP_INDICATOR_STATUS_PASSIVE;
app->icon = NULL;
app->aicon = NULL;
app->menu = NULL;