Пример #1
0
void
panel_menu_button_load_from_mateconf (PanelWidget *panel,
				   gboolean     locked,
				   int          position,
				   gboolean     exactpos,
				   const char  *id)
{
	MateConfClient *client;
	const char  *key;
	char        *menu_path;
	char        *custom_icon;
	char        *tooltip;
	gboolean     use_menu_path;
	gboolean     use_custom_icon;
	gboolean     has_arrow;

	client  = panel_mateconf_get_client ();

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "menu_path");
	menu_path = mateconf_client_get_string (client, key, NULL);

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "custom_icon");
	custom_icon = mateconf_client_get_string (client, key, NULL);

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "tooltip");
	tooltip = mateconf_client_get_string (client, key, NULL);

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_menu_path");
	use_menu_path = mateconf_client_get_bool (client, key, NULL);

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "use_custom_icon");
	use_custom_icon = mateconf_client_get_bool (client, key, NULL);

	key = panel_mateconf_full_key (PANEL_MATECONF_OBJECTS, id, "has_arrow");
	has_arrow = mateconf_client_get_bool (client, key, NULL);

	panel_menu_button_load (menu_path,
				use_menu_path,
				custom_icon,
				use_custom_icon,
				tooltip,
				panel,
				locked,
				position,
				exactpos,
				has_arrow,
				id);

	g_free (menu_path);
	g_free (custom_icon);
	g_free (tooltip);
}
Пример #2
0
static gboolean
trash_empty_require_confirmation (void)
{
  return mateconf_client_get_bool (mateconf_client_get_default (),
                                "/apps/caja/preferences/confirm_trash",
                                NULL);
}
Пример #3
0
static void
xfapplet_cleanup_unused_mateconf_keys ()
{
	MateConfClient *client;
	gchar	*dir;
	gchar	*in_use_key;
	int	 i = 0;

	client = mateconf_client_get_default ();
	
	while (1) {
		dir = g_strdup_printf (XFAPPLET_MATECONF_DIR "applet_%d", i++);
		if (mateconf_client_dir_exists (client, dir, NULL)) {
			in_use_key = g_strdup_printf ("%s/in_use", dir);
			if (!mateconf_client_get_bool (client, in_use_key, NULL))
				mateconf_client_recursive_unset (client, dir, MATECONF_UNSET_INCLUDING_SCHEMA_NAMES, NULL);
			g_free (in_use_key);
			g_free (dir);
		}
		else
			break;
	}

	g_object_unref (client);

	g_free (dir);
}
gboolean
mate_panel_applet_mateconf_get_bool (MatePanelApplet  *applet,
			     const gchar  *key,
			     GError      **opt_error)
{
	MateConfClient  *client;
	gchar        *full_key;
	gboolean      retval;
	GError      **error = NULL;
	GError       *our_error = NULL;

	g_return_val_if_fail (PANEL_IS_APPLET (applet), FALSE);

	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_bool (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;
}
static void
idol_screensaver_update_from_state (IdolObject *idol,
				     IdolScreensaverPlugin *pi)
{
	gboolean lock_screensaver_on_audio, can_get_frames;
	BaconVideoWidget *bvw;
	MateConfClient *gc;

	bvw = BACON_VIDEO_WIDGET (idol_get_video_widget ((Idol *)(idol)));
	gc = mateconf_client_get_default ();

	lock_screensaver_on_audio = mateconf_client_get_bool (gc, 
							   MATECONF_PREFIX"/lock_screensaver_on_audio",
							   NULL);
	can_get_frames = bacon_video_widget_can_get_frames (bvw, NULL);

	if (idol_is_playing (idol) != FALSE && can_get_frames)
		idol_scrsaver_disable (pi->scr);
	else if (idol_is_playing (idol) != FALSE && !lock_screensaver_on_audio)
		idol_scrsaver_disable (pi->scr);
	else
		idol_scrsaver_enable (pi->scr);

	g_object_unref (gc);
}
static void
marco_titlebar_load_sensitivity (AppearanceData *data)
{
  gtk_widget_set_sensitive (appearance_capplet_get_widget (data, "window_title_font"),
			    !mateconf_client_get_bool (data->client,
						    WINDOW_TITLE_USES_SYSTEM_KEY,
						    NULL));
}
Пример #7
0
gboolean
mcharmap_settings_get_snap_pow2 (void)
{
  if (!mcharmap_settings_initialized ()) {
      return get_default_snap_pow2 ();
  }
  
  return mateconf_client_get_bool (client, MATECONF_PREFIX"/snap_cols_pow2", NULL);
}
static void
disable_kbd_shortcuts_changed_cb (MateConfClient *client,
				  guint cnxn_id,
				  MateConfEntry *entry,
				  Idol *idol)
{
	idol->disable_kbd_shortcuts = mateconf_client_get_bool (idol->gc,
							      MATECONF_PREFIX"/disable_keyboard_shortcuts", NULL);
}
Пример #9
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
autoload_chapters_changed_cb (MateConfClient *client, guint cnxn_id,
			      MateConfEntry *entry, Idol *idol)
{
	GObject *item;

	item = gtk_builder_get_object (idol->xml, "tpw_auto_chapters_checkbutton");
	g_signal_handlers_disconnect_by_func (item,
					      auto_chapters_toggled_cb, idol);

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item),
				      mateconf_client_get_bool (idol->gc, MATECONF_PREFIX"/autoload_chapters", NULL));

	g_signal_connect (item, "toggled",
			  G_CALLBACK (auto_chapters_toggled_cb), idol);
}
static void
remember_position_changed_cb (MateConfClient *client, guint cnxn_id,
                              MateConfEntry *entry, Idol *idol)
{
	GObject *item;

	item = gtk_builder_get_object (idol->xml, "tpw_remember_position_checkbutton");
	g_signal_handlers_block_by_func (item, remember_position_checkbutton_toggled_cb,
					 idol);

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item),
				      mateconf_client_get_bool (idol->gc,
							     MATECONF_PREFIX"/remember_position", NULL));

	g_signal_handlers_unblock_by_func (item, remember_position_checkbutton_toggled_cb,
					   idol);
}
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;
	}
}
gboolean
_mate_mateconf_get_bool (const char *key)
{
	MateConfClient *client;
	gboolean ret;

	mateui_mateconf_lazy_init ();

	client = mateconf_client_get_default ();

	ret = mateconf_client_get_bool (client,
				     key,
                                     NULL);

	g_object_unref (G_OBJECT (client));

	return ret;
}
/*
 *   Yes Gconf's C API sucks, yes matecomponent-config is a far better
 * way to access configuration, yes I hate this code; Michael.
 */
