Esempio n. 1
0
static void
tracker_power_init (TrackerPower *power)
{
	TrackerPowerPriv *priv;

	g_message ("Initializing UPower...");

	priv = GET_PRIV (power);

	/* connect to a UPower instance */
	priv->client = up_client_new ();
#ifdef HAVE_UP_CLIENT_GET_ON_LOW_BATTERY
	g_signal_connect (priv->client, "changed",
	                  G_CALLBACK (tracker_power_client_changed_cb), power);
	tracker_power_client_changed_cb (priv->client, power);
#else
        g_signal_connect (priv->client, "notify::on-battery",
                          G_CALLBACK (on_on_battery_changed), power);
	on_on_battery_changed (priv->client, NULL, power);
	priv->composite_device = up_client_get_display_device (priv->client);
	g_signal_connect (priv->composite_device, "notify::warning-level",
			  G_CALLBACK (on_warning_level_changed), power);
	on_warning_level_changed (priv->composite_device, NULL, power);
#endif /* HAVE_UP_CLIENT_GET_ON_LOW_BATTERY */
}
static void
gsm_logout_dialog_init (GsmLogoutDialog *logout_dialog)
{
        logout_dialog->priv = GSM_LOGOUT_DIALOG_GET_PRIVATE (logout_dialog);

        logout_dialog->priv->timeout_id = 0;
        logout_dialog->priv->timeout = 0;
        logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL;

        gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE);
        gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
        gtk_window_stick (GTK_WINDOW (logout_dialog));
#ifdef HAVE_UPOWER
        logout_dialog->priv->up_client = up_client_new ();
#endif
#ifdef HAVE_SYSTEMD
        if (LOGIND_RUNNING())
            logout_dialog->priv->systemd = gsm_get_systemd ();
        else
#endif
        logout_dialog->priv->consolekit = gsm_get_consolekit ();

        g_signal_connect (logout_dialog,
                          "destroy",
                          G_CALLBACK (gsm_logout_dialog_destroy),
                          NULL);

        g_signal_connect (logout_dialog,
                          "show",
                          G_CALLBACK (gsm_logout_dialog_show),
                          NULL);
}
static void
csm_logout_dialog_init (CsmLogoutDialog *logout_dialog)
{
        logout_dialog->priv = CSM_LOGOUT_DIALOG_GET_PRIVATE (logout_dialog);

        logout_dialog->priv->timeout_id = 0;
        logout_dialog->priv->timeout = 0;
        logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL;

        gtk_window_set_skip_taskbar_hint (GTK_WINDOW (logout_dialog), TRUE);
        gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
        gtk_window_stick (GTK_WINDOW (logout_dialog));

#ifdef HAVE_OLD_UPOWER
        logout_dialog->priv->up_client = up_client_new ();
#endif

        logout_dialog->priv->system = csm_get_system ();

        g_signal_connect (logout_dialog,
                          "destroy",
                          G_CALLBACK (csm_logout_dialog_destroy),
                          NULL);

        g_signal_connect (logout_dialog,
                          "show",
                          G_CALLBACK (csm_logout_dialog_show),
                          NULL);
}
Esempio n. 4
0
char *
battstat_upower_initialise (void (*callback) (void))
{
  char *error_str;
  int i, num;

  status_updated_callback = callback;

  if( upc != NULL )
    return g_strdup( "Already initialised!" );

  if( (upc = up_client_new() ) == NULL )
    goto error_out;

  GCancellable *cancellable = g_cancellable_new();
  GError *gerror;

  if (! up_client_enumerate_devices_sync( upc, cancellable, &gerror ) ) {
    sprintf(error_str, "Unable to enumerate upower devices: %s\n", gerror->message);
    goto error_shutdownclient;
  }

  g_signal_connect_after( upc, "device-changed", device_cb, NULL );
  g_signal_connect_after( upc, "device-added", device_cb, NULL );
  g_signal_connect_after( upc, "device-removed", device_cb, NULL );

  return NULL;

error_shutdownclient:
  g_object_unref( upc );
  upc = NULL;

error_out:
  return "Can not initialize upower";
}
Esempio n. 5
0
/**
 * gpm_control_init:
 * @control: This control class instance
 **/
