pidgin/pidginconversationwindow.c

Sat, 11 Dec 2021 20:04:54 -0600

author
Gary Kramlich <grim@reaperworld.com>
date
Sat, 11 Dec 2021 20:04:54 -0600
changeset 41197
1fbba07f21cf
parent 41186
f8275d257afe
child 41252
aaa984be3a68
permissions
-rw-r--r--

Remove unnecessary gtk-doc comments from pidgin

Testing Done:
Compiled

Reviewed at https://reviews.imfreedom.org/r/1176/

40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /*
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2 * Pidgin - Internet Messenger
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 * Copyright (C) Pidgin Developers <devel@pidgin.im>
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 *
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 * Pidgin is the legal property of its developers, whose names are too numerous
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6 * to list here. Please refer to the COPYRIGHT file distributed with this
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 * source distribution.
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 *
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 * This program is free software; you can redistribute it and/or modify
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 * it under the terms of the GNU General Public License as published by
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 * the Free Software Foundation; either version 2 of the License, or
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 * (at your option) any later version.
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 *
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 * GNU General Public License for more details.
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 *
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 * along with this program; if not, see <https://www.gnu.org/licenses/>.
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 */
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 #include "pidginconversationwindow.h"
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
25 #include "gtkconv.h"
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
26
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
27 enum {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
28 PIDGIN_CONVERSATION_WINDOW_COLUMN_OBJECT,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
29 PIDGIN_CONVERSATION_WINDOW_COLUMN_ICON,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
30 PIDGIN_CONVERSATION_WINDOW_COLUMN_MARKUP,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
31 };
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
32
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
33 enum {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
34 SIG_CONVERSATION_SWITCHED,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
35 N_SIGNALS,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
36 };
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
37 static guint signals[N_SIGNALS] = {0, };
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
38
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 struct _PidginConversationWindow {
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 GtkApplicationWindow parent;
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 GtkWidget *vbox;
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
43
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
44 GtkWidget *view;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
45 GtkTreeStore *model;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
46
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
47 GtkWidget *stack;
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 };
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 G_DEFINE_TYPE(PidginConversationWindow, pidgin_conversation_window,
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 GTK_TYPE_APPLICATION_WINDOW)
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
53 static GtkWidget *default_window = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
54
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
55 /******************************************************************************
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
56 * Callbacks
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
57 *****************************************************************************/
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
58 static void
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
59 pidgin_conversation_window_selection_changed(GtkTreeSelection *selection,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
60 gpointer data)
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
61 {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
62 PidginConversationWindow *window = PIDGIN_CONVERSATION_WINDOW(data);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
63 GtkTreeModel *model = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
64 GtkTreeIter iter;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
65 gboolean changed = FALSE;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
66
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
67 if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
68 gchar *markup = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
69
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
70 gtk_tree_model_get(model, &iter,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
71 PIDGIN_CONVERSATION_WINDOW_COLUMN_MARKUP, &markup,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
72 -1);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
73
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
74 gtk_stack_set_visible_child_name(GTK_STACK(window->stack), markup);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
75 g_free(markup);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
76
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
77 changed = TRUE;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
78 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
79
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
80 if(!changed) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
81 gtk_stack_set_visible_child_name(GTK_STACK(window->stack), "__empty__");
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
82 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
83 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
84
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
85 static gboolean
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
86 pidgin_conversation_window_foreach_destroy(GtkTreeModel *model,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
87 GtkTreePath *path,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
88 GtkTreeIter *iter,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
89 gpointer data)
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
90 {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
91 PurpleConversation *conversation = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
92
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
93 gtk_tree_model_get(model, iter,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
94 PIDGIN_CONVERSATION_WINDOW_COLUMN_OBJECT, &conversation,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
95 -1);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
96
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
97 if(conversation != NULL) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
98 pidgin_conversation_detach(conversation);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
99
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
100 gtk_list_store_remove(GTK_LIST_STORE(model), iter);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
101 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
102
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
103 return FALSE;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
104 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
105
41186
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
106 static gboolean
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
107 pidgin_conversation_window_key_pressed_cb(GtkEventControllerKey *controller,
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
108 guint keyval,
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
109 G_GNUC_UNUSED guint keycode,
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
110 GdkModifierType state,
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
111 gpointer data)
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
112 {
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
113 PidginConversationWindow *window = data;
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
114
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
115 /* If CTRL was held down... */
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
116 if (state & GDK_CONTROL_MASK) {
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
117 switch (keyval) {
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
118 case GDK_KEY_Page_Down:
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
119 case GDK_KEY_KP_Page_Down:
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
120 case ']':
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
121 pidgin_conversation_window_select_next(window);
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
122 return TRUE;
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
123 break;
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
124
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
125 case GDK_KEY_Page_Up:
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
126 case GDK_KEY_KP_Page_Up:
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
127 case '[':
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
128 pidgin_conversation_window_select_previous(window);
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
129 return TRUE;
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
130 break;
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
131 } /* End of switch */
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
132 }
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
133
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
134 /* If ALT (or whatever) was held down... */
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
135 else if (state & GDK_MOD1_MASK) {
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
136 if ('1' <= keyval && keyval <= '9') {
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
137 guint switchto = keyval - '1';
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
138 pidgin_conversation_window_select_nth(window, switchto);
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
139
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
140 return TRUE;
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
141 }
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
142 }
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
143
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
144 return FALSE;
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
145 }
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
146
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
147 /******************************************************************************
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
148 * GObjectImplementation
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
149 *****************************************************************************/
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
150 static void
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
151 pidgin_conversation_window_dispose(GObject *obj) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
152 PidginConversationWindow *window = PIDGIN_CONVERSATION_WINDOW(obj);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
153
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
154 if(GTK_IS_TREE_MODEL(window->model)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
155 gtk_tree_model_foreach(GTK_TREE_MODEL(window->model),
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
156 pidgin_conversation_window_foreach_destroy, window);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
157 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
158
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
159 G_OBJECT_CLASS(pidgin_conversation_window_parent_class)->dispose(obj);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
160 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
161
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
162 static void
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
163 pidgin_conversation_window_init(PidginConversationWindow *window) {
40627
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
164 GtkBuilder *builder = NULL;
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
165 GtkWidget *menubar = NULL;
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
166 GMenuModel *model = NULL;
41186
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
167 GtkEventController *key = NULL;
40627
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
168
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
169 gtk_widget_init_template(GTK_WIDGET(window));
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
170
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
171 gtk_window_set_application(GTK_WINDOW(window),
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
172 GTK_APPLICATION(g_application_get_default()));
40627
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
173
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
174 /* setup our menu */
41030
ec8b76f3bf0a Fix the resource path so we can use the automatic stuff that GtkApplication supports
Gary Kramlich <grim@reaperworld.com>
parents: 40629
diff changeset
175 builder = gtk_builder_new_from_resource("/im/pidgin/Pidgin3/Conversations/menu.ui");
40627
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
176
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
177 model = (GMenuModel *)gtk_builder_get_object(builder, "conversation");
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
178 menubar = gtk_menu_bar_new_from_model(model);
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
179
40627
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
180 gtk_box_pack_start(GTK_BOX(window->vbox), menubar, FALSE, FALSE, 0);
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
181 gtk_widget_show(menubar);
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
182
3d6797191bf5 Create a new menu bar for PidginConversationWindow. This is just the menu itself and no behavior.
Gary Kramlich <grim@reaperworld.com>
parents: 40577
diff changeset
183 g_object_unref(G_OBJECT(builder));
41186
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
184
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
185 key = gtk_event_controller_key_new(GTK_WIDGET(window));
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
186 gtk_event_controller_set_propagation_phase(key, GTK_PHASE_CAPTURE);
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
187 g_signal_connect(G_OBJECT(key), "key-pressed",
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
188 G_CALLBACK(pidgin_conversation_window_key_pressed_cb),
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
189 window);
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
190 g_object_set_data_full(G_OBJECT(window), "key-press-controller", key,
f8275d257afe Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents: 41184
diff changeset
191 g_object_unref);
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
192 }
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
193
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
194 static void
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
195 pidgin_conversation_window_class_init(PidginConversationWindowClass *klass) {
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
196 GObjectClass *obj_class = G_OBJECT_CLASS(klass);
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
197 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
198
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
199 obj_class->dispose = pidgin_conversation_window_dispose;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
200
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
201 signals[SIG_CONVERSATION_SWITCHED] = g_signal_new_class_handler(
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
202 "conversation-switched",
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
203 G_OBJECT_CLASS_TYPE(obj_class),
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
204 G_SIGNAL_RUN_LAST,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
205 NULL,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
206 NULL,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
207 NULL,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
208 NULL,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
209 G_TYPE_NONE,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
210 1,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
211 PURPLE_TYPE_CONVERSATION
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
212 );
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
213
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
214 gtk_widget_class_set_template_from_resource(
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
215 widget_class,
41030
ec8b76f3bf0a Fix the resource path so we can use the automatic stuff that GtkApplication supports
Gary Kramlich <grim@reaperworld.com>
parents: 40629
diff changeset
216 "/im/pidgin/Pidgin3/Conversations/window.ui"
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
217 );
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
218
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
219 gtk_widget_class_bind_template_child(widget_class, PidginConversationWindow,
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
220 vbox);
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
221
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
222 gtk_widget_class_bind_template_child(widget_class, PidginConversationWindow,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
223 model);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
224 gtk_widget_class_bind_template_child(widget_class, PidginConversationWindow,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
225 view);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
226
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
227 gtk_widget_class_bind_template_child(widget_class, PidginConversationWindow,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
228 stack);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
229
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
230 gtk_widget_class_bind_template_callback(widget_class,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
231 pidgin_conversation_window_selection_changed);
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
232 }
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
233
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
234 /******************************************************************************
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
235 * API
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
236 *****************************************************************************/
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
237 GtkWidget *
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
238 pidgin_conversation_window_get_default(void) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
239 if(!GTK_IS_WIDGET(default_window)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
240 default_window = pidgin_conversation_window_new();
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
241 g_object_add_weak_pointer(G_OBJECT(default_window),
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
242 (gpointer)&default_window);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
243 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
244
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
245 return default_window;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
246 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
247
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
248 GtkWidget *
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
249 pidgin_conversation_window_new(void) {
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
250 return GTK_WIDGET(g_object_new(PIDGIN_TYPE_CONVERSATION_WINDOW, NULL));
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
251 }
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
252
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
253 void
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
254 pidgin_conversation_window_add(PidginConversationWindow *window,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
255 PurpleConversation *conversation)
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
256 {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
257 PidginConversation *gtkconv = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
258 GtkTreeIter iter;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
259 const gchar *markup = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
260
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
261 g_return_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
262 g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
263
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
264 markup = purple_conversation_get_name(conversation);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
265
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
266 gtkconv = PIDGIN_CONVERSATION(conversation);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
267 if(gtkconv != NULL) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
268 GtkWidget *parent = gtk_widget_get_parent(gtkconv->tab_cont);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
269
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
270 if(GTK_IS_WIDGET(parent)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
271 g_object_ref(gtkconv->tab_cont);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
272 gtk_container_remove(GTK_CONTAINER(parent), gtkconv->tab_cont);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
273 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
274
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
275 gtk_stack_add_named(GTK_STACK(window->stack), gtkconv->tab_cont, markup);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
276 gtk_widget_show_all(gtkconv->tab_cont);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
277
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
278 if(GTK_IS_WIDGET(parent)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
279 g_object_unref(gtkconv->tab_cont);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
280 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
281 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
282
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
283 gtk_tree_store_prepend(window->model, &iter, NULL);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
284 gtk_tree_store_set(window->model, &iter,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
285 PIDGIN_CONVERSATION_WINDOW_COLUMN_OBJECT, conversation,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
286 PIDGIN_CONVERSATION_WINDOW_COLUMN_MARKUP, markup,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
287 -1);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
288
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
289 if(!gtk_widget_is_visible(GTK_WIDGET(window))) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
290 gtk_widget_show_all(GTK_WIDGET(window));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
291 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
292 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
293
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
294 void
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
295 pidgin_conversation_window_remove(PidginConversationWindow *window,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
296 PurpleConversation *conversation)
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
297 {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
298 GtkTreeIter iter;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
299 GObject *obj = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
300
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
301 g_return_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
302 g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
303
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
304 if(!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(window->model), &iter)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
305 /* The tree is empty. */
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
306 return;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
307 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
308
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
309 do {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
310 gtk_tree_model_get(GTK_TREE_MODEL(window->model), &iter,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
311 PIDGIN_CONVERSATION_WINDOW_COLUMN_OBJECT, &obj,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
312 -1);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
313
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
314 if(PURPLE_CONVERSATION(obj) == conversation) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
315 gtk_tree_store_remove(window->model, &iter);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
316
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
317 g_clear_object(&obj);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
318
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
319 break;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
320 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
321
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
322 g_clear_object(&obj);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
323 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(window->model), &iter));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
324 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
325
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
326 guint
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
327 pidgin_conversation_window_get_count(PidginConversationWindow *window) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
328 GList *children = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
329 guint count = 0;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
330
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
331 g_return_val_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window), 0);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
332
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
333 children = gtk_container_get_children(GTK_CONTAINER(window));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
334 while(children != NULL) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
335 children = g_list_delete_link(children, children);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
336 count++;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
337 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
338
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
339 return count;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
340 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
341
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
342 PurpleConversation *
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
343 pidgin_conversation_window_get_selected(PidginConversationWindow *window) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
344 PurpleConversation *conversation = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
345 GtkTreeSelection *selection = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
346 GtkTreeIter iter;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
347
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
348 g_return_val_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window), NULL);
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
349
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
350 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(window->view));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
351 if(gtk_tree_selection_get_selected(selection, NULL, &iter)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
352
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
353 gtk_tree_model_get(GTK_TREE_MODEL(window->model), &iter,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
354 PIDGIN_CONVERSATION_WINDOW_COLUMN_OBJECT, &conversation,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
355 -1);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
356 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
357
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
358 return conversation;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
359 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
360
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
361 void
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
362 pidgin_conversation_window_select(PidginConversationWindow *window,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
363 PurpleConversation *conversation)
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
364 {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
365 const gchar *name = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
366
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
367 g_return_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
368 g_return_if_fail(PURPLE_IS_CONVERSATION(conversation));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
369
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
370 name = purple_conversation_get_name(conversation);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
371 gtk_stack_set_visible_child_name(GTK_STACK(window->stack), name);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
372 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
373
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
374 void
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
375 pidgin_conversation_window_select_previous(PidginConversationWindow *window) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
376 GtkTreeIter iter;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
377 GtkTreeModel *model = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
378 GtkTreeSelection *selection = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
379 gboolean set = FALSE;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
380
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
381 g_return_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
382
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
383 model = GTK_TREE_MODEL(window->model);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
384
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
385 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(window->view));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
386 if(gtk_tree_selection_get_selected(selection, NULL, &iter)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
387 if(gtk_tree_model_iter_previous(model, &iter)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
388 gtk_tree_selection_select_iter(selection, &iter);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
389 set = TRUE;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
390 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
391 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
392
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
393 if(!set) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
394 pidgin_conversation_window_select_last(window);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
395 }
40577
953d563429b8 Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
396 }
41184
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
397
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
398
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
399 void
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
400 pidgin_conversation_window_select_next(PidginConversationWindow *window) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
401 GtkTreeIter iter;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
402 GtkTreeModel *model = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
403 GtkTreeSelection *selection = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
404 gboolean set = FALSE;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
405
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
406 g_return_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
407
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
408 model = GTK_TREE_MODEL(window->model);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
409
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
410 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(window->view));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
411 if(gtk_tree_selection_get_selected(selection, NULL, &iter)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
412 if(gtk_tree_model_iter_next(model, &iter)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
413 gtk_tree_selection_select_iter(selection, &iter);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
414 set = TRUE;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
415 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
416 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
417
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
418 if(!set) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
419 pidgin_conversation_window_select_first(window);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
420 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
421 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
422
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
423 void
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
424 pidgin_conversation_window_select_first(PidginConversationWindow *window) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
425 GtkTreeIter iter;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
426 GtkTreeModel *model = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
427
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
428 g_return_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
429
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
430 model = GTK_TREE_MODEL(window->model);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
431
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
432 if(gtk_tree_model_get_iter_first(model, &iter)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
433 GtkTreeSelection *selection = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
434
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
435 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(window->view));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
436 gtk_tree_selection_select_iter(selection, &iter);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
437 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
438 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
439
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
440 void
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
441 pidgin_conversation_window_select_last(PidginConversationWindow *window) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
442 GtkTreeIter iter;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
443 GtkTreeModel *model = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
444 gint count = 0;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
445
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
446 g_return_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
447
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
448 model = GTK_TREE_MODEL(window->model);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
449 count = gtk_tree_model_iter_n_children(model, NULL);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
450
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
451 if(gtk_tree_model_iter_nth_child(model, &iter, NULL, count - 1)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
452 GtkTreeSelection *selection = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
453
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
454 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(window->view));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
455 gtk_tree_selection_select_iter(selection, &iter);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
456 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
457 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
458
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
459 void
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
460 pidgin_conversation_window_select_nth(PidginConversationWindow *window,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
461 guint nth)
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
462 {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
463 GtkTreeIter iter;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
464 GtkTreeModel *model = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
465
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
466 g_return_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
467
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
468 model = GTK_TREE_MODEL(window->model);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
469
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
470 if(gtk_tree_model_iter_nth_child(model, &iter, NULL, nth)) {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
471 GtkTreeSelection *selection = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
472
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
473 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(window->view));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
474 gtk_tree_selection_select_iter(selection, &iter);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
475 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
476 }
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
477
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
478 gboolean
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
479 pidgin_conversation_window_conversation_is_selected(PidginConversationWindow *window,
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
480 PurpleConversation *conversation)
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
481 {
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
482 const gchar *name = NULL, *visible = NULL;
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
483
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
484 g_return_val_if_fail(PIDGIN_IS_CONVERSATION_WINDOW(window), FALSE);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
485 g_return_val_if_fail(PURPLE_IS_CONVERSATION(conversation), FALSE);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
486
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
487 name = purple_conversation_get_name(conversation);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
488 visible = gtk_stack_get_visible_child_name(GTK_STACK(window->stack));
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
489
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
490 return purple_strequal(name, visible);
05b5c210352b Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents: 41030
diff changeset
491 }

mercurial