static gboolean
get (const char *key, gboolean def)
{
	gboolean ret;
	GError  *err = NULL;

	if (!client)					
		client = mateconf_client_get_default ();	

	ret = mateconf_client_get_bool (client, key, &err);

	if (err) {
		static int warned = 0;
		if (!warned++)
			g_warning ("Failed to get '%s': '%s'", key, err->message);
		g_error_free (err);
		ret = def;
	}

	return ret;
}
static void
no_deinterlace_changed_cb (MateConfClient *client,
			   guint cnxn_id,
			   MateConfEntry *entry,
			   Idol *idol)
{
	GObject *button;
	gboolean value;

	button = gtk_builder_get_object (idol->xml, "tpw_no_deinterlace_checkbutton");

	g_signal_handlers_block_matched (button,
					 G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, idol);

	value = mateconf_client_get_bool (idol->gc,
				       MATECONF_PREFIX"/disable_deinterlacing", NULL);

	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), value);
	bacon_video_widget_set_deinterlacing (idol->bvw, !value);

	g_signal_handlers_unblock_matched (button,
					   G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, idol);
}
static void
lock_screensaver_on_audio_changed_cb (MateConfClient *client, guint cnxn_id,
				      MateConfEntry *entry, Idol *idol)
{
	GObject *item, *radio;
	gboolean value;

	item = gtk_builder_get_object (idol->xml, "tpw_audio_toggle_button");
	g_signal_handlers_disconnect_by_func (item,
					      audio_screensaver_button_toggled_cb, idol);

	value = mateconf_client_get_bool (idol->gc,
				       MATECONF_PREFIX"/lock_screensaver_on_audio", NULL);
	if (value != FALSE) {
		radio = gtk_builder_get_object (idol->xml, "tpw_audio_toggle_button");
	} else {
		radio = gtk_builder_get_object (idol->xml, "tpw_video_toggle_button");
	}
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio), TRUE);

	g_signal_connect (item, "toggled",
			  G_CALLBACK (audio_screensaver_button_toggled_cb), idol);
}
/* Log Out
 */