static void
gpm_control_init (GpmControl *control)
{
	control->priv = GPM_CONTROL_GET_PRIVATE (control);

	control->priv->client = up_client_new ();
	control->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
}
static void
mpd_lid_device_init (MpdLidDevice *self)
{
  MpdLidDevicePrivate *priv = GET_PRIVATE (self);

  priv->client = up_client_new ();
  g_signal_connect (priv->client, "changed",
                    G_CALLBACK (_client_changed_cb), self);
	g_object_get (priv->client,
                "lid-is-closed", &priv->closed,
                NULL);
}
Esempio n. 7
0
static OfficeRunner *
new_runner (void)
{
	OfficeRunner *run;

	run = g_new0 (OfficeRunner, 1);
	run->connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM,
					  NULL, NULL);
	run->lid_switch_fd = -1;
	run->client = up_client_new ();
	g_signal_connect (G_OBJECT (run->client), "notify::lid-is-closed",
			  G_CALLBACK (lid_is_closed_cb), run);

	run->ui = gtk_builder_new ();
	gtk_builder_add_from_file (run->ui, PKGDATADIR "office-runner.ui", NULL);
	run->window = WID ("window1");
	run->time_label = WID ("time_label");
	count_tick (NULL, NULL, run);
	run->your_time_label = WID ("your_time_label");

	/* FIXME: No running man for now */
	gtk_widget_set_no_show_all (WID ("run_image"), TRUE);
	gtk_widget_hide (WID ("run_image"));
	gtk_widget_set_no_show_all (WID ("time_image"), TRUE);
	gtk_widget_hide (WID ("time_image"));

	run->large_icon_size = gtk_icon_size_register ("large", 256, 256);
	gtk_image_set_from_icon_name (IWID("trophy_image"), "trophy-silver", run->large_icon_size);

	g_signal_connect (run->window, "delete-event",
			  G_CALLBACK (window_delete_event_cb), run);
	run->run_button = WID ("run_button");
	g_signal_connect (run->run_button, "clicked",
			  G_CALLBACK (run_button_clicked_cb), run);
	run->notebook = WID ("notebook1");

	load_records (run);

	/* Start the blocking here */
	switch_to_page (run, RUN_PAGE);

	return run;
}
static void
tracker_power_init (TrackerPower *power)
{
	TrackerPowerPriv *priv;

	g_message ("Initializing UPower...");

	priv = GET_PRIV (power);

	/* connect to a UPower instance */
	priv->client = up_client_new ();
	g_signal_connect (priv->client, "changed",
	                  G_CALLBACK (tracker_power_client_changed_cb), power);

	/* coldplug */
	priv->on_battery = up_client_get_on_battery (priv->client);
#ifdef HAVE_UP_CLIENT_GET_WARNING_LEVEL
	priv->on_low_battery = up_client_get_warning_level (priv->client) >= UP_DEVICE_LEVEL_LOW;
#else
	priv->on_low_battery = up_client_get_on_low_battery (priv->client);
#endif
}
Esempio n. 9
0
int
main(int argc, char **argv) {
    int i;
    UpClient *upclient;
    IxpClient *client;

    signals_setup(&quit_handler);

    client = ixp_nsmount("wmii");
    if(client == NULL) {
        printf("ixp_nsmount: %s\n", ixp_errbuf());
        abort();
    }

    mainloop = g_main_loop_new(NULL, FALSE);

    upclient = up_client_new();

    sb_init(&sb, client);
    sb_add(&sb, &sbe_ac);    
    for(i = 0; i < MAX_BATTERIES; i++) {
        sb_add(&sb, &sbe_batteries[i]);
    }

    up_client_enumerate_devices_sync(upclient, NULL, NULL);

    g_signal_connect(upclient, "device-added", G_CALLBACK(device_added_cb), NULL);
    g_signal_connect(upclient, "device-removed", G_CALLBACK(device_removed_cb), NULL);
    g_signal_connect(upclient, "device-changed", G_CALLBACK(device_changed_cb), NULL);
    g_signal_connect(upclient, "changed", G_CALLBACK(changed_cb), NULL);

    update_sb(upclient);

    g_main_loop_run(mainloop);

    sb_finish(&sb);

    ixp_unmount(client);
}
static void
gsm_logout_dialog_init (GsmLogoutDialog *logout_dialog)
{
    logout_dialog->priv = GSM_LOGOUT_DIALOG_GET_PRIVATE (logout_dialog);

    logout_dialog->priv->timeout_id = 0;
    logout_dialog->priv->timeout = 0;
    logout_dialog->priv->default_response = GTK_RESPONSE_CANCEL;
    logout_dialog->priv->info_label = NULL;

    gtk_window_set_resizable (GTK_WINDOW (logout_dialog), FALSE);
    gtk_dialog_set_has_separator (GTK_DIALOG (logout_dialog), FALSE);
    gtk_window_set_keep_above (GTK_WINDOW (logout_dialog), TRUE);
    gtk_window_stick (GTK_WINDOW (logout_dialog));

    /* use HIG spacings */
    gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (logout_dialog)->vbox), 12);
    gtk_container_set_border_width (GTK_CONTAINER (logout_dialog), 6);

    gtk_dialog_add_button (GTK_DIALOG (logout_dialog), GTK_STOCK_HELP,
                           GTK_RESPONSE_HELP);
    logout_dialog->priv->cancel_button =
        gtk_dialog_add_button (GTK_DIALOG (logout_dialog),
                               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);

    logout_dialog->priv->up_client = up_client_new ();

    logout_dialog->priv->consolekit = gsm_get_consolekit ();

    g_signal_connect (logout_dialog,
                      "destroy",
                      G_CALLBACK (gsm_logout_dialog_destroy),
                      NULL);

    g_signal_connect (logout_dialog,
                      "show",
                      G_CALLBACK (gsm_logout_dialog_show),
                      NULL);
}
Esempio n. 11
0
/**
 * gpm_backlight_init:
 * @brightness: This brightness class instance
 *
 * initialises the brightness class. NOTE: We expect laptop_panel objects
 * to *NOT* be removed or added during the session.
 * We only control the first laptop_panel object if there are more than one.
 **/
