aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c37
-rw-r--r--src/service.c55
-rw-r--r--src/service.h3
3 files changed, 13 insertions, 82 deletions
diff --git a/src/main.c b/src/main.c
index 7bb6b92..ef615dc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -33,37 +33,6 @@
****
***/
-static gboolean replace = FALSE;
-
-static void
-parse_command_line (int * argc, char *** argv)
-{
- GError * error;
- GOptionContext * option_context;
-
- static GOptionEntry entries[] =
- {
- { "replace", 'r', 0, G_OPTION_ARG_NONE, &replace, "Replace the currently-running service", NULL },
- { NULL }
- };
-
- error = NULL;
- option_context = g_option_context_new ("- indicator-power service");
- g_option_context_add_main_entries (option_context, entries, GETTEXT_PACKAGE);
- if (!g_option_context_parse (option_context, argc, argv, &error))
- {
- g_print ("option parsing failed: %s\n", error->message);
- g_error_free (error);
- exit (EXIT_FAILURE);
- }
-
- g_option_context_free (option_context);
-}
-
-/***
-****
-***/
-
static void
on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop)
{
@@ -72,7 +41,7 @@ on_name_lost (gpointer instance G_GNUC_UNUSED, gpointer loop)
}
int
-main (int argc, char ** argv)
+main (int argc G_GNUC_UNUSED, char ** argv G_GNUC_UNUSED)
{
GMainLoop * loop;
IndicatorPowerService * service;
@@ -83,11 +52,9 @@ main (int argc, char ** argv)
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
textdomain (GETTEXT_PACKAGE);
- parse_command_line (&argc, &argv);
-
/* run */
device_provider = indicator_power_device_provider_upower_new ();
- service = indicator_power_service_new (replace, device_provider);
+ service = indicator_power_service_new (device_provider);
loop = g_main_loop_new (NULL, FALSE);
g_signal_connect (service, INDICATOR_POWER_SERVICE_SIGNAL_NAME_LOST,
G_CALLBACK(on_name_lost), loop);
diff --git a/src/service.c b/src/service.c
index f314906..012ef13 100644
--- a/src/service.c
+++ b/src/service.c
@@ -48,7 +48,6 @@ static guint signals[LAST_SIGNAL] = { 0 };
enum
{
PROP_0,
- PROP_REPLACE,
PROP_DEVICE_PROVIDER,
LAST_PROP
};
@@ -109,8 +108,6 @@ struct _IndicatorPowerServicePrivate
GSimpleAction * header_action;
GSimpleAction * show_time_action;
- gboolean replace;
-
IndicatorPowerDevice * primary_device;
GList * devices; /* IndicatorPowerDevice */
@@ -802,29 +799,6 @@ on_devices_changed (IndicatorPowerService * self)
***/
static void
-my_constructed (GObject * o)
-{
- GBusNameOwnerFlags owner_flags;
- IndicatorPowerService * self = INDICATOR_POWER_SERVICE(o);
- priv_t * p = self->priv;
-
- /* own the name here in constructed() instead of init()
- so that we know the value of the 'replace' property */
- owner_flags = G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT;
- if (p->replace)
- owner_flags |= G_BUS_NAME_OWNER_FLAGS_REPLACE;
-
- p->own_id = g_bus_own_name (G_BUS_TYPE_SESSION,
- BUS_NAME,
- owner_flags,
- on_bus_acquired,
- NULL,
- on_name_lost,
- self,
- NULL);
-}
-
-static void
my_get_property (GObject * o,
guint property_id,
GValue * value,
@@ -835,10 +809,6 @@ my_get_property (GObject * o,
switch (property_id)
{
- case PROP_REPLACE:
- g_value_set_boolean (value, p->replace);
- break;
-
case PROP_DEVICE_PROVIDER:
g_value_set_object (value, p->device_provider);
break;
@@ -858,10 +828,6 @@ my_set_property (GObject * o,
switch (property_id)
{
- case PROP_REPLACE:
- self->priv->replace = g_value_get_boolean (value);
- break;
-
case PROP_DEVICE_PROVIDER:
indicator_power_service_set_device_provider (self, g_value_get_object (value));
break;
@@ -938,6 +904,15 @@ indicator_power_service_init (IndicatorPowerService * self)
G_CALLBACK(rebuild_header_now), self);
g_signal_connect (p->settings, "changed::" SETTINGS_SHOW_TIME_S,
G_CALLBACK(on_show_time_setting_changed), self);
+
+ p->own_id = g_bus_own_name (G_BUS_TYPE_SESSION,
+ BUS_NAME,
+ G_BUS_NAME_OWNER_FLAGS_ALLOW_REPLACEMENT,
+ on_bus_acquired,
+ NULL,
+ on_name_lost,
+ self,
+ NULL);
}
static void
@@ -946,7 +921,6 @@ indicator_power_service_class_init (IndicatorPowerServiceClass * klass)
GObjectClass * object_class = G_OBJECT_CLASS (klass);
object_class->dispose = my_dispose;
- object_class->constructed = my_constructed;
object_class->get_property = my_get_property;
object_class->set_property = my_set_property;
@@ -963,13 +937,6 @@ indicator_power_service_class_init (IndicatorPowerServiceClass * klass)
properties[PROP_0] = NULL;
- properties[PROP_REPLACE] = g_param_spec_boolean (
- "replace",
- "Replace Service",
- "Replace existing service",
- FALSE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_CONSTRUCT_ONLY);
-
properties[PROP_DEVICE_PROVIDER] = g_param_spec_object (
"device-provider",
"Device Provider",
@@ -985,11 +952,9 @@ indicator_power_service_class_init (IndicatorPowerServiceClass * klass)
***/
IndicatorPowerService *
-indicator_power_service_new (gboolean replace,
- IndicatorPowerDeviceProvider * device_provider)
+indicator_power_service_new (IndicatorPowerDeviceProvider * device_provider)
{
GObject * o = g_object_new (INDICATOR_TYPE_POWER_SERVICE,
- "replace", replace,
"device-provider", device_provider,
NULL);
diff --git a/src/service.h b/src/service.h
index 77cc362..76ed10f 100644
--- a/src/service.h
+++ b/src/service.h
@@ -64,8 +64,7 @@ struct _IndicatorPowerServiceClass
GType indicator_power_service_get_type (void);
-IndicatorPowerService * indicator_power_service_new (gboolean replace,
- IndicatorPowerDeviceProvider * provider);
+IndicatorPowerService * indicator_power_service_new (IndicatorPowerDeviceProvider * provider);
void indicator_power_service_set_device_provider (IndicatorPowerService * self,
IndicatorPowerDeviceProvider * provider);