gint
mate_panel_applet_mateconf_get_int (MatePanelApplet  *applet,
			    const gchar  *key,
			    GError      **opt_error)
{
	MateConfClient  *client;
	gchar        *full_key;
	gint          retval;
	GError      **error = NULL;
	GError       *our_error = NULL;

	g_return_val_if_fail (PANEL_IS_APPLET (applet), -1);

	if (opt_error)
		error = opt_error;
	else
		error = &our_error;

	full_key = mate_panel_applet_mateconf_get_full_key (applet, key);

	client = mate_panel_applet_mateconf_get_client ();

	retval = mateconf_client_get_int (client, full_key, error);

	g_free (full_key);

	if (!opt_error && our_error) {
		g_warning (G_STRLOC ": mateconf error : '%s'", our_error->message);
		g_error_free (our_error);
	}

	return retval;
}
gint
xkb_get_default_group ()
{
	return mateconf_client_get_int (xkb_mateconf_client,
				     MATEKBD_DESKTOP_CONFIG_KEY_DEFAULT_GROUP,
				     NULL);
}
Exemplo n.º 3
0
/**
 * gucharma_settings_add_window:
 * @window: a #GtkWindow
 *
 * Restore the window configuration, and persist changes to the window configuration:
 * window width and height, and maximised and fullscreen state.
 * @window must not be realised yet.
 */