static void
gpm_backlight_init (GpmBacklight *backlight)
{
	gboolean lid_is_present = TRUE;
	GpmPrefsServer *prefs_server;

	backlight->priv = GPM_BACKLIGHT_GET_PRIVATE (backlight);

	/* record our idle time */
	backlight->priv->idle_timer = g_timer_new ();

	/* watch for manual brightness changes (for the popup widget) */
	backlight->priv->brightness = gpm_brightness_new ();
	g_signal_connect (backlight->priv->brightness, "brightness-changed",
			  G_CALLBACK (brightness_changed_cb), backlight);

	/* we use up_client for the ac-adapter-changed signal */
	backlight->priv->client = up_client_new ();
	g_signal_connect (backlight->priv->client, "changed",
			  G_CALLBACK (gpm_backlight_client_changed_cb), backlight);

	/* gets caps */
	backlight->priv->can_dim = gpm_brightness_has_hw (backlight->priv->brightness);

	/* we use DeviceKit-power to see if we should show the lid UI */
	g_object_get (backlight->priv->client,
		      "lid-is-present", &lid_is_present,
		      NULL);

	/* expose ui in prefs program */
	prefs_server = gpm_prefs_server_new ();
	if (lid_is_present)
		gpm_prefs_server_set_capability (prefs_server, GPM_PREFS_SERVER_LID);
	if (backlight->priv->can_dim)
		gpm_prefs_server_set_capability (prefs_server, GPM_PREFS_SERVER_BACKLIGHT);
	g_object_unref (prefs_server);

	/* watch for dim value changes */
	backlight->priv->conf = gconf_client_get_default ();

	/* watch gnome-power-manager keys */
	gconf_client_add_dir (backlight->priv->conf, GPM_CONF_DIR, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
	gconf_client_notify_add (backlight->priv->conf, GPM_CONF_DIR,
				 (GConfClientNotifyFunc) gpm_conf_gconf_key_changed_cb,
				 backlight, NULL, NULL);

	/* set the main brightness, this is designed to be updated if the user changes the
	 * brightness so we can undim to the 'correct' value */
	backlight->priv->master_percentage = gconf_client_get_int (backlight->priv->conf, GPM_CONF_BACKLIGHT_BRIGHTNESS_AC, NULL);

	/* watch for brightness up and down buttons and also check lid state */
	backlight->priv->button = gpm_button_new ();
	g_signal_connect (backlight->priv->button, "button-pressed",
			  G_CALLBACK (gpm_backlight_button_pressed_cb), backlight);

	/* watch for idle mode changes */
	backlight->priv->idle = gpm_idle_new ();
	g_signal_connect (backlight->priv->idle, "idle-changed",
			  G_CALLBACK (idle_changed_cb), backlight);

	/* assumption */
	backlight->priv->system_is_idle = FALSE;
	backlight->priv->idle_dim_timeout = gconf_client_get_int (backlight->priv->conf, GPM_CONF_BACKLIGHT_IDLE_DIM_TIME, NULL);
	gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout);

	/* use a visual widget */
	backlight->priv->popup = gsd_media_keys_window_new ();
	gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
						 "gpm-brightness-lcd",
						 TRUE);
        gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);

	/* DPMS mode poll class */
	backlight->priv->dpms = gpm_dpms_new ();

	/* we refresh DPMS on resume */
	backlight->priv->control = gpm_control_new ();
	g_signal_connect (backlight->priv->control, "resume",
			  G_CALLBACK (control_resume_cb), backlight);

	/* Don't do dimming on inactive console */
	backlight->priv->consolekit = egg_console_kit_new ();

	/* sync at startup */
	gpm_backlight_brightness_evaluate_and_set (backlight, FALSE);
}
Esempio n. 12
0
/**
 * gpm_backlight_init:
 * @brightness: This brightness class instance
 *
 * initialises the brightness class. NOTE: We expect laptop_panel objects
 * to *NOT* be removed or added during the session.
 * We only control the first laptop_panel object if there are more than one.
 **/
