Tue, 06 Aug 2024 02:07:35 -0500
Remove the pidgin_text_buffer_api
The purposed for this code is being replaced by the markup api which we haven't
implemented yet, but nothing was using this, so we can remove it.
Testing Done:
Ran the turtles.
Reviewed at https://reviews.imfreedom.org/r/3356/
|
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 | |
|
41254
ef50e0dc74b0
Add a group for conversation in the PidginConversationWindow tree view
Gary Kramlich <grim@reaperworld.com>
parents:
41252
diff
changeset
|
23 | #include <glib/gi18n-lib.h> |
|
ef50e0dc74b0
Add a group for conversation in the PidginConversationWindow tree view
Gary Kramlich <grim@reaperworld.com>
parents:
41252
diff
changeset
|
24 | |
|
41701
43f994f7f9f2
Replace GtkStack in PidginDisplayWindow with AdwViewStack
Gary Kramlich <grim@reaperworld.com>
parents:
41696
diff
changeset
|
25 | #include <adwaita.h> |
|
43f994f7f9f2
Replace GtkStack in PidginDisplayWindow with AdwViewStack
Gary Kramlich <grim@reaperworld.com>
parents:
41696
diff
changeset
|
26 | |
|
42597
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
27 | #include <gplugin.h> |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
28 | #include <gplugin-gtk.h> |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
29 | |
|
41702
4289b30044ed
Rename pidginconversationwindow.[ch] to pidgindisplaywindow.[ch]
Gary Kramlich <grim@reaperworld.com>
parents:
41701
diff
changeset
|
30 | #include "pidgindisplaywindow.h" |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
31 | |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
32 | #include "pidginconversation.h" |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
33 | #include "pidgindisplayitem.h" |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
34 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
35 | enum { |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
36 | SIG_CONVERSATION_SWITCHED, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
37 | N_SIGNALS, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
38 | }; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
39 | static guint signals[N_SIGNALS] = {0, }; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
40 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
41 | struct _PidginDisplayWindow { |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
42 | GtkApplicationWindow parent; |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
43 | |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
44 | GtkWidget *view; |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
45 | GtkWidget *bin; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
46 | |
|
42597
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
47 | GtkWidget *plugin_list; |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
48 | |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
49 | GListStore *base_model; |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
50 | GListModel *selection_model; |
|
41254
ef50e0dc74b0
Add a group for conversation in the PidginConversationWindow tree view
Gary Kramlich <grim@reaperworld.com>
parents:
41252
diff
changeset
|
51 | |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
52 | GMenuModel *conversation_menu; |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
53 | PidginDisplayItem *conversations_item; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
54 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
55 | GListStore *conversation_model; |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
56 | }; |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
57 | |
|
42575
580339aa47cc
Make sure all of the final types in pidgin are defined as such
Gary Kramlich <grim@reaperworld.com>
parents:
42559
diff
changeset
|
58 | G_DEFINE_FINAL_TYPE(PidginDisplayWindow, pidgin_display_window, |
|
580339aa47cc
Make sure all of the final types in pidgin are defined as such
Gary Kramlich <grim@reaperworld.com>
parents:
42559
diff
changeset
|
59 | GTK_TYPE_APPLICATION_WINDOW) |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
60 | |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
61 | static GtkWidget *default_window = NULL; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
62 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
63 | /****************************************************************************** |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
64 | * Helpers |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
65 | *****************************************************************************/ |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
66 | static GListModel * |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
67 | pidgin_display_window_create_model(GObject *item, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
68 | G_GNUC_UNUSED gpointer data) |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
69 | { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
70 | GListModel *model = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
71 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
72 | model = pidgin_display_item_get_children(PIDGIN_DISPLAY_ITEM(item)); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
73 | if(model != NULL) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
74 | return g_object_ref(model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
75 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
76 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
77 | return NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
78 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
79 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
80 | static gboolean |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
81 | pidgin_display_window_find_conversation(gconstpointer a, gconstpointer b) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
82 | PidginDisplayItem *item_a = PIDGIN_DISPLAY_ITEM((gpointer)a); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
83 | PidginDisplayItem *item_b = PIDGIN_DISPLAY_ITEM((gpointer)b); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
84 | PurpleConversation *conversation_a = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
85 | PurpleConversation *conversation_b = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
86 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
87 | conversation_a = g_object_get_data(G_OBJECT(item_a), "conversation"); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
88 | conversation_b = g_object_get_data(G_OBJECT(item_b), "conversation"); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
89 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
90 | return (conversation_a == conversation_b); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
91 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
92 | |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
93 | static gboolean |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
94 | pidgin_display_window_find_conversation_by_id(gconstpointer a, |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
95 | G_GNUC_UNUSED gconstpointer b, |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
96 | gpointer user_data) |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
97 | { |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
98 | PidginDisplayItem *item_a = PIDGIN_DISPLAY_ITEM((gpointer)a); |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
99 | const char *a_id = pidgin_display_item_get_id(item_a); |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
100 | const char *id = user_data; |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
101 | |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
102 | return purple_strequal(a_id, id); |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
103 | } |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
104 | |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
105 | /****************************************************************************** |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
106 | * Callbacks |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
107 | *****************************************************************************/ |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
108 | static void |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
109 | pidgin_display_window_leave_conversation_cb(GObject *source, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
110 | GAsyncResult *result, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
111 | gpointer data) |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
112 | { |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
113 | PurpleConversation *conversation = data; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
114 | GError *error = NULL; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
115 | gboolean left = FALSE; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
116 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
117 | left = purple_protocol_conversation_leave_conversation_finish(PURPLE_PROTOCOL_CONVERSATION(source), |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
118 | result, &error); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
119 | if(error != NULL) { |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
120 | g_warning("failed to leave conversation: '%s'", error->message); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
121 | g_clear_error(&error); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
122 | } else if(left) { |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
123 | PurpleConversationManager *manager = NULL; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
124 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
125 | manager = purple_conversation_manager_get_default(); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
126 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
127 | purple_conversation_manager_unregister(manager, conversation); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
128 | } else { |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
129 | g_warning("failed to leave conversation for unknown reasons"); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
130 | } |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
131 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
132 | g_clear_object(&conversation); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
133 | } |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
134 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
135 | /****************************************************************************** |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
136 | * Conversation Actions |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
137 | *****************************************************************************/ |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
138 | static void |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
139 | pidgin_display_window_leave_conversation(G_GNUC_UNUSED GSimpleAction *simple, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
140 | GVariant *parameter, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
141 | G_GNUC_UNUSED gpointer data) |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
142 | { |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
143 | PurpleAccount *account = NULL; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
144 | PurpleAccountManager *account_manager = NULL; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
145 | PurpleConversation *conversation = NULL; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
146 | PurpleConversationManager *conversation_manager = NULL; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
147 | PurpleProtocol *protocol = NULL; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
148 | GStrv parts = NULL; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
149 | const char *id = NULL; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
150 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
151 | if(!g_variant_is_of_type(parameter, G_VARIANT_TYPE_STRING)) { |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
152 | g_warning("parameter is of type %s, expected %s", |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
153 | g_variant_get_type_string(parameter), |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
154 | (char *)G_VARIANT_TYPE_STRING); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
155 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
156 | return; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
157 | } |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
158 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
159 | id = g_variant_get_string(parameter, NULL); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
160 | parts = g_strsplit(id, "-", 2); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
161 | if(g_strv_length(parts) != 2) { |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
162 | g_warning("unexpected id format '%s'", id); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
163 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
164 | g_strfreev(parts); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
165 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
166 | return; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
167 | } |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
168 | |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
169 | account_manager = purple_account_manager_get_default(); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
170 | account = purple_account_manager_find_by_id(account_manager, parts[0]); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
171 | if(!PURPLE_IS_ACCOUNT(account)) { |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
172 | g_warning("failed to find account with id '%s'", parts[0]); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
173 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
174 | g_strfreev(parts); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
175 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
176 | return; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
177 | } |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
178 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
179 | conversation_manager = purple_conversation_manager_get_default(); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
180 | conversation = purple_conversation_manager_find_with_id(conversation_manager, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
181 | account, parts[1]); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
182 | if(!PURPLE_IS_CONVERSATION(conversation)) { |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
183 | g_warning("failed to find conversation with id '%s'", parts[1]); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
184 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
185 | g_strfreev(parts); |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
186 | |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
187 | return; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
188 | } |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
189 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
190 | /* We're done with parts now so free it. */ |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
191 | g_strfreev(parts); |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
192 | |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
193 | protocol = purple_account_get_protocol(account); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
194 | if(PURPLE_IS_PROTOCOL_CONVERSATION(protocol)) { |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
195 | PurpleProtocolConversation *protocol_conversation = NULL; |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
196 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
197 | protocol_conversation = PURPLE_PROTOCOL_CONVERSATION(protocol); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
198 | |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
199 | purple_protocol_conversation_leave_conversation_async(protocol_conversation, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
200 | conversation, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
201 | NULL, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
202 | pidgin_display_window_leave_conversation_cb, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
203 | g_object_ref(conversation)); |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
204 | } |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
205 | } |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
206 | |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
207 | static GActionEntry conversation_entries[] = { |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
208 | { |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
209 | .name = "leave", |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
210 | .activate = pidgin_display_window_leave_conversation, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
211 | .parameter_type = "s", |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
212 | } |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
213 | }; |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
214 | |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
215 | /****************************************************************************** |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
216 | * Callbacks |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
217 | *****************************************************************************/ |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
218 | static gboolean |
|
41947
7b3312d0760c
Bump C standard to C99 for Pidgin files and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41849
diff
changeset
|
219 | pidgin_display_window_key_pressed_cb(G_GNUC_UNUSED GtkEventControllerKey *controller, |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
220 | guint keyval, |
|
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
221 | G_GNUC_UNUSED guint keycode, |
|
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
222 | GdkModifierType state, |
|
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
223 | gpointer data) |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
224 | { |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
225 | PidginDisplayWindow *window = data; |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
226 | |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
227 | 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
|
228 | switch (keyval) { |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
229 | 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
|
230 | 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
|
231 | case ']': |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
232 | pidgin_display_window_select_next(window); |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
233 | return TRUE; |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
234 | break; |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
235 | case GDK_KEY_Home: |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
236 | pidgin_display_window_select_first(window); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
237 | return TRUE; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
238 | break; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
239 | case GDK_KEY_End: |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
240 | pidgin_display_window_select_last(window); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
241 | return TRUE; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
242 | break; |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
243 | 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
|
244 | 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
|
245 | case '[': |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
246 | pidgin_display_window_select_previous(window); |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
247 | return TRUE; |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
248 | break; |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
249 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
250 | } else if (state & GDK_ALT_MASK) { |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
251 | 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
|
252 | guint switchto = keyval - '1'; |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
253 | pidgin_display_window_select_nth(window, switchto); |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
254 | |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
255 | return TRUE; |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
256 | } |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
257 | } |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
258 | |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
259 | return FALSE; |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
260 | } |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
261 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
262 | static void |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
263 | pidgin_display_window_selected_item_changed_cb(GObject *self, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
264 | G_GNUC_UNUSED GParamSpec *pspec, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
265 | gpointer data) |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
266 | { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
267 | PidginDisplayItem *item = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
268 | PidginDisplayWindow *window = data; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
269 | GtkSingleSelection *selection = GTK_SINGLE_SELECTION(self); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
270 | GtkTreeListRow *row = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
271 | GtkWidget *widget = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
272 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
273 | row = gtk_single_selection_get_selected_item(selection); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
274 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
275 | item = gtk_tree_list_row_get_item(row); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
276 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
277 | widget = pidgin_display_item_get_widget(item); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
278 | if(GTK_IS_WIDGET(widget)) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
279 | adw_bin_set_child(ADW_BIN(window->bin), widget); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
280 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
281 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
282 | |
|
42559
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
283 | static void |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
284 | pidgin_display_window_conversation_registered_cb(G_GNUC_UNUSED PurpleConversationManager *manager, |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
285 | PurpleConversation *conversation, |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
286 | gpointer data) |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
287 | { |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
288 | PidginDisplayWindow *window = data; |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
289 | |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
290 | pidgin_display_window_add(window, conversation); |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
291 | } |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
292 | |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
293 | static void |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
294 | pidgin_display_window_conversation_unregistered_cb(G_GNUC_UNUSED PurpleConversationManager *manager, |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
295 | PurpleConversation *conversation, |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
296 | gpointer data) |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
297 | { |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
298 | PidginDisplayWindow *window = data; |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
299 | |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
300 | pidgin_display_window_remove(window, conversation); |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
301 | } |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
302 | |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
303 | static void |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
304 | pidgin_display_window_conversation_present_cb(PurpleConversation *conversation, |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
305 | gpointer data) |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
306 | { |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
307 | pidgin_display_window_select(data, conversation); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
308 | } |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
309 | |
|
42797
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
310 | static gboolean |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
311 | pidgin_display_window_show_item_menu_cb(G_GNUC_UNUSED GObject *source, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
312 | PidginDisplayItem *item, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
313 | G_GNUC_UNUSED gpointer data) |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
314 | { |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
315 | GMenuModel *model = NULL; |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
316 | |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
317 | if(!PIDGIN_IS_DISPLAY_ITEM(item)) { |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
318 | return FALSE; |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
319 | } |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
320 | |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
321 | model = pidgin_display_item_get_menu(item); |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
322 | |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
323 | return G_IS_MENU_MODEL(model); |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
324 | } |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
325 | |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
326 | static char * |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
327 | pidgin_display_window_show_item_actions_cb(G_GNUC_UNUSED GObject *source, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
328 | gboolean item_selected, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
329 | gboolean item_contains_pointer, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
330 | gboolean menu_button_active, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
331 | G_GNUC_UNUSED gpointer data) |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
332 | { |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
333 | if(item_selected || item_contains_pointer || menu_button_active) { |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
334 | return g_strdup("actions"); |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
335 | } |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
336 | |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
337 | return g_strdup("notifications"); |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
338 | } |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
339 | |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | /****************************************************************************** |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
341 | * GObject Implementation |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
342 | *****************************************************************************/ |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
343 | static void |
|
42215
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
344 | pidgin_display_window_finalize(GObject *obj) { |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
345 | PidginDisplayWindow *window = PIDGIN_DISPLAY_WINDOW(obj); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
346 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
347 | g_clear_object(&window->conversation_model); |
|
42215
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
348 | g_clear_object(&window->selection_model); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
349 | |
|
42215
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
350 | G_OBJECT_CLASS(pidgin_display_window_parent_class)->finalize(obj); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
351 | } |
|
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 | static void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
354 | pidgin_display_window_init(PidginDisplayWindow *window) { |
|
41560
2579a5138f0c
A bunch of random fixes for the the gtk4 branch
Gary Kramlich <grim@reaperworld.com>
parents:
41527
diff
changeset
|
355 | GtkEventController *key = NULL; |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
356 | GtkTreeListModel *tree_model = NULL; |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
357 | GSimpleActionGroup *conversation_actions = NULL; |
|
42597
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
358 | GPluginManager *plugin_manager = NULL; |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
359 | gpointer settings_backend = 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
|
360 | |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | gtk_widget_init_template(GTK_WIDGET(window)); |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
362 | |
|
42215
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
363 | /* Add a reference to the selection model as we use it internally and with |
|
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
364 | * out it we get some weird call backs being called when it's nulled out |
|
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
365 | * during destruction. |
|
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
366 | */ |
|
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
367 | g_object_ref(window->selection_model); |
|
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
368 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
369 | /* Setup the tree list model. */ |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
370 | tree_model = gtk_tree_list_model_new(G_LIST_MODEL(window->base_model), |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
371 | FALSE, TRUE, |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
372 | (GtkTreeListModelCreateModelFunc)pidgin_display_window_create_model, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
373 | window, NULL); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
374 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
375 | /* Set the model of the selection to the tree model. */ |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
376 | gtk_single_selection_set_model(GTK_SINGLE_SELECTION(window->selection_model), |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
377 | G_LIST_MODEL(tree_model)); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
378 | g_clear_object(&tree_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
379 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
380 | /* Set the application and add all of our actions. */ |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
381 | gtk_window_set_application(GTK_WINDOW(window), |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
382 | 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
|
383 | |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
384 | conversation_actions = g_simple_action_group_new(); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
385 | g_action_map_add_action_entries(G_ACTION_MAP(conversation_actions), |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
386 | conversation_entries, |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
387 | G_N_ELEMENTS(conversation_entries), |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
388 | window); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
389 | gtk_widget_insert_action_group(GTK_WIDGET(window), "conversation", |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
390 | G_ACTION_GROUP(conversation_actions)); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
391 | g_clear_object(&conversation_actions); |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
392 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
393 | /* Add a key controller. */ |
|
41560
2579a5138f0c
A bunch of random fixes for the the gtk4 branch
Gary Kramlich <grim@reaperworld.com>
parents:
41527
diff
changeset
|
394 | key = gtk_event_controller_key_new(); |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
395 | 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
|
396 | g_signal_connect(G_OBJECT(key), "key-pressed", |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
397 | G_CALLBACK(pidgin_display_window_key_pressed_cb), |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
398 | window); |
|
41560
2579a5138f0c
A bunch of random fixes for the the gtk4 branch
Gary Kramlich <grim@reaperworld.com>
parents:
41527
diff
changeset
|
399 | gtk_widget_add_controller(GTK_WIDGET(window), key); |
|
42597
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
400 | |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
401 | /* Set up the plugin list. */ |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
402 | plugin_manager = gplugin_manager_get_default(); |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
403 | gplugin_gtk_view_set_manager(GPLUGIN_GTK_VIEW(window->plugin_list), |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
404 | plugin_manager); |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
405 | |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
406 | settings_backend = purple_core_get_settings_backend(); |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
407 | gplugin_gtk_view_set_settings_backend(GPLUGIN_GTK_VIEW(window->plugin_list), |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
408 | settings_backend); |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
409 | } |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
410 | |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
411 | static void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
412 | pidgin_display_window_class_init(PidginDisplayWindowClass *klass) { |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
413 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
414 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
415 | |
|
42215
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
416 | obj_class->finalize = pidgin_display_window_finalize; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
417 | |
|
41479
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41476
diff
changeset
|
418 | /** |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
419 | * PidginDisplayWindow::conversation-switched: |
|
41479
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41476
diff
changeset
|
420 | * @window: The conversation window. |
|
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41476
diff
changeset
|
421 | * @new_conv: The now active conversation. |
|
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41476
diff
changeset
|
422 | * |
|
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41476
diff
changeset
|
423 | * Emitted when a window switched from one conversation to another. |
|
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41476
diff
changeset
|
424 | */ |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
425 | 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
|
426 | "conversation-switched", |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
427 | G_OBJECT_CLASS_TYPE(obj_class), |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
428 | G_SIGNAL_RUN_LAST, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
429 | NULL, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
430 | NULL, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
431 | NULL, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
432 | NULL, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
433 | G_TYPE_NONE, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
434 | 1, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
435 | PURPLE_TYPE_CONVERSATION |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
436 | ); |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
437 | |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
438 | gtk_widget_class_set_template_from_resource( |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
439 | widget_class, |
|
42762
17f602456139
Move Display/window.ui to display-window.ui
Gary Kramlich <grim@reaperworld.com>
parents:
42714
diff
changeset
|
440 | "/im/pidgin/Pidgin3/display-window.ui" |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
441 | ); |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
442 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
443 | gtk_widget_class_bind_template_child(widget_class, PidginDisplayWindow, |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
444 | view); |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
445 | gtk_widget_class_bind_template_child(widget_class, PidginDisplayWindow, |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
446 | bin); |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
447 | gtk_widget_class_bind_template_child(widget_class, PidginDisplayWindow, |
|
42597
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
448 | plugin_list); |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
449 | gtk_widget_class_bind_template_child(widget_class, PidginDisplayWindow, |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
450 | base_model); |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
451 | gtk_widget_class_bind_template_child(widget_class, PidginDisplayWindow, |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
452 | selection_model); |
|
41849
413cde086275
Add a placeholder to PidginDisplayWindow for the ContactList
Gary Kramlich <grim@reaperworld.com>
parents:
41702
diff
changeset
|
453 | gtk_widget_class_bind_template_child(widget_class, PidginDisplayWindow, |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
454 | conversation_menu); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
455 | gtk_widget_class_bind_template_child(widget_class, PidginDisplayWindow, |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
456 | conversations_item); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
457 | gtk_widget_class_bind_template_child(widget_class, PidginDisplayWindow, |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
458 | conversation_model); |
|
41527
4dff8cd4e9ea
Convert PidginConversationWindow to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41484
diff
changeset
|
459 | |
|
4dff8cd4e9ea
Convert PidginConversationWindow to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41484
diff
changeset
|
460 | gtk_widget_class_bind_template_callback(widget_class, |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
461 | pidgin_display_window_key_pressed_cb); |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
462 | gtk_widget_class_bind_template_callback(widget_class, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
463 | pidgin_display_window_selected_item_changed_cb); |
|
42797
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
464 | gtk_widget_class_bind_template_callback(widget_class, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
465 | pidgin_display_window_show_item_menu_cb); |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
466 | gtk_widget_class_bind_template_callback(widget_class, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
467 | pidgin_display_window_show_item_actions_cb); |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
468 | } |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
469 | |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
470 | /****************************************************************************** |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
471 | * API |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
472 | *****************************************************************************/ |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
473 | GtkWidget * |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
474 | pidgin_display_window_get_default(void) { |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
475 | if(!GTK_IS_WIDGET(default_window)) { |
|
42559
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
476 | PurpleConversationManager *manager = NULL; |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
477 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
478 | default_window = pidgin_display_window_new(); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
479 | 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
|
480 | (gpointer)&default_window); |
|
42559
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
481 | |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
482 | manager = purple_conversation_manager_get_default(); |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
483 | g_signal_connect_object(manager, "registered", |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
484 | G_CALLBACK(pidgin_display_window_conversation_registered_cb), |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
485 | default_window, 0); |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
486 | g_signal_connect_object(manager, "unregistered", |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
487 | G_CALLBACK(pidgin_display_window_conversation_unregistered_cb), |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
488 | default_window, 0); |
|
41184
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 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
491 | return default_window; |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
492 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
493 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
494 | GtkWidget * |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
495 | pidgin_display_window_new(void) { |
|
41582
4ee4a8ddc190
Explicitly set show-menubar so our menubars are shown
Gary Kramlich <grim@reaperworld.com>
parents:
41560
diff
changeset
|
496 | return g_object_new( |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
497 | PIDGIN_TYPE_DISPLAY_WINDOW, |
|
41582
4ee4a8ddc190
Explicitly set show-menubar so our menubars are shown
Gary Kramlich <grim@reaperworld.com>
parents:
41560
diff
changeset
|
498 | "show-menubar", TRUE, |
|
4ee4a8ddc190
Explicitly set show-menubar so our menubars are shown
Gary Kramlich <grim@reaperworld.com>
parents:
41560
diff
changeset
|
499 | NULL); |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
500 | } |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
501 | |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
502 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
503 | pidgin_display_window_add(PidginDisplayWindow *window, |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
504 | PurpleConversation *purple_conversation) |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
505 | { |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
506 | GtkWidget *pidgin_conversation = NULL; |
|
42609
648a1b5dd96a
use a globally unique id when creating new Pidgin::DisplayItem's
Markus Fischer <ivanhoe@fiscari.de>
parents:
42597
diff
changeset
|
507 | const char *conversation_id = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
508 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
509 | g_return_if_fail(PIDGIN_IS_DISPLAY_WINDOW(window)); |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
510 | g_return_if_fail(PURPLE_IS_CONVERSATION(purple_conversation)); |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
511 | |
|
42609
648a1b5dd96a
use a globally unique id when creating new Pidgin::DisplayItem's
Markus Fischer <ivanhoe@fiscari.de>
parents:
42597
diff
changeset
|
512 | conversation_id = purple_conversation_get_id(purple_conversation); |
|
648a1b5dd96a
use a globally unique id when creating new Pidgin::DisplayItem's
Markus Fischer <ivanhoe@fiscari.de>
parents:
42597
diff
changeset
|
513 | g_return_if_fail(conversation_id != NULL); |
|
648a1b5dd96a
use a globally unique id when creating new Pidgin::DisplayItem's
Markus Fischer <ivanhoe@fiscari.de>
parents:
42597
diff
changeset
|
514 | |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
515 | pidgin_conversation = pidgin_conversation_from_purple_conversation(purple_conversation); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
516 | |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
517 | if(!PIDGIN_IS_CONVERSATION(pidgin_conversation)) { |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
518 | pidgin_conversation = pidgin_conversation_new(purple_conversation); |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
519 | } |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
520 | |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
521 | if(PIDGIN_IS_CONVERSATION(pidgin_conversation)) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
522 | PidginDisplayItem *item = NULL; |
|
42609
648a1b5dd96a
use a globally unique id when creating new Pidgin::DisplayItem's
Markus Fischer <ivanhoe@fiscari.de>
parents:
42597
diff
changeset
|
523 | PurpleAccount *account = purple_conversation_get_account(purple_conversation); |
|
648a1b5dd96a
use a globally unique id when creating new Pidgin::DisplayItem's
Markus Fischer <ivanhoe@fiscari.de>
parents:
42597
diff
changeset
|
524 | const char *account_id = NULL; |
|
648a1b5dd96a
use a globally unique id when creating new Pidgin::DisplayItem's
Markus Fischer <ivanhoe@fiscari.de>
parents:
42597
diff
changeset
|
525 | char *id = NULL; |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
526 | gboolean item_exists = FALSE; |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
527 | |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
528 | GtkWidget *parent = gtk_widget_get_parent(pidgin_conversation); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
529 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
530 | if(GTK_IS_WIDGET(parent)) { |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
531 | g_object_ref(pidgin_conversation); |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
532 | gtk_widget_unparent(pidgin_conversation); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
533 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
534 | |
|
42804
be8c8b5471ca
Update pidgin to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents:
42798
diff
changeset
|
535 | account_id = purple_account_get_id(account); |
|
42609
648a1b5dd96a
use a globally unique id when creating new Pidgin::DisplayItem's
Markus Fischer <ivanhoe@fiscari.de>
parents:
42597
diff
changeset
|
536 | id = g_strdup_printf("%s-%s", account_id, conversation_id); |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
537 | item_exists = |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
538 | g_list_store_find_with_equal_func_full(window->conversation_model, |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
539 | NULL, |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
540 | pidgin_display_window_find_conversation_by_id, |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
541 | id, |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
542 | NULL); |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
543 | if (!item_exists) { |
|
42766
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
544 | PurpleProtocol *protocol = NULL; |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
545 | GMenu *menu = NULL; |
|
42766
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
546 | const char *icon_name = NULL; |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
547 | |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
548 | menu = purple_menu_copy(window->conversation_menu); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
549 | purple_menu_populate_dynamic_targets(menu, "id", id, NULL); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
550 | |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
551 | item = pidgin_display_item_new(pidgin_conversation, id); |
|
42798
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
552 | pidgin_display_item_set_menu(item, G_MENU_MODEL(menu)); |
|
1c536113a68a
Add a menu to Pidgin.DisplayItem for Conversations that allows you to leave them
Gary Kramlich <grim@reaperworld.com>
parents:
42797
diff
changeset
|
553 | g_clear_object(&menu); |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
554 | g_object_set_data(G_OBJECT(item), "conversation", purple_conversation); |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
555 | |
|
42766
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
556 | protocol = purple_account_get_protocol(account); |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
557 | icon_name = purple_protocol_get_icon_name(protocol); |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
558 | if(!purple_strempty(icon_name)) { |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
559 | pidgin_display_item_set_icon_name(item, icon_name); |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
560 | } |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
561 | |
|
42774
4858aea578c4
Bind the Pidgin.DisplayItem:title property to Purple.Conversation:title-for-display
Gary Kramlich <grim@reaperworld.com>
parents:
42766
diff
changeset
|
562 | g_object_bind_property(purple_conversation, "title-for-display", |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
563 | item, "title", |
|
42774
4858aea578c4
Bind the Pidgin.DisplayItem:title property to Purple.Conversation:title-for-display
Gary Kramlich <grim@reaperworld.com>
parents:
42766
diff
changeset
|
564 | G_BINDING_SYNC_CREATE); |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
565 | |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
566 | g_signal_connect_object(purple_conversation, "present", |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
567 | G_CALLBACK(pidgin_display_window_conversation_present_cb), |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
568 | window, G_CONNECT_DEFAULT); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
569 | |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
570 | g_list_store_append(window->conversation_model, item); |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
571 | g_clear_object(&item); |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
572 | } |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
573 | g_free(id); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
574 | if(GTK_IS_WIDGET(parent)) { |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
575 | g_object_unref(pidgin_conversation); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
576 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
577 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
578 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
579 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
580 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
581 | pidgin_display_window_remove(PidginDisplayWindow *window, |
|
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
582 | PurpleConversation *conversation) |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
583 | { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
584 | PidginDisplayItem *item = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
585 | guint position = 0; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
586 | gboolean found = FALSE; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
587 | gchar *id = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
588 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
589 | g_return_if_fail(PIDGIN_IS_DISPLAY_WINDOW(window)); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
590 | 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
|
591 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
592 | /* Create a wrapper item for our find function. */ |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
593 | id = g_uuid_string_random(); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
594 | item = g_object_new(PIDGIN_TYPE_DISPLAY_ITEM, "id", id, NULL); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
595 | g_free(id); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
596 | g_object_set_data(G_OBJECT(item), "conversation", conversation); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
597 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
598 | found = g_list_store_find_with_equal_func(window->conversation_model, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
599 | item, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
600 | pidgin_display_window_find_conversation, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
601 | &position); |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
602 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
603 | g_clear_object(&item); |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
604 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
605 | if(found) { |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
606 | g_signal_handlers_disconnect_by_func(conversation, |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
607 | G_CALLBACK(pidgin_display_window_conversation_present_cb), |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
608 | window); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
609 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
610 | g_list_store_remove(window->conversation_model, position); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
611 | } |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
612 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
613 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
614 | guint |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
615 | pidgin_display_window_get_count(G_GNUC_UNUSED PidginDisplayWindow *window) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
616 | /* TODO: This is only used by the gestures plugin and that will probably |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
617 | * need some rewriting and different api for a mixed content window list |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
618 | * this is now. |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
619 | */ |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
620 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
621 | return 0; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
622 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
623 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
624 | PurpleConversation * |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
625 | pidgin_display_window_get_selected(PidginDisplayWindow *window) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
626 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
627 | GtkTreeListRow *tree_row = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
628 | GObject *selected = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
629 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
630 | g_return_val_if_fail(PIDGIN_IS_DISPLAY_WINDOW(window), NULL); |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
631 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
632 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
633 | tree_row = gtk_single_selection_get_selected_item(selection); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
634 | selected = gtk_tree_list_row_get_item(tree_row); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
635 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
636 | if(PIDGIN_IS_DISPLAY_ITEM(selected)) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
637 | return g_object_get_data(selected, "conversation"); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
638 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
639 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
640 | return NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
641 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
642 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
643 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
644 | pidgin_display_window_select(PidginDisplayWindow *window, |
|
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
645 | PurpleConversation *conversation) |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
646 | { |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
647 | PidginDisplayItem *item = NULL; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
648 | guint position = 0; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
649 | gboolean found = FALSE; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
650 | gchar *id = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
651 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
652 | g_return_if_fail(PIDGIN_IS_DISPLAY_WINDOW(window)); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
653 | g_return_if_fail(PURPLE_IS_CONVERSATION(conversation)); |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
654 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
655 | /* Create a wrapper item for our find function. */ |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
656 | id = g_uuid_string_random(); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
657 | item = g_object_new(PIDGIN_TYPE_DISPLAY_ITEM, "id", id, NULL); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
658 | g_free(id); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
659 | g_object_set_data(G_OBJECT(item), "conversation", conversation); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
660 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
661 | found = g_list_store_find_with_equal_func(window->conversation_model, |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
662 | item, |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
663 | pidgin_display_window_find_conversation, |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
664 | &position); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
665 | g_clear_object(&item); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
666 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
667 | if(found) { |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
668 | /* Figure out where the conversations_item is because we need to add to |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
669 | * that position. |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
670 | */ |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
671 | guint conversations_position = 0; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
672 | guint real_position = 0; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
673 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
674 | g_list_store_find(window->base_model, window->conversations_item, |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
675 | &conversations_position); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
676 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
677 | /* Since this is a nested model, we need to increment by one to get to |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
678 | * the correct item. |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
679 | */ |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
680 | real_position = conversations_position + position + 1; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
681 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
682 | gtk_single_selection_set_selected(GTK_SINGLE_SELECTION(window->selection_model), |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
683 | real_position); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
684 | } |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
685 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
686 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
687 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
688 | pidgin_display_window_select_previous(PidginDisplayWindow *window) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
689 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
690 | guint position = 0; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
691 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
692 | g_return_if_fail(PIDGIN_IS_DISPLAY_WINDOW(window)); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
693 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
694 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
695 | position = gtk_single_selection_get_selected(selection); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
696 | if(position == 0) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
697 | position = g_list_model_get_n_items(G_LIST_MODEL(selection)) - 1; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
698 | } else { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
699 | position = position - 1; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
700 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
701 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
702 | gtk_single_selection_set_selected(selection, position); |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
703 | } |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
704 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
705 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
706 | pidgin_display_window_select_next(PidginDisplayWindow *window) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
707 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
708 | guint position = 0; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
709 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
710 | g_return_if_fail(PIDGIN_IS_DISPLAY_WINDOW(window)); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
711 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
712 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
713 | position = gtk_single_selection_get_selected(selection); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
714 | if(position + 1 >= g_list_model_get_n_items(G_LIST_MODEL(selection))) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
715 | position = 0; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
716 | } else { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
717 | position = position + 1; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
718 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
719 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
720 | gtk_single_selection_set_selected(selection, position); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
721 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
722 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
723 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
724 | pidgin_display_window_select_first(PidginDisplayWindow *window) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
725 | GtkSingleSelection *selection = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
726 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
727 | g_return_if_fail(PIDGIN_IS_DISPLAY_WINDOW(window)); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
728 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
729 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
730 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
731 | /* The selection has autoselect set to true, which won't do anything if |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
732 | * this is an invalid value. |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
733 | */ |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
734 | gtk_single_selection_set_selected(selection, 0); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
735 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
736 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
737 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
738 | pidgin_display_window_select_last(PidginDisplayWindow *window) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
739 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
740 | guint n_items = 0; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
741 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
742 | g_return_if_fail(PIDGIN_IS_DISPLAY_WINDOW(window)); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
743 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
744 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
745 | n_items = g_list_model_get_n_items(G_LIST_MODEL(selection)); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
746 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
747 | /* The selection has autoselect set to true, which won't do anything if |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
748 | * this is an invalid value. |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
749 | */ |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
750 | gtk_single_selection_set_selected(selection, n_items - 1); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
751 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
752 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
753 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
754 | pidgin_display_window_select_nth(PidginDisplayWindow *window, |
|
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
755 | guint nth) |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
756 | { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
757 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
758 | guint n_items = 0; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
759 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
760 | g_return_if_fail(PIDGIN_IS_DISPLAY_WINDOW(window)); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
761 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
762 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
763 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
764 | /* The selection has autoselect set to true, but this isn't bound checking |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
765 | * or something on the children models, so we verify before setting. |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
766 | */ |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
767 | n_items = g_list_model_get_n_items(G_LIST_MODEL(selection)); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
768 | if(nth < n_items) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
769 | gtk_single_selection_set_selected(selection, nth); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
770 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
771 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
772 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
773 | gboolean |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
774 | pidgin_display_window_conversation_is_selected(PidginDisplayWindow *window, |
|
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
775 | PurpleConversation *conversation) |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
776 | { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
777 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
778 | GObject *selected = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
779 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
780 | g_return_val_if_fail(PIDGIN_IS_DISPLAY_WINDOW(window), FALSE); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
781 | 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
|
782 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
783 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
784 | selected = gtk_single_selection_get_selected_item(selection); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
785 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
786 | if(PIDGIN_IS_DISPLAY_ITEM(selected)) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
787 | PurpleConversation *selected_conversation = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
788 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
789 | selected_conversation = g_object_get_data(G_OBJECT(selected), |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
790 | "conversation"); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
791 | if(selected_conversation != NULL) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
792 | return (selected_conversation == conversation); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
793 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
794 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
795 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
796 | return FALSE; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
797 | } |