static void
panel_action_logout (GtkWidget *widget)
{
	PanelSessionManager *manager;
	gboolean             not_prompt;

	not_prompt = mateconf_client_get_bool (panel_mateconf_get_client (),
					    LOGOUT_PROMPT_KEY, NULL);
	/* this avoids handling errors from mateconf since prompting is
	 * safer */
	not_prompt = !not_prompt;

	manager = panel_session_manager_get ();

	if (not_prompt)
		panel_session_manager_request_logout (manager,
						      PANEL_SESSION_MANAGER_LOGOUT_MODE_NO_CONFIRMATION);
	else
		/* FIXME: we need to use widget to get the screen for the
		 * confirmation dialog, see
		 * http://bugzilla.gnome.org/show_bug.cgi?id=536914 */
		panel_session_manager_request_logout (manager,
						      PANEL_SESSION_MANAGER_LOGOUT_MODE_NORMAL);
}
Пример #18
0
/**
 * _mate_vfs_use_handler_for_scheme:
 * @scheme: the URI scheme
 *
 * Checks MateConf to see if there is a URL handler
 * defined for this scheme and if it is enabled.
 *
 * Return value: TRUE if handler is defined and enabled,
 * FALSE otherwise.
 *
 * Since: 2.4
 */
gboolean
_mate_vfs_use_handler_for_scheme (const char *scheme)
{
	MateConfClient *client;
	gboolean ret;
	char *path;
	
	g_return_val_if_fail (scheme != NULL, FALSE);
	
	if (!mateconf_is_initialized ()) {
		if (!mateconf_init (0, NULL, NULL)) {
			return FALSE;
		}
	}
	
	client = mateconf_client_get_default ();
	path = g_strconcat (MATECONF_URL_HANDLER_PATH, scheme, "/enabled", NULL);
	ret = mateconf_client_get_bool (client, path, NULL);
	
	g_free (path);
	g_object_unref (G_OBJECT (client));
	
	return ret;
}
/* Find out if the lockdown key has been set.
 * Currently returns false on error... */
