Wed, 01 Jan 2025 15:32:28 -0600
Prepare for the 2.90.1 release
Testing Done:
Ran `meson dist`
Reviewed at https://reviews.imfreedom.org/r/3716/
|
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 | /****************************************************************************** |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
62 | * Helpers |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
63 | *****************************************************************************/ |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
64 | static GListModel * |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
65 | pidgin_display_window_create_model(GObject *item, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
66 | G_GNUC_UNUSED gpointer data) |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
67 | { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
68 | GListModel *model = NULL; |
|
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 | 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
|
71 | if(model != NULL) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
72 | return g_object_ref(model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
73 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
74 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
75 | return NULL; |
|
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 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
78 | static gboolean |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
79 | 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
|
80 | PidginDisplayItem *item_a = PIDGIN_DISPLAY_ITEM((gpointer)a); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
81 | PidginDisplayItem *item_b = PIDGIN_DISPLAY_ITEM((gpointer)b); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
82 | PurpleConversation *conversation_a = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
83 | PurpleConversation *conversation_b = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
84 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
85 | 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
|
86 | 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
|
87 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
88 | return (conversation_a == conversation_b); |
|
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 | |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
91 | static gboolean |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
92 | 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
|
93 | 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
|
94 | gpointer user_data) |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
95 | { |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
96 | 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
|
97 | 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
|
98 | 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
|
99 | |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
100 | 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
|
101 | } |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
102 | |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
103 | /****************************************************************************** |
|
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
|
104 | * 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
|
105 | *****************************************************************************/ |
|
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 | 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
|
107 | 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
|
108 | 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
|
109 | 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
|
110 | { |
|
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 | 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
|
112 | 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
|
113 | 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
|
114 | |
|
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 | 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
|
116 | 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
|
117 | 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
|
118 | 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
|
119 | 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
|
120 | } 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
|
121 | 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
|
122 | |
|
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 | 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
|
124 | |
|
43031
e8a8813478e8
Update Pidgin for the ConversationManager deprecations
Gary Kramlich <grim@reaperworld.com>
parents:
42836
diff
changeset
|
125 | purple_conversation_manager_remove(manager, conversation); |
|
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
|
126 | } 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
|
127 | 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
|
128 | } |
|
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 | |
|
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 | 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
|
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 | |
|
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 | * Conversation Actions |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
135 | *****************************************************************************/ |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
136 | 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
|
137 | 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
|
138 | 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
|
139 | G_GNUC_UNUSED gpointer data) |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
140 | { |
|
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
|
141 | 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
|
142 | 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
|
143 | 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
|
144 | 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
|
145 | 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
|
146 | 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
|
147 | 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
|
148 | |
|
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 | 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
|
150 | 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
|
151 | 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
|
152 | (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
|
153 | |
|
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 | 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
|
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 | |
|
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 | 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
|
158 | 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
|
159 | 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
|
160 | 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
|
161 | |
|
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_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
|
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 | 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
|
165 | } |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
166 | |
|
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
|
167 | 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
|
168 | 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
|
169 | 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
|
170 | 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
|
171 | |
|
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_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
|
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 | 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
|
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 | |
|
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 | 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
|
178 | 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
|
179 | 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
|
180 | 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
|
181 | 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
|
182 | |
|
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_strfreev(parts); |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
184 | |
|
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
|
185 | 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
|
186 | } |
|
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 | |
|
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 | /* 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
|
189 | g_strfreev(parts); |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
190 | |
|
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
|
191 | 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
|
192 | 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
|
193 | 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
|
194 | |
|
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 | 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
|
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 | 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
|
198 | 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
|
199 | 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
|
200 | 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
|
201 | g_object_ref(conversation)); |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
202 | } |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
203 | } |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
204 | |
|
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
|
205 | static GActionEntry conversation_entries[] = { |
|
41482
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 | .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
|
208 | .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
|
209 | .parameter_type = "s", |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
210 | } |
|
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
211 | }; |
|
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 | /****************************************************************************** |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
214 | * Callbacks |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
215 | *****************************************************************************/ |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
216 | 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
|
217 | 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
|
218 | guint keyval, |
|
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
219 | 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
|
220 | GdkModifierType state, |
|
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
221 | gpointer data) |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
222 | { |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
223 | 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
|
224 | |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
225 | 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
|
226 | switch (keyval) { |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
227 | 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
|
228 | 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
|
229 | case ']': |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
230 | 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
|
231 | return TRUE; |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
232 | break; |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
233 | case GDK_KEY_Home: |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
234 | pidgin_display_window_select_first(window); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
235 | return TRUE; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
236 | break; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
237 | case GDK_KEY_End: |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
238 | pidgin_display_window_select_last(window); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
239 | return TRUE; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
240 | break; |
|
41186
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
241 | 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
|
242 | 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
|
243 | case '[': |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
244 | 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
|
245 | return TRUE; |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
246 | break; |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
247 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
248 | } 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
|
249 | 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
|
250 | 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
|
251 | 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
|
252 | |
|
f8275d257afe
Move conversation window key handling into its file
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41184
diff
changeset
|
253 | return TRUE; |
|
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 | } |
|
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 | return FALSE; |
|
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 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
260 | static void |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
261 | 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
|
262 | G_GNUC_UNUSED GParamSpec *pspec, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
263 | gpointer data) |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
264 | { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
265 | PidginDisplayItem *item = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
266 | PidginDisplayWindow *window = data; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
267 | GtkSingleSelection *selection = GTK_SINGLE_SELECTION(self); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
268 | GtkTreeListRow *row = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
269 | GtkWidget *widget = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
270 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
271 | row = gtk_single_selection_get_selected_item(selection); |
|
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 | item = gtk_tree_list_row_get_item(row); |
|
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 | widget = pidgin_display_item_get_widget(item); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
276 | if(GTK_IS_WIDGET(widget)) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
277 | 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
|
278 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
279 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
280 | |
|
42559
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
281 | static void |
|
43032
82caf56f970d
Update Pidgin to use the new Purple.ConversationManager signals
Gary Kramlich <grim@reaperworld.com>
parents:
43031
diff
changeset
|
282 | pidgin_display_window_conversation_added_cb(G_GNUC_UNUSED PurpleConversationManager *manager, |
|
82caf56f970d
Update Pidgin to use the new Purple.ConversationManager signals
Gary Kramlich <grim@reaperworld.com>
parents:
43031
diff
changeset
|
283 | PurpleConversation *conversation, |
|
82caf56f970d
Update Pidgin to use the new Purple.ConversationManager signals
Gary Kramlich <grim@reaperworld.com>
parents:
43031
diff
changeset
|
284 | gpointer data) |
|
42559
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
285 | { |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
286 | PidginDisplayWindow *window = 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 | pidgin_display_window_add(window, conversation); |
|
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 | |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
291 | static void |
|
43032
82caf56f970d
Update Pidgin to use the new Purple.ConversationManager signals
Gary Kramlich <grim@reaperworld.com>
parents:
43031
diff
changeset
|
292 | pidgin_display_window_conversation_removed_cb(G_GNUC_UNUSED PurpleConversationManager *manager, |
|
82caf56f970d
Update Pidgin to use the new Purple.ConversationManager signals
Gary Kramlich <grim@reaperworld.com>
parents:
43031
diff
changeset
|
293 | PurpleConversation *conversation, |
|
82caf56f970d
Update Pidgin to use the new Purple.ConversationManager signals
Gary Kramlich <grim@reaperworld.com>
parents:
43031
diff
changeset
|
294 | gpointer data) |
|
42559
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
295 | { |
|
7bde7363e0f3
Fix opening of conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42554
diff
changeset
|
296 | PidginDisplayWindow *window = 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 | pidgin_display_window_remove(window, conversation); |
|
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 | |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
301 | static void |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
302 | pidgin_display_window_conversation_present_cb(PurpleConversation *conversation, |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
303 | gpointer data) |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
304 | { |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
305 | pidgin_display_window_select(data, conversation); |
|
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 | |
|
42797
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
308 | static gboolean |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
309 | 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
|
310 | PidginDisplayItem *item, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
311 | G_GNUC_UNUSED gpointer data) |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
312 | { |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
313 | GMenuModel *model = NULL; |
|
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 | if(!PIDGIN_IS_DISPLAY_ITEM(item)) { |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
316 | return FALSE; |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
317 | } |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
318 | |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
319 | model = pidgin_display_item_get_menu(item); |
|
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 | return G_IS_MENU_MODEL(model); |
|
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 | |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
324 | static char * |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
325 | 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
|
326 | gboolean item_selected, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
327 | gboolean item_contains_pointer, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
328 | gboolean menu_button_active, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
329 | G_GNUC_UNUSED gpointer data) |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
330 | { |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
331 | if(item_selected || item_contains_pointer || menu_button_active) { |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
332 | return g_strdup("actions"); |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
333 | } |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
334 | |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
335 | return g_strdup("notifications"); |
|
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 | |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
338 | /****************************************************************************** |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
339 | * GObject Implementation |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
340 | *****************************************************************************/ |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
341 | static void |
|
42215
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
342 | 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
|
343 | 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
|
344 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
345 | g_clear_object(&window->conversation_model); |
|
42215
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
346 | 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
|
347 | |
|
42215
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
348 | 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
|
349 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
350 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
351 | static void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
352 | 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
|
353 | GtkEventController *key = NULL; |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
354 | 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
|
355 | GSimpleActionGroup *conversation_actions = NULL; |
|
42597
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
356 | GPluginManager *plugin_manager = NULL; |
|
43079
82415d67612f
Move default window tracking to the application
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43032
diff
changeset
|
357 | PurpleConversationManager *conversation_manager = NULL; |
|
42597
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
358 | 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
|
359 | |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
360 | gtk_widget_init_template(GTK_WIDGET(window)); |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
361 | |
|
42215
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
362 | /* 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
|
363 | * 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
|
364 | * during destruction. |
|
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
365 | */ |
|
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
366 | g_object_ref(window->selection_model); |
|
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
367 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
368 | /* Setup the tree list model. */ |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
369 | 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
|
370 | FALSE, TRUE, |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
371 | (GtkTreeListModelCreateModelFunc)pidgin_display_window_create_model, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
372 | window, NULL); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
373 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
374 | /* 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
|
375 | 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
|
376 | G_LIST_MODEL(tree_model)); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
377 | g_clear_object(&tree_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
378 | |
|
43080
dd2d26e6c6f9
Set the application on all windows
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43079
diff
changeset
|
379 | /* Add all of our actions. */ |
|
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
|
380 | 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
|
381 | 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
|
382 | 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
|
383 | 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
|
384 | 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
|
385 | 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
|
386 | 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
|
387 | g_clear_object(&conversation_actions); |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
388 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
389 | /* 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
|
390 | 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
|
391 | 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
|
392 | 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
|
393 | 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
|
394 | window); |
|
41560
2579a5138f0c
A bunch of random fixes for the the gtk4 branch
Gary Kramlich <grim@reaperworld.com>
parents:
41527
diff
changeset
|
395 | 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
|
396 | |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
397 | /* Set up the plugin list. */ |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
398 | plugin_manager = gplugin_manager_get_default(); |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
399 | 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
|
400 | plugin_manager); |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
401 | |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
402 | settings_backend = purple_core_get_settings_backend(); |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
403 | 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
|
404 | settings_backend); |
|
43079
82415d67612f
Move default window tracking to the application
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43032
diff
changeset
|
405 | |
|
82415d67612f
Move default window tracking to the application
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43032
diff
changeset
|
406 | conversation_manager = purple_conversation_manager_get_default(); |
|
82415d67612f
Move default window tracking to the application
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43032
diff
changeset
|
407 | g_signal_connect_object(conversation_manager, "added", |
|
82415d67612f
Move default window tracking to the application
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43032
diff
changeset
|
408 | G_CALLBACK(pidgin_display_window_conversation_added_cb), |
|
82415d67612f
Move default window tracking to the application
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43032
diff
changeset
|
409 | window, 0); |
|
82415d67612f
Move default window tracking to the application
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43032
diff
changeset
|
410 | g_signal_connect_object(conversation_manager, "removed", |
|
82415d67612f
Move default window tracking to the application
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43032
diff
changeset
|
411 | G_CALLBACK(pidgin_display_window_conversation_removed_cb), |
|
82415d67612f
Move default window tracking to the application
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43032
diff
changeset
|
412 | window, 0); |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
413 | } |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
414 | |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
415 | static void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
416 | 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
|
417 | GObjectClass *obj_class = G_OBJECT_CLASS(klass); |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
418 | GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
419 | |
|
42215
a0108bfcb108
Reference the selection_model in PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42202
diff
changeset
|
420 | 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
|
421 | |
|
41479
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41476
diff
changeset
|
422 | /** |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
423 | * PidginDisplayWindow::conversation-switched: |
|
41479
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41476
diff
changeset
|
424 | * @window: The conversation window. |
|
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41476
diff
changeset
|
425 | * @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
|
426 | * |
|
3d2e114380f6
Add source files to GObject introspection
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41476
diff
changeset
|
427 | * 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
|
428 | */ |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
429 | 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
|
430 | "conversation-switched", |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
431 | G_OBJECT_CLASS_TYPE(obj_class), |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
432 | G_SIGNAL_RUN_LAST, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
433 | NULL, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
434 | NULL, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
435 | NULL, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
436 | NULL, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
437 | G_TYPE_NONE, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
438 | 1, |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
439 | PURPLE_TYPE_CONVERSATION |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
440 | ); |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
441 | |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
442 | gtk_widget_class_set_template_from_resource( |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
443 | widget_class, |
|
42762
17f602456139
Move Display/window.ui to display-window.ui
Gary Kramlich <grim@reaperworld.com>
parents:
42714
diff
changeset
|
444 | "/im/pidgin/Pidgin3/display-window.ui" |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
445 | ); |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
446 | |
|
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, |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
448 | view); |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
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 | bin); |
|
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, |
|
42597
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
452 | plugin_list); |
|
cc322d213d2e
Add the Plugins list to the PidginDisplayWindow
Gary Kramlich <grim@reaperworld.com>
parents:
42575
diff
changeset
|
453 | 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
|
454 | base_model); |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
455 | 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
|
456 | selection_model); |
|
41849
413cde086275
Add a placeholder to PidginDisplayWindow for the ContactList
Gary Kramlich <grim@reaperworld.com>
parents:
41702
diff
changeset
|
457 | 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
|
458 | 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
|
459 | 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
|
460 | conversations_item); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
461 | 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
|
462 | conversation_model); |
|
41527
4dff8cd4e9ea
Convert PidginConversationWindow to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41484
diff
changeset
|
463 | |
|
4dff8cd4e9ea
Convert PidginConversationWindow to GTK4
Gary Kramlich <grim@reaperworld.com>
parents:
41484
diff
changeset
|
464 | 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
|
465 | pidgin_display_window_key_pressed_cb); |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
466 | gtk_widget_class_bind_template_callback(widget_class, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
467 | pidgin_display_window_selected_item_changed_cb); |
|
42797
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
468 | gtk_widget_class_bind_template_callback(widget_class, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
469 | pidgin_display_window_show_item_menu_cb); |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
470 | gtk_widget_class_bind_template_callback(widget_class, |
|
767b7685a4a4
Add a menu to PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42795
diff
changeset
|
471 | pidgin_display_window_show_item_actions_cb); |
|
40577
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 | |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
474 | /****************************************************************************** |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
475 | * API |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
476 | *****************************************************************************/ |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
477 | GtkWidget * |
|
43080
dd2d26e6c6f9
Set the application on all windows
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43079
diff
changeset
|
478 | pidgin_display_window_new(GtkApplication *application) { |
|
41582
4ee4a8ddc190
Explicitly set show-menubar so our menubars are shown
Gary Kramlich <grim@reaperworld.com>
parents:
41560
diff
changeset
|
479 | 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
|
480 | PIDGIN_TYPE_DISPLAY_WINDOW, |
|
43080
dd2d26e6c6f9
Set the application on all windows
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
43079
diff
changeset
|
481 | "application", application, |
|
41582
4ee4a8ddc190
Explicitly set show-menubar so our menubars are shown
Gary Kramlich <grim@reaperworld.com>
parents:
41560
diff
changeset
|
482 | "show-menubar", TRUE, |
|
4ee4a8ddc190
Explicitly set show-menubar so our menubars are shown
Gary Kramlich <grim@reaperworld.com>
parents:
41560
diff
changeset
|
483 | NULL); |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
484 | } |
|
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
485 | |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
486 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
487 | pidgin_display_window_add(PidginDisplayWindow *window, |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
488 | PurpleConversation *purple_conversation) |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
489 | { |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
490 | 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
|
491 | const char *conversation_id = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
492 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
493 | 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
|
494 | 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
|
495 | |
|
42609
648a1b5dd96a
use a globally unique id when creating new Pidgin::DisplayItem's
Markus Fischer <ivanhoe@fiscari.de>
parents:
42597
diff
changeset
|
496 | 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
|
497 | 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
|
498 | |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
499 | 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
|
500 | |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
501 | if(!PIDGIN_IS_CONVERSATION(pidgin_conversation)) { |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
502 | pidgin_conversation = pidgin_conversation_new(purple_conversation); |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
503 | } |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
504 | |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
505 | if(PIDGIN_IS_CONVERSATION(pidgin_conversation)) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
506 | 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
|
507 | 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
|
508 | 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
|
509 | char *id = NULL; |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
510 | gboolean item_exists = FALSE; |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
511 | |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
512 | 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
|
513 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
514 | if(GTK_IS_WIDGET(parent)) { |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
515 | g_object_ref(pidgin_conversation); |
|
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
516 | gtk_widget_unparent(pidgin_conversation); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
517 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
518 | |
|
42804
be8c8b5471ca
Update pidgin to use get id and username directly on PurpleAccount
Gary Kramlich <grim@reaperworld.com>
parents:
42798
diff
changeset
|
519 | 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
|
520 | 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
|
521 | item_exists = |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
522 | 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
|
523 | NULL, |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
524 | 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
|
525 | id, |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
526 | NULL); |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
527 | if (!item_exists) { |
|
42766
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
528 | 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
|
529 | GMenu *menu = NULL; |
|
42766
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
530 | const char *icon_name = NULL; |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
531 | |
|
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
|
532 | 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
|
533 | 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
|
534 | |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
535 | 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
|
536 | 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
|
537 | 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
|
538 | 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
|
539 | |
|
42766
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
540 | protocol = purple_account_get_protocol(account); |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
541 | icon_name = purple_protocol_get_icon_name(protocol); |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
542 | if(!purple_strempty(icon_name)) { |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
543 | pidgin_display_item_set_icon_name(item, icon_name); |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
544 | } |
|
d823c3372e97
Some cleanups for PidginDisplayItem
Gary Kramlich <grim@reaperworld.com>
parents:
42762
diff
changeset
|
545 | |
|
42774
4858aea578c4
Bind the Pidgin.DisplayItem:title property to Purple.Conversation:title-for-display
Gary Kramlich <grim@reaperworld.com>
parents:
42766
diff
changeset
|
546 | 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
|
547 | 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
|
548 | G_BINDING_SYNC_CREATE); |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
549 | |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
550 | g_signal_connect_object(purple_conversation, "present", |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
551 | G_CALLBACK(pidgin_display_window_conversation_present_cb), |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
552 | window, G_CONNECT_DEFAULT); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
553 | |
|
42625
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
554 | 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
|
555 | g_clear_object(&item); |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
556 | } |
|
36732747258f
Only open new conversations if they are not already open
Markus Fischer <ivanhoe@fiscari.de>
parents:
42609
diff
changeset
|
557 | g_free(id); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
558 | if(GTK_IS_WIDGET(parent)) { |
|
42301
d3930fe5505c
The start of the new conversation window
Gary Kramlich <grim@reaperworld.com>
parents:
42295
diff
changeset
|
559 | g_object_unref(pidgin_conversation); |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
560 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
561 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
562 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
563 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
564 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
565 | 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
|
566 | PurpleConversation *conversation) |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
567 | { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
568 | PidginDisplayItem *item = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
569 | guint position = 0; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
570 | gboolean found = FALSE; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
571 | gchar *id = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
572 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
573 | 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
|
574 | 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
|
575 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
576 | /* Create a wrapper item for our find function. */ |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
577 | id = g_uuid_string_random(); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
578 | 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
|
579 | g_free(id); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
580 | 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
|
581 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
582 | 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
|
583 | item, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
584 | pidgin_display_window_find_conversation, |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
585 | &position); |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
586 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
587 | g_clear_object(&item); |
|
41482
c51a28d28a2d
Start implementing the conversation window actions.
Gary Kramlich <grim@reaperworld.com>
parents:
41479
diff
changeset
|
588 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
589 | if(found) { |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
590 | g_signal_handlers_disconnect_by_func(conversation, |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
591 | G_CALLBACK(pidgin_display_window_conversation_present_cb), |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
592 | window); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
593 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
594 | g_list_store_remove(window->conversation_model, position); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
595 | } |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
596 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
597 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
598 | guint |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
599 | 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
|
600 | /* 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
|
601 | * 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
|
602 | * this is now. |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
603 | */ |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
604 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
605 | return 0; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
606 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
607 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
608 | PurpleConversation * |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
609 | pidgin_display_window_get_selected(PidginDisplayWindow *window) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
610 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
611 | GtkTreeListRow *tree_row = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
612 | GObject *selected = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
613 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
614 | 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
|
615 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
616 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
617 | 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
|
618 | 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
|
619 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
620 | if(PIDGIN_IS_DISPLAY_ITEM(selected)) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
621 | 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
|
622 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
623 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
624 | return NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
625 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
626 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
627 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
628 | 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
|
629 | PurpleConversation *conversation) |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
630 | { |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
631 | PidginDisplayItem *item = NULL; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
632 | guint position = 0; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
633 | gboolean found = FALSE; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
634 | gchar *id = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
635 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
636 | 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
|
637 | g_return_if_fail(PURPLE_IS_CONVERSATION(conversation)); |
|
42795
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
638 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
639 | /* Create a wrapper item for our find function. */ |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
640 | id = g_uuid_string_random(); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
641 | 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
|
642 | g_free(id); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
643 | g_object_set_data(G_OBJECT(item), "conversation", conversation); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
644 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
645 | 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
|
646 | item, |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
647 | pidgin_display_window_find_conversation, |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
648 | &position); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
649 | g_clear_object(&item); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
650 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
651 | if(found) { |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
652 | /* 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
|
653 | * that position. |
|
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 | guint conversations_position = 0; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
656 | guint real_position = 0; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
657 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
658 | 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
|
659 | &conversations_position); |
|
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 | /* 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
|
662 | * the correct item. |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
663 | */ |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
664 | real_position = conversations_position + position + 1; |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
665 | |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
666 | 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
|
667 | real_position); |
|
fedfa85c0b40
Implement presenting and selecting conversations
Gary Kramlich <grim@reaperworld.com>
parents:
42774
diff
changeset
|
668 | } |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
669 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
670 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
671 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
672 | pidgin_display_window_select_previous(PidginDisplayWindow *window) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
673 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
674 | guint position = 0; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
675 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
676 | 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
|
677 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
678 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
679 | position = gtk_single_selection_get_selected(selection); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
680 | if(position == 0) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
681 | 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
|
682 | } else { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
683 | position = position - 1; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
684 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
685 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
686 | gtk_single_selection_set_selected(selection, position); |
|
40577
953d563429b8
Create a new PidginConversationWindow widget
Gary Kramlich <grim@reaperworld.com>
parents:
diff
changeset
|
687 | } |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
688 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
689 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
690 | pidgin_display_window_select_next(PidginDisplayWindow *window) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
691 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
692 | guint position = 0; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
693 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
694 | 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
|
695 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
696 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
697 | position = gtk_single_selection_get_selected(selection); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
698 | 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
|
699 | position = 0; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
700 | } else { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
701 | position = position + 1; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
702 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
703 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
704 | 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
|
705 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
706 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
707 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
708 | pidgin_display_window_select_first(PidginDisplayWindow *window) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
709 | GtkSingleSelection *selection = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
710 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
711 | 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
|
712 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
713 | 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
|
714 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
715 | /* 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
|
716 | * this is an invalid value. |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
717 | */ |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
718 | 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
|
719 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
720 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
721 | void |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
722 | pidgin_display_window_select_last(PidginDisplayWindow *window) { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
723 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
724 | guint n_items = 0; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
725 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
726 | 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
|
727 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
728 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
729 | 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
|
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, n_items - 1); |
|
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_nth(PidginDisplayWindow *window, |
|
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
739 | guint nth) |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
740 | { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
741 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
742 | guint n_items = 0; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
743 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
744 | 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
|
745 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
746 | 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
|
747 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
748 | /* 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
|
749 | * 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
|
750 | */ |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
751 | 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
|
752 | if(nth < n_items) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
753 | 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
|
754 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
755 | } |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
756 | |
|
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
757 | gboolean |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
758 | 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
|
759 | PurpleConversation *conversation) |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
760 | { |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
761 | GtkSingleSelection *selection = NULL; |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
762 | GObject *selected = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
763 | |
|
41696
35f8ce475b21
Rename PidginConversationWindow to PidginDisplayWindow as it holds more than conversations now
Gary Kramlich <grim@reaperworld.com>
parents:
41582
diff
changeset
|
764 | 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
|
765 | 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
|
766 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
767 | selection = GTK_SINGLE_SELECTION(window->selection_model); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
768 | selected = gtk_single_selection_get_selected_item(selection); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
769 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
770 | if(PIDGIN_IS_DISPLAY_ITEM(selected)) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
771 | PurpleConversation *selected_conversation = NULL; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
772 | |
|
42050
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
773 | 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
|
774 | "conversation"); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
775 | if(selected_conversation != NULL) { |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
776 | return (selected_conversation == conversation); |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
777 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
778 | } |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
779 | |
|
5ac6db2b8c2d
Make the DisplayWindow use a GtkListView
Gary Kramlich <grim@reaperworld.com>
parents:
41947
diff
changeset
|
780 | return FALSE; |
|
41184
05b5c210352b
Move conversation management from gtkconv.c to PidginConversationWindow.
Gary Kramlich <grim@reaperworld.com>
parents:
41030
diff
changeset
|
781 | } |