pidgin/pidgin

Convert PidginRoomlistDialog to Glade.

2019-12-19, Elliott Sales de Andrade
19acef70137d
Parents a133a6fcc822
Children 41e9424fc96f
Convert PidginRoomlistDialog to Glade.
--- a/pidgin/gtkroomlist.c Sun Dec 22 18:54:41 2019 -0500
+++ b/pidgin/gtkroomlist.c Thu Dec 19 05:00:44 2019 -0500
@@ -33,8 +33,13 @@
#include "gtkroomlist.h"
-typedef struct {
- GtkWidget *window;
+#define PIDGIN_TYPE_ROOMLIST_DIALOG (pidgin_roomlist_dialog_get_type())
+G_DECLARE_FINAL_TYPE(PidginRoomlistDialog, pidgin_roomlist_dialog, PIDGIN,
+ ROOMLIST_DIALOG, GtkDialog)
+
+struct _PidginRoomlistDialog {
+ GtkDialog parent;
+
GtkWidget *account_widget;
GtkWidget *progress;
GtkWidget *sw;
@@ -50,7 +55,9 @@
gboolean pg_needs_pulse;
guint pg_update_to;
-} PidginRoomlistDialog;
+};
+
+G_DEFINE_TYPE(PidginRoomlistDialog, pidgin_roomlist_dialog, GTK_TYPE_DIALOG)
typedef struct {
PidginRoomlistDialog *dialog;
@@ -78,7 +85,7 @@
static gint delete_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d)
{
- PidginRoomlistDialog *dialog = d;
+ PidginRoomlistDialog *dialog = PIDGIN_ROOMLIST_DIALOG(w);
if (dialog->roomlist && purple_roomlist_get_in_progress(dialog->roomlist))
purple_roomlist_cancel_get_list(dialog->roomlist);
@@ -99,7 +106,6 @@
}
dialog->progress = NULL;
- g_free(dialog);
return FALSE;
}
@@ -144,8 +150,7 @@
rl = purple_roomlist_get_ui_data(dialog->roomlist);
rl->dialog = dialog;
- if (dialog->account_widget)
- gtk_widget_set_sensitive(dialog->account_widget, FALSE);
+ gtk_widget_set_sensitive(dialog->account_widget, FALSE);
gtk_container_add(GTK_CONTAINER(dialog->sw), rl->tree);
@@ -166,8 +171,7 @@
{
purple_roomlist_cancel_get_list(dialog->roomlist);
- if (dialog->account_widget)
- gtk_widget_set_sensitive(dialog->account_widget, TRUE);
+ gtk_widget_set_sensitive(dialog->account_widget, TRUE);
gtk_widget_set_sensitive(dialog->stop_button, FALSE);
gtk_widget_set_sensitive(dialog->list_button, TRUE);
@@ -175,14 +179,6 @@
gtk_widget_set_sensitive(dialog->join_button, FALSE);
}
-static void close_button_cb(GtkButton *button, PidginRoomlistDialog *dialog)
-{
- GtkWidget *window = dialog->window;
-
- delete_win_cb(NULL, NULL, dialog);
- gtk_widget_destroy(window);
-}
-
struct _menu_cb_info {
PurpleRoomlist *list;
PurpleRoomlistRoom *room;
@@ -523,93 +519,71 @@
return FALSE;
}
+static void
+pidgin_roomlist_dialog_class_init(PidginRoomlistDialogClass *klass)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
+
+ gtk_widget_class_set_template_from_resource(
+ widget_class, "/im/pidgin/Pidgin/Roomlist/roomlist.ui");
+
+ gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
+ account_widget);
+ gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
+ add_button);
+ gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
+ close_button);
+ gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
+ join_button);
+ gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
+ list_button);
+ gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
+ progress);
+ gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
+ stop_button);
+ gtk_widget_class_bind_template_child(widget_class, PidginRoomlistDialog,
+ sw);
+
+ gtk_widget_class_bind_template_callback(widget_class,
+ add_room_to_blist_cb);
+ gtk_widget_class_bind_template_callback(widget_class, delete_win_cb);
+ gtk_widget_class_bind_template_callback(widget_class,
+ dialog_select_account_cb);
+ gtk_widget_class_bind_template_callback(widget_class, join_button_cb);
+ gtk_widget_class_bind_template_callback(widget_class, list_button_cb);
+ gtk_widget_class_bind_template_callback(widget_class, stop_button_cb);
+}
+
+static void
+pidgin_roomlist_dialog_init(PidginRoomlistDialog *self)
+{
+ gtk_widget_init_template(GTK_WIDGET(self));
+
+ pidgin_account_chooser_set_filter_func(
+ PIDGIN_ACCOUNT_CHOOSER(self->account_widget),
+ account_filter_func);
+}
+
static PidginRoomlistDialog *
pidgin_roomlist_dialog_new_with_account(PurpleAccount *account)
{
PidginRoomlistDialog *dialog;
- GtkWidget *window, *vbox, *vbox2, *bbox;
- dialog = g_new0(PidginRoomlistDialog, 1);
+ dialog = g_object_new(PIDGIN_TYPE_ROOMLIST_DIALOG, NULL);
dialog->account = account;
- /* Create the window. */
- dialog->window = window = pidgin_create_dialog(_("Room List"), 0, "room list", TRUE);
-
- g_signal_connect(G_OBJECT(window), "delete_event",
- G_CALLBACK(delete_win_cb), dialog);
-
- /* Create the parent vbox for everything. */
- vbox = pidgin_dialog_get_vbox_with_properties(GTK_DIALOG(window), FALSE, PIDGIN_HIG_BORDER);
-
- vbox2 = gtk_box_new(GTK_ORIENTATION_VERTICAL, PIDGIN_HIG_BORDER);
- gtk_container_add(GTK_CONTAINER(vbox), vbox2);
- gtk_widget_show(vbox2);
-
- /* accounts dropdown list */
- dialog->account_widget =
- pidgin_account_chooser_new(dialog->account, FALSE);
- pidgin_account_chooser_set_filter_func(
- PIDGIN_ACCOUNT_CHOOSER(dialog->account_widget),
- account_filter_func);
- g_signal_connect(dialog->account_widget, "changed",
- G_CALLBACK(dialog_select_account_cb), dialog);
- if (!dialog->account) /* this is normally null, and we normally don't care what the first selected item is */
+ if (!account) {
+ /* This is normally NULL, and we normally don't care what the
+ * first selected item is */
dialog->account = pidgin_account_chooser_get_selected(
dialog->account_widget);
- pidgin_add_widget_to_vbox(GTK_BOX(vbox2), _("_Account:"), NULL, dialog->account_widget, TRUE, NULL);
-
- /* scrolled window */
- dialog->sw = pidgin_make_scrollable(NULL, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC, GTK_SHADOW_IN, -1, 250);
- gtk_box_pack_start(GTK_BOX(vbox2), dialog->sw, TRUE, TRUE, 0);
-
- /* progress bar */
- dialog->progress = gtk_progress_bar_new();
- gtk_progress_bar_set_pulse_step(GTK_PROGRESS_BAR(dialog->progress), 0.1);
- gtk_box_pack_start(GTK_BOX(vbox2), dialog->progress, FALSE, FALSE, 0);
- gtk_widget_show(dialog->progress);
-
- /* button box */
- bbox = pidgin_dialog_get_action_area(GTK_DIALOG(window));
- gtk_box_set_spacing(GTK_BOX(bbox), PIDGIN_HIG_BOX_SPACE);
- gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
-
- /* stop button */
- dialog->stop_button = pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_STOP,
- G_CALLBACK(stop_button_cb), dialog);
- gtk_widget_set_sensitive(dialog->stop_button, FALSE);
-
- /* list button */
- dialog->list_button = pidgin_pixbuf_button_from_stock(_("_Get List"), GTK_STOCK_REFRESH,
- PIDGIN_BUTTON_HORIZONTAL);
- gtk_box_pack_start(GTK_BOX(bbox), dialog->list_button, FALSE, FALSE, 0);
- g_signal_connect(G_OBJECT(dialog->list_button), "clicked",
- G_CALLBACK(list_button_cb), dialog);
- gtk_widget_show(dialog->list_button);
-
- /* add button */
- dialog->add_button = pidgin_pixbuf_button_from_stock(_("_Add Chat"), GTK_STOCK_ADD,
- PIDGIN_BUTTON_HORIZONTAL);
- gtk_box_pack_start(GTK_BOX(bbox), dialog->add_button, FALSE, FALSE, 0);
- g_signal_connect(G_OBJECT(dialog->add_button), "clicked",
- G_CALLBACK(add_room_to_blist_cb), dialog);
- gtk_widget_set_sensitive(dialog->add_button, FALSE);
- gtk_widget_show(dialog->add_button);
-
- /* join button */
- dialog->join_button = pidgin_pixbuf_button_from_stock(_("_Join"), PIDGIN_STOCK_CHAT,
- PIDGIN_BUTTON_HORIZONTAL);
- gtk_box_pack_start(GTK_BOX(bbox), dialog->join_button, FALSE, FALSE, 0);
- g_signal_connect(G_OBJECT(dialog->join_button), "clicked",
- G_CALLBACK(join_button_cb), dialog);
- gtk_widget_set_sensitive(dialog->join_button, FALSE);
- gtk_widget_show(dialog->join_button);
-
- /* close button */
- dialog->close_button = pidgin_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE,
- G_CALLBACK(close_button_cb), dialog);
+ } else {
+ pidgin_account_chooser_set_selected(dialog->account_widget,
+ account);
+ }
/* show the dialog window and return the dialog */
- gtk_widget_show(dialog->window);
+ gtk_widget_show(GTK_WIDGET(dialog));
return dialog;
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pidgin/resources/Roomlist/roomlist.ui Thu Dec 19 05:00:44 2019 -0500
@@ -0,0 +1,237 @@
+<?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.
+
+-->
+<interface>
+ <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="GtkImage" id="add_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-add</property>
+ </object>
+ <object class="GtkImage" id="join_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">pidgin-chat</property>
+ </object>
+ <object class="GtkImage" id="refresh_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-refresh</property>
+ </object>
+ <template class="PidginRoomlistDialog" parent="GtkDialog">
+ <property name="can_focus">False</property>
+ <property name="title" translatable="yes">Room List</property>
+ <property name="role">room list</property>
+ <property name="type_hint">dialog</property>
+ <signal name="delete-event" handler="delete_win_cb" swapped="no"/>
+ <child>
+ <placeholder/>
+ </child>
+ <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">
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="stop_button">
+ <property name="label">gtk-stop</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="stop_button_cb" object="PidginRoomlistDialog" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="list_button">
+ <property name="label" translatable="yes">_Get List</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="image">refresh_image</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="list_button_cb" object="PidginRoomlistDialog" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="add_button">
+ <property name="label" translatable="yes">_Add Chat</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="image">add_image</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="add_room_to_blist_cb" object="PidginRoomlistDialog" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="join_button">
+ <property name="label" translatable="yes">_Join</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="image">join_image</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked" handler="join_button_cb" object="PidginRoomlistDialog" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
+ <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="PidginRoomlistDialog" swapped="yes"/>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">5</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">_Account:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">account_widget</property>
+ <accessibility>
+ <relation type="label-for" target="account_widget"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="PidginAccountChooser" id="account_widget">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <signal name="changed" handler="dialog_select_account_cb" object="PidginRoomlistDialog" swapped="no"/>
+ <accessibility>
+ <relation type="labelled-by" target="label1"/>
+ </accessibility>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="sw">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <property name="min_content_height">250</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkProgressBar" id="progress">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
--- a/pidgin/resources/pidgin.gresource.xml Sun Dec 22 18:54:41 2019 -0500
+++ b/pidgin/resources/pidgin.gresource.xml Thu Dec 19 05:00:44 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">Roomlist/roomlist.ui</file>
<file compressed="true">Whiteboard/whiteboard.ui</file>
<file compressed="true">Xfer/xfer.ui</file>
</gresource>