/**
 * mateui_mateconf_lazy_init:
 *
 * Description:  Internal libmate/ui routine.  You never have
 * to do this from your code.  But all places in libmate/ui
 * that need mateconf should call this before calling any mateconf
 * calls.
 **/
void
_mateui_mateconf_lazy_init (void)
{
	/* Note this is the same as in libmate/libmate/mate-mateconf.c, keep
	 * this in sync (it's called mate_mateconf_lazy_init) */
        gchar *settings_dir;
	MateConfClient* client = NULL;
	static gboolean initialized = FALSE;

	if (initialized)
		return;

	initialized = TRUE;

        client = mateconf_client_get_default ();

        mateconf_client_add_dir (client,
			      "/desktop/mate",
			      MATECONF_CLIENT_PRELOAD_NONE, NULL);

        settings_dir = mate_mateconf_get_mate_libs_settings_relative ("");

        mateconf_client_add_dir (client,
			      settings_dir,
			      /* Possibly we should turn preload on for this */
			      MATECONF_CLIENT_PRELOAD_NONE,
			      NULL);
        g_free (settings_dir);

        /* Leak the MateConfClient reference, we want to keep
         * the client alive forever.
         */
}
void font_init(AppearanceData* data)
{
	GObject* peditor;
	GtkWidget* widget;

	data->font_details = NULL;
	data->font_groups = NULL;

	mateconf_client_add_dir(data->client, "/desktop/mate/interface", MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	mateconf_client_add_dir(data->client, "/apps/caja/preferences", MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	mateconf_client_add_dir(data->client, MARCO_DIR, MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
  
	#ifdef HAVE_XFT2
		mateconf_client_add_dir(data->client, FONT_RENDER_DIR, MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	#endif /* HAVE_XFT2 */

	widget = appearance_capplet_get_widget(data, "application_font");
	peditor = mateconf_peditor_new_font(NULL, GTK_FONT_KEY, widget, "conv-from-widget-cb", application_font_to_mateconf, NULL);
	g_signal_connect_swapped(peditor, "value-changed", G_CALLBACK (application_font_changed), widget);
	application_font_changed(widget);

	peditor = mateconf_peditor_new_font(NULL, DOCUMENT_FONT_KEY, appearance_capplet_get_widget (data, "document_font"), NULL);

	peditor = mateconf_peditor_new_font(NULL, DESKTOP_FONT_KEY, appearance_capplet_get_widget (data, "desktop_font"), NULL);

	peditor = mateconf_peditor_new_font(NULL, WINDOW_TITLE_FONT_KEY, appearance_capplet_get_widget (data, "window_title_font"), NULL);

	peditor = mateconf_peditor_new_font(NULL, MONOSPACE_FONT_KEY, appearance_capplet_get_widget (data, "monospace_font"), NULL);

	mateconf_client_notify_add (data->client, WINDOW_TITLE_USES_SYSTEM_KEY, marco_changed, data, NULL, NULL);

	marco_titlebar_load_sensitivity(data);

	#ifdef HAVE_XFT2
		setup_font_pair(appearance_capplet_get_widget(data, "monochrome_radio"), appearance_capplet_get_widget (data, "monochrome_sample"), ANTIALIAS_NONE, HINT_FULL);
		setup_font_pair(appearance_capplet_get_widget(data, "best_shapes_radio"), appearance_capplet_get_widget (data, "best_shapes_sample"), ANTIALIAS_GRAYSCALE, HINT_MEDIUM);
		setup_font_pair(appearance_capplet_get_widget(data, "best_contrast_radio"), appearance_capplet_get_widget (data, "best_contrast_sample"), ANTIALIAS_GRAYSCALE, HINT_FULL);
		setup_font_pair(appearance_capplet_get_widget(data, "subpixel_radio"), appearance_capplet_get_widget (data, "subpixel_sample"), ANTIALIAS_RGBA, HINT_FULL);

		font_render_load (data->client);

		mateconf_client_notify_add (data->client, FONT_RENDER_DIR, font_render_changed, data->client, NULL, NULL);

		g_signal_connect (appearance_capplet_get_widget (data, "details_button"), "clicked", G_CALLBACK (cb_show_details), data);
	#else /* !HAVE_XFT2 */
		gtk_widget_hide (appearance_capplet_get_widget (data, "font_render_frame"));
	#endif /* HAVE_XFT2 */
}
static void
gn_combo_history_mateconf_register_id (GnComboHistory *history)
{
	gchar *key;
	   
	g_return_if_fail (GN_IS_COMBO_HISTORY (history));

	if (!history->priv->mateconf_client)
		history->priv->mateconf_client = mateconf_client_get_default ();

	key = g_strconcat ("/apps/mate-settings/",
			  "mate-nettool",
			   "/history-",
			   history->priv->id,
			   NULL);

	mateconf_client_add_dir (history->priv->mateconf_client,
			      key,	MATECONF_CLIENT_PRELOAD_NONE,
			      NULL);
	   
	history->priv->mateconf_notify = mateconf_client_notify_add (
							       history->priv->mateconf_client, key,
							       gn_on_mateconf_history_changed,
							       (gpointer) history, NULL, NULL);

	g_free (key);
}
static gboolean
impl_activate (IdolPlugin *plugin,
	       IdolObject *idol,
	       GError **error)
{
	IdolScreensaverPlugin *pi = IDOL_SCREENSAVER_PLUGIN (plugin);
	MateConfClient *gc;

	pi->bvw = BACON_VIDEO_WIDGET (idol_get_video_widget (idol));

	gc = mateconf_client_get_default ();
	mateconf_client_add_dir (gc, MATECONF_PREFIX,
			      MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	pi->handler_id_mateconf = mateconf_client_notify_add (gc, MATECONF_PREFIX"/lock_screensaver_on_audio",
							(MateConfClientNotifyFunc) lock_screensaver_on_audio_changed_cb,
							plugin, NULL, NULL);
	g_object_unref (gc);

	pi->handler_id_playing = g_signal_connect (G_OBJECT (idol),
						   "notify::playing",
						   G_CALLBACK (property_notify_cb),
						   pi);
	pi->handler_id_metadata = g_signal_connect (G_OBJECT (pi->bvw),
						    "got-metadata",
						    G_CALLBACK (got_metadata_cb),
						    pi);

	pi->idol = g_object_ref (idol);

	/* Force setting the current status */
	idol_screensaver_update_from_state (idol, pi);

	return TRUE;
}
static void
hard_drive_status_tile_init (HardDriveStatusTile * tile)
{
    HardDriveStatusTilePrivate *priv = HARD_DRIVE_STATUS_TILE_GET_PRIVATE (tile);

    priv->mateconf = mateconf_client_get_default ();
    mateconf_client_add_dir (priv->mateconf, TIMEOUT_KEY_DIR, MATECONF_CLIENT_PRELOAD_NONE, NULL);
}
int main (int argc, char** argv)
{
    MateDACapplet* capplet;

    gchar* start_page = NULL;

    GOptionContext* context;
    GOptionEntry option_entries[] = {
		{
			"show-page",
			'p',
			G_OPTION_FLAG_IN_MAIN,
			G_OPTION_ARG_STRING,
			&start_page,
			/* TRANSLATORS: don't translate the terms in brackets */
			N_("Specify the name of the page to show (internet|multimedia|system|a11y)"),
			N_("page")
		},
		{NULL}
    };

    context = g_option_context_new(_("- MATE Default Applications"));
    g_option_context_add_main_entries (context, option_entries, GETTEXT_PACKAGE);

    capplet_init (context, &argc, &argv);

    capplet = g_new0(MateDACapplet, 1);
    capplet->mateconf = mateconf_client_get_default();
    mateconf_client_add_dir(capplet->mateconf, "/desktop/mate/url-handlers", MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL);
    mateconf_client_add_dir(capplet->mateconf, "/desktop/mate/applications", MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL);

    mate_da_xml_load_list(capplet);

    show_dialog(capplet, start_page);
    g_free(start_page);

    gtk_main();

    g_object_unref(capplet->mateconf);

    mate_da_xml_free(capplet);

    return 0;
}
static void
calendar_sources_load_sources (CalendarSources    *sources,
			       CalendarSourceData *source_data,
			       const char         *sources_key,
			       const char         *selected_sources_key,
			       const char         *selected_sources_dir)
{
  MateConfClient *mateconf_client;
  GError      *error;

  dprintf ("---------------------------\n");
  dprintf ("Loading sources:\n");
  dprintf ("  sources_key: %s\n", sources_key);
  dprintf ("  selected_sources_key: %s\n", selected_sources_key);
  dprintf ("  selected_sources_dir: %s\n", selected_sources_dir);

  mateconf_client = sources->priv->mateconf_client;

  error = NULL;
  source_data->selected_sources = mateconf_client_get_list (mateconf_client,
							 selected_sources_key,
							 MATECONF_VALUE_STRING,
							 &error);
  if (error)
    {
      g_warning ("Failed to get selected sources from '%s': %s\n",
		 selected_sources_key,
		 error->message);
      g_error_free (error);
      return;
    }

  mateconf_client_add_dir (mateconf_client,
			selected_sources_dir,
			MATECONF_CLIENT_PRELOAD_NONE,
			NULL);
  source_data->selected_sources_dir = g_strdup (selected_sources_dir);

  source_data->selected_sources_listener =
    mateconf_client_notify_add (mateconf_client,
			     selected_sources_dir,
			     (MateConfClientNotifyFunc) calendar_sources_selected_sources_notify,
			     source_data, NULL, NULL);

  source_data->esource_list = e_source_list_new_for_mateconf (mateconf_client, sources_key);
  g_signal_connect (source_data->esource_list, "changed",
		    G_CALLBACK (calendar_sources_esource_list_changed),
		    source_data);

  calendar_sources_load_esource_list (source_data);

  source_data->loaded = TRUE;

  dprintf ("---------------------------\n");
}
void
mateconf_bookmarks_hook_up_menu (MateConfEditorWindow *window,
			      GtkWidget *menu,
			      GtkWidget *add_bookmark,
			      GtkWidget *edit_bookmarks)
{
	MateConfClient *client;
	guint notify_id;

	g_object_set_data (G_OBJECT (menu), "editor-window", window);

	client = mateconf_client_get_default ();
	
	/* Add a notify function */
	mateconf_client_add_dir (client, "/apps/mateconf-editor/bookmarks",
			      MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	notify_id = mateconf_client_notify_add (client, "/apps/mateconf-editor/bookmarks",
					     mateconf_bookmarks_key_changed, menu, NULL, NULL);
	g_object_set_data_full (G_OBJECT (menu), "notify-id", GINT_TO_POINTER (notify_id),
				remove_notify_id);


	notify_id = mateconf_client_notify_add (client, "/desktop/mate/interface/menus_have_icons",
					     mateconf_bookmarks_have_icons_notify, menu, NULL, NULL); 
	g_object_set_data_full (G_OBJECT (menu), "notify-id-x", GINT_TO_POINTER (notify_id),
				remove_notify_id);

	mateconf_bookmarks_update_menu (menu);

        {
                gboolean have_icons;
                MateConfValue *value;
                GError *err;

                err = NULL;
                value = mateconf_client_get (client, "/desktop/mate/interface/menus_have_icons", &err);

                if (err != NULL || value == NULL || value->type != MATECONF_VALUE_BOOL)
                        return;

                have_icons = mateconf_value_get_bool (value);
                mateconf_bookmarks_set_have_icons (menu, have_icons);

                mateconf_value_free (value);
        }

	if ( ! mateconf_client_key_is_writable (client, "/apps/mateconf-editor/bookmarks", NULL)) {
		gtk_widget_set_sensitive (add_bookmark, FALSE);
		gtk_widget_set_sensitive (edit_bookmarks, FALSE);
	}

	g_object_unref (client);
}
void
mcharmap_settings_initialize (void)
{
  client = mateconf_client_get_default ();

  if (client == NULL) {
    g_message(_("MateConf could not be initialized."));
    return;
  }

  mateconf_client_add_dir (client, MATECONF_PREFIX,
                        MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
}
static void
panel_menu_button_connect_to_mateconf (PanelMenuButton *button)
{
	MateConfClient *client;
	const char  *key;

	client  = panel_mateconf_get_client ();

	key = panel_mateconf_sprintf (PANEL_CONFIG_DIR "/objects/%s",
				   button->priv->applet_id);
	mateconf_client_add_dir (client, key, MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	button->priv->mateconf_notify =
		mateconf_client_notify_add (client, key,
					 (MateConfClientNotifyFunc) panel_menu_button_mateconf_notify,
					 button, NULL, NULL);
}
void
matecomponent_ui_preferences_add_engine (MateComponentUIEngine *engine)
{
	if (!client)
		client = mateconf_client_get_default ();
	
	if (engine_list == NULL) {
		/* We need to intialize the notifiers */
		mateconf_client_add_dir (client, GLOBAL_INTERFACE_KEY, MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL);
		
		desktop_notify_id = mateconf_client_notify_add (client, GLOBAL_INTERFACE_KEY,
							     keys_changed_fn,
							     NULL, NULL, NULL);
	}

	engine_list = g_slist_prepend (engine_list, engine);
}
void
matekbd_indicator_config_init (MatekbdIndicatorConfig * ind_config,
			    MateConfClient * conf_client, XklEngine * engine)
{
	GError *gerror = NULL;
	gchar *sp;

	memset (ind_config, 0, sizeof (*ind_config));
	ind_config->conf_client = conf_client;
	ind_config->engine = engine;
	g_object_ref (ind_config->conf_client);

	mateconf_client_add_dir (ind_config->conf_client,
			      MATEKBD_INDICATOR_CONFIG_DIR,
			      MATECONF_CLIENT_PRELOAD_NONE, &gerror);
	if (gerror != NULL) {
		g_warning ("err1:%s\n", gerror->message);
		g_error_free (gerror);
		gerror = NULL;
	}

	ind_config->icon_theme = gtk_icon_theme_get_default ();

	gtk_icon_theme_append_search_path (ind_config->icon_theme, sp =
					   g_build_filename (g_get_home_dir
							     (),
							     ".icons/flags",
							     NULL));
	g_free (sp);

	gtk_icon_theme_append_search_path (ind_config->icon_theme,
					   sp =
					   g_build_filename (DATADIR,
							     "pixmaps/flags",
							     NULL));
	g_free (sp);

	gtk_icon_theme_append_search_path (ind_config->icon_theme,
					   sp =
					   g_build_filename (DATADIR,
							     "icons/flags",
							     NULL));
	g_free (sp);
}
static void
pluma_drawspaces_plugin_init (PlumaDrawspacesPlugin *plugin)
{
	pluma_debug_message (DEBUG_PLUGINS, "PlumaDrawspacesPlugin initializing");

	plugin->priv = PLUMA_DRAWSPACES_PLUGIN_GET_PRIVATE (plugin);

	plugin->priv->mateconf_client = mateconf_client_get_default ();

	mateconf_client_add_dir (plugin->priv->mateconf_client,
			      MATECONF_KEY_BASE,
			      MATECONF_CLIENT_PRELOAD_ONELEVEL,
			      NULL);

	plugin->priv->connection_id = mateconf_client_notify_add (plugin->priv->mateconf_client,
							       MATECONF_KEY_BASE,
							       on_mateconf_notify,
							       plugin, NULL, NULL);
}
int
main (int argc, char** argv)
{
  MateConfClient *client;
  GtkWidget *main_window;
  
  gtk_init (&argc, &argv);

  /* Get the default client */
  client = mateconf_client_get_default ();

  /* Tell MateConfClient that we're interested in the given directory.
   * This means MateConfClient will receive notification of changes
   * to this directory, and cache keys under this directory.
   * So _don't_ add "/" or something silly like that or you'll end
   * up with a copy of the whole MateConf database. ;-)
   *
   * We pass NULL for the error to use the default error handler;
   * and use PRELOAD_NONE to avoid loading all config keys on
   * startup. If your app pretty much reads all config keys
   * on startup, then preloading the cache may make sense.
   */
   
  mateconf_client_add_dir (client, "/apps/basic-mateconf-app",
                        MATECONF_CLIENT_PRELOAD_NONE, NULL);

  main_window = create_main_window (client);
  
  gtk_widget_show_all (main_window);
  
  gtk_main ();

  /* This ensures we cleanly detach from the MateConf server (assuming
   * we hold the last reference). It's purely a bit of cleanliness,
   * the server does survive fine if we crash.
   */
  g_object_unref (G_OBJECT (client));
  
  return 0;
}
int
main(int argc, char** argv)
{
  GtkWidget* window;
  GtkWidget* entry;
  MateConfClient* client;

  gtk_init(&argc, &argv);
  mateconf_init(argc, argv, NULL);
  
  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  entry = gtk_entry_new();

  gtk_container_add(GTK_CONTAINER(window), entry);  

  client = mateconf_client_get_default();

  mateconf_client_add_dir(client,
                       "/extra/test/directory",
                       MATECONF_CLIENT_PRELOAD_NONE,
                       NULL);


  g_signal_connect (G_OBJECT (entry), "activate",
                    G_CALLBACK (entry_activated_callback),
                    client);

  /* If key isn't writable, then set insensitive */
  gtk_widget_set_sensitive (entry,
                            mateconf_client_key_is_writable (client,
                                                          "/extra/test/directory/key", NULL));
  
  gtk_widget_show_all(window);

  gtk_main();

  return 0;
}
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);
}
static void
mateconf_bookmarks_dialog_init (MateConfBookmarksDialog *dialog)
{
	GtkWidget *scrolled_window, *hbox, *vbox;
	GtkWidget *content_area;
	GtkCellRenderer *cell;
	GtkTreeViewColumn *column;
	MateConfClient *client;
       
	hbox = gtk_hbox_new (FALSE, 6);
	gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);

	content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));

	gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
	gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
	gtk_box_set_spacing (GTK_BOX (content_area), 2);
	gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE);
	gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 200);
	
	gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
	gtk_window_set_title (GTK_WINDOW (dialog), _("Edit Bookmarks"));

	dialog->list_store = gtk_list_store_new (1, G_TYPE_STRING);
	g_signal_connect (dialog->list_store, "row_deleted",
			  G_CALLBACK (mateconf_bookmarks_dialog_row_deleted), dialog);
	scrolled_window = gtk_scrolled_window_new (NULL, NULL);
	gtk_box_pack_start (GTK_BOX (hbox), scrolled_window, TRUE, TRUE, 0);
	
	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN);
	gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	dialog->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (dialog->list_store));
	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (dialog->tree_view), TRUE);
	
	g_signal_connect (gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tree_view)), "changed",
			  G_CALLBACK (mateconf_bookmarks_dialog_selection_changed), dialog);
	mateconf_bookmarks_dialog_populate_model (dialog);

	column = gtk_tree_view_column_new ();

	cell = gtk_cell_renderer_pixbuf_new ();
	g_object_set (G_OBJECT (cell),
		      "stock-id", STOCK_BOOKMARK,
		      NULL);
	gtk_tree_view_column_pack_start (column, cell, FALSE);
	
	cell = gtk_cell_renderer_text_new ();
	gtk_tree_view_column_pack_start (column, cell, TRUE);
	gtk_tree_view_column_set_attributes (column, cell,
					     "text", 0,
					     NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (dialog->tree_view), column);

	gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (dialog->tree_view), FALSE);
	
	g_object_unref (dialog->list_store);
	gtk_container_add (GTK_CONTAINER (scrolled_window), dialog->tree_view);

	vbox = gtk_vbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (hbox), vbox, FALSE, FALSE, 0);
	dialog->delete_button = gtk_button_new_from_stock (GTK_STOCK_DELETE);
	gtk_widget_set_sensitive (dialog->delete_button, FALSE);
	g_signal_connect (dialog->delete_button, "clicked",
			  G_CALLBACK (mateconf_bookmarks_dialog_delete_bookmark), dialog);
	
	gtk_box_pack_start (GTK_BOX (vbox), dialog->delete_button, FALSE, FALSE, 0);

	gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
	gtk_widget_show_all (hbox);

	/* Listen for mateconf changes */
	client = mateconf_client_get_default ();
	mateconf_client_add_dir (client, BOOKMARKS_KEY, MATECONF_CLIENT_PRELOAD_NONE, NULL);

	dialog->notify_id = mateconf_client_notify_add (client, BOOKMARKS_KEY,
						     mateconf_bookmarks_dialog_bookmarks_key_changed,
						     dialog,
						     NULL,
						     NULL);

	g_object_unref (client);
}
void themes_init(AppearanceData* data)
{
  GtkWidget *w, *del_button;
  GList *theme_list, *l;
  GtkListStore *theme_store;
  GtkTreeModel *sort_model;
  MateThemeMetaInfo *meta_theme = NULL;
  GtkIconView *icon_view;
  GtkCellRenderer *renderer;
  GtkSettings *settings;
  char *url;

  /* initialise some stuff */
  mate_theme_init ();
  mate_wm_manager_init ();

  data->revert_application_font = NULL;
  data->revert_documents_font = NULL;
  data->revert_desktop_font = NULL;
  data->revert_windowtitle_font = NULL;
  data->revert_monospace_font = NULL;
  data->theme_save_dialog = NULL;
  data->theme_message_area = NULL;
  data->theme_info_icon = NULL;
  data->theme_error_icon = NULL;
  data->theme_custom = mate_theme_meta_info_new ();
  data->theme_icon = gdk_pixbuf_new_from_file (MATECC_PIXMAP_DIR "/theme-thumbnailing.png", NULL);
  data->theme_store = theme_store =
      gtk_list_store_new (NUM_COLS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);

  /* set up theme list */
  theme_list = mate_theme_meta_info_find_all ();
  mate_theme_info_register_theme_change ((ThemeChangedCallback) theme_changed_on_disk_cb, data);

  data->theme_custom = theme_load_from_mateconf (data->client);
  data->theme_custom->name = g_strdup (CUSTOM_THEME_NAME);
  data->theme_custom->readable_name = g_strdup_printf ("<i>%s</i>", _("Custom"));

  for (l = theme_list; l; l = l->next) {
    MateThemeMetaInfo *info = l->data;

    gtk_list_store_insert_with_values (theme_store, NULL, 0,
        COL_LABEL, info->readable_name,
        COL_NAME, info->name,
        COL_THUMBNAIL, data->theme_icon,
        -1);

    if (!meta_theme && theme_is_equal (data->theme_custom, info))
      meta_theme = info;
  }

  if (!meta_theme) {
    /* add custom theme */
    meta_theme = data->theme_custom;

    gtk_list_store_insert_with_values (theme_store, NULL, 0,
        COL_LABEL, meta_theme->readable_name,
        COL_NAME, meta_theme->name,
        COL_THUMBNAIL, data->theme_icon,
        -1);

    theme_thumbnail_generate (meta_theme, data);
  }

  theme_list = g_list_sort (theme_list, (GCompareFunc) theme_list_sort_func);

  g_list_foreach (theme_list, (GFunc) theme_thumbnail_generate, data);
  g_list_free (theme_list);

  icon_view = GTK_ICON_VIEW (appearance_capplet_get_widget (data, "theme_list"));

  renderer = gtk_cell_renderer_pixbuf_new ();
  g_object_set (renderer, "xpad", 5, "ypad", 5,
                          "xalign", 0.5, "yalign", 1.0, NULL);
  gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (icon_view), renderer, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view), renderer,
                                  "pixbuf", COL_THUMBNAIL, NULL);

  renderer = gtk_cell_renderer_text_new ();
  g_object_set (renderer, "alignment", PANGO_ALIGN_CENTER,
			  "wrap-mode", PANGO_WRAP_WORD_CHAR,
			  "wrap-width", gtk_icon_view_get_item_width (icon_view),
			  "width", gtk_icon_view_get_item_width (icon_view),
			  "xalign", 0.0, "yalign", 0.0, NULL);
  gtk_cell_layout_pack_end (GTK_CELL_LAYOUT (icon_view), renderer, FALSE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (icon_view), renderer,
                                  "markup", COL_LABEL, NULL);

  sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (theme_store));
  gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (sort_model), COL_LABEL, theme_store_sort_func, NULL, NULL);
  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (sort_model), COL_LABEL, GTK_SORT_ASCENDING);
  gtk_icon_view_set_model (icon_view, GTK_TREE_MODEL (sort_model));

  g_signal_connect (icon_view, "selection-changed", (GCallback) theme_selection_changed_cb, data);
  g_signal_connect_after (icon_view, "realize", (GCallback) theme_select_name, meta_theme->name);

  w = appearance_capplet_get_widget (data, "theme_install");
  gtk_button_set_image (GTK_BUTTON (w),
                        gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON));
  g_signal_connect (w, "clicked", (GCallback) theme_install_cb, data);

  w = appearance_capplet_get_widget (data, "theme_save");
  gtk_button_set_image (GTK_BUTTON (w),
                        gtk_image_new_from_stock (GTK_STOCK_SAVE_AS, GTK_ICON_SIZE_BUTTON));
  g_signal_connect (w, "clicked", (GCallback) theme_save_cb, data);

  w = appearance_capplet_get_widget (data, "theme_custom");
  gtk_button_set_image (GTK_BUTTON (w),
                        gtk_image_new_from_stock (GTK_STOCK_EDIT, GTK_ICON_SIZE_BUTTON));
  g_signal_connect (w, "clicked", (GCallback) theme_custom_cb, data);

  del_button = appearance_capplet_get_widget (data, "theme_delete");
  g_signal_connect (del_button, "clicked", (GCallback) theme_delete_cb, data);

  w = appearance_capplet_get_widget (data, "theme_vbox");
  gtk_drag_dest_set (w, GTK_DEST_DEFAULT_ALL,
		     drop_types, G_N_ELEMENTS (drop_types),
		     GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_MOVE);
  g_signal_connect (w, "drag-data-received", (GCallback) theme_drag_data_received_cb, data);
  if (is_locked_down (data->client))
    gtk_widget_set_sensitive (w, FALSE);

  w = appearance_capplet_get_widget (data, "more_themes_linkbutton");
  url = mateconf_client_get_string (data->client, MORE_THEMES_URL_KEY, NULL);
  if (url != NULL && url[0] != '\0') {
    gtk_link_button_set_uri (GTK_LINK_BUTTON (w), url);
    gtk_widget_show (w);
  } else {
    gtk_widget_hide (w);
  }
  g_free (url);

  /* listen to mateconf changes, too */
  mateconf_client_add_dir (data->client, "/apps/marco/general", MATECONF_CLIENT_PRELOAD_NONE, NULL);
  mateconf_client_add_dir (data->client, "/desktop/mate/interface", MATECONF_CLIENT_PRELOAD_NONE, NULL);
  mateconf_client_notify_add (data->client, MARCO_THEME_KEY, (MateConfClientNotifyFunc) theme_mateconf_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, CURSOR_THEME_KEY, (MateConfClientNotifyFunc) theme_mateconf_changed, data, NULL, NULL);
