static void
nautilus_file_background_write_desktop_default_settings (void)
{
	/* We just unset all the gconf keys so they go back to
	 * defaults
	 */
	GConfClient *client;
	GConfChangeSet *set;

	client = gconf_client_get_default ();
	set = gconf_change_set_new ();

	/* the list of keys here has to be kept in sync with libgnome
	 * schemas, which isn't the most maintainable thing ever.
	 */
 	gconf_change_set_unset (set, "/desktop/gnome/background/picture_options");
	gconf_change_set_unset (set, "/desktop/gnome/background/picture_filename");
	gconf_change_set_unset (set, "/desktop/gnome/background/picture_opacity");
	gconf_change_set_unset (set, "/desktop/gnome/background/primary_color");
	gconf_change_set_unset (set, "/desktop/gnome/background/secondary_color");
	gconf_change_set_unset (set, "/desktop/gnome/background/color_shading_type");

	/* this isn't atomic yet so it'll be a bit inefficient, but
	 * someday it might be atomic.
	 */
 	gconf_client_commit_change_set (client, set, FALSE, NULL);

	gconf_change_set_unref (set);
	
	g_object_unref (G_OBJECT (client));
}
int
main (int argc, char *argv[])
{
	GConfClient	*client;
	GConfChangeSet	*changeset;
	GladeXML	*dialog = NULL;
	GtkWidget	*dialog_win;
	
	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	gnome_program_init ("brightside-properties", VERSION,
			LIBGNOMEUI_MODULE, argc, argv,
			NULL);

	client = gconf_client_get_default ();
	gconf_client_add_dir (client, BRIGHTSIDE_KEY_ROOT,
			GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
	conf_client = client;

	changeset = gconf_change_set_new ();
	dialog = create_dialog ();
	setup_dialog (dialog, changeset);

	dialog_win = gtk_dialog_new_with_buttons(
			_("Screen Actions"), NULL, 
			GTK_DIALOG_NO_SEPARATOR,
			GTK_STOCK_HELP, GTK_RESPONSE_HELP,
			GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
			NULL);
	gtk_container_set_border_width (GTK_CONTAINER (dialog_win), 5);
	gtk_box_set_spacing (GTK_BOX (GTK_DIALOG(dialog_win)->vbox), 2);
	gtk_dialog_set_default_response (GTK_DIALOG (dialog_win), 
			GTK_RESPONSE_CLOSE);
	g_signal_connect (G_OBJECT (dialog_win), "response", 
			(GCallback) dialog_button_clicked_cb, changeset);
	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog_win)->vbox), 
			WID ("prefs_widget"), TRUE, TRUE, 0);
	gtk_window_set_resizable (GTK_WINDOW (dialog_win), FALSE);
	gtk_window_set_icon_from_file (GTK_WINDOW (dialog_win), 
			BRIGHTSIDE_DATA "brightside.svg", NULL);
	gtk_widget_show_all (dialog_win);
	
	if (is_running () == FALSE)
		g_spawn_command_line_async ("brightside", NULL);
	
	gtk_main ();

	gconf_change_set_unref (changeset);

	g_object_unref (dialog);

	return 0;
}
gboolean
on_userlist_import_page_2_next (GnomeDruidPage * druidpage, GtkWidget * widget, gpointer user_data)
{
	GtkWidget *file_chooser = glade_xml_get_widget (gladexml_import_userlist, "ImportFileChooser");
	GIOChannel *channel = NULL;
	gchar *line = NULL;
	gsize len, terminator_pos;
	gchar *filename = NULL;
	gsize status = -1;

	g_assert (file_chooser);

	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (file_chooser));
	channel = g_io_channel_new_file (filename, "r", NULL);
	if (!channel)
	{
		GtkDialog *msgdialog = gtk_message_dialog_new_with_markup (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
									   "<span weight=\"bold\"size=\"larger\">Plik nie został wybrany</span>\n\nWymagane pola nie zostały wypełnione prawidłowo, spróbuj jeszcze raz.");
		gtk_dialog_run (GTK_DIALOG (msgdialog));
		gtk_widget_destroy (GTK_WIDGET (msgdialog));
		goto end;
	}

	g_io_channel_set_encoding (channel, NULL, NULL);
	
	GConfChangeSet *changeset = gconf_change_set_new();

	while (status != G_IO_STATUS_ERROR && status != G_IO_STATUS_EOF)
	{
		status = g_io_channel_read_line (channel, &line, &len, &terminator_pos, NULL);

		if (status == G_IO_STATUS_ERROR || status == G_IO_STATUS_EOF)
		{
			g_free (line);
			continue;
		}

		gnomegadu_ui_import_userlist_process_line (line, changeset);
		
		if (!gconf_client_commit_change_set(gconf, changeset, TRUE, NULL))
		    g_printerr("Some error while import");
		    
		g_free (line);
	}

	gconf_change_set_unref(changeset);

	gconf_client_suggest_sync (gconf, NULL);
	g_io_channel_unref (channel);

      end:
	g_free (filename);
	return FALSE;
}
Example #4
0
static gboolean
gconf_settings_backend_write_tree (GSettingsBackend *backend,
                                   GTree            *tree,
                                   gpointer          origin_tag)
{
  GConfSettingsBackend *gconf = GCONF_SETTINGS_BACKEND (backend);
  GConfChangeSet       *changeset;
  GConfChangeSet       *reversed;
  gboolean              success;

  changeset = gconf_change_set_new ();

  g_tree_foreach (tree, (GTraverseFunc) gconf_settings_backend_write_one_to_changeset, changeset);

  if (gconf_change_set_size (changeset) != g_tree_nnodes (tree))
    {
      gconf_change_set_unref (changeset);
      return FALSE;
    }

  reversed = gconf_client_reverse_change_set (gconf->priv->client, changeset, NULL);
  success = gconf_client_commit_change_set (gconf->priv->client, changeset, TRUE, NULL);

  g_tree_foreach (tree, (GTraverseFunc) gconf_settings_backend_add_ignore_notifications, gconf);

  if (!success)
    {
      /* This is a tricky situation: when committing, some keys will have been
       * changed, so there will be notifications that we'll want to ignore. But
       * we can't ignore notifications for what was not committed. Note that
       * when we'll commit the reversed changeset, it should fail for the same
       * key, so there'll be no other notifications created. And in the worst
       * case, it's no big deal... */
      gconf_change_set_foreach (changeset,
                                (GConfChangeSetForeachFunc) gconf_settings_backend_remove_ignore_notifications,
                                gconf);
      gconf_client_commit_change_set (gconf->priv->client, reversed, FALSE, NULL);
    }
  else
    g_settings_backend_changed_tree (backend, tree, origin_tag);

  gconf_change_set_unref (changeset);
  gconf_change_set_unref (reversed);

  return success;
}
Example #5
0
static void
unset_in_db (GConfDefaults   *mechanism,
	     const gchar     *address,
             const gchar    **includes,
             const gchar    **excludes,
	     GError         **error)
{
	GConfEngine *engine;
	GConfClient *dest = NULL;
	GConfChangeSet *changes = NULL;
	int i;

	engine = gconf_engine_get_local (address, error);
	if (*error)
		goto out;

	dest = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	changes = gconf_change_set_new ();

 	/* recursively copy each include, leaving out the excludes */
	for (i = 0; includes[i]; i++) {
		if (gconf_client_dir_exists (dest, includes[i], NULL))
			unset_tree (dest, includes[i], changes, excludes);
		else
			unset_entry (dest, includes[i], changes, excludes);
	}

	gconf_client_commit_change_set (dest, changes, TRUE, error);
	gconf_client_suggest_sync (dest, NULL);

out:
	if (dest)
		g_object_unref (dest);
	if (changes)
		gconf_change_set_unref (changes);
}
int
main (int argc, char **argv)
{
	GConfChangeSet *changeset;
	GladeXML       *dialog;
	GnomeProgram   *program;
 	GOptionContext *context;
	gboolean apply_only = FALSE;
	gboolean get_legacy = FALSE;
 	GOptionEntry cap_options[] = {
 		{ "apply", 0, 0, G_OPTION_ARG_NONE, &apply_only,
		  N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
		{ "init-session-settings", 0, 0, G_OPTION_ARG_NONE, &apply_only,
		  N_("Just apply settings and quit (compatibility only; now handled by daemon)"), NULL },
 		{ "get-legacy", 0, 0, G_OPTION_ARG_NONE, &get_legacy,
		  N_("Retrieve and store legacy settings"), NULL },
 		{ NULL }
	};

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

        /* Since gstreamer and gnome-vfs require threads, we
         * have to initialise threads here as the first call to glib.
         */
        g_thread_init (NULL);

 	context = g_option_context_new (N_("- GNOME Sound Preferences"));
#if GLIB_CHECK_VERSION (2, 12, 0)
        g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
#endif
 	g_option_context_add_main_entries (context, cap_options, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gst_init_get_option_group ());

	program = gnome_program_init ("gnome-sound-properties", VERSION,
				      LIBGNOMEUI_MODULE, argc, argv,
 			    	      GNOME_PARAM_GOPTION_CONTEXT, context,
				      NULL);

	activate_settings_daemon ();

	gconf_client = gconf_client_get_default ();
	gconf_client_add_dir (gconf_client, "/desktop/gnome/sound", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);
	gconf_client_add_dir (gconf_client, "/apps/metacity/general", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);

	if (get_legacy) {
		get_legacy_settings ();
	} else {
		dialog = create_dialog ();

		if (dialog) {
			changeset = gconf_change_set_new ();
			setup_dialog (dialog, changeset);
			setup_devices ();

			dialog_win = WID ("sound_prefs_dialog");
			g_signal_connect (dialog_win, "response", G_CALLBACK (dialog_response_cb), changeset);
			g_signal_connect (dialog_win, "destroy", G_CALLBACK (gtk_main_quit), NULL);
			capplet_set_icon (dialog_win, "gnome-sound-properties");
			gtk_widget_show (dialog_win);

			gtk_main ();
			gconf_change_set_unref (changeset);
			g_object_unref (dialog);
		}
	}

	g_object_unref (gconf_client);
	g_object_unref (program);

	return 0;
}
Example #7
0
static void
do_copy_authorized (GConfDefaults          *mechanism,
                    DBusGMethodInvocation  *context,
		    gpointer                user_data)
{
        CopyData    *data = user_data;
	GConfClient *source = NULL;
	GConfClient *dest = NULL;
	GConfChangeSet *changes = NULL;
	GConfEngine *engine;
        char *address = NULL;
        gint i;
	GError *error;

	error = NULL;
	engine = gconf_engine_get_local (data->dest_address, &error);
	if (error)
		goto cleanup;

	dest = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	/* find the address to from the caller id */
        address = gconf_address_for_caller (data->mechanism, data->context, &error);
	if (error)
		goto cleanup;

	engine = gconf_engine_get_local (address, &error);
	if (error)
		goto cleanup;

	source = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	changes = gconf_change_set_new ();

	if (data->value) {
		g_assert (data->includes[1] == NULL);
                g_assert (data->excludes == NULL);

		gconf_change_set_set (changes, data->includes[0], data->value);
	}
	else {
	 	/* recursively copy each include, leaving out the excludes */
		for (i = 0; data->includes[i]; i++) {
			if (gconf_client_dir_exists (source, data->includes[i], NULL))
				copy_tree (source, data->includes[i], changes, (const char **)data->excludes);
			else
				copy_entry (source, data->includes[i], changes, (const char **)data->excludes);
		}
	}

	gconf_client_commit_change_set (dest, changes, FALSE, &error);
	gconf_client_suggest_sync (dest, NULL);

	if (data->changeset_callback) {
		data->changeset_callback (data->mechanism, changes, data->user_data);
	}

cleanup:
	g_free (address);
	if (changes)
		gconf_change_set_unref (changes);
	if (dest)
		g_object_unref (dest);
	if (source)
		g_object_unref (source);

	if (error) {
		throw_error (data->context,
			     GCONF_DEFAULTS_ERROR_GENERAL,
			     "%s", error->message);
		g_error_free (error);
	}
	else
        	dbus_g_method_return (data->context);
}
Example #8
0
void gglk_do_styles(GtkMenuItem *unused_menuitem,
		    gpointer unused_data)
{
    static GtkWidget *dialog_styles;

    GtkTreeView *tree;
    GtkTreeStore *store;
    GtkTreeSelection *select;
    GtkTreeIter parent_iter, iter;
    int i;

    if(dialog_styles) {
	gtk_window_present(GTK_WINDOW(dialog_styles));
	return;
    }

    dialog_styles = create_dialog_styles();
    g_signal_connect(dialog_styles, "destroy",
		     G_CALLBACK(gtk_widget_destroyed),
		     &dialog_styles);
    g_signal_connect(dialog_styles, "response",
		     G_CALLBACK(gglk_style_response),
		     NULL);

    if(!gglk_style_changeset) {
	gglk_style_changeset = gconf_change_set_new();
    } else {
	gconf_change_set_clear(gglk_style_changeset);
    }

    {
	GtkTextBuffer *buffer;
	GtkTextIter text_start, text_end;

	buffer = gtk_text_view_get_buffer(
	    GTK_TEXT_VIEW(lookup_widget(dialog_styles, "preview")));
	gtk_text_buffer_create_tag(buffer, "default", NULL);
	gtk_text_buffer_get_bounds(buffer, &text_start, &text_end);
	gtk_text_buffer_apply_tag_by_name(buffer, "default",
					  &text_start, &text_end);
    }

    tree = GTK_TREE_VIEW(lookup_widget(dialog_styles, "treeview_styles"));
    store = gtk_tree_store_new(2, G_TYPE_STRING, G_TYPE_INT);
    gtk_tree_view_set_model(tree, GTK_TREE_MODEL(store));

    gtk_tree_view_insert_column_with_attributes(tree, -1, "Style",
						gtk_cell_renderer_text_new(),
						"text", 0,
						NULL);

    select = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
    gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE);
    g_signal_connect(select, "changed",
		     G_CALLBACK(gglk_style_selection_changed),
		     dialog_styles);

    gtk_tree_store_append(store, &parent_iter, NULL);
    gtk_tree_store_set(store, &parent_iter,
		       0, gglk_get_tag(style_AllStyles),
		       1, style_AllStyles,
		       -1);
    gtk_tree_selection_select_iter(select, &parent_iter);

    for(i = 0; i < style_NUMSTYLES; i++) {
	gtk_tree_store_append(store, &iter, &parent_iter);
	gtk_tree_store_set(store, &iter,
			   0, gglk_get_tag(i),
			   1, i,
			   -1);
    }

    gtk_tree_store_append(store, &iter, NULL);
    gtk_tree_store_set(store, &iter,
		       0, gglk_get_tag(style_TextGrid),
		       1, style_TextGrid,
		       -1);

    gtk_tree_store_append(store, &iter, NULL);
    gtk_tree_store_set(store, &iter,
		       0, gglk_get_tag(style_Hyperlinks),
		       1, style_Hyperlinks,
		       -1);

    gtk_tree_view_expand_all(tree);

#if 0
    g_signal_connect(lookup_widget(dialog_styles, "important_toggle"),
		     "clicked", G_CALLBACK(gglk_style_toggle), NULL);
#endif
    
    gtk_widget_show(dialog_styles);

}
Example #9
0
static void
do_set_value (GConfDefaults          *mechanism,
              gboolean                mandatory,
              const char             *path,
              const char             *value,
              DBusGMethodInvocation  *context,
              GConfChangeSet        **changeset_out)
{
	GConfClient *dest = NULL;
	GConfChangeSet *changes = NULL;
	GConfEngine *engine;
	GConfValue *gvalue;
	GError *error;
	GError *error2;
	const char *action;
	const char *annotation_key;
	const char *default_action;
	const char *dest_address;

	if (changeset_out)
		*changeset_out = NULL;

	stop_killtimer ();

	if (mandatory) {
		annotation_key = "org.gnome.gconf.defaults.set-mandatory.prefix";
		default_action = "org.gnome.gconf.defaults.set-mandatory";
		dest_address = "xml:merged:/etc/gconf/gconf.xml.mandatory";
	}
	else {
		annotation_key = "org.gnome.gconf.defaults.set-system.prefix";
		default_action = "org.gnome.gconf.defaults.set-system";
		dest_address = "xml:merged:/etc/gconf/gconf.xml.system";
	}

	action = polkit_action_for_gconf_path (mechanism, annotation_key, path);
	if (action == NULL)
		action = default_action;

	if (!check_polkit_for_action (mechanism, context, action))
		goto out;

	error = NULL;
	engine = gconf_engine_get_local (dest_address, &error);
	if (error)
		goto cleanup;

	dest = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	changes = gconf_change_set_new ();

	gvalue = gconf_value_decode (value);
	if (!gvalue)
		goto cleanup;

	gconf_change_set_set (changes, path, gvalue);
	gconf_value_free (gvalue);

	gconf_client_commit_change_set (dest, changes, FALSE, &error);
	gconf_client_suggest_sync (dest, NULL);

	if (changeset_out) {
		*changeset_out = changes;
		changes = NULL;
	}

cleanup:
	if (changes)
		gconf_change_set_unref (changes);
	if (dest)
		g_object_unref (dest);

	if (error) {
		g_print ("failed to set GConf values:  %s\n", error->message);
		error2 = g_error_new_literal (GCONF_DEFAULTS_ERROR,
					      GCONF_DEFAULTS_ERROR_GENERAL,
					      error->message);
		g_error_free (error);

		dbus_g_method_return_error (context, error2);
		g_error_free (error2);
	}
	else
		dbus_g_method_return (context);

out:
	start_killtimer ();
}
Example #10
0
static void
do_copy (GConfDefaults          *mechanism,
	 gboolean                mandatory,
	 const char            **includes,
	 const char            **excludes,
	 DBusGMethodInvocation  *context,
	 GConfChangeSet        **changeset_out)
{
        char *address = NULL;
	GConfClient *source = NULL;
	GConfClient *dest = NULL;
	GConfChangeSet *changes = NULL;
	GConfEngine *engine;
	GError *error;
	GError *error2;
	const char *action;
	const char *annotation_key;
	const char *default_action;
	const char *dest_address;
	int i;

	if (changeset_out)
		*changeset_out = NULL;

        stop_killtimer ();

	/* check privileges for each include */
	if (mandatory) {
		annotation_key = "org.gnome.gconf.defaults.set-mandatory.prefix"; 
		default_action = "org.gnome.gconf.defaults.set-mandatory";
		dest_address = "xml:merged:" SYSGCONFDIR "/gconf.xml.mandatory";
	}
	else {
		annotation_key = "org.gnome.gconf.defaults.set-system.prefix";
		default_action = "org.gnome.gconf.defaults.set-system";
		dest_address = "xml:merged:" SYSGCONFDIR "/gconf.xml.system";
	}

	for (i = 0; includes[i]; i++) {
		action = polkit_action_for_gconf_path (mechanism, annotation_key, includes[i]);
		if (action == NULL)
			action = default_action;

		if (!check_polkit_for_action (mechanism, context, action))
			goto out;
	}

	error = NULL;
	engine = gconf_engine_get_local (dest_address, &error);
	if (error)
		goto cleanup;

	dest = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	/* find the address to from the caller id */
	address = gconf_address_for_caller (mechanism, context, &error);
	if (error)
		goto cleanup;

	engine = gconf_engine_get_local (address, &error);
	if (error)
		goto cleanup;

	source = gconf_client_get_for_engine (engine);
	gconf_engine_unref (engine);

	changes = gconf_change_set_new ();

 	/* recursively copy each include, leaving out the excludes */
	for (i = 0; includes[i]; i++) {
		if (gconf_client_dir_exists (source, includes[i], NULL))
			copy_tree (source, includes[i], changes, excludes);
		else
			copy_entry (source, includes[i], changes, excludes);
	}

	gconf_client_commit_change_set (dest, changes, FALSE, &error);
	gconf_client_suggest_sync (dest, NULL);

	if (changeset_out) {
		*changeset_out = changes;
		changes = NULL;
	}

cleanup:
	g_free (address);
	if (changes)
		gconf_change_set_unref (changes);
	if (dest)
		g_object_unref (dest);
	if (source)
		g_object_unref (source);

	if (error) {
		g_print ("failed to set GConf values:  %s\n", error->message);
		error2 = g_error_new_literal (GCONF_DEFAULTS_ERROR,
					      GCONF_DEFAULTS_ERROR_GENERAL,
					      error->message);
		g_error_free (error);

		dbus_g_method_return_error (context, error2);
		g_error_free (error2);
	}
	else
		dbus_g_method_return (context);

out:
	start_killtimer ();
}
Example #11
0
static GtkWidget*
create_prefs_dialog(GtkWidget* parent, GConfClient* client)
{
    GConfChangeSet* cs;
    GtkWidget* dialog;
    GtkWidget* bbox;
    GtkWidget* apply;
    GtkWidget* revert;
    GtkWidget* ok;
    GtkWidget* cancel;
    GtkWidget* vbox_outer;
    GtkWidget* vbox_inner;
    GtkWidget* entry;

    dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);

    apply = gtk_button_new_with_label("Apply");
    revert = gtk_button_new_with_label("Revert");

    ok = gtk_button_new_with_label("OK");
    cancel = gtk_button_new_with_label("Cancel");

    g_object_set_data(dialog, "apply", apply);
    g_object_set_data(dialog, "revert", revert);
    g_object_set_data(dialog, "ok", ok);
    g_object_set_data(dialog, "cancel", cancel);

    bbox = gtk_hbutton_box_new();

    vbox_outer = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);

    vbox_inner = gtk_box_new(GTK_ORIENTATION_VERTICAL, 10);

    gtk_container_add(GTK_CONTAINER(dialog), vbox_outer);

    gtk_box_pack_start(GTK_BOX(vbox_outer), vbox_inner, TRUE, TRUE, 0);
    gtk_box_pack_end(GTK_BOX(vbox_outer), bbox, FALSE, FALSE, 0);

    gtk_container_add(GTK_CONTAINER(bbox), apply);
    gtk_container_add(GTK_CONTAINER(bbox), revert);
    gtk_container_add(GTK_CONTAINER(bbox), ok);
    gtk_container_add(GTK_CONTAINER(bbox), cancel);

    cs = gconf_change_set_new();

    g_object_set_data(dialog, "changeset", cs);
    g_object_set_data(dialog, "client", client);

    /* Grab a reference */
    g_object_ref(G_OBJECT(client));

    g_signal_connect(dialog, "destroy",
                     G_CALLBACK(prefs_dialog_destroy_callback),
                     NULL);

    prefs_dialog_update_sensitivity(dialog);

    g_signal_connect(apply, "clicked",
                     G_CALLBACK(apply_button_callback),
                     dialog);

    g_signal_connect(revert, "clicked",
                     G_CALLBACK(revert_button_callback),
                     dialog);

    g_signal_connect(ok, "clicked",
                     G_CALLBACK(ok_button_callback),
                     dialog);

    g_signal_connect(cancel, "clicked",
                     G_CALLBACK(cancel_button_callback),
                     dialog);

    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(parent));

    entry = create_config_entry(dialog, client, "/apps/basic-gconf-app/foo");
    gtk_box_pack_start(GTK_BOX(vbox_inner), entry,
                       FALSE, FALSE, 0);

    entry = create_config_entry(dialog, client, "/apps/basic-gconf-app/bar");
    gtk_box_pack_start(GTK_BOX(vbox_inner), entry,
                       FALSE, FALSE, 0);

    entry = create_config_entry(dialog, client, "/apps/basic-gconf-app/baz");
    gtk_box_pack_start(GTK_BOX(vbox_inner), entry,
                       FALSE, FALSE, 0);

    entry = create_config_entry(dialog, client, "/apps/basic-gconf-app/blah");
    gtk_box_pack_start(GTK_BOX(vbox_inner), entry,
                       FALSE, FALSE, 0);

    return dialog;
}
gboolean
gnomegadu_protocol_loop (GIOChannel * source, GIOCondition condition, gpointer data)
{
	static gint prev_check = GG_CHECK_READ;
	gboolean ret = TRUE;
	struct gg_event *e = NULL;

	/* w przypadku bledu/utraty polaczenia postap tak jak w przypadku disconnect */
	if (!gnomegadu_gadugadu_session || !(e = gg_watch_fd (gnomegadu_gadugadu_session)) || (condition & G_IO_ERR) ||
	    ((condition & G_IO_HUP)
	     && ((gnomegadu_gadugadu_session->state != GG_STATE_CONNECTING_GG) && (gnomegadu_gadugadu_session->check != GG_CHECK_WRITE))))
	{
		g_printerr ("gnomegadu_protocol_loop(): some kind of problem while processing\n");
		gnomegadu_gadugadu_disconnect ();
		prev_check = GG_CHECK_READ;
		return FALSE;
	}

	switch (e->type)
	{
	case GG_EVENT_NONE:
		g_print ("GG_EVENT_NONE\n");
		break;

	case GG_EVENT_PONG:
		g_print ("GG_EVENT_PONG\n");
		gg_ping (gnomegadu_gadugadu_session);
		break;

	case GG_EVENT_CONN_FAILED:
		g_print ("GG_EVENT_CONN_FAILED\n");
		gnomegadu_gadugadu_disconnect ();
		ret = FALSE;
		break;

	case GG_EVENT_DISCONNECT:
		g_print ("GG_EVENT_DISCONNECT\n");
		gnomegadu_gadugadu_disconnect ();
		ret = FALSE;
		break;

	case GG_EVENT_CONN_SUCCESS:
	{
		g_print ("GG_EVENT_CONN_SUCCESS\n");
		//wysyłam swoją listę
		gint i, j = 0;
		uint32_t *uins;
		GSList *contacts_list = gnomegadu_conf_get_contacts ();
		GSList *contacts_list_start = contacts_list;

		gnomegadu_protocol_is_connected = TRUE;

		if (!contacts_list)
			break;

		i = g_slist_length (contacts_list);
		uins = g_malloc0 (i * sizeof (uint32_t));
		while (contacts_list)
		{
			gchar *uin_str;
			gchar *path = (gchar *) contacts_list->data;
			gchar *uin_path = g_strconcat (path, "/uin", NULL);
			uin_str = gconf_client_get_string (gconf, uin_path, NULL);
			uins[j++] = g_strtod (uin_str, NULL);

			g_free (uin_path);
			contacts_list = g_slist_next(contacts_list);
		}

		if (j > 0)
			gg_notify (gnomegadu_gadugadu_session, uins, i);

		/* pingpong */
		g_timeout_add(100000, gnomegadu_protocol_ping, NULL);


		g_slist_foreach (contacts_list_start, gnomegadu_conf_free_list_of_string, NULL);
		g_slist_free (contacts_list_start);
		g_free (uins);
	}
		break;

//      case GG_EVENT_NOTIFY_DESCR:
	case GG_EVENT_NOTIFY:
	{
		gint i;
		g_print ("GG_EVENT_NOTIFY\n");

		for (i = 0; e->event.notify[i].uin; i++)
		{
			gchar *uin_str = g_strdup_printf ("%d", e->event.notify[i].uin);
			gint new_status = gnomegadu_gadugadu_from_protocol_status (e->event.notify[i].status);
			gnomegadu_userlist_set_model_status (uin_str, new_status, NULL);	//tutaj dodac obsluge opisów
			g_free (uin_str);
		}
	}
		break;
	case GG_EVENT_NOTIFY60:
	{
		gint i;
		g_print ("GG_EVENT_NOTIFY60\n");

		for (i = 0; e->event.notify60[i].uin; i++)
		{
			gchar *descr_utf = NULL;
			gchar *uin_str = g_strdup_printf ("%d", e->event.notify60[i].uin);
			gint new_status = gnomegadu_gadugadu_from_protocol_status (e->event.notify60[i].status);

			if (e->event.notify60[i].descr)
				descr_utf =
					g_convert (e->event.notify60[i].descr, strlen (e->event.notify60[i].descr), "UTF-8", "WINDOWS-1250", NULL, NULL, NULL);

			gnomegadu_userlist_set_model_status (uin_str, new_status, descr_utf);
			g_free (uin_str);
		}
	}
	break;
	case GG_EVENT_STATUS:
	case GG_EVENT_STATUS60:
	{
		GdkPixbuf *pix = NULL;
		gchar *descr_utf = NULL;
		gchar *uuid = NULL;
		gchar *display = NULL;
		gchar *notify_txt = NULL;
		gint new_status;
		gchar *uin_str  = NULL; 
		
		if (e->type == GG_EVENT_STATUS)
		{
		    new_status = gnomegadu_gadugadu_from_protocol_status (e->event.status.status);
		    uin_str    = g_strdup_printf ("%d", e->event.status.uin);

		    if (e->event.status.descr)
			descr_utf = g_convert (e->event.status.descr, strlen (e->event.status.descr), "UTF-8", "WINDOWS-1250", NULL, NULL, NULL);

		} else {
		    new_status = gnomegadu_gadugadu_from_protocol_status (e->event.status60.status);
		    uin_str    = g_strdup_printf ("%d", e->event.status60.uin);

		    if (e->event.status60.descr)
			descr_utf = g_convert (e->event.status60.descr, strlen (e->event.status60.descr), "UTF-8", "WINDOWS-1250", NULL, NULL, NULL);

		}
		
		gnomegadu_userlist_set_model_status (uin_str, new_status, descr_utf);

		uuid = gnomegadu_conf_contact_get_uuid_for_uin(uin_str);
		display = gnomegadu_conf_contact_get_display_for_uuid(uuid);

		pix = gnomegadu_stock_get_pixbuf (gnomegadu_ui_status_get_icon_name (new_status));
		notify_txt = g_strdup_printf("Status: %s\n<span size=\"smaller\" style=\"italic\">%s</span>",gnomegadu_protocol_status_txt(new_status),descr_utf ? descr_utf : "");
		gnomegadu_ui_notify_show (display, notify_txt, pix);
		g_object_unref (pix);
		
		gnomegadu_tray_blinking(2000);

		g_free (notify_txt);
		g_free (display);
		g_free (uuid);
		g_free (uin_str);
	}    
	break;
	case GG_EVENT_USERLIST:
	{
		g_print ("GG_EVENT_USERLIST\n");
		if (e->event.userlist.type == GG_USERLIST_GET_REPLY)
		{
			gint i;
			gfloat step;
			gchar **split_buf = NULL;
			GtkWidget *progress = glade_xml_get_widget (gladexml_import_userlist_progress, "ImportUserlistServerProgress");
			GtkWidget *progress_window = glade_xml_get_widget (gladexml_import_userlist_progress, "ImportUserlistServerProgressWindow");

			if (!progress_window || !progress)
				break;

			gchar *buf = e->event.userlist.reply;
			if (!buf)
			{
				gtk_widget_destroy(GTK_WIDGET(progress_window));
				
				GtkDialog *msgdialog = gtk_message_dialog_new_with_markup (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_CLOSE,
											   "<span weight=\"bold\"size=\"larger\">Lista jest pusta</span>\n\nLista kontaktów na serwerze jest pusta.");
				gtk_dialog_run (GTK_DIALOG (msgdialog));
				gtk_widget_destroy (GTK_WIDGET (msgdialog));
				break;
			}

			GConfChangeSet *changeset = gconf_change_set_new();

			split_buf = g_strsplit (buf, "\r\n", 2048);
			step = 1 / (gfloat)g_strv_length (split_buf);
			for (i = 0; i < g_strv_length (split_buf); i++)
			{
				gdouble percentage = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR (progress));
				
				if (percentage < 1)
					gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), percentage + step);
				
				while (g_main_context_pending(NULL))
					g_main_context_iteration(NULL,TRUE);

				gnomegadu_ui_import_userlist_process_line (split_buf[i], changeset);
				
				if (!gconf_client_commit_change_set(gconf, changeset, TRUE, NULL))
					g_printerr("Some error while import");
			}

			gconf_change_set_unref(changeset);

			gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), 1);
			
			while (g_main_context_pending(NULL))
				g_main_context_iteration(NULL,TRUE);
			
			gtk_widget_destroy(GTK_WIDGET(progress_window));
		}

	}
	break;
	case GG_EVENT_MSG:
	{
		gchar *uin_sender = NULL;
		
		if (e->event.msg.msgclass == GG_CLASS_CHAT)
		{
			gint i      = 0;
			uin_sender  = g_strdup_printf("%d", e->event.msg.sender);
			gchar *txt  = g_strdup((gchar *)e->event.msg.message);
			gchar *txt_utf = NULL;
			GList *list = NULL;

			g_print("message from sender: (%s):%s\n",uin_sender,txt);
			
			/* first add sender */
			list 	  = g_list_append(list,g_strdup(uin_sender));

			if (e->event.msg.recipients_count > 0)
			{
				gchar *uin_str_2 = NULL;
				/* then add recipients */
				for (i = 0; i < e->event.msg.recipients_count; i++)
				{
				    uin_str_2 = g_strdup_printf("%d",e->event.msg.recipients[i]);
				    list = g_list_append(list,g_strdup(uin_str_2));
				    g_free(uin_str_2);

				    g_print("conference(%d): %s\n",e->event.msg.recipients_count,uin_str_2);
				}
			}

			g_assert(list);
			
			//chat window
			GladeXML *chat_window_xml = gnomegadu_ui_chat_find(list,TRUE);
			g_assert(chat_window_xml);

			txt_utf = g_convert (txt, strlen (txt), "UTF-8", "WINDOWS-1250", NULL, NULL, NULL);
			gnomegadu_ui_chat_append_text(chat_window_xml,txt_utf,GNOMEGADU_CHAT_RCV, uin_sender);

			g_free(txt);
			g_free(uin_sender);			
		}
	}
	break;

	}

	gg_free_event (e);

	if (gnomegadu_gadugadu_session && prev_check != gnomegadu_gadugadu_session->check)
	{
		prev_check = gnomegadu_gadugadu_session->check;

		if (gnomegadu_gadugadu_session->check == GG_CHECK_READ)
		{
			g_source_remove (gnomegadu_watch_protocol);
			gnomegadu_watch_protocol = g_io_add_watch (gnomegadu_source_chan, G_IO_IN | G_IO_ERR | G_IO_HUP, gnomegadu_protocol_loop, NULL);
			ret = FALSE;
		}

		if (gnomegadu_gadugadu_session->check == GG_CHECK_WRITE)
		{
			g_source_remove (gnomegadu_watch_protocol);
			gnomegadu_watch_protocol = g_io_add_watch (gnomegadu_source_chan, G_IO_OUT | G_IO_ERR | G_IO_HUP, gnomegadu_protocol_loop, NULL);
			ret = FALSE;
		}
	}

	return ret;
}