void
mcharmap_settings_add_window (GtkWindow *window)
{
#ifdef HAVE_MATECONF
  WindowState *state;
  int width, height;
  gboolean maximised, fullscreen;

  g_return_if_fail (GTK_IS_WINDOW (window));
#if GTK_CHECK_VERSION (2,20,0)
  g_return_if_fail (!gtk_widget_get_realized (GTK_WIDGET (window)));
#else
  g_return_if_fail (!GTK_WIDGET_REALIZED (window));
#endif

  state = g_slice_new0 (WindowState);
  g_object_set_data_full (G_OBJECT (window), "GamesConf::WindowState",
                          state, (GDestroyNotify) free_window_state);

  g_signal_connect (window, "configure-event",
                    G_CALLBACK (window_configure_event_cb), state);
  g_signal_connect (window, "window-state-event",
                    G_CALLBACK (window_state_event_cb), state);

  maximised = mateconf_client_get_bool (client, MATECONF_PREFIX "/maximized", NULL);
  fullscreen = mateconf_client_get_bool (client, MATECONF_PREFIX "/fullscreen", NULL);
  width = mateconf_client_get_int (client, MATECONF_PREFIX "/width", NULL);
  height = mateconf_client_get_int (client, MATECONF_PREFIX "/height", NULL);

  if (width > 0 && height > 0) {
    gtk_window_set_default_size (GTK_WINDOW (window), width, height);
  }
  if (maximised) {
    gtk_window_maximize (GTK_WINDOW (window));
  }
  if (fullscreen) {
    gtk_window_fullscreen (GTK_WINDOW (window));
  }
#endif /* HAVE_MATECONF */
}
static void
matekbd_indicator_config_load_font (MatekbdIndicatorConfig * ind_config)
{
	GError *gerror = NULL;

	ind_config->font_family =
	    mateconf_client_get_string (ind_config->conf_client,
				     MATEKBD_INDICATOR_CONFIG_KEY_FONT_FAMILY,
				     &gerror);
	if (gerror != NULL) {
		g_warning ("Error reading configuration:%s\n",
			   gerror->message);
		ind_config->font_family = g_strdup ("Helvetica");
		g_error_free (gerror);
		gerror = NULL;
	}

	ind_config->font_size =
	    mateconf_client_get_int (ind_config->conf_client,
				  MATEKBD_INDICATOR_CONFIG_KEY_FONT_SIZE,
				  &gerror);
	if (gerror != NULL) {
		g_warning ("Error reading configuration:%s\n",
			   gerror->message);
		ind_config->font_size = 10;
		g_error_free (gerror);
		gerror = NULL;
	}

	if (ind_config->font_family == NULL ||
	    ind_config->font_family[0] == '\0') {
		PangoFontDescription *fd = NULL;
		GtkStyle *style =
		    gtk_rc_get_style_by_paths (gtk_settings_get_default (),
					       GTK_STYLE_PATH,
					       GTK_STYLE_PATH,
					       GTK_TYPE_LABEL);
		if (style != NULL)
			fd = style->font_desc;
		if (fd != NULL) {
			ind_config->font_family =
			    g_strdup (pango_font_description_get_family
				      (fd));
			ind_config->font_size =
			    pango_font_description_get_size (fd) /
			    PANGO_SCALE;
		}
	}
	xkl_debug (150, "font: [%s], size %d\n", ind_config->font_family,
		   ind_config->font_size);

}
void
matekbd_indicator_config_load_from_mateconf (MatekbdIndicatorConfig * ind_config)
{
	GError *gerror = NULL;

	ind_config->secondary_groups_mask =
	    mateconf_client_get_int (ind_config->conf_client,
				  MATEKBD_INDICATOR_CONFIG_KEY_SECONDARIES,
				  &gerror);
	if (gerror != NULL) {
		g_warning ("Error reading configuration:%s\n",
			   gerror->message);
		ind_config->secondary_groups_mask = 0;
		g_error_free (gerror);
		gerror = NULL;
	}

	ind_config->show_flags =
	    mateconf_client_get_bool (ind_config->conf_client,
				   MATEKBD_INDICATOR_CONFIG_KEY_SHOW_FLAGS,
				   &gerror);
	if (gerror != NULL) {
		g_warning ("Error reading kbdConfiguration:%s\n",
			   gerror->message);
		ind_config->show_flags = FALSE;
		g_error_free (gerror);
		gerror = NULL;
	}

	matekbd_indicator_config_load_font (ind_config);
	matekbd_indicator_config_load_colors (ind_config);

	matekbd_indicator_config_free_enabled_plugins (ind_config);
	ind_config->enabled_plugins =
	    mateconf_client_get_list (ind_config->conf_client,
				   MATEKBD_INDICATOR_CONFIG_KEY_ENABLED_PLUGINS,
				   MATECONF_VALUE_STRING, &gerror);

	if (gerror != NULL) {
		g_warning ("Error reading kbd_configuration:%s\n",
			   gerror->message);
		ind_config->enabled_plugins = NULL;
		g_error_free (gerror);
		gerror = NULL;
	}
}
static void
tile_show_event_cb (GtkWidget * widget, gpointer user_data)
{
    HardDriveStatusTile *tile = HARD_DRIVE_STATUS_TILE (widget);
    HardDriveStatusTilePrivate *priv = HARD_DRIVE_STATUS_TILE_GET_PRIVATE (tile);

    update_tile (tile);
    if (!priv->update_timeout)
    {
        int timeout;

        timeout = mateconf_client_get_int (priv->mateconf, TIMEOUT_KEY, NULL);
        timeout = MAX (timeout, 1000);

        priv->timeout_notify =
            mateconf_client_notify_add (priv->mateconf, TIMEOUT_KEY, timeout_changed_cb, tile,
                                        NULL, NULL);

        priv->update_timeout = g_timeout_add (timeout, timeout_cb, tile);
    }
}
static MateThemeMetaInfo *
theme_load_from_mateconf (MateConfClient *client)
{
  MateThemeMetaInfo *theme;
  gchar *scheme;

  theme = mate_theme_meta_info_new ();

  theme->gtk_theme_name = mateconf_client_get_string (client, GTK_THEME_KEY, NULL);
  if (theme->gtk_theme_name == NULL)
    theme->gtk_theme_name = g_strdup ("Clearlooks");

  scheme = mateconf_client_get_string (client, COLOR_SCHEME_KEY, NULL);
  if (scheme == NULL || !strcmp (scheme, "")) {
    g_free (scheme);
    scheme = gtkrc_get_color_scheme_for_theme (theme->gtk_theme_name);
  }
  theme->gtk_color_scheme = scheme;

  theme->marco_theme_name = mateconf_client_get_string (client, MARCO_THEME_KEY, NULL);
  if (theme->marco_theme_name == NULL)
    theme->marco_theme_name = g_strdup ("Clearlooks");

  theme->icon_theme_name = mateconf_client_get_string (client, ICON_THEME_KEY, NULL);
  if (theme->icon_theme_name == NULL)
    theme->icon_theme_name = g_strdup ("mate");

  theme->notification_theme_name = mateconf_client_get_string (client, NOTIFICATION_THEME_KEY, NULL);

  theme->cursor_theme_name = mateconf_client_get_string (client, CURSOR_THEME_KEY, NULL);
#ifdef HAVE_XCURSOR
  theme->cursor_size = mateconf_client_get_int (client, CURSOR_SIZE_KEY, NULL);
#endif
  if (theme->cursor_theme_name == NULL)
    theme->cursor_theme_name = g_strdup ("default");

  theme->application_font = mateconf_client_get_string (client, APPLICATION_FONT_KEY, NULL);

  return theme;
}
DrWright *
drwright_new (void)
{
    DrWright  *dr;
    GtkWidget *item;
    MateConfClient *client;
    GtkActionGroup *action_group;

    static const char ui_description[] =
        "<ui>"
        "  <popup name='Pop'>"
        "    <menuitem action='Preferences'/>"
        "    <menuitem action='About'/>"
        "    <separator/>"
        "    <menuitem action='TakeABreak'/>"
        "  </popup>"
        "</ui>";

    dr = g_new0 (DrWright, 1);

    client = mateconf_client_get_default ();

    mateconf_client_add_dir (client,
                             MATECONF_PATH,
                             MATECONF_CLIENT_PRELOAD_NONE,
                             NULL);

    mateconf_client_notify_add (client, MATECONF_PATH,
                                mateconf_notify_cb,
                                dr,
                                NULL,
                                NULL);

    dr->type_time = 60 * mateconf_client_get_int (
                        client, MATECONF_PATH "/type_time", NULL);

    dr->warn_time = MIN (dr->type_time / 12, 60*3);

    dr->break_time = 60 * mateconf_client_get_int (
                         client, MATECONF_PATH "/break_time", NULL);

    dr->enabled = mateconf_client_get_bool (
                      client,
                      MATECONF_PATH "/enabled",
                      NULL);

    g_object_unref (client);

    if (debug) {
        setup_debug_values (dr);
    }

    dr->ui_manager = gtk_ui_manager_new ();

    action_group = gtk_action_group_new ("MenuActions");
    gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
    gtk_action_group_add_actions (action_group, actions, G_N_ELEMENTS (actions), dr);
    gtk_ui_manager_insert_action_group (dr->ui_manager, action_group, 0);
    gtk_ui_manager_add_ui_from_string (dr->ui_manager, ui_description, -1, NULL);

    item = gtk_ui_manager_get_widget (dr->ui_manager, "/Pop/TakeABreak");
    gtk_widget_set_sensitive (item, dr->enabled);

    dr->timer = drw_timer_new ();
    dr->idle_timer = drw_timer_new ();

    dr->state = STATE_START;

    dr->monitor = drw_monitor_new ();

    g_signal_connect (dr->monitor,
                      "activity",
                      G_CALLBACK (activity_detected_cb),
                      dr);

#ifdef HAVE_APP_INDICATOR
    init_app_indicator (dr);
#else
    dr->neutral_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar.png", NULL);
    dr->red_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar-red.png", NULL);
    dr->green_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar-green.png", NULL);
    dr->disabled_bar = gdk_pixbuf_new_from_file (IMAGEDIR "/bar-disabled.png", NULL);

    init_tray_icon (dr);
#endif /* HAVE_APP_INDICATOR */

    g_timeout_add_seconds (12,
                           (GSourceFunc) update_status,
                           dr);

    g_timeout_add_seconds (1,
                           (GSourceFunc) maybe_change_state,
                           dr);

    return dr;
}
void
idol_setup_preferences (Idol *idol)
{
	GtkWidget *menu, *content_area;
	gboolean show_visuals, auto_resize, is_local, no_deinterlace, lock_screensaver_on_audio, auto_chapters;
	int connection_speed;
	guint i, hidden;
	char *visual, *font, *encoding;
	GList *list, *l;
	BvwAudioOutType audio_out;
	MateConfValue *value;
	GObject *item;

	static struct {
		const char *name;
		BvwVideoProperty prop;
		const char *label;
	} props[4] = {
		{ "tpw_contrast_scale", BVW_VIDEO_CONTRAST, "tpw_contrast_label" },
		{ "tpw_saturation_scale", BVW_VIDEO_SATURATION, "tpw_saturation_label" },
		{ "tpw_bright_scale", BVW_VIDEO_BRIGHTNESS, "tpw_brightness_label" },
		{ "tpw_hue_scale", BVW_VIDEO_HUE, "tpw_hue_label" }
	};

	g_return_if_fail (idol->gc != NULL);

	is_local = idol_display_is_local ();

	mateconf_client_add_dir (idol->gc, MATECONF_PREFIX,
			MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/auto_resize",
			(MateConfClientNotifyFunc) auto_resize_changed_cb,
			idol, NULL, NULL);
	mateconf_client_add_dir (idol->gc, "/desktop/mate/lockdown",
			MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);

	/* Work-around builder dialogue not parenting properly for
	 * On top windows */
	item = gtk_builder_get_object (idol->xml, "tpw_notebook");
	idol->prefs = gtk_dialog_new_with_buttons (_("Preferences"),
			GTK_WINDOW (idol->win),
			GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_STOCK_CLOSE,
			GTK_RESPONSE_ACCEPT,
			NULL);
	gtk_container_set_border_width (GTK_CONTAINER (idol->prefs), 5);
	content_area = gtk_dialog_get_content_area (GTK_DIALOG (idol->prefs));
	gtk_box_set_spacing (GTK_BOX (content_area), 2);
	gtk_widget_reparent (GTK_WIDGET (item), content_area);
	gtk_widget_show_all (content_area);
	item = gtk_builder_get_object (idol->xml, "idol_preferences_window");
	gtk_widget_destroy (GTK_WIDGET (item));

	g_signal_connect (G_OBJECT (idol->prefs), "response",
			G_CALLBACK (gtk_widget_hide), NULL);
	g_signal_connect (G_OBJECT (idol->prefs), "delete-event",
			G_CALLBACK (gtk_widget_hide_on_delete), NULL);
        g_signal_connect (idol->prefs, "destroy",
                          G_CALLBACK (gtk_widget_destroyed), &idol->prefs);

	/* Remember position */
	idol->remember_position = mateconf_client_get_bool (idol->gc,
			MATECONF_PREFIX"/remember_position", NULL);
	item = gtk_builder_get_object (idol->xml, "tpw_remember_position_checkbutton");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), idol->remember_position);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/remember_position",
	                         (MateConfClientNotifyFunc) remember_position_changed_cb,
	                         idol, NULL, NULL);

	/* Auto-resize */
	auto_resize = mateconf_client_get_bool (idol->gc,
			MATECONF_PREFIX"/auto_resize", NULL);
	item = gtk_builder_get_object (idol->xml, "tpw_display_checkbutton");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), auto_resize);
	bacon_video_widget_set_auto_resize
		(BACON_VIDEO_WIDGET (idol->bvw), auto_resize);

	/* Screensaver audio locking */
	lock_screensaver_on_audio = mateconf_client_get_bool (idol->gc,
							   MATECONF_PREFIX"/lock_screensaver_on_audio", NULL);
	if (lock_screensaver_on_audio != FALSE)
		item = gtk_builder_get_object (idol->xml, "tpw_audio_toggle_button");
	else
		item = gtk_builder_get_object (idol->xml, "tpw_video_toggle_button");
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), TRUE);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/lock_screensaver_on_audio",
				 (MateConfClientNotifyFunc) lock_screensaver_on_audio_changed_cb,
				 idol, NULL, NULL);

	/* Disable deinterlacing */
	item = gtk_builder_get_object (idol->xml, "tpw_no_deinterlace_checkbutton");
	no_deinterlace = mateconf_client_get_bool (idol->gc,
						MATECONF_PREFIX"/disable_deinterlacing", NULL);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), no_deinterlace);
	bacon_video_widget_set_deinterlacing (idol->bvw, !no_deinterlace);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/disable_deinterlacing",
				 (MateConfClientNotifyFunc) no_deinterlace_changed_cb,
				 idol, NULL, NULL);

	/* Connection Speed */
	connection_speed = bacon_video_widget_get_connection_speed (idol->bvw);
	item = gtk_builder_get_object (idol->xml, "tpw_speed_combobox");
	gtk_combo_box_set_active (GTK_COMBO_BOX (item), connection_speed);

	/* Enable visuals */
	item = gtk_builder_get_object (idol->xml, "tpw_visuals_checkbutton");
	show_visuals = mateconf_client_get_bool (idol->gc,
			MATECONF_PREFIX"/show_vfx", NULL);
	if (is_local == FALSE && show_visuals != FALSE)
		show_visuals = ask_show_visuals (idol);

	g_signal_handlers_disconnect_by_func (item, checkbutton2_toggled_cb, idol);
	gtk_toggle_button_set_active
		(GTK_TOGGLE_BUTTON (item), show_visuals);
	idol_prefs_set_show_visuals (idol, show_visuals);
	g_signal_connect (item, "toggled", G_CALLBACK (checkbutton2_toggled_cb), idol);

	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/show_vfx",
			(MateConfClientNotifyFunc) show_vfx_changed_cb,
			idol, NULL, NULL);

	/* Auto-load subtitles */
	item = gtk_builder_get_object (idol->xml, "tpw_auto_subtitles_checkbutton");
	idol->autoload_subs = mateconf_client_get_bool (idol->gc,
					      MATECONF_PREFIX"/autoload_subtitles", NULL);

	g_signal_handlers_disconnect_by_func (item, checkbutton3_toggled_cb, idol);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), idol->autoload_subs);
	g_signal_connect (item, "toggled", G_CALLBACK (checkbutton3_toggled_cb), idol);

	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/autoload_subtitles",
				 (MateConfClientNotifyFunc) autoload_subtitles_changed_cb,
				 idol, NULL, NULL);

	/* Auto-load external chapters */
	item = gtk_builder_get_object (idol->xml, "tpw_auto_chapters_checkbutton");
	auto_chapters = mateconf_client_get_bool (idol->gc,
					       MATECONF_PREFIX"/autoload_chapters", NULL);

	g_signal_handlers_disconnect_by_func (item, auto_chapters_toggled_cb, idol);
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item), auto_chapters);
	g_signal_connect (item, "toggled", G_CALLBACK (auto_chapters_toggled_cb), idol);

	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/autoload_chapters",
				 (MateConfClientNotifyFunc) autoload_chapters_changed_cb,
				 idol, NULL, NULL);

	/* Visuals list */
	list = bacon_video_widget_get_visuals_list (idol->bvw);
	menu = gtk_menu_new ();
	gtk_widget_show (menu);

	visual = mateconf_client_get_string (idol->gc,
			MATECONF_PREFIX"/visual", NULL);
	if (visual == NULL || strcmp (visual, "") == 0) {
		g_free (visual);
		visual = g_strdup ("goom");
	}

	item = gtk_builder_get_object (idol->xml, "tpw_visuals_type_combobox");

	i = 0;
	for (l = list; l != NULL; l = l->next) {
		const char *name = l->data;

		gtk_combo_box_append_text (GTK_COMBO_BOX (item), name);

		if (strcmp (name, visual) == 0)
			gtk_combo_box_set_active (GTK_COMBO_BOX (item), i);

		i++;
	}
	g_free (visual);

	/* Visualisation quality */
	i = mateconf_client_get_int (idol->gc,
			MATECONF_PREFIX"/visual_quality", NULL);
	bacon_video_widget_set_visuals_quality (idol->bvw, i);
	item = gtk_builder_get_object (idol->xml, "tpw_visuals_size_combobox");
	gtk_combo_box_set_active (GTK_COMBO_BOX (item), i);

	/* Brightness and all */
	hidden = 0;
	for (i = 0; i < G_N_ELEMENTS (props); i++) {
		int prop_value;
		item = gtk_builder_get_object (idol->xml, props[i].name);
		prop_value = bacon_video_widget_get_video_property (idol->bvw,
							       props[i].prop);
		if (prop_value >= 0)
			gtk_range_set_value (GTK_RANGE (item), (gdouble) prop_value);
		else {
			gtk_range_set_value (GTK_RANGE (item), (gdouble) 65535/2);
			gtk_widget_hide (GTK_WIDGET (item));
			item = gtk_builder_get_object (idol->xml, props[i].label);
			gtk_widget_hide (GTK_WIDGET (item));
			hidden++;
		}
	}

	if (hidden == G_N_ELEMENTS (props)) {
		item = gtk_builder_get_object (idol->xml, "tpw_bright_contr_vbox");
		gtk_widget_hide (GTK_WIDGET (item));
	}

	/* Sound output type */
	item = gtk_builder_get_object (idol->xml, "tpw_sound_output_combobox");
	audio_out = bacon_video_widget_get_audio_out_type (idol->bvw);
	gtk_combo_box_set_active (GTK_COMBO_BOX (item), audio_out);

	/* Subtitle font selection */
	item = gtk_builder_get_object (idol->xml, "font_sel_button");
	gtk_font_button_set_title (GTK_FONT_BUTTON (item),
				   _("Select Subtitle Font"));
	font = mateconf_client_get_string (idol->gc,
		MATECONF_PREFIX"/subtitle_font", NULL);
	if (font && strcmp (font, "") != 0) {
		gtk_font_button_set_font_name (GTK_FONT_BUTTON (item), font);
		bacon_video_widget_set_subtitle_font (idol->bvw, font);
	}
	g_free (font);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/subtitle_font",
			(MateConfClientNotifyFunc) font_changed_cb,
			idol, NULL, NULL);

	/* Subtitle encoding selection */
	item = gtk_builder_get_object (idol->xml, "subtitle_encoding_combo");
	idol_subtitle_encoding_init (GTK_COMBO_BOX (item));
	value = mateconf_client_get_without_default (idol->gc,
			MATECONF_PREFIX"/subtitle_encoding", NULL);
	/* Make sure the default is UTF-8 */
	if (value != NULL) {
		if (mateconf_value_get_string (value) == NULL) {
			encoding = g_strdup ("UTF-8");
		} else {
			encoding = g_strdup (mateconf_value_get_string (value));
			if (encoding[0] == '\0') {
				g_free (encoding);
				encoding = g_strdup ("UTF-8");
			}
		}
		mateconf_value_free (value);
	} else {
		encoding = g_strdup ("UTF-8");
	}
	idol_subtitle_encoding_set (GTK_COMBO_BOX(item), encoding);
	if (encoding && strcasecmp (encoding, "") != 0) {
		bacon_video_widget_set_subtitle_encoding (idol->bvw, encoding);
	}
	g_free (encoding);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/subtitle_encoding",
			(MateConfClientNotifyFunc) encoding_changed_cb,
			idol, NULL, NULL);

	/* Disable keyboard shortcuts */
	idol->disable_kbd_shortcuts = mateconf_client_get_bool (idol->gc,
							      MATECONF_PREFIX"/disable_keyboard_shortcuts", NULL);
	mateconf_client_notify_add (idol->gc, MATECONF_PREFIX"/disable_keyboard_shortcuts",
				 (MateConfClientNotifyFunc) disable_kbd_shortcuts_changed_cb,
				 idol, NULL, NULL);
}
Exemplo n.º 10
0
void
mate_panel_applet_save_position (AppletInfo *applet_info,
			    const char *id,
			    gboolean    immediate)
{
	PanelMateConfKeyType  key_type;
	MateConfClient       *client;
	PanelWidget       *panel_widget;
	const char        *key;
	const char        *toplevel_id;
	char              *old_toplevel_id;
	gboolean           right_stick;
	gboolean           locked;
	int                position;

	g_return_if_fail (applet_info != NULL);

	if (!immediate) {
		if (!queued_position_source)
			queued_position_source =
				g_timeout_add_seconds (1,
						       (GSourceFunc) mate_panel_applet_position_save_timeout,
						       NULL);

		if (!g_slist_find (queued_position_saves, applet_info))
			queued_position_saves =
				g_slist_prepend (queued_position_saves, applet_info);

		return;
	}

	if (!(toplevel_id = mate_panel_applet_get_toplevel_id (applet_info)))
		return;

	client  = panel_mateconf_get_client ();

	key_type = applet_info->type == PANEL_OBJECT_APPLET ? PANEL_MATECONF_APPLETS : PANEL_MATECONF_OBJECTS;

	panel_widget = mate_panel_applet_get_panel_widget (applet_info);

	/* FIXME: Instead of getting keys, comparing and setting, there
	   should be a dirty flag */

	key = panel_mateconf_full_key (key_type, id, "toplevel_id");
	old_toplevel_id = mateconf_client_get_string (client, key, NULL);
	if (old_toplevel_id == NULL || strcmp (old_toplevel_id, toplevel_id) != 0)
		mateconf_client_set_string (client, key, toplevel_id, NULL);
	g_free (old_toplevel_id);

	/* Note: changing some properties of the panel that may not be locked down
	   (e.g. background) can change the state of the "panel_right_stick" and
	   "position" properties of an applet that may in fact be locked down.
	   So check if these are writable before attempting to write them */

	right_stick = panel_is_applet_right_stick (applet_info->widget) ? 1 : 0;
	key = panel_mateconf_full_key (
			key_type, id, "panel_right_stick");
	if (mateconf_client_key_is_writable (client, key, NULL) &&
	    (mateconf_client_get_bool (client, key, NULL) ? 1 : 0) != right_stick)
		mateconf_client_set_bool (client, key, right_stick, NULL);

	position = mate_panel_applet_get_position (applet_info);
	if (right_stick && !panel_widget->packed)
		position = panel_widget->size - position;

	key = panel_mateconf_full_key (key_type, id, "position");
	if (mateconf_client_key_is_writable (client, key, NULL) &&
	    mateconf_client_get_int (client, key, NULL) != position)
		mateconf_client_set_int (client, key, position, NULL);

	locked = panel_widget_get_applet_locked (panel_widget, applet_info->widget) ? 1 : 0;
	key = panel_mateconf_full_key (key_type, id, "locked");
	if (mateconf_client_get_bool (client, key, NULL) ? 1 : 0 != locked)
		mateconf_client_set_bool (client, key, locked, NULL);
}