#ifdef HAVE_XCURSOR
  mateconf_client_notify_add (data->client, CURSOR_SIZE_KEY, (MateConfClientNotifyFunc) theme_mateconf_changed, data, NULL, NULL);
#endif
  mateconf_client_notify_add (data->client, BACKGROUND_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, APPLICATION_FONT_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, DOCUMENTS_FONT_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, DESKTOP_FONT_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, WINDOWTITLE_FONT_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);
  mateconf_client_notify_add (data->client, MONOSPACE_FONT_KEY, (MateConfClientNotifyFunc) background_or_font_changed, data, NULL, NULL);

  settings = gtk_settings_get_default ();
  g_signal_connect (settings, "notify::gtk-color-scheme", (GCallback) theme_setting_changed_cb, data);
  g_signal_connect (settings, "notify::gtk-theme-name", (GCallback) theme_setting_changed_cb, data);
  g_signal_connect (settings, "notify::gtk-icon-theme-name", (GCallback) theme_setting_changed_cb, data);

  /* monitor individual font choice buttons, so
     "revert font" option (if any) can be cleared */
  w = appearance_capplet_get_widget (data, "application_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "document_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "desktop_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "window_title_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
  w = appearance_capplet_get_widget (data, "monospace_font");
  g_signal_connect (w, "font_set", (GCallback) custom_font_cb, data);
}
int
main (int argc, char **argv)
{
	char           *desktopfile;
	GOptionContext *context;
	GError         *error;

	bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	/* We will register explicitly when we're ready -- see panel-session.c */
	egg_sm_client_set_mode (EGG_SM_CLIENT_MODE_DISABLED);

	g_set_prgname ("mate-panel");

	desktopfile = panel_g_lookup_in_applications_dirs ("mate-panel.desktop");
	if (desktopfile) {
		egg_set_desktop_file (desktopfile);
		g_free (desktopfile);
	}

	context = g_option_context_new ("");
	g_option_context_add_group (context,
				    egg_sm_client_get_option_group ());
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);

	gtk_init (&argc, &argv);

	error = NULL;
	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_printerr ("%s\n", error->message);
		g_error_free (error);
		g_option_context_free (context);

		return 1;
	}

	g_option_context_free (context);

	/* reset the configuration and exit. */
	if (reset == TRUE)
	{
		panel_reset();
		return 0;
	}


	if (!egg_get_desktop_file ()) {
		g_set_application_name (_("Panel"));
		gtk_window_set_default_icon_name (PANEL_ICON_PANEL);
	}

	if (!panel_shell_register (replace)) {
		panel_cleanup_do ();
		return -1;
	}

	panel_action_protocol_init ();
	panel_multiscreen_init ();
	panel_init_stock_icons_and_items ();

	mateconf_client_add_dir (panel_mateconf_get_client (),
			      "/desktop/mate/interface",
			      MATECONF_CLIENT_PRELOAD_NONE,
			      NULL);

	panel_global_config_load ();
	panel_lockdown_init ();
	panel_profile_load ();

	/*add forbidden lists to ALL panels*/
	g_slist_foreach (panels,
			 (GFunc)panel_widget_add_forbidden,
			 NULL);

	xstuff_init ();

	/* Flush to make sure our struts are seen by everyone starting
	 * immediate after (eg, the caja desktop). */
	gdk_flush ();

	/* Do this at the end, to be sure that we're really ready when
	 * connecting to the session manager */
	panel_session_init ();

	gtk_main ();

	panel_lockdown_finalize ();

	mateconf_client_remove_dir (panel_mateconf_get_client (),
				 "/desktop/mate/interface",
				 NULL);

	panel_cleanup_do ();

	return 0;
}
Beispiel #21
0
static void
mc_setup_listeners (MCData *mc)
{
    MateConfClient *client;
    char        *key;
    int          i = 0;

    client = mateconf_client_get_default ();
    mateconf_client_add_dir (client, "/apps/mini-commander",
			  MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL);

    key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (mc->applet), "show_default_theme");
    mc->listeners [i++] = mateconf_client_notify_add (
				client, key,
				(MateConfClientNotifyFunc) show_default_theme_changed,
                                mc,
                                NULL, NULL);
    g_free (key);

    key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (mc->applet), "autocomplete_history");
    mc->listeners [i++] = mateconf_client_notify_add (
				client, key,
				(MateConfClientNotifyFunc) auto_complete_history_changed,
                                mc,
                                NULL, NULL);
    g_free (key);

    key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (mc->applet), "normal_size_x");
    mc->listeners [i++] = mateconf_client_notify_add (
				client, key,
				(MateConfClientNotifyFunc) normal_size_x_changed,
                                mc,
                                NULL, NULL);
    g_free (key);

    key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (mc->applet), "normal_size_y");
    mc->listeners [i++] = mateconf_client_notify_add (
				client, key,
				(MateConfClientNotifyFunc) normal_size_y_changed,
                                mc,
                                NULL, NULL);
    g_free (key);

    key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (mc->applet), "cmd_line_color_fg_r");
    mc->listeners [i++] = mateconf_client_notify_add (
				client, key,
				(MateConfClientNotifyFunc) cmd_line_color_fg_r_changed,
                                mc,
                                NULL, NULL);
    g_free (key);


    key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (mc->applet), "cmd_line_color_fg_g");
    mc->listeners [i++] = mateconf_client_notify_add (
				client, key,
				(MateConfClientNotifyFunc) cmd_line_color_fg_g_changed,
                                mc,
                                NULL, NULL);
    g_free (key);


    key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (mc->applet), "cmd_line_color_fg_b");
    mc->listeners [i++] = mateconf_client_notify_add (
				client, key,
				(MateConfClientNotifyFunc) cmd_line_color_fg_b_changed,
                                mc,
                                NULL, NULL);
    g_free (key);

    key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (mc->applet), "cmd_line_color_bg_r");
    mc->listeners [i++] = mateconf_client_notify_add (
				client, key,
				(MateConfClientNotifyFunc) cmd_line_color_bg_r_changed,
                                mc,
                                NULL, NULL);
    g_free (key);

    key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (mc->applet), "cmd_line_color_bg_g");
    mc->listeners [i++] = mateconf_client_notify_add (
				client, key,
				(MateConfClientNotifyFunc) cmd_line_color_bg_g_changed,
                                mc,
                                NULL, NULL);
    g_free (key);

    key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (mc->applet), "cmd_line_color_bg_b");
    mc->listeners [i++] = mateconf_client_notify_add (
				client, key,
				(MateConfClientNotifyFunc) cmd_line_color_bg_b_changed,
                                mc,
                                NULL, NULL);
    g_free (key);

    mc->listeners [i++] = mateconf_client_notify_add (
				client, "/apps/mini-commander/macro_patterns",
				(MateConfClientNotifyFunc) macros_changed,
                                mc,
                                NULL, NULL);

    mc->listeners [i++] = mateconf_client_notify_add (
				client, "/apps/mini-commander/macro_commands",
				(MateConfClientNotifyFunc) macros_changed,
                                mc,
                                NULL, NULL);

    g_assert (i == MC_NUM_LISTENERS);

    g_object_unref (client);
}