static void
gpm_backlight_init (GpmBacklight *backlight)
{
    backlight->priv = GPM_BACKLIGHT_GET_PRIVATE (backlight);

    /* record our idle time */
    backlight->priv->idle_timer = g_timer_new ();

    /* watch for manual brightness changes (for the popup widget) */
    backlight->priv->brightness = gpm_brightness_new ();
    g_signal_connect (backlight->priv->brightness, "brightness-changed",
                      G_CALLBACK (brightness_changed_cb), backlight);

    /* we use up_client for the ac-adapter-changed signal */
    backlight->priv->client = up_client_new ();
    g_signal_connect (backlight->priv->client, "changed",
                      G_CALLBACK (gpm_backlight_client_changed_cb), backlight);

    /* gets caps */
    backlight->priv->can_dim = gpm_brightness_has_hw (backlight->priv->brightness);

    /* watch for dim value changes */
    backlight->priv->settings = g_settings_new (GPM_SETTINGS_SCHEMA);
    g_signal_connect (backlight->priv->settings, "changed", G_CALLBACK (gpm_settings_key_changed_cb), backlight);

    /* set the main brightness, this is designed to be updated if the user changes the
     * brightness so we can undim to the 'correct' value */
    backlight->priv->master_percentage = g_settings_get_double (backlight->priv->settings, GPM_SETTINGS_BRIGHTNESS_AC);

    /* watch for brightness up and down buttons and also check lid state */
    backlight->priv->button = gpm_button_new ();
    g_signal_connect (backlight->priv->button, "button-pressed",
                      G_CALLBACK (gpm_backlight_button_pressed_cb), backlight);

    /* watch for idle mode changes */
    backlight->priv->idle = gpm_idle_new ();
    g_signal_connect (backlight->priv->idle, "idle-changed",
                      G_CALLBACK (idle_changed_cb), backlight);

    /* assumption */
    backlight->priv->system_is_idle = FALSE;
    backlight->priv->idle_dim_timeout = g_settings_get_int (backlight->priv->settings, GPM_SETTINGS_IDLE_DIM_TIME);
    gpm_idle_set_timeout_dim (backlight->priv->idle, backlight->priv->idle_dim_timeout);

    /* use a visual widget */
    backlight->priv->popup = gsd_media_keys_window_new ();
    gsd_media_keys_window_set_action_custom (GSD_MEDIA_KEYS_WINDOW (backlight->priv->popup),
            "gpm-brightness-lcd",
            TRUE);
    gtk_window_set_position (GTK_WINDOW (backlight->priv->popup), GTK_WIN_POS_NONE);

    /* DPMS mode poll class */
    backlight->priv->dpms = gpm_dpms_new ();

    /* we refresh DPMS on resume */
    backlight->priv->control = gpm_control_new ();
    g_signal_connect (backlight->priv->control, "resume",
                      G_CALLBACK (control_resume_cb), backlight);

    /* Don't do dimming on inactive console */
    backlight->priv->consolekit = egg_console_kit_new ();

    /* sync at startup */
    gpm_backlight_brightness_evaluate_and_set (backlight, FALSE, TRUE);
}
Esempio n. 13
0
/**
 * main:
 **/
