# HG changeset patch # User mikanbako # Date 1217945949 -32400 # Node ID 0b0b4cab7c0e4386919e3e1f9e0363a7a8e82b49 # Parent 1265988dc2bf12c3540a81f7e99ef8ba491b72aa move some UI definition of preferences per conversation from pidgin-twitter.c to prefs.ui diff -r 1265988dc2bf -r 0b0b4cab7c0e pidgin-twitter.c --- a/pidgin-twitter.c Tue Aug 05 01:26:08 2008 +0900 +++ b/pidgin-twitter.c Tue Aug 05 23:19:09 2008 +0900 @@ -2956,8 +2956,7 @@ { PidginConversation *gtkconv = (PidginConversation *) gtkconv_ptr; PurpleConversation *conv = gtkconv->active_conv; - GtkWidget *dialog; - GtkWidget *notebook = gtk_notebook_new(); + GtkWidget *dialog, *vbox; gchar *title; title = g_strdup_printf("\"%s\" Account Preference", conv->title); @@ -2986,42 +2985,50 @@ G_CALLBACK(closed_account_preference_window_cb), pref_button); - /* Screen Name */ - build_screen_name_preference_form(conv, notebook); /* API Base Post */ if(is_twitter_conv(conv)) - build_twitter_api_preference_form(conv, notebook); + vbox = build_twitter_preference_form(conv); + else + vbox = build_default_preference_form(conv); gtk_button_set_label(GTK_BUTTON(pref_button), ACCOUNT_PREF_BUTTON_NORMAL); gtk_widget_set_sensitive(pref_button, FALSE); - gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), notebook); + gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog)->vbox), vbox); gtk_widget_show_all(GTK_WIDGET(dialog)); } -static void -build_screen_name_preference_form(PurpleConversation *conv, - GtkWidget *notebook) +static GtkWidget* +build_default_preference_form(PurpleConversation *conv) { PurpleAccount *account = purple_conversation_get_account(conv); const char *conv_name = purple_conversation_get_name(conv); - GtkWidget *tab_label, *child, *line, *container, *widget; - - child = gtk_vbox_new(FALSE, 0); - - /********************/ - /* screen name form */ - /********************/ - line = gtk_hbox_new(TRUE, 0); - - /* label */ - widget = gtk_label_new("screen name"); - container = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); - gtk_container_add(GTK_CONTAINER(container), widget); - gtk_alignment_set_padding(GTK_ALIGNMENT(container), 0, 0, 20, 0); - gtk_box_pack_start_defaults(GTK_BOX(line), container); - - /* entry */ - widget = gtk_entry_new(); + GtkWidget *widget; + gchar *filename; + GError *err = NULL; + GtkBuilder *builder = gtk_builder_new(); + +#ifdef _WIN32 + filename = g_build_filename(purple_user_dir(), + "pidgin-twitter", "prefs.ui", NULL); +#else + filename = g_build_filename(DATADIR, + "pidgin-twitter", "prefs.ui", NULL); +#endif + + gtk_builder_add_from_file(builder, filename, &err); + if(err) { + twitter_debug("%s\n", err->message); + g_free(filename); + return NULL; + } + gtk_builder_connect_signals(builder, NULL); + + /**********************/ + /* connect to signals */ + /**********************/ + + /* screen name */ + widget = GTK_WIDGET(gtk_builder_get_object(builder, "screen_name")); gtk_entry_set_text(GTK_ENTRY(widget), service_account_get_string(account, conv_name, @@ -3035,58 +3042,61 @@ "changed", G_CALLBACK(account_preference_text_changed_cb), conv); - container = gtk_alignment_new(1.0, 0.5, 1.0, 0.0); - gtk_container_add(GTK_CONTAINER(container), widget); - gtk_alignment_set_padding(GTK_ALIGNMENT(container), 0, 0, 0, 20); - gtk_box_pack_start_defaults(GTK_BOX(line), container); - - gtk_box_pack_start_defaults(GTK_BOX(child), line); - - /**************************************************/ - /* the explanation why a screen name is necessary */ - /**************************************************/ - line = gtk_hbox_new(FALSE, 0); - widget = gtk_label_new("If you do not input your screen name,"); - container = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); - gtk_container_add(GTK_CONTAINER(container), widget); - gtk_alignment_set_padding(GTK_ALIGNMENT(container), 20, 0, 20, 0); - gtk_box_pack_start(GTK_BOX(line), container, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(child), line, FALSE, FALSE, 0); - - line = gtk_hbox_new(FALSE, 0); - widget = gtk_label_new("you cannot see your icon."); - container = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); - gtk_container_add(GTK_CONTAINER(container), widget); - gtk_alignment_set_padding(GTK_ALIGNMENT(container), 0, 0, 20, 0); - gtk_box_pack_start(GTK_BOX(line), line, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(child), container, FALSE, FALSE, 0); - - /***************/ - /* create page */ - /***************/ - tab_label = gtk_label_new("Screen Name"); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), child, tab_label); + + return GTK_WIDGET(gtk_builder_get_object( + builder, "account_preference_default")); } -static void -build_twitter_api_preference_form(PurpleConversation *conv, - GtkWidget *notebook) +static GtkWidget* +build_twitter_preference_form(PurpleConversation *conv) { PurpleAccount *account = purple_conversation_get_account(conv); const char *conv_name = purple_conversation_get_name(conv); - - GtkWidget *tab_label, *child, *line, *container, *widget; + GtkWidget *widget; GtkObject *adjust; int value; - - child = gtk_vbox_new(FALSE, 0); - - /*****************************/ + gchar *filename; + GError *err = NULL; + GtkBuilder *builder = gtk_builder_new(); + +#ifdef _WIN32 + filename = g_build_filename(purple_user_dir(), + "pidgin-twitter", "prefs.ui", NULL); +#else + filename = g_build_filename(DATADIR, + "pidgin-twitter", "prefs.ui", NULL); +#endif + + gtk_builder_add_from_file(builder, filename, &err); + if(err) { + twitter_debug("%s\n", err->message); + g_free(filename); + return NULL; + } + gtk_builder_connect_signals(builder, NULL); + + /**********************/ + /* connect to signals */ + /**********************/ + + /* screen name */ + widget = GTK_WIDGET(gtk_builder_get_object(builder, "twitter_screen_name")); + gtk_entry_set_text(GTK_ENTRY(widget), + service_account_get_string(account, + conv_name, + OPT_SCREEN_NAME, + EMPTY)); + gtk_entry_set_activates_default(GTK_ENTRY(widget), TRUE); + g_object_set_data(G_OBJECT(widget), + PLUGIN_ID "-account_pref-key", + OPT_SCREEN_NAME); + g_signal_connect(G_OBJECT(widget), + "changed", + G_CALLBACK(account_preference_text_changed_cb), + conv); + /* Checkbox about to use API */ - /*****************************/ - - line = gtk_hbox_new(TRUE, 0); - widget = gtk_check_button_new_with_label("Get/post statuses via API"); + widget = GTK_WIDGET(gtk_builder_get_object(builder, "twitter_api")); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), service_account_get_bool(account, conv_name, @@ -3099,27 +3109,10 @@ "toggled", G_CALLBACK(account_preference_bool_toggled_cb), conv); - container = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); - gtk_container_add(GTK_CONTAINER(container), widget); - gtk_alignment_set_padding(GTK_ALIGNMENT(container), 0, 0, 20, 0); - gtk_box_pack_start_defaults(GTK_BOX(line), container); - - gtk_box_pack_start_defaults(GTK_BOX(child), line); - - /*****************/ - /* Password Form */ - /*****************/ - - /* label */ - line = gtk_hbox_new(TRUE, 0); - widget = gtk_label_new("Password"); - container = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); - gtk_container_add(GTK_CONTAINER(container), widget); - gtk_alignment_set_padding(GTK_ALIGNMENT(container), 0, 0, 20, 0); - gtk_box_pack_start_defaults(GTK_BOX(line), container); - - /* entry */ - widget = gtk_entry_new(); + + /* Password */ + widget = GTK_WIDGET(gtk_builder_get_object(builder, + "twitter_api_password")); gtk_entry_set_visibility(GTK_ENTRY(widget), FALSE); gtk_entry_set_activates_default(GTK_ENTRY(widget), TRUE); if (gtk_entry_get_invisible_char(GTK_ENTRY(widget)) == '*') @@ -3136,26 +3129,8 @@ "changed", G_CALLBACK(account_preference_text_changed_cb), conv); - container = gtk_alignment_new(1.0, 0.5, 1.0, 0.0); - gtk_container_add(GTK_CONTAINER(container), widget); - gtk_alignment_set_padding(GTK_ALIGNMENT(container), 0, 0, 0, 20); - gtk_box_pack_start_defaults(GTK_BOX(line), container); - - gtk_box_pack_start_defaults(GTK_BOX(child), line); - - /**************************/ - /* Retrieve interval Form */ - /**************************/ - - /* label */ - line = gtk_hbox_new(FALSE, 0); - widget = gtk_label_new("Retrieve interval"); - container = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); - gtk_container_add(GTK_CONTAINER(container), widget); - gtk_alignment_set_padding(GTK_ALIGNMENT(container), 0, 0, 20, 0); - gtk_box_pack_start_defaults(GTK_BOX(line), container); - - /* spin button */ + + /* Retrieve interval */ value = service_account_get_int(account, conv_name, OPT_API_BASE_GET_INTERVAL, 0); @@ -3167,7 +3142,10 @@ value); } adjust = gtk_adjustment_new(value, 40, 3600, 10, 100, 100); - widget = gtk_spin_button_new(GTK_ADJUSTMENT(adjust), 1.0, 0); + widget = GTK_WIDGET(gtk_builder_get_object(builder, + "twitter_api_interval")); + gtk_spin_button_set_adjustment(GTK_SPIN_BUTTON(widget), + GTK_ADJUSTMENT(adjust)); gtk_spin_button_set_numeric(GTK_SPIN_BUTTON(widget), TRUE); gtk_spin_button_set_snap_to_ticks(GTK_SPIN_BUTTON(widget), TRUE); g_object_set_data(G_OBJECT(widget), @@ -3177,26 +3155,9 @@ "value-changed", G_CALLBACK(account_preference_spin_changed_cb), conv); - container = gtk_alignment_new(1.0, 0.5, 0.0, 0.0); - gtk_container_add(GTK_CONTAINER(container), widget); - gtk_alignment_set_padding(GTK_ALIGNMENT(container), 0, 0, 0, 0); - gtk_box_pack_start(GTK_BOX(line), container, FALSE, FALSE, 0); - - /* label */ - widget = gtk_label_new("sec"); - container = gtk_alignment_new(1.0, 0.5, 0.0, 0.0); - gtk_container_add(GTK_CONTAINER(container), widget); - gtk_alignment_set_padding(GTK_ALIGNMENT(container), 0, 0, 0, 20); - gtk_box_pack_start(GTK_BOX(line), container, FALSE, FALSE, 0); - - gtk_box_pack_start_defaults(GTK_BOX(child), line); - - /***************/ - /* create page */ - /***************/ - - tab_label = gtk_label_new("API Based Access"); - gtk_notebook_append_page(GTK_NOTEBOOK(notebook), child, tab_label); + + return GTK_WIDGET(gtk_builder_get_object(builder, + "account_preference_twitter")); } static void @@ -3300,8 +3261,6 @@ if(purple_prefs_exists(key)) return; - twitter_debug("eeeee : %s\n", key); - names = g_strsplit(key, "/", 0); names_length = g_strv_length(names); diff -r 1265988dc2bf -r 0b0b4cab7c0e pidgin-twitter.h --- a/pidgin-twitter.h Tue Aug 05 01:26:08 2008 +0900 +++ b/pidgin-twitter.h Tue Aug 05 23:19:09 2008 +0900 @@ -220,8 +220,8 @@ static gint get_service_type(PurpleConversation *conv); static GdkPixbuf *make_scaled_pixbuf(const gchar *url_text, gsize len); static void open_account_preference_window(GtkWidget *called_widged, gpointer gtkconv_ptr); -static void build_screen_name_preference_form(PurpleConversation *conv, GtkWidget *notebook); -static void build_twitter_api_preference_form(PurpleConversation *conv, GtkWidget *notebook); +static GtkWidget* build_default_preference_form(PurpleConversation *conv); +static GtkWidget* build_twitter_preference_form(PurpleConversation *conv); static void destroyed_pref_button_cb(GtkWidget *pref_button, gpointer dialog); static void closed_account_preference_window_cb(GtkDialog *dialog, gint response_id, gpointer pref_button); static void account_preference_text_changed_cb(GtkEditable *editable, gpointer conv_ptr); @@ -229,6 +229,7 @@ static void account_preference_bool_toggled_cb(GtkToggleButton *togglebutton, gpointer conv_ptr); static void account_preference_interval_changed(PurpleAccount *account, const char *conv_name); static void account_preference_spin_changed_cb(GtkSpinButton *spinbutton, gpointer conv_ptr); +static void add_pref(const char *key); static gchar* create_key_with_service_account(PurpleAccount *account, const char *conv_name, const char *key, gboolean create_node); static void service_account_set_string(PurpleAccount *account, const char *conv_name, const char *key, const char *value); static const char* service_account_get_string(PurpleAccount *account, const char *conv_name, const char *key, const char *default_value); diff -r 1265988dc2bf -r 0b0b4cab7c0e prefs.ui --- a/prefs.ui Tue Aug 05 01:26:08 2008 +0900 +++ b/prefs.ui Tue Aug 05 23:19:09 2008 +0900 @@ -881,4 +881,327 @@ + + + True + + + True + + + True + 20 + 20 + + + True + 0 + screen name + 10 + + + + + + + True + 1 + 4 + + + True + True + 20 + + + + + False + False + 1 + + + + + 1 + + + + + True + True + True + + + True + 20 + 20 + + + True + 0 + If you do not set your screen name, + 10 + + + + + + + 2 + + + + + True + True + True + + + True + 20 + + + True + 0 + you cannot see your icon. + 10 + + + + + + + 3 + + + + + + True + + + True + + + True + 0 + 20 + 20 + + + True + 0 + screen name + 10 + + + + + + + True + 1 + 4 + + + True + True + 20 + + + + + False + False + 1 + + + + + 1 + + + + + True + + + True + 0 + 20 + 20 + + + True + 0 + If you do not set your screen name, + 10 + + + + + + + 2 + + + + + True + + + True + 0 + 20 + + + True + 0 + you cannot see your icon. + 10 + + + + + + + 3 + + + + + True + 0 + 20 + 20 + + + True + True + Get/post statuses via API + 0 + True + + + + + 4 + + + + + True + + + True + 40 + + + True + 0 + Password + 10 + + + + + 1 + + + + + True + 1 + 4 + + + True + True + 20 + + + + + False + GTK_PACK_END + 1 + + + + + 5 + + + + + True + + + True + 2 + 10 + 40 + + + True + Retrieve interval + + + + + False + False + + + + + True + 2 + 10 + 4 + + + True + True + 1 + True + True + + + + + False + False + GTK_PACK_END + 2 + + + + + True + 10 + 8 + + + True + sec + + + + + False + False + GTK_PACK_END + 1 + + + + + False + 6 + + + +