pidgin/pidgin

Port gtkaccount to GTK4
gtk4
21 months ago, Elliott Sales de Andrade
2ee402c27fcf
Parents 661f4b3b8298
Children c8a09956bac2
Port gtkaccount to GTK4

We should still port to `GtkBuilder`, but this seems small enough to fix now.

Testing Done:
Compile only.

Reviewed at https://reviews.imfreedom.org/r/1611/
--- a/pidgin/gtkaccount.c Fri Aug 19 01:00:48 2022 -0500
+++ b/pidgin/gtkaccount.c Fri Aug 19 02:27:18 2022 -0500
@@ -173,7 +173,9 @@
{
/* Show a placeholder icon */
gtk_image_set_from_icon_name(GTK_IMAGE(dialog->icon_entry),
- "select-avatar", GTK_ICON_SIZE_LARGE_TOOLBAR);
+ "select-avatar");
+ gtk_image_set_icon_size(GTK_IMAGE(dialog->icon_entry),
+ GTK_ICON_SIZE_LARGE);
} else {
gtk_image_set_from_pixbuf(GTK_IMAGE(dialog->icon_entry), pixbuf);
g_object_unref(G_OBJECT(pixbuf));
@@ -278,13 +280,19 @@
AccountPrefsDialog *dialog = data;
if (response == GTK_RESPONSE_ACCEPT) {
+ GFile *file = NULL;
gchar *filename = NULL;
gpointer data = NULL;
size_t len = 0;
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget));
+ file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(widget));
+ filename = g_file_get_path(file);
+
data = pidgin_convert_buddy_icon(dialog->protocol, filename, &len);
set_dialog_icon(dialog, data, len, filename);
+
+ g_free(filename);
+ g_object_unref(file);
}
g_clear_object(&dialog->icon_filesel);
@@ -374,11 +382,12 @@
{
g_object_ref(G_OBJECT(dialog->protocol_menu));
hbox = g_object_get_data(G_OBJECT(dialog->protocol_menu), "container");
- gtk_container_remove(GTK_CONTAINER(hbox), dialog->protocol_menu);
+ gtk_box_remove(GTK_BOX(hbox), dialog->protocol_menu);
}
- if (dialog->login_frame != NULL)
- gtk_widget_destroy(dialog->login_frame);
+ if (dialog->login_frame != NULL) {
+ gtk_widget_unparent(dialog->login_frame);
+ }
/* Build the login options frame. */
frame = pidgin_make_frame(parent, _("Login Options"));
@@ -386,13 +395,11 @@
/* cringe */
dialog->login_frame = gtk_widget_get_parent(gtk_widget_get_parent(frame));
- gtk_box_reorder_child(GTK_BOX(parent), dialog->login_frame, 0);
- gtk_widget_show(dialog->login_frame);
+ gtk_box_reorder_child_after(GTK_BOX(parent), dialog->login_frame, NULL);
/* Main vbox */
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
- gtk_widget_show(vbox);
+ gtk_box_append(GTK_BOX(frame), vbox);
/* Protocol */
if(dialog->protocol_menu == NULL) {
@@ -401,7 +408,6 @@
dialog->protocol_id);
g_signal_connect(G_OBJECT(dialog->protocol_menu), "changed",
G_CALLBACK(set_account_protocol_cb), dialog);
- gtk_widget_show(dialog->protocol_menu);
g_object_ref(G_OBJECT(dialog->protocol_menu));
}
@@ -539,20 +545,20 @@
GtkWidget *button;
GtkWidget *label;
- if (dialog->user_frame != NULL)
- gtk_widget_destroy(dialog->user_frame);
+ if (dialog->user_frame != NULL) {
+ gtk_widget_unparent(dialog->user_frame);
+ }
/* Build the user options frame. */
frame = pidgin_make_frame(parent, _("User Options"));
dialog->user_frame = gtk_widget_get_parent(gtk_widget_get_parent(frame));
- gtk_box_reorder_child(GTK_BOX(parent), dialog->user_frame, 1);
- gtk_widget_show(dialog->user_frame);
+ gtk_box_reorder_child_after(GTK_BOX(parent), dialog->user_frame,
+ gtk_widget_get_first_child(parent));
/* Main vbox */
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_add(GTK_CONTAINER(frame), vbox);
- gtk_widget_show(vbox);
+ gtk_box_append(GTK_BOX(frame), vbox);
/* Alias */
dialog->alias_entry = gtk_entry_new();
@@ -561,27 +567,22 @@
/* Buddy icon */
dialog->icon_check = gtk_check_button_new_with_mnemonic(_("Use this buddy _icon for this account:"));
g_signal_connect(G_OBJECT(dialog->icon_check), "toggled", G_CALLBACK(icon_check_cb), dialog);
- gtk_widget_show(dialog->icon_check);
- gtk_box_pack_start(GTK_BOX(vbox), dialog->icon_check, FALSE, FALSE, 0);
+ gtk_box_append(GTK_BOX(vbox), dialog->icon_check);
dialog->icon_hbox = hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
gtk_widget_set_sensitive(hbox, gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(dialog->icon_check)));
- gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show(hbox);
+ gtk_box_append(GTK_BOX(vbox), hbox);
label = gtk_label_new(" ");
- gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
- gtk_widget_show(label);
+ gtk_box_append(GTK_BOX(hbox), label);
button = gtk_button_new();
- gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
- gtk_widget_show(button);
+ gtk_box_append(GTK_BOX(hbox), button);
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(icon_select_cb), dialog);
dialog->icon_entry = gtk_image_new();
- gtk_container_add(GTK_CONTAINER(button), dialog->icon_entry);
- gtk_widget_show(dialog->icon_entry);
+ gtk_button_set_child(GTK_BUTTON(button), dialog->icon_entry);
/* TODO: Uh, isn't this next line pretty useless? */
pidgin_set_accessible_label(dialog->icon_entry, GTK_LABEL(label));
if (dialog->icon_img) {
@@ -590,18 +591,19 @@
}
vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
- gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 0);
- gtk_widget_show(vbox2);
+ gtk_widget_set_hexpand(vbox2, TRUE);
+ gtk_widget_set_halign(vbox2, GTK_ALIGN_FILL);
+ gtk_box_append(GTK_BOX(hbox), vbox2);
hbox2 = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start(GTK_BOX(vbox2), hbox2, FALSE, FALSE, 12);
- gtk_widget_show(hbox2);
+ gtk_widget_set_margin_top(hbox2, 12);
+ gtk_widget_set_margin_bottom(hbox2, 12);
+ gtk_box_append(GTK_BOX(vbox2), hbox2);
button = gtk_button_new_with_mnemonic(_("_Remove"));
g_signal_connect(G_OBJECT(button), "clicked",
G_CALLBACK(icon_reset_cb), dialog);
- gtk_box_pack_start(GTK_BOX(hbox2), button, FALSE, FALSE, 0);
- gtk_widget_show(button);
+ gtk_box_append(GTK_BOX(hbox2), button);
if (dialog->protocol != NULL) {
PurpleBuddyIconSpec *icon_spec = purple_protocol_get_icon_spec(dialog->protocol);
@@ -701,10 +703,8 @@
/* Main vbox */
dialog->protocol_frame = vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
gtk_notebook_insert_page(GTK_NOTEBOOK(dialog->notebook), vbox,
gtk_label_new_with_mnemonic(_("Ad_vanced")), 1);
- gtk_widget_show(vbox);
for (l = opts; l != NULL; l = l->next)
{
@@ -737,8 +737,7 @@
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check),
bool_value);
- gtk_box_pack_start(GTK_BOX(vbox), check, FALSE, FALSE, 0);
- gtk_widget_show(check);
+ gtk_box_append(GTK_BOX(vbox), check);
break;
case PURPLE_PREF_INT:
@@ -792,10 +791,18 @@
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(entry),
hint);
}
+ if (str_value != NULL) {
+ GtkWidget *real_entry = NULL;
+ real_entry = gtk_combo_box_get_child(GTK_COMBO_BOX(entry));
+ gtk_editable_set_text(GTK_EDITABLE(real_entry),
+ str_value);
+ }
+ } else {
+ entry = gtk_entry_new();
+ gtk_editable_set_text(GTK_EDITABLE(entry),
+ str_value ? str_value : "");
}
- else
- entry = gtk_entry_new();
-
+
opt_entry->widget = entry;
if (purple_account_option_string_get_masked(option) && str_hints)
g_warn_if_reached();
@@ -804,13 +811,6 @@
gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
}
- if (str_value != NULL && str_hints) {
- gtk_editable_set_text(GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(entry))),
- str_value);
- } else {
- gtk_editable_set_text(GTK_EDITABLE(entry), str_value ? str_value : "");
- }
-
title = g_strdup_printf("_%s:",
purple_account_option_get_text(option));
add_pref_box(dialog, vbox, title, entry);
@@ -892,7 +892,7 @@
{
if (!dialog->protocol || !PURPLE_PROTOCOL_IMPLEMENTS(dialog->protocol, MEDIA, initiate_session)) {
if (dialog->voice_frame) {
- gtk_widget_destroy(dialog->voice_frame);
+ gtk_widget_unparent(dialog->voice_frame);
dialog->voice_frame = NULL;
dialog->suppression_check = NULL;
}
@@ -901,16 +901,13 @@
if (!dialog->voice_frame) {
dialog->voice_frame = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
- gtk_container_set_border_width(GTK_CONTAINER(dialog->voice_frame), 12);
dialog->suppression_check =
gtk_check_button_new_with_mnemonic(_("Use _silence suppression"));
- gtk_box_pack_start(GTK_BOX(dialog->voice_frame), dialog->suppression_check,
- FALSE, FALSE, 0);
+ gtk_box_append(GTK_BOX(dialog->voice_frame), dialog->suppression_check);
gtk_notebook_append_page(GTK_NOTEBOOK(dialog->notebook),
dialog->voice_frame, gtk_label_new_with_mnemonic(_("_Voice and Video")));
- gtk_widget_show_all(dialog->voice_frame);
}
if (dialog->account) {
@@ -925,7 +922,7 @@
account_win_destroy_cb(GtkWidget *w, GdkEvent *event,
AccountPrefsDialog *dialog)
{
- gtk_widget_destroy(dialog->window);
+ gtk_window_destroy(GTK_WINDOW(dialog->window));
g_list_free(dialog->user_split_entries);
g_list_free_full(dialog->protocol_opt_entries, (GDestroyNotify)protocol_opt_entry_free);
@@ -1223,15 +1220,12 @@
gtk_box_set_spacing(GTK_BOX(main_vbox), 6);
dialog->notebook = notebook = gtk_notebook_new();
- gtk_box_pack_start(GTK_BOX(main_vbox), notebook, FALSE, FALSE, 0);
- gtk_widget_show(GTK_WIDGET(notebook));
+ gtk_box_append(GTK_BOX(main_vbox), notebook);
/* Setup the inner vbox */
dialog->top_vbox = vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
- gtk_container_set_border_width(GTK_CONTAINER(vbox), 12);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), vbox,
gtk_label_new_with_mnemonic(_("_Basic")));
- gtk_widget_show(vbox);
/* Setup the top frames. */
add_login_options(dialog, vbox);
@@ -1239,8 +1233,7 @@
button = gtk_check_button_new_with_mnemonic(
_("Create _this new account on the server"));
- gtk_box_pack_start(GTK_BOX(main_vbox), button, FALSE, FALSE, 0);
- gtk_widget_show(button);
+ gtk_box_append(GTK_BOX(main_vbox), button);
dialog->register_button = button;
g_signal_connect(G_OBJECT(dialog->register_button), "toggled", G_CALLBACK(register_button_cb), dialog);
if (dialog->account == NULL)
@@ -1260,7 +1253,6 @@
}
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), dialog->proxy_options,
gtk_label_new_with_mnemonic(_("Proxy")));
- gtk_widget_show(dialog->proxy_options);
add_voice_options(dialog);