annotate src/gtksavedstatuses.c @ 13853:bbf0470cb348

[gaim-migrate @ 16312] Improvement/fixing of GntTree. Do the scrolling and stuff without 'reliably'. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 23 Jun 2006 00:45:45 +0000
parents f1dd1555b39c
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1 /**
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
2 * @file gtksavedstatus.c GTK+ Saved Status Editor UI
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
3 * @ingroup gtkui
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
4 *
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
5 * gaim
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
6 *
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
9 * source distribution.
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
10 *
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
14 * (at your option) any later version.
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
15 *
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
19 * GNU General Public License for more details.
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
20 *
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
24 */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
25
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
26 #include "account.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
27 #include "internal.h"
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
28 #include "notify.h"
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
29 #include "request.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
30 #include "savedstatuses.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
31 #include "status.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
32 #include "util.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
33
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
34 #include "gtkblist.h"
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
35 #include "gtkexpander.h"
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
36 #include "gtkgaim.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
37 #include "gtkimhtml.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
38 #include "gtkimhtmltoolbar.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
39 #include "gtksavedstatuses.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
40 #include "gtkstock.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
41 #include "gtkutils.h"
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
42
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
43 /*
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
44 * TODO: Should attach to the account-deleted and account-added signals
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
45 * and update the GtkListStores in any StatusEditor windows that
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
46 * may be open.
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
47 */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
48
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
49 /**
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
50 * These are used for the GtkTreeView when you're scrolling through
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
51 * all your saved statuses.
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
52 */
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
53 enum
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
54 {
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
55 STATUS_WINDOW_COLUMN_TITLE,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
56 STATUS_WINDOW_COLUMN_TYPE,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
57 STATUS_WINDOW_COLUMN_MESSAGE,
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
58 /** A hidden column containing a pointer to the editor for this saved status. */
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
59 STATUS_WINDOW_COLUMN_WINDOW,
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
60 STATUS_WINDOW_NUM_COLUMNS
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
61 };
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
62
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
63 /**
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
64 * These is used for the GtkTreeView containing the list of accounts
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
65 * at the bottom of the window when you're editing a particular
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
66 * saved status.
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
67 */
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
68 enum
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
69 {
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
70 /** A hidden column containing a pointer to the GaimAccount. */
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
71 STATUS_EDITOR_COLUMN_ACCOUNT,
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
72 /** A hidden column containing a pointer to the editor for this substatus. */
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
73 STATUS_EDITOR_COLUMN_WINDOW,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
74 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 STATUS_EDITOR_COLUMN_ICON,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
76 STATUS_EDITOR_COLUMN_SCREENNAME,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
77 /** A hidden column containing the ID of this GaimStatusType. */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
78 STATUS_EDITOR_COLUMN_STATUS_ID,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
79 STATUS_EDITOR_COLUMN_STATUS_NAME,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
80 STATUS_EDITOR_COLUMN_STATUS_MESSAGE,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
81 STATUS_EDITOR_NUM_COLUMNS
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
82 };
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
83
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
84 /**
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
85 * These are used in the GtkComboBox to select the specific
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
86 * GaimStatusType when setting a substatus for a particular saved
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
87 * status.
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
88 */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
89 enum
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
90 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
91 SUBSTATUS_COLUMN_ICON,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
92 /** A hidden column containing the ID of this GaimStatusType. */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
93 SUBSTATUS_COLUMN_STATUS_ID,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
94 SUBSTATUS_COLUMN_STATUS_NAME,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
95 SUBSTATUS_NUM_COLUMNS
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
96 };
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
97
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
98 typedef struct
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
99 {
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
100 GtkWidget *window;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
101 GtkListStore *model;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
102 GtkWidget *treeview;
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
103 GtkWidget *use_button;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
104 GtkWidget *modify_button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
105 GtkWidget *delete_button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
106 } StatusWindow;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
107
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
108 typedef struct
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
109 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
110 GtkWidget *window;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
111 GtkListStore *model;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
112 GtkWidget *treeview;
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
113 GtkButton *saveanduse_button;
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
114 GtkButton *save_button;
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
115
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
116 gchar *original_title;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
117 GtkEntry *title;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
118 GtkOptionMenu *type;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
119 GtkIMHtml *message;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
120 } StatusEditor;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
121
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
122 typedef struct
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
123 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
124 StatusEditor *status_editor;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
125 GaimAccount *account;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
126
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
127 GtkWidget *window;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
128 GtkListStore *model;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
129 GtkComboBox *box;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
130 GtkIMHtml *message;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
131 GtkIMHtmlToolbar *toolbar;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
132 } SubStatusEditor;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
133
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
134 static StatusWindow *status_window = NULL;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
135
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
136
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
137 /**************************************************************************
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
138 * Status window
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
139 **************************************************************************/
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
140
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
141 static gboolean
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
142 status_window_find_savedstatus(GtkTreeIter *iter, const char *title)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
143 {
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
144 GtkTreeModel *model;
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
145 char *cur;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
146
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
147 if ((status_window == NULL) || (title == NULL))
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
148 return FALSE;
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
149
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
150 model = GTK_TREE_MODEL(status_window->model);
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
151
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
152 if (!gtk_tree_model_get_iter_first(model, iter))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
153 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
154
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
155 do {
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
156 gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &cur, -1);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
157 if (!strcmp(title, cur))
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
158 {
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
159 g_free(cur);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
160 return TRUE;
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
161 }
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
162 g_free(cur);
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
163 } while (gtk_tree_model_iter_next(model, iter));
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
164
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
165 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
166 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
167
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
168 static gboolean
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
169 status_window_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
170 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
171 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
172
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
173 dialog->window = NULL;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
174 gaim_gtk_status_window_hide();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
175
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
176 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
177 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
178
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
179 #if !GTK_CHECK_VERSION(2,2,0)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
180 static void
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
181 count_selected_helper(GtkTreeModel *model, GtkTreePath *path,
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
182 GtkTreeIter *iter, gpointer user_data)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
183 {
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
184 (*(gint *)user_data)++;
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
185 }
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
186
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
187 static void
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
188 list_selected_helper(GtkTreeModel *model, GtkTreePath *path,
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
189 GtkTreeIter *iter, gpointer user_data)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
190 {
11889
04c2c3d84849 [gaim-migrate @ 14180]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11888
diff changeset
191 GList **list = (GList **)user_data;
04c2c3d84849 [gaim-migrate @ 14180]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11888
diff changeset
192 *list = g_list_append(*list, gtk_tree_path_copy(path));
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
193 }
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
194 #endif
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
195
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
196 static void
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
197 status_window_use_cb(GtkButton *button, StatusWindow *dialog)
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
198 {
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
199 GtkTreeSelection *selection;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
200 GtkTreeIter iter;
11889
04c2c3d84849 [gaim-migrate @ 14180]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11888
diff changeset
201 GList *list = NULL;
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
202 int num_selected = 0;
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
203
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
204 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
205
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
206 #if GTK_CHECK_VERSION(2,2,0)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
207 num_selected = gtk_tree_selection_count_selected_rows(selection);
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
208 #else
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
209 gtk_tree_selection_selected_foreach(selection, count_selected_helper, &num_selected);
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
210 #endif
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
211 if (num_selected != 1)
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
212 /*
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
213 * This shouldn't happen because the "Use" button should have
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
214 * been grayed out. Oh well.
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
215 */
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
216 return;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
217
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
218 #if GTK_CHECK_VERSION(2,2,0)
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
219 list = gtk_tree_selection_get_selected_rows(selection, NULL);
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
220 #else
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
221 gtk_tree_selection_selected_foreach(selection, list_selected_helper, &list);
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
222 #endif
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
223
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
224 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model),
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
225 &iter, list->data))
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
226 {
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
227 gchar *title;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
228 GaimSavedStatus *saved_status;
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
229 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
230 STATUS_WINDOW_COLUMN_TITLE, &title,
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
231 -1);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
232 saved_status = gaim_savedstatus_find(title);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
233 g_free(title);
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
234 gaim_savedstatus_activate(saved_status);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
235 }
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
236
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
237 g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
238 g_list_free(list);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
239 }
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
240
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
241 static void
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
242 status_window_add_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
243 {
13175
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
244 gaim_gtk_status_editor_show(FALSE, NULL);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
245 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
246
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
247 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
248 status_window_modify_foreach(GtkTreeModel *model, GtkTreePath *path,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
249 GtkTreeIter *iter, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
250 {
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
251 gchar *title;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
252 GaimSavedStatus *saved_status;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
253
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
254 gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &title, -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
255 saved_status = gaim_savedstatus_find(title);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
256 g_free(title);
13175
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
257 gaim_gtk_status_editor_show(TRUE, saved_status);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
258 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
259
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
260 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
261 status_window_modify_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
262 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
263 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
264 GtkTreeSelection *selection;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
265
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
266 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
267
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
268 gtk_tree_selection_selected_foreach(selection, status_window_modify_foreach, user_data);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
269 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
270
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
271 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
272 status_window_delete_confirm_cb(char *title)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
273 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
274 GtkTreeIter iter;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
275
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
276 if (status_window_find_savedstatus(&iter, title))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
277 gtk_list_store_remove(status_window->model, &iter);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
278
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
279 gaim_savedstatus_delete(title);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
280
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
281 g_free(title);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
282 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
283
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
284 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
285 status_window_delete_foreach(GtkTreeModel *model, GtkTreePath *path,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
286 GtkTreeIter *iter, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
287 {
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
288 char *title;
12237
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
289 char *buf;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
290
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
291 gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_TITLE, &title, -1);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
292
12237
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
293 buf = g_strdup_printf(_("Are you sure you want to delete %s?"), title);
12888
03f690fcb78e [gaim-migrate @ 15241]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12856
diff changeset
294 gaim_request_action(status_window, NULL, buf, NULL, 0, title, 2,
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
295 _("Delete"), status_window_delete_confirm_cb,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
296 _("Cancel"), g_free);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
297 g_free(buf);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
298 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
299
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
300 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
301 status_window_delete_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
302 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
303 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
304 GtkTreeSelection *selection;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
305
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
306 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
307
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
308 gtk_tree_selection_selected_foreach(selection, status_window_delete_foreach, user_data);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
309 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
310
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
311 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
312 status_window_close_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
313 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
314 gaim_gtk_status_window_hide();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
315 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
316
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
317 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
318 status_selected_cb(GtkTreeSelection *sel, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
319 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
320 StatusWindow *dialog = user_data;
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
321 int num_selected = 0;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
322
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
323 #if GTK_CHECK_VERSION(2,2,0)
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
324 num_selected = gtk_tree_selection_count_selected_rows(sel);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
325 #else
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
326 gtk_tree_selection_selected_foreach(sel, count_selected_helper, &num_selected);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
327 #endif
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
328
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
329 gtk_widget_set_sensitive(dialog->use_button, (num_selected == 1));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
330 gtk_widget_set_sensitive(dialog->modify_button, (num_selected > 0));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
331 gtk_widget_set_sensitive(dialog->delete_button, (num_selected > 0));
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
332 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
333
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
334 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
335 add_status_to_saved_status_list(GtkListStore *model, GaimSavedStatus *saved_status)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
336 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
337 GtkTreeIter iter;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
338 const char *title;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
339 const char *type;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
340 char *message;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
341
11651
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
342 if (gaim_savedstatus_is_transient(saved_status))
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
343 return;
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
344
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
345 title = gaim_savedstatus_get_title(saved_status);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
346 type = gaim_primitive_get_name_from_type(gaim_savedstatus_get_type(saved_status));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
347 message = gaim_markup_strip_html(gaim_savedstatus_get_message(saved_status));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
348
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
349 gtk_list_store_append(model, &iter);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
350 gtk_list_store_set(model, &iter,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
351 STATUS_WINDOW_COLUMN_TITLE, title,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
352 STATUS_WINDOW_COLUMN_TYPE, type,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
353 STATUS_WINDOW_COLUMN_MESSAGE, message,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
354 -1);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
355 free(message);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
356 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
357
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
358 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
359 populate_saved_status_list(StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
360 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
361 const GList *saved_statuses;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
362
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
363 gtk_list_store_clear(dialog->model);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
364
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
365 for (saved_statuses = gaim_savedstatuses_get_all(); saved_statuses != NULL;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
366 saved_statuses = g_list_next(saved_statuses))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
367 {
12199
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
368 add_status_to_saved_status_list(dialog->model, saved_statuses->data);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
369 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
370 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
371
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
372 static gboolean
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
373 search_func(GtkTreeModel *model, gint column, const gchar *key, GtkTreeIter *iter, gpointer search_data)
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
374 {
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
375 gboolean result;
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
376 char *haystack;
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
377
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
378 gtk_tree_model_get(model, iter, column, &haystack, -1);
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
379
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
380 result = (gaim_strcasestr(haystack, key) == NULL);
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
381
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
382 g_free(haystack);
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
383
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
384 return result;
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
385 }
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
386
12162
5e24b8e49522 [gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents: 12080
diff changeset
387 static void
12173
81c63578aa39 [gaim-migrate @ 14475]
Richard Laager <rlaager@wiktel.com>
parents: 12162
diff changeset
388 savedstatus_activated_cb(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, StatusWindow *dialog)
12162
5e24b8e49522 [gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents: 12080
diff changeset
389 {
12173
81c63578aa39 [gaim-migrate @ 14475]
Richard Laager <rlaager@wiktel.com>
parents: 12162
diff changeset
390 status_window_modify_cb(NULL, dialog);
12162
5e24b8e49522 [gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents: 12080
diff changeset
391 }
5e24b8e49522 [gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents: 12080
diff changeset
392
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
393 static GtkWidget *
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
394 create_saved_status_list(StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
395 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
396 GtkWidget *sw;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
397 GtkWidget *treeview;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
398 GtkTreeSelection *sel;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
399 GtkTreeViewColumn *column;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
400 GtkCellRenderer *renderer;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
401
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
402 /* Create the scrolled window */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
403 sw = gtk_scrolled_window_new(0, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
404 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
405 GTK_POLICY_AUTOMATIC,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
406 GTK_POLICY_ALWAYS);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
407 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
408 GTK_SHADOW_IN);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
409
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
410 /* Create the list model */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
411 dialog->model = gtk_list_store_new(STATUS_WINDOW_NUM_COLUMNS,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
412 G_TYPE_STRING,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
413 G_TYPE_STRING,
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
414 G_TYPE_STRING,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
415 G_TYPE_POINTER);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
416
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
417 /* Create the treeview */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
418 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
419 dialog->treeview = treeview;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
420 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
12162
5e24b8e49522 [gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents: 12080
diff changeset
421 g_signal_connect(G_OBJECT(treeview), "row-activated",
12173
81c63578aa39 [gaim-migrate @ 14475]
Richard Laager <rlaager@wiktel.com>
parents: 12162
diff changeset
422 G_CALLBACK(savedstatus_activated_cb), dialog);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
423
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
424 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
425 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
426 g_signal_connect(G_OBJECT(sel), "changed",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
427 G_CALLBACK(status_selected_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
428
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
429 gtk_container_add(GTK_CONTAINER(sw), treeview);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
430
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
431 /* Add columns */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
432 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
433 gtk_tree_view_column_set_title(column, _("Title"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
434 gtk_tree_view_column_set_resizable(column, TRUE);
11548
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
435 gtk_tree_view_column_set_min_width(column, 100);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
436 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
437 STATUS_WINDOW_COLUMN_TITLE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
438 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
439 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
440 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
441 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
442 STATUS_WINDOW_COLUMN_TITLE);
11548
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
443 #if GTK_CHECK_VERSION(2,6,0)
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
444 g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
445 #endif
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
446
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
447 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
448 gtk_tree_view_column_set_title(column, _("Type"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
449 gtk_tree_view_column_set_resizable(column, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
450 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
451 STATUS_WINDOW_COLUMN_TYPE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
452 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
453 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
454 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
455 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
456 STATUS_WINDOW_COLUMN_TYPE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
457
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
458 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
459 gtk_tree_view_column_set_title(column, _("Message"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
460 gtk_tree_view_column_set_resizable(column, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
461 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
462 STATUS_WINDOW_COLUMN_MESSAGE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
463 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
464 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
465 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
466 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
467 STATUS_WINDOW_COLUMN_MESSAGE);
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
468 #if GTK_CHECK_VERSION(2,6,0)
10502
6cd5cca9c451 [gaim-migrate @ 11794]
Sean Egan <seanegan@gmail.com>
parents: 10439
diff changeset
469 g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
470 #endif
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
471
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
472 /* Enable CTRL+F searching */
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
473 gtk_tree_view_set_search_column(GTK_TREE_VIEW(treeview), STATUS_WINDOW_COLUMN_TITLE);
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
474 gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(treeview), search_func, NULL, NULL);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
475
10422
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
476 /* Sort the title column by default */
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
477 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(dialog->model),
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
478 STATUS_WINDOW_COLUMN_TITLE,
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
479 GTK_SORT_ASCENDING);
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
480
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
481 /* Populate list */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
482 populate_saved_status_list(dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
483
13199
d8f238864c88 [gaim-migrate @ 15562]
Mark Doliner <mark@kingant.net>
parents: 13194
diff changeset
484 gtk_widget_show_all(sw);
d8f238864c88 [gaim-migrate @ 15562]
Mark Doliner <mark@kingant.net>
parents: 13194
diff changeset
485
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
486 return sw;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
487 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
488
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
489 static gboolean
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
490 configure_cb(GtkWidget *widget, GdkEventConfigure *event, StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
491 {
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
492 if (GTK_WIDGET_VISIBLE(widget))
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
493 {
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
494 gaim_prefs_set_int("/gaim/gtk/status/dialog/width", event->width);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
495 gaim_prefs_set_int("/gaim/gtk/status/dialog/height", event->height);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
496 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
497
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
498 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
499 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
500
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
501 void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
502 gaim_gtk_status_window_show(void)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
503 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
504 StatusWindow *dialog;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
505 GtkWidget *bbox;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
506 GtkWidget *button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
507 GtkWidget *list;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
508 GtkWidget *vbox;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
509 GtkWidget *win;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
510 int width, height;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
511
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
512 if (status_window != NULL)
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
513 {
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
514 gtk_window_present(GTK_WINDOW(status_window->window));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
515 return;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
516 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
517
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
518 status_window = dialog = g_new0(StatusWindow, 1);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
519
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
520 width = gaim_prefs_get_int("/gaim/gtk/status/dialog/width");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
521 height = gaim_prefs_get_int("/gaim/gtk/status/dialog/height");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
522
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
523 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
524 gtk_window_set_default_size(GTK_WINDOW(win), width, height);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
525 gtk_window_set_role(GTK_WINDOW(win), "statuses");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
526 gtk_window_set_title(GTK_WINDOW(win), _("Saved Statuses"));
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
527 gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
528
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
529 g_signal_connect(G_OBJECT(win), "delete_event",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
530 G_CALLBACK(status_window_destroy_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
531 g_signal_connect(G_OBJECT(win), "configure_event",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
532 G_CALLBACK(configure_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
533
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
534 /* Setup the vbox */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
535 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
536 gtk_container_add(GTK_CONTAINER(win), vbox);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
537
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
538 /* List of saved status states */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
539 list = create_saved_status_list(dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
540 gtk_box_pack_start(GTK_BOX(vbox), list, TRUE, TRUE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
541
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
542 /* Button box. */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
543 bbox = gtk_hbutton_box_new();
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
544 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
545 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
546 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
547
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
548 /* Use button */
11832
9ca386c15ffe [gaim-migrate @ 14123]
Mark Doliner <mark@kingant.net>
parents: 11811
diff changeset
549 button = gaim_pixbuf_button_from_stock(_("_Use"), GTK_STOCK_EXECUTE,
9ca386c15ffe [gaim-migrate @ 14123]
Mark Doliner <mark@kingant.net>
parents: 11811
diff changeset
550 GAIM_BUTTON_HORIZONTAL);
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
551 dialog->use_button = button;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
552 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
553 gtk_widget_set_sensitive(button, FALSE);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
554
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
555 g_signal_connect(G_OBJECT(button), "clicked",
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
556 G_CALLBACK(status_window_use_cb), dialog);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
557
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
558 /* Add button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
559 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
560 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
561
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
562 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
563 G_CALLBACK(status_window_add_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
564
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
565 /* Modify button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
566 button = gtk_button_new_from_stock(GAIM_STOCK_MODIFY);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
567 dialog->modify_button = button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
568 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
569 gtk_widget_set_sensitive(button, FALSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
570
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
571 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
572 G_CALLBACK(status_window_modify_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
573
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
574 /* Delete button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
575 button = gtk_button_new_from_stock(GTK_STOCK_DELETE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
576 dialog->delete_button = button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
577 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
578 gtk_widget_set_sensitive(button, FALSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
579
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
580 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
581 G_CALLBACK(status_window_delete_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
582
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
583 /* Close button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
584 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
585 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
586
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
587 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
588 G_CALLBACK(status_window_close_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
589
13199
d8f238864c88 [gaim-migrate @ 15562]
Mark Doliner <mark@kingant.net>
parents: 13194
diff changeset
590 gtk_widget_show_all(win);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
591 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
592
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
593 void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
594 gaim_gtk_status_window_hide(void)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
595 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
596 if (status_window == NULL)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
597 return;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
598
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
599 if (status_window->window != NULL)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
600 gtk_widget_destroy(status_window->window);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
601
12888
03f690fcb78e [gaim-migrate @ 15241]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12856
diff changeset
602 gaim_request_close_with_handle(status_window);
03f690fcb78e [gaim-migrate @ 15241]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12856
diff changeset
603 gaim_notify_close_with_handle(status_window);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
604 g_free(status_window);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
605 status_window = NULL;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
606 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
607
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
608
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
609 /**************************************************************************
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
610 * Status editor
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
611 **************************************************************************/
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
612
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
613 static void substatus_editor_cancel_cb(GtkButton *button, gpointer user_data);
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
614
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
615 static void
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
616 status_editor_remove_dialog(StatusEditor *dialog)
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
617 {
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
618 GtkTreeModel *model;
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
619 GtkTreeIter iter;
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
620
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
621 /* Remove the reference to this dialog from our parent's list store */
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
622 if (status_window_find_savedstatus(&iter, dialog->original_title))
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
623 {
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
624 gtk_list_store_set(status_window->model, &iter,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
625 STATUS_WINDOW_COLUMN_WINDOW, NULL,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
626 -1);
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
627 }
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
628
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
629 /* Close any substatus editors that may be open */
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
630 model = GTK_TREE_MODEL(dialog->model);
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
631 if (gtk_tree_model_get_iter_first(model, &iter))
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
632 {
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
633 do {
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
634 SubStatusEditor *substatus_dialog;
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
635
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
636 gtk_tree_model_get(model, &iter,
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
637 STATUS_EDITOR_COLUMN_WINDOW, &substatus_dialog,
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
638 -1);
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
639 if (substatus_dialog != NULL)
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
640 {
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
641 gtk_list_store_set(dialog->model, &iter,
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
642 STATUS_EDITOR_COLUMN_WINDOW, NULL,
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
643 -1);
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
644 substatus_editor_cancel_cb(NULL, substatus_dialog);
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
645 }
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
646 } while (gtk_tree_model_iter_next(model, &iter));
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
647 }
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
648 }
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
649
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
650
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
651 static gboolean
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
652 status_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
653 {
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
654 StatusEditor *dialog = user_data;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
655
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
656 status_editor_remove_dialog(dialog);
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
657 g_free(dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
658 g_free(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
659
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
660 return FALSE;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
661 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
662
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
663 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
664 status_editor_cancel_cb(GtkButton *button, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
665 {
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
666 StatusEditor *dialog = user_data;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
667
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
668 status_editor_remove_dialog(dialog);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
669 gtk_widget_destroy(dialog->window);
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
670 g_free(dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
671 g_free(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
672 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
673
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
674 static void
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
675 status_editor_ok_cb(GtkButton *button, gpointer user_data)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
676 {
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
677 StatusEditor *dialog = user_data;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
678 const char *title;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
679 GaimStatusPrimitive type;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
680 char *message, *unformatted;
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
681 GaimSavedStatus *saved_status = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
682 GtkTreeModel *model;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
683 GtkTreeIter iter;
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
684
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
685 title = gtk_entry_get_text(dialog->title);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
686
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
687 /*
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
688 * If we're saving this status, and the title is already taken
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
689 * then show an error dialog and don't do anything.
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
690 */
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
691 if (((button == dialog->saveanduse_button) || (button == dialog->save_button)) &&
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
692 (gaim_savedstatus_find(title) != NULL) &&
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
693 ((dialog->original_title == NULL) || (strcmp(title, dialog->original_title))))
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
694 {
12888
03f690fcb78e [gaim-migrate @ 15241]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12856
diff changeset
695 gaim_notify_error(status_window, NULL, _("Title already in use. You must "
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
696 "choose a unique title."), NULL);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
697 return;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
698 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
699
12726
868d574dd83e [gaim-migrate @ 15070]
Richard Laager <rlaager@wiktel.com>
parents: 12693
diff changeset
700 type = gtk_option_menu_get_history(dialog->type) + (GAIM_STATUS_UNSET + 1);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
701 message = gtk_imhtml_get_markup(dialog->message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
702 unformatted = gaim_markup_strip_html(message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
703
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
704 /*
13175
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
705 * If we're editing an old status, then lookup the old status.
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
706 * Note: It is possible that it has been deleted or renamed
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
707 * or something, and no longer exists.
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
708 */
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
709 if (dialog->original_title != NULL)
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
710 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
711 GtkTreeIter iter;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
712
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
713 saved_status = gaim_savedstatus_find(dialog->original_title);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
714
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
715 if (status_window_find_savedstatus(&iter, dialog->original_title))
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
716 gtk_list_store_remove(status_window->model, &iter);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
717 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
718
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
719 if (saved_status == NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
720 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
721 /* This is a new status */
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
722 if ((button == dialog->saveanduse_button)
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
723 || (button == dialog->save_button))
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
724 saved_status = gaim_savedstatus_new(title, type);
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
725 else
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
726 saved_status = gaim_savedstatus_new(NULL, type);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
727 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
728 else
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
729 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
730 /* Modify the old status */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
731 if (strcmp(title, dialog->original_title))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
732 gaim_savedstatus_set_title(saved_status, title);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
733 gaim_savedstatus_set_type(saved_status, type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
734 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
735
12951
9eaf101af7a7 [gaim-migrate @ 15304]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12888
diff changeset
736 if (*unformatted == '\0')
9eaf101af7a7 [gaim-migrate @ 15304]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12888
diff changeset
737 gaim_savedstatus_set_message(saved_status, NULL);
9eaf101af7a7 [gaim-migrate @ 15304]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12888
diff changeset
738 else
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
739 gaim_savedstatus_set_message(saved_status, message);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
740
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
741 /* Set any substatuses */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
742 model = GTK_TREE_MODEL(dialog->model);
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
743 if (gtk_tree_model_get_iter_first(model, &iter))
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
744 {
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
745 do {
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
746 GaimAccount *account;
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
747 gboolean enabled;
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
748 char *id;
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
749 char *message;
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
750 GaimStatusType *type;
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
751
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
752 gtk_tree_model_get(model, &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
753 STATUS_EDITOR_COLUMN_ACCOUNT, &account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
754 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, &enabled,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
755 STATUS_EDITOR_COLUMN_STATUS_ID, &id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
756 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, &message,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
757 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
758 if (enabled)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
759 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
760 type = gaim_account_get_status_type(account, id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
761 gaim_savedstatus_set_substatus(saved_status, account, type, message);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
762 }
13835
f1dd1555b39c [gaim-migrate @ 16284]
Mark Doliner <mark@kingant.net>
parents: 13663
diff changeset
763 else
f1dd1555b39c [gaim-migrate @ 16284]
Mark Doliner <mark@kingant.net>
parents: 13663
diff changeset
764 {
f1dd1555b39c [gaim-migrate @ 16284]
Mark Doliner <mark@kingant.net>
parents: 13663
diff changeset
765 gaim_savedstatus_unset_substatus(saved_status, account);
f1dd1555b39c [gaim-migrate @ 16284]
Mark Doliner <mark@kingant.net>
parents: 13663
diff changeset
766 }
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
767 g_free(id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
768 g_free(message);
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
769 } while (gtk_tree_model_iter_next(model, &iter));
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
770 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
771
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
772 g_free(message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
773 g_free(unformatted);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
774
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
775 status_editor_remove_dialog(dialog);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
776 gtk_widget_destroy(dialog->window);
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
777 g_free(dialog->original_title);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
778
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
779 if (status_window != NULL)
12199
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
780 add_status_to_saved_status_list(status_window->model, saved_status);
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
781
13010
e348ed834acc [gaim-migrate @ 15363]
Mark Doliner <mark@kingant.net>
parents: 12951
diff changeset
782 /* If they clicked on "Save & Use" or "Use," then activate the status */
e348ed834acc [gaim-migrate @ 15363]
Mark Doliner <mark@kingant.net>
parents: 12951
diff changeset
783 if (button != dialog->save_button)
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
784 gaim_savedstatus_activate(saved_status);
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
785
13172
12d960995cdc [gaim-migrate @ 15535]
Richard Laager <rlaager@wiktel.com>
parents: 13144
diff changeset
786 g_free(dialog);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
787 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
788
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
789 static void
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
790 editor_title_changed_cb(GtkWidget *widget, gpointer user_data)
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
791 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
792 StatusEditor *dialog = user_data;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
793 const gchar *text;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
794
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
795 text = gtk_entry_get_text(dialog->title);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
796
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
797 gtk_widget_set_sensitive(GTK_WIDGET(dialog->saveanduse_button), (*text != '\0'));
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
798 gtk_widget_set_sensitive(GTK_WIDGET(dialog->save_button), (*text != '\0'));
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
799 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
800
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
801 static GtkWidget *
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
802 create_status_type_menu(GaimStatusPrimitive type)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
803 {
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
804 int i;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
805 GtkWidget *dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
806 GtkWidget *menu;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
807 GtkWidget *item;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
808
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
809 dropdown = gtk_option_menu_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
810 menu = gtk_menu_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
811
12693
07d6cc1b5a98 [gaim-migrate @ 15036]
Richard Laager <rlaager@wiktel.com>
parents: 12329
diff changeset
812 for (i = GAIM_STATUS_UNSET + 1; i < GAIM_STATUS_NUM_PRIMITIVES; i++)
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
813 {
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
814 item = gtk_menu_item_new_with_label(gaim_primitive_get_name_from_type(i));
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
815 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
816 }
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
817
12693
07d6cc1b5a98 [gaim-migrate @ 15036]
Richard Laager <rlaager@wiktel.com>
parents: 12329
diff changeset
818 gtk_menu_set_active(GTK_MENU(menu), type - (GAIM_STATUS_UNSET + 1));
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
819 gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu);
13199
d8f238864c88 [gaim-migrate @ 15562]
Mark Doliner <mark@kingant.net>
parents: 13194
diff changeset
820 gtk_widget_show_all(menu);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
821
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
822 return dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
823 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
824
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
825 static void edit_substatus(StatusEditor *status_editor, GaimAccount *account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
826
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
827 static void
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
828 edit_substatus_cb(GtkTreeView *tv, GtkTreePath *path, GtkTreeViewColumn *col, gpointer user_data)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
829 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
830 StatusEditor *dialog = user_data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
831 GtkTreeIter iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
832 GaimAccount *account;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
833
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
834 gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model), &iter, path);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
835 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
836 STATUS_EDITOR_COLUMN_ACCOUNT, &account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
837 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
838
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
839 edit_substatus(dialog, account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
840 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
841
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
842 static void
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
843 status_editor_substatus_cb(GtkCellRendererToggle *renderer, gchar *path_str, gpointer data)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
844 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
845 StatusEditor *dialog = (StatusEditor *)data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
846 GtkTreeIter iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
847 gboolean enabled;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
848 GaimAccount *account;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
849
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
850 gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(dialog->model), &iter, path_str);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
851 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
852 STATUS_EDITOR_COLUMN_ACCOUNT, &account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
853 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, &enabled,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
854 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
855
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
856 enabled = !enabled;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
857
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
858 if (enabled)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
859 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
860 edit_substatus(dialog, account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
861 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
862 else
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
863 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
864 /* Remove the substatus */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
865 gtk_list_store_set(dialog->model, &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
866 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, enabled,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
867 STATUS_EDITOR_COLUMN_STATUS_ID, NULL,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
868 STATUS_EDITOR_COLUMN_STATUS_NAME, NULL,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
869 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, NULL,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
870 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
871 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
872 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
873
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
874 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
875 status_editor_add_columns(StatusEditor *dialog)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
876 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
877 GtkCellRenderer *renderer;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
878 GtkTreeViewColumn *column;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
879
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
880 /* Enable Different status column */
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
881 renderer = gtk_cell_renderer_toggle_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
882 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(dialog->treeview),
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
883 -1, _("Different"),
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
884 renderer,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
885 "active", STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
886 NULL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
887 g_signal_connect(G_OBJECT(renderer), "toggled",
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
888 G_CALLBACK(status_editor_substatus_cb), dialog);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
889
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
890 /* Screen Name column */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
891 column = gtk_tree_view_column_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
892 gtk_tree_view_column_set_resizable(column, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
893 gtk_tree_view_column_set_title(column, _("Screen Name"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
894 gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
895 gtk_tree_view_column_set_resizable(column, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
896
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
897 /* Icon */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
898 renderer = gtk_cell_renderer_pixbuf_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
899 gtk_tree_view_column_pack_start(column, renderer, FALSE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
900 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
901 STATUS_EDITOR_COLUMN_ICON);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
902
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
903 /* Screen Name */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
904 renderer = gtk_cell_renderer_text_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
905 gtk_tree_view_column_pack_start(column, renderer, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
906 gtk_tree_view_column_add_attribute(column, renderer, "text",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
907 STATUS_EDITOR_COLUMN_SCREENNAME);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
908
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
909 /* Status column */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
910 column = gtk_tree_view_column_new();
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
911 gtk_tree_view_column_set_resizable(column, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
912 gtk_tree_view_column_set_title(column, _("Status"));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
913 gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
914 gtk_tree_view_column_set_resizable(column, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
915 renderer = gtk_cell_renderer_text_new();
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
916 gtk_tree_view_column_pack_start(column, renderer, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
917 gtk_tree_view_column_add_attribute(column, renderer, "text",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
918 STATUS_EDITOR_COLUMN_STATUS_NAME);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
919
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
920 /* Message column */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
921 column = gtk_tree_view_column_new();
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
922 gtk_tree_view_column_set_resizable(column, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
923 gtk_tree_view_column_set_title(column, _("Message"));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
924 gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
925 gtk_tree_view_column_set_resizable(column, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
926 renderer = gtk_cell_renderer_text_new();
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
927 gtk_tree_view_column_pack_start(column, renderer, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
928 gtk_tree_view_column_add_attribute(column, renderer, "text",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
929 STATUS_EDITOR_COLUMN_STATUS_MESSAGE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
930
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
931 g_signal_connect(G_OBJECT(dialog->treeview), "row-activated",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
932 G_CALLBACK(edit_substatus_cb), dialog);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
933 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
934
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
935 static void
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
936 status_editor_set_account(GtkListStore *store, GaimAccount *account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
937 GtkTreeIter *iter, GaimSavedStatusSub *substatus)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
938 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
939 GdkPixbuf *pixbuf;
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
940 const char *id = NULL, *name = NULL, *message = NULL;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
941
13090
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
942 pixbuf = gaim_gtk_create_prpl_icon(account, 0.5);
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
943 if ((pixbuf != NULL) && !gaim_account_is_connected(account))
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
944 {
13090
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
945 gdk_pixbuf_saturate_and_pixelate(pixbuf, pixbuf, 0.0, FALSE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
946 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
947
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
948 if (substatus != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
949 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
950 const GaimStatusType *type;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
951
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
952 type = gaim_savedstatus_substatus_get_type(substatus);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
953 id = gaim_status_type_get_id(type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
954 name = gaim_status_type_get_name(type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
955 if (gaim_status_type_get_attr(type, "message"))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
956 message = gaim_savedstatus_substatus_get_message(substatus);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
957 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
958
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
959 gtk_list_store_set(store, iter,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
960 STATUS_EDITOR_COLUMN_ACCOUNT, account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
961 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, (substatus != NULL),
13090
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
962 STATUS_EDITOR_COLUMN_ICON, pixbuf,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
963 STATUS_EDITOR_COLUMN_SCREENNAME, gaim_account_get_username(account),
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
964 STATUS_EDITOR_COLUMN_STATUS_ID, id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
965 STATUS_EDITOR_COLUMN_STATUS_NAME, name,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
966 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, message,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
967 -1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
968
13090
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
969 if (pixbuf != NULL)
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
970 g_object_unref(G_OBJECT(pixbuf));
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
971 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
972
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
973 static void
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
974 status_editor_add_account(StatusEditor *dialog, GaimAccount *account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
975 GaimSavedStatusSub *substatus)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
976 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
977 GtkTreeIter iter;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
978
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
979 gtk_list_store_append(dialog->model, &iter);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
980
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
981 status_editor_set_account(dialog->model, account, &iter, substatus);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
982 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
983
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
984 static void
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
985 status_editor_populate_list(StatusEditor *dialog, GaimSavedStatus *saved_status)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
986 {
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
987 GList *iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
988 GaimSavedStatusSub *substatus;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
989
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
990 gtk_list_store_clear(dialog->model);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
991
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
992 for (iter = gaim_accounts_get_all(); iter != NULL; iter = iter->next)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
993 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
994 GaimAccount *account = (GaimAccount *)iter->data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
995
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
996 if (saved_status != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
997 substatus = gaim_savedstatus_get_substatus(saved_status, account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
998 else
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
999 substatus = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1000
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1001 status_editor_add_account(dialog, account, substatus);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1002 }
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1003 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1004
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1005 void
13175
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1006 gaim_gtk_status_editor_show(gboolean edit, GaimSavedStatus *saved_status)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1007 {
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1008 GtkTreeIter iter;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1009 StatusEditor *dialog;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1010 GtkSizeGroup *sg;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1011 GtkWidget *bbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1012 GtkWidget *button;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1013 GtkWidget *dbox;
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
1014 GtkWidget *expander;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1015 GtkWidget *dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1016 GtkWidget *entry;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1017 GtkWidget *frame;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1018 GtkWidget *hbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1019 GtkWidget *label;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1020 GtkWidget *sw;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1021 GtkWidget *text;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1022 GtkWidget *toolbar;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1023 GtkWidget *vbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1024 GtkWidget *win;
13141
39e7014cb687 [gaim-migrate @ 15504]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13090
diff changeset
1025 GList *focus_chain = NULL;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1026
13175
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1027 if (edit)
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1028 {
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1029 g_return_if_fail(saved_status != NULL);
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1030 g_return_if_fail(!gaim_savedstatus_is_transient(saved_status));
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1031 }
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1032
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1033 /* Find a possible window for this saved status and present it */
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1034 if (edit && status_window_find_savedstatus(&iter, gaim_savedstatus_get_title(saved_status)))
13175
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1035 {
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1036 gtk_tree_model_get(GTK_TREE_MODEL(status_window->model), &iter,
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1037 STATUS_WINDOW_COLUMN_WINDOW, &dialog,
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1038 -1);
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1039 if (dialog != NULL)
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1040 {
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1041 gtk_window_present(GTK_WINDOW(dialog->window));
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1042 return;
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1043 }
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1044 }
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1045
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1046 dialog = g_new0(StatusEditor, 1);
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1047 if (edit && status_window_find_savedstatus(&iter, gaim_savedstatus_get_title(saved_status)))
13175
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1048 {
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1049 gtk_list_store_set(status_window->model, &iter,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1050 STATUS_WINDOW_COLUMN_WINDOW, dialog,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1051 -1);
13175
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1052 }
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1053
13175
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1054 if (edit)
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1055 dialog->original_title = g_strdup(gaim_savedstatus_get_title(saved_status));
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1056
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1057 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1058 gtk_window_set_role(GTK_WINDOW(win), "status");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1059 gtk_window_set_title(GTK_WINDOW(win), _("Status"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1060 gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1061 gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1062
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1063 g_signal_connect(G_OBJECT(win), "delete_event",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1064 G_CALLBACK(status_editor_destroy_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1065
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1066 /* Setup the vbox */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1067 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1068 gtk_container_add(GTK_CONTAINER(win), vbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1069
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1070 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1071
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1072 /* Title */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1073 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1074 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1075
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1076 label = gtk_label_new_with_mnemonic(_("_Title:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1077 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1078 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1079 gtk_size_group_add_widget(sg, label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1080
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1081 entry = gtk_entry_new();
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1082 dialog->title = GTK_ENTRY(entry);
13175
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1083 if ((saved_status != NULL)
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1084 && !gaim_savedstatus_is_transient(saved_status)
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1085 && (gaim_savedstatus_get_title(saved_status) != NULL))
488619ad7ed5 [gaim-migrate @ 15538]
Mark Doliner <mark@kingant.net>
parents: 13173
diff changeset
1086 gtk_entry_set_text(GTK_ENTRY(entry), gaim_savedstatus_get_title(saved_status));
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1087 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1088 g_signal_connect(G_OBJECT(entry), "changed",
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1089 G_CALLBACK(editor_title_changed_cb), dialog);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1090
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1091 /* Status type */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1092 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1093 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1094
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1095 label = gtk_label_new_with_mnemonic(_("_Status:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1096 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1097 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1098 gtk_size_group_add_widget(sg, label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1099
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1100 if (saved_status != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1101 dropdown = create_status_type_menu(gaim_savedstatus_get_type(saved_status));
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
1102 else
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
1103 dropdown = create_status_type_menu(GAIM_STATUS_AWAY);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1104 dialog->type = GTK_OPTION_MENU(dropdown);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1105 gtk_box_pack_start(GTK_BOX(hbox), dropdown, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1106
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1107 /* Status message */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1108 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1109 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1110
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1111 label = gtk_label_new_with_mnemonic(_("_Message:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1112 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1113 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1114 gtk_size_group_add_widget(sg, label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1115
13280
3de53fe8345f [gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents: 13199
diff changeset
1116 frame = gaim_gtk_create_imhtml(TRUE, &text, &toolbar, NULL);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1117 dialog->message = GTK_IMHTML(text);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1118 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
13141
39e7014cb687 [gaim-migrate @ 15504]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13090
diff changeset
1119 focus_chain = g_list_prepend(focus_chain, dialog->message);
39e7014cb687 [gaim-migrate @ 15504]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13090
diff changeset
1120 gtk_container_set_focus_chain(GTK_CONTAINER(hbox), focus_chain);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1121
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1122 if ((saved_status != NULL) && (gaim_savedstatus_get_message(saved_status) != NULL))
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
1123 gtk_imhtml_append_text(GTK_IMHTML(text),
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1124 gaim_savedstatus_get_message(saved_status), 0);
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
1125
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1126 /* Different status message expander */
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
1127 expander = gtk_expander_new_with_mnemonic(_("Use a _different status for some accounts"));
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
1128 gtk_box_pack_start(GTK_BOX(vbox), expander, FALSE, FALSE, 0);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1129
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
1130 /* Setup the box that the expander will cover */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1131 dbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE);
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
1132 gtk_container_add(GTK_CONTAINER(expander), dbox);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1133
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1134 /* Different status message treeview */
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1135 sw = gtk_scrolled_window_new(NULL, NULL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1136 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1137 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1138 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1139 GTK_SHADOW_IN);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1140 gtk_box_pack_start(GTK_BOX(dbox), sw, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1141
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1142 /* Create the list model */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1143 dialog->model = gtk_list_store_new(STATUS_EDITOR_NUM_COLUMNS,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1144 G_TYPE_POINTER,
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1145 G_TYPE_POINTER,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1146 G_TYPE_BOOLEAN,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1147 GDK_TYPE_PIXBUF,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1148 G_TYPE_STRING,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1149 G_TYPE_STRING,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1150 G_TYPE_STRING,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1151 G_TYPE_STRING);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1152
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1153 /* Create the treeview */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1154 dialog->treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1155 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(dialog->treeview), TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1156 gtk_widget_set_size_request(dialog->treeview, 400, 250);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1157 gtk_container_add(GTK_CONTAINER(sw), dialog->treeview);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1158
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1159 /* Add columns */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1160 status_editor_add_columns(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1161
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1162 /* Populate list */
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1163 status_editor_populate_list(dialog, saved_status);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1164
13193
3426bc61bb8b [gaim-migrate @ 15556]
Mark Doliner <mark@kingant.net>
parents: 13178
diff changeset
1165 /* Expand the treeview if we have substatuses */
3426bc61bb8b [gaim-migrate @ 15556]
Mark Doliner <mark@kingant.net>
parents: 13178
diff changeset
1166 gtk_expander_set_expanded(GTK_EXPANDER(expander),
3426bc61bb8b [gaim-migrate @ 15556]
Mark Doliner <mark@kingant.net>
parents: 13178
diff changeset
1167 (saved_status != NULL) && gaim_savedstatus_has_substatuses(saved_status));
3426bc61bb8b [gaim-migrate @ 15556]
Mark Doliner <mark@kingant.net>
parents: 13178
diff changeset
1168
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1169 /* Button box */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1170 bbox = gtk_hbutton_box_new();
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1171 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1172 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1173 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1174
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1175 /* Cancel button */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1176 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1177 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1178
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1179 g_signal_connect(G_OBJECT(button), "clicked",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1180 G_CALLBACK(status_editor_cancel_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1181
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1182 /* Use button */
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1183 button = gaim_pixbuf_button_from_stock(_("_Use"), GTK_STOCK_EXECUTE,
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1184 GAIM_BUTTON_HORIZONTAL);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1185 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1186
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1187 g_signal_connect(G_OBJECT(button), "clicked",
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1188 G_CALLBACK(status_editor_ok_cb), dialog);
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1189
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1190 /* Save & Use button */
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1191 button = gaim_pixbuf_button_from_stock(_("Sa_ve & Use"), GTK_STOCK_OK,
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1192 GAIM_BUTTON_HORIZONTAL);
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1193 dialog->saveanduse_button = GTK_BUTTON(button);
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1194 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1195 if (dialog->original_title == NULL)
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1196 gtk_widget_set_sensitive(button, FALSE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1197
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1198 g_signal_connect(G_OBJECT(button), "clicked",
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1199 G_CALLBACK(status_editor_ok_cb), dialog);
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1200
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1201 /* Save button */
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1202 button = gtk_button_new_from_stock(GTK_STOCK_SAVE);
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1203 dialog->save_button = GTK_BUTTON(button);
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1204 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1205 if (dialog->original_title == NULL)
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1206 gtk_widget_set_sensitive(button, FALSE);
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1207
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1208 g_signal_connect(G_OBJECT(button), "clicked",
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1209 G_CALLBACK(status_editor_ok_cb), dialog);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1210
13199
d8f238864c88 [gaim-migrate @ 15562]
Mark Doliner <mark@kingant.net>
parents: 13194
diff changeset
1211 gtk_widget_show_all(win);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1212 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1213
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1214
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
1215 /**************************************************************************
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1216 * SubStatus editor
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1217 **************************************************************************/
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1218
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1219 static void
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1220 substatus_selection_changed_cb(GtkComboBox *box, gpointer user_data)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1221 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1222 SubStatusEditor *select = user_data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1223 GtkTreeIter iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1224 char *id;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1225 GaimStatusType *type;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1226
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1227 if (!gtk_combo_box_get_active_iter(box, &iter))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1228 return;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1229 gtk_tree_model_get(GTK_TREE_MODEL(select->model), &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1230 SUBSTATUS_COLUMN_STATUS_ID, &id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1231 -1);
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1232 type = gaim_account_get_status_type(select->account, id);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1233 g_free(id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1234
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1235 if (gaim_status_type_get_attr(type, "message") == NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1236 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1237 gtk_widget_set_sensitive(GTK_WIDGET(select->message), FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1238 gtk_widget_set_sensitive(GTK_WIDGET(select->toolbar), FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1239 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1240 else
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1241 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1242 gtk_widget_set_sensitive(GTK_WIDGET(select->message), TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1243 gtk_widget_set_sensitive(GTK_WIDGET(select->toolbar), TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1244 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1245 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1246
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1247 static gboolean
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1248 status_editor_find_account_in_treemodel(GtkTreeIter *iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1249 StatusEditor *status_editor,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1250 GaimAccount *account)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1251 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1252 GtkTreeModel *model;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1253 GaimAccount *cur;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1254
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1255 g_return_val_if_fail(status_editor != NULL, FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1256 g_return_val_if_fail(account != NULL, FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1257
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1258 model = GTK_TREE_MODEL(status_editor->model);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1259
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1260 if (!gtk_tree_model_get_iter_first(model, iter))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1261 return FALSE;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1262
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1263 do {
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1264 gtk_tree_model_get(model, iter, STATUS_EDITOR_COLUMN_ACCOUNT, &cur, -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1265 if (cur == account)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1266 return TRUE;
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1267 } while (gtk_tree_model_iter_next(model, iter));
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1268
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1269 return FALSE;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1270 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1271
12246
b7a51e68d0b8 [gaim-migrate @ 14548]
Mark Doliner <mark@kingant.net>
parents: 12238
diff changeset
1272 static void
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1273 substatus_editor_remove_dialog(SubStatusEditor *dialog)
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1274 {
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1275 GtkTreeIter iter;
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1276
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1277 if (status_editor_find_account_in_treemodel(&iter, dialog->status_editor, dialog->account))
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1278 {
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1279 /* Remove the reference to this dialog from our parent's list store */
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1280 gtk_list_store_set(dialog->status_editor->model, &iter,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1281 STATUS_EDITOR_COLUMN_WINDOW, NULL,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1282 -1);
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1283 }
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1284 }
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1285
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1286 static gboolean
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1287 substatus_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1288 {
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1289 SubStatusEditor *dialog = user_data;
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1290
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1291 substatus_editor_remove_dialog(dialog);
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1292 g_free(dialog);
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1293
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1294 return FALSE;
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1295 }
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1296
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1297 static void
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1298 substatus_editor_cancel_cb(GtkButton *button, gpointer user_data)
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1299 {
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1300 SubStatusEditor *dialog = user_data;
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1301
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1302 substatus_editor_remove_dialog(dialog);
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1303 gtk_widget_destroy(dialog->window);
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1304 g_free(dialog);
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1305 }
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1306
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1307
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1308 static void
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1309 substatus_editor_ok_cb(GtkButton *button, gpointer user_data)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1310 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1311 SubStatusEditor *dialog = user_data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1312 StatusEditor *status_editor;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1313 GtkTreeIter iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1314 GaimStatusType *type;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1315 char *id = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1316 char *message = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1317 const char *name = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1318
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1319 if (!gtk_combo_box_get_active_iter(dialog->box, &iter))
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1320 {
12856
be1cd5952a48 [gaim-migrate @ 15207]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12823
diff changeset
1321 gtk_widget_destroy(dialog->window);
be1cd5952a48 [gaim-migrate @ 15207]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12823
diff changeset
1322 g_free(dialog);
be1cd5952a48 [gaim-migrate @ 15207]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12823
diff changeset
1323 return;
be1cd5952a48 [gaim-migrate @ 15207]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12823
diff changeset
1324 }
be1cd5952a48 [gaim-migrate @ 15207]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12823
diff changeset
1325
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1326 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1327 SUBSTATUS_COLUMN_STATUS_ID, &id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1328 -1);
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1329 type = gaim_account_get_status_type(dialog->account, id);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1330 if (gaim_status_type_get_attr(type, "message") != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1331 message = gtk_imhtml_get_text(GTK_IMHTML(dialog->message), NULL, NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1332 name = gaim_status_type_get_name(type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1333
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1334 status_editor = dialog->status_editor;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1335
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1336 if (status_editor_find_account_in_treemodel(&iter, status_editor, dialog->account))
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1337 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1338 gtk_list_store_set(status_editor->model, &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1339 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, TRUE,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1340 STATUS_EDITOR_COLUMN_STATUS_ID, id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1341 STATUS_EDITOR_COLUMN_STATUS_NAME, name,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1342 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, message,
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1343 STATUS_EDITOR_COLUMN_WINDOW, NULL,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1344 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1345 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1346
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1347 gtk_widget_destroy(dialog->window);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1348 g_free(id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1349 g_free(message);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1350 g_free(dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1351 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1352
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1353 static void
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1354 edit_substatus(StatusEditor *status_editor, GaimAccount *account)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1355 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1356 char *tmp;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1357 SubStatusEditor *dialog;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1358 GtkSizeGroup *sg;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1359 GtkWidget *bbox;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1360 GtkWidget *button;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1361 GtkWidget *combo;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1362 GtkWidget *hbox;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1363 GtkWidget *frame;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1364 GtkWidget *label;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1365 GtkWidget *text;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1366 GtkWidget *toolbar;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1367 GtkWidget *vbox;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1368 GtkWidget *win;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1369 GtkTreeIter iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1370 GtkCellRenderer *rend;
13194
7099a443131d [gaim-migrate @ 15557]
Mark Doliner <mark@kingant.net>
parents: 13193
diff changeset
1371 const char *status_id = NULL;
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1372 const GList *list;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1373 gboolean select = FALSE;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1374
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1375 g_return_if_fail(status_editor != NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1376 g_return_if_fail(account != NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1377
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1378 status_editor_find_account_in_treemodel(&iter, status_editor, account);
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1379 gtk_tree_model_get(GTK_TREE_MODEL(status_editor->model), &iter,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1380 STATUS_EDITOR_COLUMN_WINDOW, &dialog,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1381 -1);
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1382 if (dialog != NULL)
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1383 {
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1384 gtk_window_present(GTK_WINDOW(dialog->window));
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1385 return;
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1386 }
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1387
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1388 dialog = g_new0(SubStatusEditor, 1);
13144
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1389 gtk_list_store_set(status_editor->model, &iter,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1390 STATUS_EDITOR_COLUMN_WINDOW, dialog,
e90e8655290d [gaim-migrate @ 15507]
Richard Laager <rlaager@wiktel.com>
parents: 13141
diff changeset
1391 -1);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1392 dialog->status_editor = status_editor;
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1393 dialog->account = account;
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1394
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1395 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1396 gtk_window_set_role(GTK_WINDOW(win), "substatus");
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1397 tmp = g_strdup_printf(_("Status for %s"), gaim_account_get_username(account));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1398 gtk_window_set_title(GTK_WINDOW(win), tmp);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1399 g_free(tmp);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1400 gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1401 gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1402
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1403 g_signal_connect(G_OBJECT(win), "delete_event",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1404 G_CALLBACK(substatus_editor_destroy_cb), dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1405
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1406 /* Setup the vbox */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1407 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1408 gtk_container_add(GTK_CONTAINER(win), vbox);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1409
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1410 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1411
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1412 /* Status type */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1413 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1414 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1415
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1416 label = gtk_label_new_with_mnemonic(_("_Status:"));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1417 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1418 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1419 gtk_size_group_add_widget(sg, label);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1420
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1421 dialog->model = gtk_list_store_new(SUBSTATUS_NUM_COLUMNS,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1422 GDK_TYPE_PIXBUF,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1423 G_TYPE_STRING,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1424 G_TYPE_STRING);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1425 combo = gtk_combo_box_new_with_model(GTK_TREE_MODEL(dialog->model));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1426 dialog->box = GTK_COMBO_BOX(combo);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1427
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1428 rend = GTK_CELL_RENDERER(gtk_cell_renderer_pixbuf_new());
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1429 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), rend, FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1430 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), rend,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1431 "pixbuf", SUBSTATUS_COLUMN_ICON, NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1432
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1433 rend = GTK_CELL_RENDERER(gtk_cell_renderer_text_new());
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1434 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), rend, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1435 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), rend,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1436 "text", SUBSTATUS_COLUMN_STATUS_NAME, NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1437
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1438 g_signal_connect(G_OBJECT(combo), "changed",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1439 G_CALLBACK(substatus_selection_changed_cb), dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1440
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1441 gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1442
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1443 /* Status mesage */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1444 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1445 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1446
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1447 label = gtk_label_new_with_mnemonic(_("_Message:"));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1448 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1449 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1450 gtk_size_group_add_widget(sg, label);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1451
13280
3de53fe8345f [gaim-migrate @ 15646]
Richard Laager <rlaager@wiktel.com>
parents: 13199
diff changeset
1452 frame = gaim_gtk_create_imhtml(TRUE, &text, &toolbar, NULL);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1453 dialog->message = GTK_IMHTML(text);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1454 dialog->toolbar = GTK_IMHTMLTOOLBAR(toolbar);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1455 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1456
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1457 /* Button box */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1458 bbox = gtk_hbutton_box_new();
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1459 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1460 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1461 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1462
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1463 /* Cancel button */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1464 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1465 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1466
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1467 g_signal_connect(G_OBJECT(button), "clicked",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1468 G_CALLBACK(substatus_editor_cancel_cb), dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1469
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1470 /* OK button */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1471 button = gtk_button_new_from_stock(GTK_STOCK_OK);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1472 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1473
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1474 g_signal_connect(G_OBJECT(button), "clicked",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1475 G_CALLBACK(substatus_editor_ok_cb), dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1476
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1477 /* Seed the input widgets with the current values */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1478 /* TODO: Get the current values from our parent's list store, not the saved_status! */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1479 if (status_editor->original_title != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1480 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1481 GaimSavedStatus *saved_status = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1482 GaimSavedStatusSub *substatus = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1483
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1484 saved_status = gaim_savedstatus_find(status_editor->original_title);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1485 if (saved_status != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1486 substatus = gaim_savedstatus_get_substatus(saved_status, account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1487
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1488 if (substatus != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1489 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1490 gtk_imhtml_append_text(dialog->message,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1491 gaim_savedstatus_substatus_get_message(substatus),
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1492 0);
13194
7099a443131d [gaim-migrate @ 15557]
Mark Doliner <mark@kingant.net>
parents: 13193
diff changeset
1493 status_id = gaim_status_type_get_id(gaim_savedstatus_substatus_get_type(substatus));
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1494 }
13194
7099a443131d [gaim-migrate @ 15557]
Mark Doliner <mark@kingant.net>
parents: 13193
diff changeset
1495 /* TODO: Else get the generic status type from our parent */
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1496 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1497
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1498 for (list = gaim_account_get_status_types(account); list; list = list->next)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1499 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1500 GaimStatusType *status_type;
13090
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
1501 GdkPixbuf *pixbuf;
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1502 const char *id, *name;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1503
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1504 status_type = list->data;
13010
e348ed834acc [gaim-migrate @ 15363]
Mark Doliner <mark@kingant.net>
parents: 12951
diff changeset
1505
e348ed834acc [gaim-migrate @ 15363]
Mark Doliner <mark@kingant.net>
parents: 12951
diff changeset
1506 /* Only allow users to select statuses that are flagged as "user settable" */
e348ed834acc [gaim-migrate @ 15363]
Mark Doliner <mark@kingant.net>
parents: 12951
diff changeset
1507 if (!gaim_status_type_is_user_settable(status_type))
e348ed834acc [gaim-migrate @ 15363]
Mark Doliner <mark@kingant.net>
parents: 12951
diff changeset
1508 continue;
e348ed834acc [gaim-migrate @ 15363]
Mark Doliner <mark@kingant.net>
parents: 12951
diff changeset
1509
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1510 id = gaim_status_type_get_id(status_type);
13090
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
1511 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, status_type, 0.5);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1512 name = gaim_status_type_get_name(status_type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1513
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1514 gtk_list_store_append(dialog->model, &iter);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1515 gtk_list_store_set(dialog->model, &iter,
13090
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
1516 SUBSTATUS_COLUMN_ICON, pixbuf,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1517 SUBSTATUS_COLUMN_STATUS_ID, id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1518 SUBSTATUS_COLUMN_STATUS_NAME, name,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1519 -1);
13090
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
1520 if (pixbuf != NULL)
0aa231ebbfd5 [gaim-migrate @ 15452]
Mark Doliner <mark@kingant.net>
parents: 13014
diff changeset
1521 g_object_unref(pixbuf);
13194
7099a443131d [gaim-migrate @ 15557]
Mark Doliner <mark@kingant.net>
parents: 13193
diff changeset
1522 if ((status_id != NULL) && !strcmp(status_id, id))
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1523 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1524 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1525 select = TRUE;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1526 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1527 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1528
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1529 if (!select)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1530 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1531
13199
d8f238864c88 [gaim-migrate @ 15562]
Mark Doliner <mark@kingant.net>
parents: 13194
diff changeset
1532 gtk_widget_show_all(win);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1533 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1534
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1535
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1536 /**************************************************************************
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1537 * Utilities *
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1538 **************************************************************************/
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1539
12246
b7a51e68d0b8 [gaim-migrate @ 14548]
Mark Doliner <mark@kingant.net>
parents: 12238
diff changeset
1540 static void
b7a51e68d0b8 [gaim-migrate @ 14548]
Mark Doliner <mark@kingant.net>
parents: 12238
diff changeset
1541 status_menu_cb(GtkComboBox *widget, void(*callback)(GaimSavedStatus*))
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1542 {
12237
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1543 GtkTreeIter iter;
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1544 gchar *title = NULL;
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1545
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1546 if (!gtk_combo_box_get_active_iter(widget, &iter))
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1547 return;
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1548
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1549 gtk_tree_model_get(gtk_combo_box_get_model(widget), &iter,
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1550 STATUS_WINDOW_COLUMN_TITLE, &title, -1);
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1551 callback(gaim_savedstatus_find(title));
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1552 g_free(title);
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1553 }
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1554
12817
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1555 static gint
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1556 saved_status_sort_alphabetically_func(gconstpointer a, gconstpointer b)
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1557 {
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1558 const GaimSavedStatus *saved_status_a = a;
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1559 const GaimSavedStatus *saved_status_b = b;
12823
292a846fdeea [gaim-migrate @ 15171]
Richard Laager <rlaager@wiktel.com>
parents: 12817
diff changeset
1560 return g_utf8_collate(gaim_savedstatus_get_title(saved_status_a),
12817
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1561 gaim_savedstatus_get_title(saved_status_b));
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1562 }
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1563
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1564 GtkWidget *gaim_gtk_status_menu(GaimSavedStatus *current_status, GCallback callback)
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1565 {
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1566 GtkWidget *combobox;
12817
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1567 GList *sorted, *cur;
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1568 int i;
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1569 int index = -1;
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1570
12199
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1571 combobox = gtk_combo_box_new_text();
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1572
12817
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1573 sorted = g_list_copy((GList *)gaim_savedstatuses_get_all());
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1574 sorted = g_list_sort(sorted, saved_status_sort_alphabetically_func);
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1575 for (cur = sorted, i = 0;
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1576 cur != NULL;
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1577 cur = g_list_next(cur))
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1578 {
12817
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1579 GaimSavedStatus *status = (GaimSavedStatus *)cur->data;
13178
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1580 if (!gaim_savedstatus_is_transient(status))
35190e33a785 [gaim-migrate @ 15541]
Mark Doliner <mark@kingant.net>
parents: 13176
diff changeset
1581 {
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1582 gtk_combo_box_append_text(GTK_COMBO_BOX(combobox),
12199
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1583 gaim_savedstatus_get_title(status));
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1584 if (status == current_status)
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1585 index = i;
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1586 i++;
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1587 }
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1588 }
12817
c0fc1e9c6768 [gaim-migrate @ 15165]
Mark Doliner <mark@kingant.net>
parents: 12726
diff changeset
1589 g_list_free(sorted);
12246
b7a51e68d0b8 [gaim-migrate @ 14548]
Mark Doliner <mark@kingant.net>
parents: 12238
diff changeset
1590
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1591 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), index);
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1592 g_signal_connect(G_OBJECT(combobox), "changed", G_CALLBACK(status_menu_cb), callback);
12329
a83644e2a2a8 [gaim-migrate @ 14633]
Mark Doliner <mark@kingant.net>
parents: 12246
diff changeset
1593
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1594 return combobox;
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1595 }
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1596
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1597
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1598 /**************************************************************************
10814
364a2ef907ae [gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents: 10732
diff changeset
1599 * GTK+ saved status glue
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
1600 **************************************************************************/
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1601
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1602 void *
13014
5efbb0162f86 [gaim-migrate @ 15367]
Mark Doliner <mark@kingant.net>
parents: 13010
diff changeset
1603 gaim_gtk_status_get_handle(void)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1604 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1605 static int handle;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1606
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1607 return &handle;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1608 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1609
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1610 void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1611 gaim_gtk_status_init(void)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1612 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1613 gaim_prefs_add_none("/gaim/gtk/status");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1614 gaim_prefs_add_none("/gaim/gtk/status/dialog");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1615 gaim_prefs_add_int("/gaim/gtk/status/dialog/width", 550);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1616 gaim_prefs_add_int("/gaim/gtk/status/dialog/height", 250);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1617 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1618
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1619 void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1620 gaim_gtk_status_uninit(void)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1621 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1622 gaim_gtk_status_window_hide();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1623 }