int
main (int argc, char **argv)
{
	gint retval = EXIT_FAILURE;
	guint i;
	GOptionContext *context;
	gboolean opt_dump = FALSE;
	gboolean opt_wakeups = FALSE;
	gboolean opt_enumerate = FALSE;
	gboolean opt_monitor = FALSE;
	gchar *opt_show_info = FALSE;
	gboolean opt_version = FALSE;
	gboolean ret;
	GError *error = NULL;
	gchar *text = NULL;

	UpClient *client;
	UpDevice *device;

	const GOptionEntry entries[] = {
		{ "enumerate", 'e', 0, G_OPTION_ARG_NONE, &opt_enumerate, _("Enumerate objects paths for devices"), NULL },
		{ "dump", 'd', 0, G_OPTION_ARG_NONE, &opt_dump, _("Dump all parameters for all objects"), NULL },
		{ "wakeups", 'w', 0, G_OPTION_ARG_NONE, &opt_wakeups, _("Get the wakeup data"), NULL },
		{ "monitor", 'm', 0, G_OPTION_ARG_NONE, &opt_monitor, _("Monitor activity from the power daemon"), NULL },
		{ "monitor-detail", 0, 0, G_OPTION_ARG_NONE, &opt_monitor_detail, _("Monitor with detail"), NULL },
		{ "show-info", 'i', 0, G_OPTION_ARG_STRING, &opt_show_info, _("Show information about object path"), NULL },
		{ "version", 'v', 0, G_OPTION_ARG_NONE, &opt_version, "Print version of client and daemon", NULL },
		{ NULL }
	};

	g_type_init ();

	context = g_option_context_new ("UPower tool");
	g_option_context_add_main_entries (context, entries, NULL);
	g_option_context_add_group (context, egg_debug_get_option_group ());
	g_option_context_parse (context, &argc, &argv, NULL);
	g_option_context_free (context);

	loop = g_main_loop_new (NULL, FALSE);
	client = up_client_new ();

	if (opt_version) {
		gchar *daemon_version;
		g_object_get (client,
			      "daemon-version", &daemon_version,
			      NULL);
		g_print ("UPower client version %s\n"
			 "UPower daemon version %s\n",
			 PACKAGE_VERSION, daemon_version);
		g_free (daemon_version);
		retval = 0;
		goto out;
	}

	/* wakeups */
	if (opt_wakeups) {
		up_tool_show_wakeups ();
		retval = EXIT_SUCCESS;
		goto out;
	}

	if (opt_enumerate || opt_dump) {
		GPtrArray *devices;
		ret = up_client_enumerate_devices_sync (client, NULL, &error);
		if (!ret) {
			egg_warning ("failed to enumerate: %s", error->message);
			goto out;
		}
		devices = up_client_get_devices (client);
		for (i=0; i < devices->len; i++) {
			device = (UpDevice*) g_ptr_array_index (devices, i);
			if (opt_enumerate) {
				g_print ("%s\n", up_device_get_object_path (device));
			} else {
				g_print ("Device: %s\n", up_device_get_object_path (device));
				text = up_device_to_text (device);
				g_print ("%s\n", text);
				g_free (text);
			}
		}
		g_ptr_array_unref (devices);
		if (opt_dump) {
			g_print ("Daemon:\n");
			up_client_print (client);
		}
		retval = EXIT_SUCCESS;
		goto out;
	}

	if (opt_monitor || opt_monitor_detail) {
		ret = up_client_enumerate_devices_sync (client, NULL, &error);
		if (!ret) {
			egg_warning ("failed to enumerate: %s", error->message);
			goto out;
		}
		if (!up_tool_do_monitor (client))
			goto out;
		retval = EXIT_SUCCESS;
		goto out;
	}

	if (opt_show_info != NULL) {
		device = up_device_new ();
		ret = up_device_set_object_path_sync (device, opt_show_info, NULL, &error);
		if (!ret) {
			g_print ("failed to set path: %s\n", error->message);
			g_error_free (error);
		} else {
			text = up_device_to_text (device);
			g_print ("%s\n", text);
			g_free (text);
		}
		g_object_unref (device);
		retval = EXIT_SUCCESS;
		goto out;
	}
out:
	g_object_unref (client);
	return retval;
}
static void
cc_power_panel_init (CcPowerPanel *self)
{
  GError     *error;
  GtkWidget  *widget;
  gint        value;
  char       *text;

  self->priv = POWER_PANEL_PRIVATE (self);

  self->priv->builder = gtk_builder_new ();
  gtk_builder_set_translation_domain (self->priv->builder, GETTEXT_PACKAGE);
  error = NULL;
  gtk_builder_add_from_file (self->priv->builder,
                             CINNAMONCC_UI_DIR "/power.ui",
                             &error);

  if (error != NULL)
    {
      g_warning ("Could not load interface file: %s", error->message);
      g_error_free (error);
      return;
    }

  /* Make sure to set liststores (glade likes removing them from Gtk.ComboBoxText items in the .ui file....) */
  gtk_combo_box_set_model (GTK_COMBO_BOX(SWID("combobox_display_ac")), LS("liststore_display"));
  gtk_combo_box_set_model (GTK_COMBO_BOX(SWID("combobox_display_battery")), LS("liststore_display"));
  gtk_combo_box_set_model (GTK_COMBO_BOX(SWID("combobox_sleep_ac")), LS("liststore_suspend"));
  gtk_combo_box_set_model (GTK_COMBO_BOX(SWID("combobox_sleep_battery")), LS("liststore_suspend"));

  /* add levelbar */
  self->priv->levelbar_primary = SWID("levelbar_primary");
  self->priv->cancellable = g_cancellable_new ();

  /* get initial icon state */
  g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                            G_DBUS_PROXY_FLAGS_NONE,
                            NULL,
                            "org.cinnamon.SettingsDaemon",
                            "/org/cinnamon/SettingsDaemon/Power",
                            "org.cinnamon.SettingsDaemon.Power",
                            self->priv->cancellable,
                            got_power_proxy_cb,
                            self);

  /* find out if there are any battery or UPS devices attached
   * and setup UI accordingly */
  self->priv->up_client = up_client_new ();
  set_ac_battery_ui_mode (self);

  self->priv->csd_settings = g_settings_new ("org.cinnamon.settings-daemon.plugins.power");
  self->priv->session_settings = g_settings_new ("org.cinnamon.desktop.session");

  /* auto-display-off time */
  value = g_settings_get_int (self->priv->csd_settings, "sleep-display-ac");
  widget = SWID("combobox_display_ac");
  set_value_for_combo (GTK_COMBO_BOX (widget), value);
  g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-display-ac");
  g_signal_connect (widget, "changed", G_CALLBACK (combo_time_changed_cb), self);

  value = g_settings_get_int (self->priv->csd_settings, "sleep-display-battery");
  widget = SWID("combobox_display_battery");
  set_value_for_combo (GTK_COMBO_BOX (widget), value);
  g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-display-battery");
  g_signal_connect (widget, "changed", G_CALLBACK (combo_time_changed_cb), self);

  /* auto-sleep time */
  value = g_settings_get_int (self->priv->csd_settings, "sleep-inactive-ac-timeout");
  widget = SWID("combobox_sleep_ac");
  set_value_for_combo (GTK_COMBO_BOX (widget), value);
  g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-inactive-ac-timeout");
  g_signal_connect (widget, "changed", G_CALLBACK (combo_time_changed_cb), self);

  value = g_settings_get_int (self->priv->csd_settings, "sleep-inactive-battery-timeout");
  widget = SWID("combobox_sleep_battery");
  set_value_for_combo (GTK_COMBO_BOX (widget), value);
  g_object_set_data (G_OBJECT(widget), "_gsettings_key", "sleep-inactive-battery-timeout");
  g_signal_connect (widget, "changed", G_CALLBACK (combo_time_changed_cb), self);

  /* actions */
  value = g_settings_get_enum (self->priv->csd_settings, "critical-battery-action");
  widget = SWID("combobox_critical");
  disable_unavailable_combo_items (self, GTK_COMBO_BOX (widget));
  set_value_for_combo (GTK_COMBO_BOX (widget), value);
  g_object_set_data (G_OBJECT(widget), "_gsettings_key", "critical-battery-action");
  g_signal_connect (widget, "changed",
                    G_CALLBACK (combo_enum_changed_cb),
                    self);

  value = g_settings_get_enum (self->priv->csd_settings, "lid-close-ac-action");
  widget = SWID("combobox_lid_ac");
  disable_unavailable_combo_items (self, GTK_COMBO_BOX (widget));
  set_value_for_combo (GTK_COMBO_BOX (widget), value);
  g_object_set_data (G_OBJECT(widget), "_gsettings_key", "lid-close-ac-action");
  g_signal_connect (widget, "changed",
                    G_CALLBACK (combo_enum_changed_cb),
                    self);

  value = g_settings_get_enum (self->priv->csd_settings, "lid-close-battery-action");
  widget = SWID("combobox_lid_battery");
  disable_unavailable_combo_items (self, GTK_COMBO_BOX (widget));
  set_value_for_combo (GTK_COMBO_BOX (widget), value);
  g_object_set_data (G_OBJECT(widget), "_gsettings_key", "lid-close-battery-action");
  g_signal_connect (widget, "changed",
                    G_CALLBACK (combo_enum_changed_cb),
                    self);

  widget = SWID ("vbox_power");
  gtk_widget_reparent (widget, (GtkWidget *) self);

  value = g_settings_get_enum (self->priv->csd_settings, "button-power");
  widget = SWID ("combobox_power_button");
  disable_unavailable_combo_items (self, GTK_COMBO_BOX (widget));
  set_value_for_combo (GTK_COMBO_BOX (widget), value);
  g_object_set_data (G_OBJECT (widget), "_gsettings_key", "button-power");
  g_signal_connect (widget, "changed",
                    G_CALLBACK (combo_enum_changed_cb),
                    self);
}