--- a/pidgin/gtkprivacy.c Thu Dec 19 05:00:44 2019 -0500
+++ b/pidgin/gtkprivacy.c Sat Dec 21 16:40:52 2019 -0500
@@ -32,9 +32,12 @@
#include "pidginaccountchooser.h"
+#define PIDGIN_TYPE_PRIVACY_DIALOG (pidgin_privacy_dialog_get_type()) +G_DECLARE_FINAL_TYPE(PidginPrivacyDialog, pidgin_privacy_dialog, PIDGIN, + PRIVACY_DIALOG, GtkDialog) +struct _PidginPrivacyDialog { @@ -55,9 +58,9 @@
+ GtkWidget *account_chooser;
@@ -119,85 +122,6 @@
gtk_widget_set_sensitive(dialog->remove_button, TRUE);
-build_list(PidginPrivacyDialog *dialog, GtkListStore *model,
- GtkWidget **ret_treeview)
- GtkTreeViewColumn *column;
- treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
- *ret_treeview = treeview;
- rend = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(NULL, rend,
- gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(column), TRUE);
- gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE);
- sw = pidgin_make_scrollable(treeview, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, 200);
- gtk_widget_show(treeview);
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
- g_signal_connect(G_OBJECT(sel), "changed",
- G_CALLBACK(user_selected_cb), dialog);
-build_allow_list(PidginPrivacyDialog *dialog)
- dialog->allow_store = gtk_list_store_new(1, G_TYPE_STRING);
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(dialog->allow_store), 0, GTK_SORT_ASCENDING);
- widget = build_list(dialog, dialog->allow_store, &list);
- dialog->allow_list = list;
- rebuild_allow_list(dialog);
-build_block_list(PidginPrivacyDialog *dialog)
- dialog->block_store = gtk_list_store_new(1, G_TYPE_STRING);
- gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(dialog->block_store), 0, GTK_SORT_ASCENDING);
- widget = build_list(dialog, dialog->block_store, &list);
- dialog->block_list = list;
- rebuild_block_list(dialog);
-destroy_cb(GtkWidget *w, GdkEvent *event, PidginPrivacyDialog *dialog)
- pidgin_privacy_dialog_hide();
select_account_cb(GtkWidget *chooser, PidginPrivacyDialog *dialog)
@@ -206,6 +130,21 @@
dialog->account = account;
+ gtk_widget_set_sensitive(dialog->type_menu, TRUE); + gtk_widget_set_sensitive(dialog->add_button, TRUE); + /* dialog->remove_button is enabled when a user is selected. */ + gtk_widget_set_sensitive(dialog->removeall_button, TRUE); + gtk_widget_set_sensitive(dialog->type_menu, FALSE); + gtk_widget_set_sensitive(dialog->add_button, FALSE); + gtk_widget_set_sensitive(dialog->remove_button, FALSE); + gtk_widget_set_sensitive(dialog->removeall_button, FALSE); + gtk_list_store_clear(dialog->allow_store); + gtk_list_store_clear(dialog->block_store); for (i = 0; i < menu_entry_count; i++) {
if (menu_entries[i].type == purple_account_get_privacy_type(account)) {
gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), i);
@@ -316,55 +255,63 @@
+G_DEFINE_TYPE(PidginPrivacyDialog, pidgin_privacy_dialog, GTK_TYPE_DIALOG) -close_cb(GtkWidget *button, PidginPrivacyDialog *dialog)
+pidgin_privacy_dialog_class_init(PidginPrivacyDialogClass *klass) - gtk_widget_destroy(dialog->win);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + gtk_widget_class_set_template_from_resource( + widget_class, "/im/pidgin/Pidgin/Privacy/dialog.ui"); - pidgin_privacy_dialog_hide();
+ gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_child(widget_class, PidginPrivacyDialog, + gtk_widget_class_bind_template_callback(widget_class, add_cb); + gtk_widget_class_bind_template_callback(widget_class, remove_cb); + gtk_widget_class_bind_template_callback(widget_class, removeall_cb); + gtk_widget_class_bind_template_callback(widget_class, select_account_cb); + gtk_widget_class_bind_template_callback(widget_class, type_changed_cb); + gtk_widget_class_bind_template_callback(widget_class, user_selected_cb); -static PidginPrivacyDialog *
-privacy_dialog_new(void)
+pidgin_privacy_dialog_init(PidginPrivacyDialog *dialog) - PidginPrivacyDialog *dialog;
- dialog = g_new0(PidginPrivacyDialog, 1);
- dialog->win = pidgin_create_dialog(_("Privacy"), PIDGIN_HIG_BORDER, "privacy", TRUE);
- g_signal_connect(G_OBJECT(dialog->win), "delete_event",
- G_CALLBACK(destroy_cb), dialog);
- vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(dialog->win), FALSE, PIDGIN_HIG_BORDER);
+ gtk_widget_init_template(GTK_WIDGET(dialog)); - /* Description label */
- _("Changes to privacy settings take effect immediately."));
- gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
- gtk_label_set_xalign(GTK_LABEL(label), 0);
- gtk_widget_show(label);
- /* Accounts drop-down */
- dropdown = pidgin_account_chooser_new(NULL, FALSE);
- pidgin_add_widget_to_vbox(GTK_BOX(vbox), _("Set privacy for:"), NULL, dropdown, TRUE, NULL);
- g_signal_connect(dropdown, "changed", G_CALLBACK(select_account_cb),
- dialog->account = pidgin_account_chooser_get_selected(dropdown);
+ pidgin_account_chooser_get_selected(dialog->account_chooser); /* Add the drop-down list with the allow/block types. */
- dialog->type_menu = gtk_combo_box_text_new();
- gtk_box_pack_start(GTK_BOX(vbox), dialog->type_menu, FALSE, FALSE, 0);
- gtk_widget_show(dialog->type_menu);
for (i = 0; i < menu_entry_count; i++) {
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(dialog->type_menu),
_(menu_entries[i].text));
@@ -372,40 +319,11 @@
if (menu_entries[i].type == purple_account_get_privacy_type(dialog->account))
gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->type_menu), selected);
- g_signal_connect(G_OBJECT(dialog->type_menu), "changed",
- G_CALLBACK(type_changed_cb), dialog);
- /* Build the treeview for the allow list. */
- dialog->allow_widget = build_allow_list(dialog);
- gtk_box_pack_start(GTK_BOX(vbox), dialog->allow_widget, TRUE, TRUE, 0);
- /* Build the treeview for the block list. */
- dialog->block_widget = build_block_list(dialog);
- gtk_box_pack_start(GTK_BOX(vbox), dialog->block_widget, TRUE, TRUE, 0);
- /* Add the button box for Add, Remove, Remove All */
- dialog->button_box = pidgin_dialog_get_action_area(GTK_DIALOG(dialog->win));
- button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), GTK_STOCK_ADD, G_CALLBACK(add_cb), dialog);
- dialog->add_button = button;
- button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), GTK_STOCK_REMOVE, G_CALLBACK(remove_cb), dialog);
- dialog->remove_button = button;
- /* TODO: This button should be sensitive/invisitive more cleverly */
- gtk_widget_set_sensitive(button, FALSE);
- /* Remove All button */
- button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), _("Remove Al_l"), G_CALLBACK(removeall_cb), dialog);
- dialog->removeall_button = button;
- button = pidgin_dialog_add_button(GTK_DIALOG(dialog->win), GTK_STOCK_CLOSE, G_CALLBACK(close_cb), dialog);
- dialog->close_button = button;
+ /* Rebuild the allow and block lists views. */ + rebuild_allow_list(dialog); + rebuild_block_list(dialog); type_changed_cb(GTK_COMBO_BOX(dialog->type_menu), dialog);
@@ -420,7 +338,6 @@
dialog->in_allow_list = FALSE;
@@ -428,23 +345,20 @@
g_return_if_fail(purple_connections_get_all() != NULL);
- if (privacy_dialog == NULL)
- privacy_dialog = privacy_dialog_new();
+ if (privacy_dialog == NULL) { + privacy_dialog = g_object_new(PIDGIN_TYPE_PRIVACY_DIALOG, NULL); + g_signal_connect(privacy_dialog, "destroy", + G_CALLBACK(gtk_widget_destroyed), &privacy_dialog); - gtk_widget_show(privacy_dialog->win);
- gdk_window_raise(gtk_widget_get_window(privacy_dialog->win));
+ gtk_widget_show(GTK_WIDGET(privacy_dialog)); + gdk_window_raise(gtk_widget_get_window(GTK_WIDGET(privacy_dialog))); pidgin_privacy_dialog_hide(void)
- if (privacy_dialog == NULL)
- g_object_unref(G_OBJECT(privacy_dialog->allow_store));
- g_object_unref(G_OBJECT(privacy_dialog->block_store));
- g_free(privacy_dialog);
+ gtk_widget_destroy(GTK_WIDGET(privacy_dialog)); --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/resources/Privacy/dialog.ui Sat Dec 21 16:40:52 2019 -0500
@@ -0,0 +1,289 @@
+<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 +Pidgin - Internet Messenger +Copyright (C) Pidgin Developers <devel@pidgin.im> +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + <requires lib="gtk+" version="3.20"/> + <requires lib="pidgin" version="3.0"/> + <!-- interface-license-type gplv2 --> + <!-- interface-name Pidgin --> + <!-- interface-description Internet Messenger --> + <!-- interface-copyright Pidgin Developers <devel@pidgin.im> --> + <object class="GtkListStore" id="allow_store"> + <!-- column-name column1 --> + <column type="gchararray"/> + <object class="GtkListStore" id="block_store"> + <!-- column-name column1 --> + <column type="gchararray"/> + <template class="PidginPrivacyDialog" parent="GtkDialog"> + <property name="can_focus">False</property> + <property name="title" translatable="yes">Privacy</property> + <property name="role">privacy</property> + <property name="type_hint">dialog</property> + <signal name="close" handler="gtk_widget_destroy" swapped="no"/> + <child internal-child="vbox"> + <object class="GtkBox"> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="button_box"> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <object class="GtkButton" id="add_button"> + <property name="label">gtk-add</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + <signal name="clicked" handler="add_cb" object="PidginPrivacyDialog" swapped="no"/> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + <object class="GtkButton" id="remove_button"> + <property name="label">gtk-remove</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + <signal name="clicked" handler="remove_cb" object="PidginPrivacyDialog" swapped="no"/> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + <object class="GtkButton" id="removeall_button"> + <property name="label" translatable="yes">Remove Al_l</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="removeall_cb" object="PidginPrivacyDialog" swapped="no"/> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + <object class="GtkButton" id="close_button"> + <property name="label">gtk-close</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + <signal name="clicked" handler="gtk_widget_destroy" object="PidginPrivacyDialog" swapped="yes"/> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">3</property> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <property name="spacing">6</property> + <object class="GtkLabel"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Changes to privacy settings take effect immediately.</property> + <property name="xalign">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + <object class="GtkBox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">5</property> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Set privacy for:</property> + <property name="use_underline">True</property> + <property name="mnemonic_widget">account_chooser</property> + <relation type="label-for" target="account_chooser"/> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + <object class="PidginAccountChooser" id="account_chooser"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <signal name="changed" handler="select_account_cb" object="PidginPrivacyDialog" swapped="no"/> + <relation type="labelled-by" target="label1"/> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> + <object class="GtkComboBoxText" id="type_menu"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <signal name="changed" handler="type_changed_cb" object="PidginPrivacyDialog" swapped="no"/> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + <object class="GtkScrolledWindow" id="allow_widget"> + <property name="height_request">200</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="shadow_type">in</property> + <object class="GtkTreeView" id="allow_list"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">allow_store</property> + <property name="headers_visible">False</property> + <property name="search_column">0</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"> + <signal name="changed" handler="user_selected_cb" object="PidginPrivacyDialog" swapped="no"/> + <object class="GtkTreeViewColumn"> + <property name="clickable">True</property> + <property name="sort_column_id">0</property> + <object class="GtkCellRendererText"/> + <attribute name="text">0</attribute> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">3</property> + <object class="GtkScrolledWindow" id="block_widget"> + <property name="height_request">200</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="shadow_type">in</property> + <object class="GtkTreeView" id="block_list"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="model">block_store</property> + <property name="headers_visible">False</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"> + <signal name="changed" handler="user_selected_cb" object="PidginPrivacyDialog" swapped="no"/> + <object class="GtkTreeViewColumn"> + <property name="clickable">True</property> + <property name="sort_column_id">0</property> + <object class="GtkCellRendererText"/> + <attribute name="text">0</attribute> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">4</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">1</property> --- a/pidgin/resources/pidgin.gresource.xml Thu Dec 19 05:00:44 2019 -0500
+++ b/pidgin/resources/pidgin.gresource.xml Sat Dec 21 16:40:52 2019 -0500
@@ -13,6 +13,7 @@
<file compressed="true">Plugins/dialog.ui</file>
<file compressed="true">Prefs/prefs.ui</file>
<file compressed="true">Prefs/vv.ui</file>
+ <file compressed="true">Privacy/dialog.ui</file> <file compressed="true">Roomlist/roomlist.ui</file>
<file compressed="true">Whiteboard/whiteboard.ui</file>
<file compressed="true">Xfer/xfer.ui</file>