pidgin/pidginprotocolchooser.c

Fri, 14 Feb 2020 00:50:39 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Fri, 14 Feb 2020 00:50:39 -0600
changeset 40297
082c07053a79
child 40299
e2f8638bac5a
permissions
-rw-r--r--

Add the new PidginProtocolChooser and implement it in account dialog

40297
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, write to the Free Software
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 */
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 #include "pidginprotocolchooser.h"
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 #include "pidginprotocolstore.h"
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 /******************************************************************************
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 * Structs
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 *****************************************************************************/
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 struct _PidginProtocolChooser {
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 GtkComboBox parent;
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 GtkListStore *model;
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 };
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 /******************************************************************************
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 * GObject Implementation
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 *****************************************************************************/
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 G_DEFINE_TYPE(PidginProtocolChooser, pidgin_protocol_chooser,
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 GTK_TYPE_COMBO_BOX)
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 static void
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 pidgin_protocol_chooser_class_init(PidginProtocolChooserClass *klass)
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 {
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 gtk_widget_class_set_template_from_resource(widget_class,
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 "/im/pidgin/Pidgin/Protocols/chooser.ui");
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 gtk_widget_class_bind_template_child(widget_class, PidginProtocolChooser,
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 model);
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 }
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
55
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 static void
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 pidgin_protocol_chooser_init(PidginProtocolChooser *chooser) {
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 gtk_widget_init_template(GTK_WIDGET(chooser));
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 }
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 /******************************************************************************
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 * Public API
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 *****************************************************************************/
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 GtkWidget *
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
65 pidgin_protocol_chooser_new(void) {
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
66 return GTK_WIDGET(g_object_new(PIDGIN_TYPE_PROTOCOL_CHOOSER, NULL));
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 }
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 gchar *
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
70 pidgin_protocol_chooser_get_selected(PidginProtocolChooser *chooser)
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 {
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 GtkTreeIter iter;
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 gchar *name = NULL;
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 g_return_val_if_fail(PIDGIN_IS_PROTOCOL_CHOOSER(chooser), NULL);
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77 if(gtk_combo_box_get_active_iter(GTK_COMBO_BOX(chooser), &iter)) {
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 gtk_tree_model_get(GTK_TREE_MODEL(chooser->model), &iter,
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 PIDGIN_PROTOCOL_STORE_COLUMN_NAME, &name,
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 -1);
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 }
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 return name;
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 }
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 void
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 pidgin_protocol_chooser_set_selected(PidginProtocolChooser *chooser,
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 const gchar *name)
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 {
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 GtkTreeIter iter;
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 gchar *iter_name = NULL;
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 g_return_if_fail(PIDGIN_IS_PROTOCOL_CHOOSER(chooser));
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(chooser->model), &iter)) {
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 do {
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 gtk_tree_model_get(GTK_TREE_MODEL(chooser->model), &iter,
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 PIDGIN_PROTOCOL_STORE_COLUMN_NAME, &iter_name,
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 -1);
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
101 if(purple_strequal(iter_name, name)) {
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
102 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(chooser), &iter);
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 g_free(iter_name);
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 return;
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 }
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
108
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 g_free(iter_name);
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
110 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(chooser->model),
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
111 &iter));
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
112 }
082c07053a79 Add the new PidginProtocolChooser and implement it in account dialog
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
113 }

mercurial