static gboolean is_locked_down(MateConfClient* client)
{
	return mateconf_client_get_bool(client, LOCKDOWN_KEY, NULL);
}
Пример #20
0
void
prop_cb (GtkAction    *action,
				 ProgressData *battstat)
{
  GtkBuilder *builder;
  GtkWidget *combo_ptr, *spin_ptr;
  MateConfClient *client;
  GtkListStore *liststore;
  GtkCellRenderer *renderer;
  GtkTreeIter iter;
  /* Shouldn't this be used for something later on? */
  gboolean   inhibit_command_line;

  client = mateconf_client_get_default ();
  inhibit_command_line = mateconf_client_get_bool (client, "/desktop/mate/lockdown/inhibit_command_line", NULL);

  if (DEBUG) g_print("prop_cb()\n");

   if (battstat->prop_win) { 
     gtk_window_set_screen (GTK_WINDOW (battstat->prop_win),
			    gtk_widget_get_screen (battstat->applet));
     gtk_window_present (GTK_WINDOW (battstat->prop_win));
     return;
   } 

  builder = gtk_builder_new ();
  gtk_builder_add_from_file (builder, GTK_BUILDERDIR"/battstat_applet.ui", NULL);

  battstat->prop_win = GTK_DIALOG (gtk_builder_get_object (builder, 
  				   "battstat_properties"));
  gtk_window_set_screen (GTK_WINDOW (battstat->prop_win),
			 gtk_widget_get_screen (battstat->applet));

  g_signal_connect (G_OBJECT (battstat->prop_win), "delete_event",
		  G_CALLBACK (gtk_true), NULL);
  
  battstat->lowbatt_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "lowbatt_toggle"));
  g_signal_connect (G_OBJECT (battstat->lowbatt_toggle), "toggled",
  		    G_CALLBACK (lowbatt_toggled), battstat);

  if (!key_writable (MATE_PANEL_APPLET (battstat->applet),
			  "low_battery_notification"))
  {
	  hard_set_sensitive (battstat->lowbatt_toggle, FALSE);
  }

  battstat->hbox_ptr = GTK_WIDGET (gtk_builder_get_object (builder, "hbox_ptr"));
  hard_set_sensitive (battstat->hbox_ptr, battstat->lowbattnotification);

  combo_ptr = GTK_WIDGET (gtk_builder_get_object (builder, "combo_ptr"));
  g_signal_connect (G_OBJECT (combo_ptr), "changed",
		  G_CALLBACK (combo_ptr_cb), battstat);

  liststore = gtk_list_store_new (1, G_TYPE_STRING);
  gtk_combo_box_set_model (GTK_COMBO_BOX (combo_ptr),
		  GTK_TREE_MODEL (liststore));
  gtk_cell_layout_clear (GTK_CELL_LAYOUT (combo_ptr));
  renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_ptr),
		  renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_ptr),
		  renderer,
		  "text", 0,
		  NULL);
  gtk_list_store_append (liststore, &iter);
  /* TRANSLATOR: this is a selectable item in a drop-down menu to end
   * this sentence:
   *   "Warn when battery charge drops to: [XX] percent".
   */
  gtk_list_store_set (liststore, &iter, 0, _("Percent"), -1);
  gtk_list_store_append (liststore, &iter);
  /* TRANSLATOR: this is a selectable item in a drop-down menu to end
   * this sentence:
   *   "Warn when battery charge drops to: [XX] minutes remaining"
   */
  gtk_list_store_set (liststore, &iter, 0, _("Minutes Remaining"), -1);

  spin_ptr = GTK_WIDGET (gtk_builder_get_object (builder, "spin_ptr"));
  gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin_ptr),
		  battstat->red_val);
  g_signal_connect (G_OBJECT (spin_ptr), "value-changed",
		  G_CALLBACK (spin_ptr_cb), battstat);

  if (battstat->red_value_is_time)
	  gtk_combo_box_set_active (GTK_COMBO_BOX (combo_ptr), 1);
  else
	  gtk_combo_box_set_active (GTK_COMBO_BOX (combo_ptr), 0);

  battstat->full_toggle = GTK_WIDGET (gtk_builder_get_object (builder, "full_toggle"));
  g_signal_connect (G_OBJECT (battstat->full_toggle), "toggled",
  		    G_CALLBACK (full_toggled), battstat);

  if (!key_writable (MATE_PANEL_APPLET (battstat->applet),
			  "full_battery_notification"))
  {
	  hard_set_sensitive (battstat->full_toggle, FALSE);
  }
  if (battstat->fullbattnot)
  {
     gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (battstat->full_toggle),
		     TRUE);
  }
  if (battstat->lowbattnotification)
  {
    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (battstat->lowbatt_toggle),
		    TRUE);
  }

  battstat->radio_traditional_battery = GTK_WIDGET (gtk_builder_get_object (builder,
		  "battery_view_2"));
  g_signal_connect (G_OBJECT (battstat->radio_traditional_battery), "toggled",
  		    G_CALLBACK (radio_traditional_toggled), battstat);

  if (!key_writable (MATE_PANEL_APPLET (battstat->applet), "show_battery"))
	  hard_set_sensitive (battstat->radio_traditional_battery, FALSE);
  
  if (battstat->showbattery)
  {
    gtk_toggle_button_set_active (
		    GTK_TOGGLE_BUTTON (battstat->radio_traditional_battery),
		    TRUE);
  }
  
  battstat->radio_ubuntu_battery = GTK_WIDGET (gtk_builder_get_object (builder,
		  "battery_view"));
  g_signal_connect (G_OBJECT (battstat->radio_ubuntu_battery), "toggled",
  		    G_CALLBACK (radio_ubuntu_toggled), battstat);

  if (!key_writable (MATE_PANEL_APPLET (battstat->applet), "show_status"))
	  hard_set_sensitive (battstat->radio_ubuntu_battery, FALSE);
	
  if (battstat->showstatus)
  {
    gtk_toggle_button_set_active (
		    GTK_TOGGLE_BUTTON (battstat->radio_ubuntu_battery), TRUE);
  }

  battstat->radio_text_1 = GTK_WIDGET (gtk_builder_get_object (builder, "show_text_radio"));
  battstat->radio_text_2 = GTK_WIDGET (gtk_builder_get_object (builder,
		  "show_text_radio_2"));
  battstat->check_text = GTK_WIDGET (gtk_builder_get_object (builder,
		  "show_text_remaining"));

  g_object_unref (builder);
  
  g_signal_connect (G_OBJECT (battstat->radio_text_1), "toggled",
		  G_CALLBACK (show_text_toggled), battstat);
  g_signal_connect (G_OBJECT (battstat->radio_text_2), "toggled",
		  G_CALLBACK (show_text_toggled), battstat);
  g_signal_connect (G_OBJECT (battstat->check_text), "toggled",
		  G_CALLBACK (show_text_toggled), battstat);
  
  if (!key_writable (MATE_PANEL_APPLET (battstat->applet), "show_text"))
  {
	  hard_set_sensitive (battstat->check_text, FALSE);
	  hard_set_sensitive (battstat->radio_text_1, FALSE);
	  hard_set_sensitive (battstat->radio_text_2, FALSE);
  }

  if (battstat->showtext == APPLET_SHOW_PERCENT)
  {
	  gtk_toggle_button_set_active (
			  GTK_TOGGLE_BUTTON (battstat->check_text), TRUE);
	  gtk_toggle_button_set_active (
			  GTK_TOGGLE_BUTTON (battstat->radio_text_2), TRUE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
			  TRUE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
			  TRUE);
  }
  else if (battstat->showtext == APPLET_SHOW_TIME)
  {
	  gtk_toggle_button_set_active (
			  GTK_TOGGLE_BUTTON (battstat->check_text),
			  TRUE);
	  gtk_toggle_button_set_active (
			  GTK_TOGGLE_BUTTON (battstat->radio_text_1),
			  TRUE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
			  TRUE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
			  TRUE);
  }
  else /* APPLET_SHOW_NONE */
  {
	  gtk_toggle_button_set_active (
			  GTK_TOGGLE_BUTTON (battstat->check_text), FALSE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_1),
			  FALSE);
	  gtk_widget_set_sensitive (GTK_WIDGET (battstat->radio_text_2),
			  FALSE);
  }

   gtk_dialog_set_default_response (GTK_DIALOG (battstat->prop_win),
		   GTK_RESPONSE_CLOSE);
   gtk_window_set_resizable (GTK_WINDOW (battstat->prop_win), FALSE);
   gtk_dialog_set_has_separator (GTK_DIALOG (battstat->prop_win), FALSE);
   
   g_signal_connect (G_OBJECT (battstat->prop_win), "response",
   		     G_CALLBACK (response_cb), battstat);
   gtk_widget_show_all (GTK_WIDGET (battstat->prop_win));
}
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;
}
Пример #22
0
void
procdialog_create_preferences_dialog (ProcData *procdata)
{
	static GtkWidget *dialog = NULL;

	typedef SpinButtonUpdater SBU;

	static SBU interval_updater("/apps/procman/update_interval");
	static SBU graph_interval_updater("/apps/procman/graph_update_interval");
	static SBU disks_interval_updater("/apps/procman/disks_interval");

	GtkWidget *notebook;
	GtkWidget *proc_box;
	GtkWidget *sys_box;
	GtkWidget *main_vbox;
	GtkWidget *vbox, *vbox2, *vbox3;
	GtkWidget *hbox, *hbox2, *hbox3;
	GtkWidget *label;
	GtkAdjustment *adjustment;
	GtkWidget *spin_button;
	GtkWidget *check_button;
	GtkWidget *tab_label;
	GtkWidget *smooth_button;
	GtkSizeGroup *size;
	gfloat update;
	gchar *tmp;
	
	if (prefs_dialog)
		return;
		
	size = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
	
	dialog = gtk_dialog_new_with_buttons (_("System Monitor Preferences"),
					      GTK_WINDOW (procdata->app),
					      GTK_DIALOG_DESTROY_WITH_PARENT,
					      GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
					      NULL);
	/* FIXME: we should not declare the window size, but let it's   */
	/* driven by window childs. The problem is that the fields list */
	/* have to show at least 4 items to respect HIG. I don't know   */
	/* any function to set list height by contents/items inside it. */
	gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 420);
	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
	prefs_dialog = dialog;
	
	main_vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
	gtk_box_set_spacing (GTK_BOX (main_vbox), 2);
	
	notebook = gtk_notebook_new ();
	gtk_container_set_border_width (GTK_CONTAINER (notebook), 5);
	gtk_box_pack_start (GTK_BOX (main_vbox), notebook, TRUE, TRUE, 0);
	
	proc_box = gtk_vbox_new (FALSE, 18);
	gtk_container_set_border_width (GTK_CONTAINER (proc_box), 12);
	tab_label = gtk_label_new (_("Processes"));
	gtk_widget_show (tab_label);
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), proc_box, tab_label);
	
	vbox = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (proc_box), vbox, FALSE, FALSE, 0);
	
	tmp = g_strdup_printf ("<b>%s</b>", _("Behavior"));
	label = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_label_set_markup (GTK_LABEL (label), tmp);
	g_free (tmp);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
	
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
	
	label = gtk_label_new ("    ");
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
	
	vbox2 = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
			  
	hbox2 = gtk_hbox_new (FALSE, 12);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
	
	label = gtk_label_new_with_mnemonic (_("_Update interval in seconds:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
	
	hbox3 = gtk_hbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0);
	
	update = (gfloat) procdata->config.update_interval;
	adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0,
							  MIN_UPDATE_INTERVAL / 1000,
							  MAX_UPDATE_INTERVAL / 1000,
							  0.25,
							  1.0,
							  1.0);

	spin_button = gtk_spin_button_new (adjustment, 1.0, 2);
	gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0);
	g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
				   G_CALLBACK (SBU::callback), &interval_updater);
	gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
	

	hbox2 = gtk_hbox_new(FALSE, 6);
	gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, 0);

	smooth_button = gtk_check_button_new_with_mnemonic(_("Enable _smooth refresh"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(smooth_button),
				     mateconf_client_get_bool(procdata->client,
							   SmoothRefresh::KEY.c_str(),
							   NULL));
	g_signal_connect(G_OBJECT(smooth_button), "toggled",
			 G_CALLBACK(smooth_refresh_toggled), procdata);
	gtk_box_pack_start(GTK_BOX(hbox2), smooth_button, TRUE, TRUE, 0);



	hbox2 = gtk_hbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
		
	check_button = gtk_check_button_new_with_mnemonic (_("Alert before ending or _killing processes"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), 
				      procdata->config.show_kill_warning);
	g_signal_connect (G_OBJECT (check_button), "toggled",
			    G_CALLBACK (show_kill_dialog_toggled), procdata);
	gtk_box_pack_start (GTK_BOX (hbox2), check_button, FALSE, FALSE, 0);
	



	hbox2 = gtk_hbox_new(FALSE, 6);
	gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, 0);

	GtkWidget *solaris_button;
	solaris_button = gtk_check_button_new_with_mnemonic(_("Solaris mode"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(solaris_button),
				     mateconf_client_get_bool(procdata->client,
							   procman::mateconf::solaris_mode.c_str(),
							   NULL));
	g_signal_connect(G_OBJECT(solaris_button), "toggled",
			 G_CALLBACK(solaris_mode_toggled), procdata);
	gtk_box_pack_start(GTK_BOX(hbox2), solaris_button, TRUE, TRUE, 0);




	hbox2 = gtk_hbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
	
	vbox = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (proc_box), vbox, TRUE, TRUE, 0);
	
	tmp = g_strdup_printf ("<b>%s</b>", _("Information Fields"));
	label = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_label_set_markup (GTK_LABEL (label), tmp);
	g_free (tmp);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
	
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
	
	label = gtk_label_new ("    ");
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
	
	vbox2 = create_field_page (procdata->tree, _("Process i_nformation shown in list:"));
	gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
	
	sys_box = gtk_vbox_new (FALSE, 12);
	gtk_container_set_border_width (GTK_CONTAINER (sys_box), 12);
	tab_label = gtk_label_new (_("Resources"));
	gtk_widget_show (tab_label);
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sys_box, tab_label);
	
	vbox = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (sys_box), vbox, FALSE, FALSE, 0);
	
	tmp = g_strdup_printf ("<b>%s</b>", _("Graphs"));
	label = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_label_set_markup (GTK_LABEL (label), tmp);
	g_free (tmp);
	gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0);
	
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
	
	label = gtk_label_new ("    ");
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
	
	vbox2 = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
	
	hbox2 = gtk_hbox_new (FALSE, 12);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
		
	label = gtk_label_new_with_mnemonic (_("_Update interval in seconds:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
	gtk_size_group_add_widget (size, label);
	
	hbox3 = gtk_hbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0);
			  
	update = (gfloat) procdata->config.graph_update_interval;
	adjustment = (GtkAdjustment *) gtk_adjustment_new(update / 1000.0, 0.25, 
							  100.0, 0.25, 1.0, 1.0);
	spin_button = gtk_spin_button_new (adjustment, 1.0, 2);
	g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
			  G_CALLBACK(SBU::callback),
			  &graph_interval_updater);
	gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0);
	gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
	

	GtkWidget *bits_button;
	bits_button = gtk_check_button_new_with_mnemonic(_("Show network speed in bits"));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(bits_button),
				     mateconf_client_get_bool(procdata->client,
							   procman::mateconf::network_in_bits.c_str(),
							   NULL));
	g_signal_connect(G_OBJECT(bits_button), "toggled",
			 G_CALLBACK(network_in_bits_toggled), procdata);
	gtk_box_pack_start(GTK_BOX(vbox2), bits_button, TRUE, TRUE, 0);


	
	hbox2 = gtk_hbox_new (FALSE, 12);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox2, TRUE, TRUE, 0);
	
	/*
	 * Devices
	 */
	vbox = gtk_vbox_new (FALSE, 6);
	gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
	tab_label = gtk_label_new (_("File Systems"));
	gtk_widget_show (tab_label);
	gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, tab_label);
	
	tmp = g_strdup_printf ("<b>%s</b>", _("File Systems"));
	label = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_label_set_markup (GTK_LABEL (label), tmp);
	g_free (tmp);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
	
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
	
	label = gtk_label_new ("    ");
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
	
	vbox2 = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (hbox), vbox2, TRUE, TRUE, 0);
	
	hbox2 = gtk_hbox_new (FALSE, 12);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
	
	label = gtk_label_new_with_mnemonic (_("_Update interval in seconds:"));
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, FALSE, 0);
	
	hbox3 = gtk_hbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (hbox2), hbox3, TRUE, TRUE, 0);
			  
	update = (gfloat) procdata->config.disks_update_interval;
	adjustment = (GtkAdjustment *) gtk_adjustment_new (update / 1000.0, 1.0, 
							   100.0, 1.0, 1.0, 1.0);
	spin_button = gtk_spin_button_new (adjustment, 1.0, 0);
	gtk_box_pack_start (GTK_BOX (hbox3), spin_button, FALSE, FALSE, 0);
	gtk_label_set_mnemonic_widget (GTK_LABEL (label), spin_button);
	g_signal_connect (G_OBJECT (spin_button), "focus_out_event",
			  G_CALLBACK(SBU::callback),
			  &disks_interval_updater);
		

	hbox2 = gtk_hbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (vbox2), hbox2, FALSE, FALSE, 0);
	check_button = gtk_check_button_new_with_mnemonic (_("Show _all filesystems"));
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button),
				      procdata->config.show_all_fs);
	g_signal_connect (G_OBJECT (check_button), "toggled",
			    G_CALLBACK (show_all_fs_toggled), procdata);
	gtk_box_pack_start (GTK_BOX (hbox2), check_button, FALSE, FALSE, 0);


	vbox2 = gtk_vbox_new (FALSE, 6);
	gtk_box_pack_start (GTK_BOX (vbox), vbox2, FALSE, FALSE, 0);

	label = gtk_label_new ("    ");
	gtk_box_pack_start (GTK_BOX (vbox2), label, FALSE, FALSE, 0);
	
	tmp = g_strdup_printf ("<b>%s</b>", _("Information Fields"));
	label = gtk_label_new (NULL);
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_label_set_markup (GTK_LABEL (label), tmp);
	g_free (tmp);
	gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
	
	hbox = gtk_hbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
	
	label = gtk_label_new ("    ");
	gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
	
	vbox3 = create_field_page (procdata->disk_list, _("File system i_nformation shown in list:"));
	gtk_box_pack_start (GTK_BOX (hbox), vbox3, TRUE, TRUE, 0);

	gtk_widget_show_all (dialog);
	g_signal_connect (G_OBJECT (dialog), "response",
				  G_CALLBACK (prefs_dialog_button_pressed), procdata);
	
	switch (procdata->config.current_tab) {
	case PROCMAN_TAB_SYSINFO:
	case PROCMAN_TAB_PROCESSES:
		gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
		break;
	case PROCMAN_TAB_RESOURCES:
		gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
		break;
	case PROCMAN_TAB_DISKS:
		gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 2);
		break;

	}
}
Пример #23
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);
}
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);
}