annotate src/gtksavedstatuses.c @ 12260:0a9574ed62cd

[gaim-migrate @ 14562] Returning 0 means "this SNAC has not been handled, keep trying to find something to deal with it." It shouldn't hurt anything... but 1 is better. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Tue, 29 Nov 2005 22:59:30 +0000
parents b7a51e68d0b8
children a83644e2a2a8
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,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
58 STATUS_WINDOW_NUM_COLUMNS
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
59 };
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
60
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
61 /**
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
62 * These is used for the GtkTreeView containing the list of accounts
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
63 * 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
64 * saved status.
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
65 */
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
66 enum
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
67 {
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
68 /** A hidden column containing a pointer to the GaimAccount */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
69 STATUS_EDITOR_COLUMN_ACCOUNT,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
70 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71 STATUS_EDITOR_COLUMN_ICON,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
72 STATUS_EDITOR_COLUMN_SCREENNAME,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
73 /** A hidden column containing the ID of this GaimStatusType. */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
74 STATUS_EDITOR_COLUMN_STATUS_ID,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
75 STATUS_EDITOR_COLUMN_STATUS_NAME,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
76 STATUS_EDITOR_COLUMN_STATUS_MESSAGE,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
77 STATUS_EDITOR_NUM_COLUMNS
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
78 };
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
79
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
80 /**
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
81 * These are used in the GtkComboBox to select the specific
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
82 * GaimStatusType when setting a substatus for a particular saved
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
83 * status.
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 enum
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
86 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
87 /** A hidden column containing a pointer to the GaimAccount. */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
88 SUBSTATUS_COLUMN_ACCOUNT,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
89 SUBSTATUS_COLUMN_ICON,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
90 /** A hidden column containing the ID of this GaimStatusType. */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
91 SUBSTATUS_COLUMN_STATUS_ID,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
92 SUBSTATUS_COLUMN_STATUS_NAME,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
93 SUBSTATUS_NUM_COLUMNS
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
94 };
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
95
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
96 typedef struct
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
97 {
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
98 GtkWidget *window;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
99 GtkListStore *model;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
100 GtkWidget *treeview;
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
101 GtkWidget *use_button;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
102 GtkWidget *modify_button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
103 GtkWidget *delete_button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
104 } StatusWindow;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
105
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
106 typedef struct
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 GtkWidget *window;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
109 GtkListStore *model;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
110 GtkWidget *treeview;
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
111 GtkWidget *save_button;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
112
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
113 gchar *original_title;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
114 GtkEntry *title;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
115 GtkOptionMenu *type;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
116 GtkIMHtml *message;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
117 } StatusEditor;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
118
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
119 typedef struct
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
120 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
121 StatusEditor *status_editor;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
122 GaimAccount *account;
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 GtkWidget *window;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
125 GtkListStore *model;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
126 GtkComboBox *box;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
127 GtkIMHtml *message;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
128 GtkIMHtmlToolbar *toolbar;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
129 } SubStatusEditor;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
130
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
131 static StatusWindow *status_window = NULL;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
132
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
133
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
134 /**************************************************************************
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
135 * Status window
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 static gboolean
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
139 status_window_find_savedstatus(GtkTreeIter *iter, const char *title)
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 GtkTreeModel *model = GTK_TREE_MODEL(status_window->model);
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
142 char *cur;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
143
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
144 if (!gtk_tree_model_get_iter_first(model, iter))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
145 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
146
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
147 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
148 if (!strcmp(title, cur))
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
149 {
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
150 g_free(cur);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
151 return TRUE;
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
152 }
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
153 g_free(cur);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
154
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
155 while (gtk_tree_model_iter_next(model, iter))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
156 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
157 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
158 if (!strcmp(title, cur))
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
159 {
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
160 g_free(cur);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
161 return TRUE;
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
162 }
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
163 g_free(cur);
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
166 return FALSE;
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
169 static gboolean
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
170 status_window_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
171 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
172 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
173
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
174 dialog->window = NULL;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
175 gaim_gtk_status_window_hide();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
176
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
177 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
178 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
179
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
180 #if !GTK_CHECK_VERSION(2,2,0)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
181 static void
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
182 count_selected_helper(GtkTreeModel *model, GtkTreePath *path,
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
183 GtkTreeIter *iter, gpointer user_data)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
184 {
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
185 (*(gint *)user_data)++;
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
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
188 static void
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
189 list_selected_helper(GtkTreeModel *model, GtkTreePath *path,
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
190 GtkTreeIter *iter, gpointer user_data)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
191 {
11889
04c2c3d84849 [gaim-migrate @ 14180]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11888
diff changeset
192 GList **list = (GList **)user_data;
04c2c3d84849 [gaim-migrate @ 14180]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11888
diff changeset
193 *list = g_list_append(*list, gtk_tree_path_copy(path));
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
194 }
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
195 #endif
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
196
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
197 static void
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
198 status_window_use_cb(GtkButton *button, StatusWindow *dialog)
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
199 {
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
200 GtkTreeSelection *selection;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
201 GtkTreeIter iter;
11889
04c2c3d84849 [gaim-migrate @ 14180]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11888
diff changeset
202 GList *list = NULL;
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
203 int num_selected = 0;
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
204
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
205 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
206
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
207 #if GTK_CHECK_VERSION(2,2,0)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
208 num_selected = gtk_tree_selection_count_selected_rows(selection);
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
209 #else
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
210 gtk_tree_selection_selected_foreach(selection, count_selected_helper, &num_selected);
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
211 #endif
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
212 if (num_selected != 1)
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
213 /*
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
214 * This shouldn't happen because the "Use" button should have
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
215 * been grayed out. Oh well.
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
216 */
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
217 return;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
218
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
219 #if GTK_CHECK_VERSION(2,2,0)
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
220 list = gtk_tree_selection_get_selected_rows(selection, NULL);
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
221 #else
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
222 gtk_tree_selection_selected_foreach(selection, list_selected_helper, &list);
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
223 #endif
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
224
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
225 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model),
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
226 &iter, list->data))
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
227 {
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
228 gchar *title;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
229 GaimSavedStatus *saved_status;
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
230 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
231 STATUS_WINDOW_COLUMN_TITLE, &title,
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
232 -1);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
233 saved_status = gaim_savedstatus_find(title);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
234 g_free(title);
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
235 gaim_savedstatus_activate(saved_status);
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
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
238 g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
239 g_list_free(list);
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
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
242 static void
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
243 status_window_add_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
244 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
245 gaim_gtk_status_editor_show(NULL);
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
248 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
249 status_window_modify_foreach(GtkTreeModel *model, GtkTreePath *path,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
250 GtkTreeIter *iter, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
251 {
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
252 gchar *title;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
253 GaimSavedStatus *saved_status;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
254
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
255 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
256 saved_status = gaim_savedstatus_find(title);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
257 g_free(title);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
258 gaim_gtk_status_editor_show(saved_status);
10421
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
261 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
262 status_window_modify_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
263 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
264 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
265 GtkTreeSelection *selection;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
266
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
267 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
268
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
269 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
270 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
271
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
272 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
273 status_window_delete_confirm_cb(char *title)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
274 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
275 GtkTreeIter iter;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
276
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
277 if (status_window_find_savedstatus(&iter, title))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
278 gtk_list_store_remove(status_window->model, &iter);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
279
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
280 gaim_savedstatus_delete(title);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
281
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
282 g_free(title);
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
285 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
286 status_window_delete_foreach(GtkTreeModel *model, GtkTreePath *path,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
287 GtkTreeIter *iter, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
288 {
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
289 char *title;
12237
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
290 char *buf;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
291
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
292 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
293
12237
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
294 buf = g_strdup_printf(_("Are you sure you want to delete %s?"), title);
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
295 gaim_request_action(NULL, NULL, buf, NULL, 0, title, 2,
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
296 _("Delete"), status_window_delete_confirm_cb,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
297 _("Cancel"), g_free);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
298 g_free(buf);
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
301 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
302 status_window_delete_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
303 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
304 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
305 GtkTreeSelection *selection;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
306
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
307 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
308
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
309 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
310 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
311
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
312 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
313 status_window_close_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
314 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
315 gaim_gtk_status_window_hide();
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
318 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
319 status_selected_cb(GtkTreeSelection *sel, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
320 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
321 StatusWindow *dialog = user_data;
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
322 int num_selected = 0;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
323
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
324 #if GTK_CHECK_VERSION(2,2,0)
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
325 num_selected = gtk_tree_selection_count_selected_rows(sel);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
326 #else
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
327 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
328 #endif
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
329
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
330 gtk_widget_set_sensitive(dialog->use_button, (num_selected == 1));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
331 gtk_widget_set_sensitive(dialog->modify_button, (num_selected > 0));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
332 gtk_widget_set_sensitive(dialog->delete_button, (num_selected > 0));
10421
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
335 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
336 add_status_to_saved_status_list(GtkListStore *model, GaimSavedStatus *saved_status)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
337 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
338 GtkTreeIter iter;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
339 const char *title;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
340 const char *type;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
341 char *message;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
342
11651
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
343 if (gaim_savedstatus_is_transient(saved_status))
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
344 return;
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
345
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
346 title = gaim_savedstatus_get_title(saved_status);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
347 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
348 message = gaim_markup_strip_html(gaim_savedstatus_get_message(saved_status));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
349
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
350 gtk_list_store_append(model, &iter);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
351 gtk_list_store_set(model, &iter,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
352 STATUS_WINDOW_COLUMN_TITLE, title,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
353 STATUS_WINDOW_COLUMN_TYPE, type,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
354 STATUS_WINDOW_COLUMN_MESSAGE, message,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
355 -1);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
356 free(message);
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
359 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
360 populate_saved_status_list(StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
361 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
362 const GList *saved_statuses;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
363
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
364 gtk_list_store_clear(dialog->model);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
365
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
366 for (saved_statuses = gaim_savedstatuses_get_all(); saved_statuses != NULL;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
367 saved_statuses = g_list_next(saved_statuses))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
368 {
12199
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
369 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
370 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
371 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
372
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
373 static gboolean
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
374 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
375 {
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
376 gboolean result;
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
377 char *haystack;
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
378
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
379 gtk_tree_model_get(model, iter, column, &haystack, -1);
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
380
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
381 result = (gaim_strcasestr(haystack, key) == NULL);
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
382
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
383 g_free(haystack);
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
384
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
385 return result;
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
386 }
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
387
12162
5e24b8e49522 [gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents: 12080
diff changeset
388 static void
12173
81c63578aa39 [gaim-migrate @ 14475]
Richard Laager <rlaager@wiktel.com>
parents: 12162
diff changeset
389 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
390 {
12173
81c63578aa39 [gaim-migrate @ 14475]
Richard Laager <rlaager@wiktel.com>
parents: 12162
diff changeset
391 status_window_modify_cb(NULL, dialog);
12162
5e24b8e49522 [gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents: 12080
diff changeset
392 }
5e24b8e49522 [gaim-migrate @ 14463]
Richard Laager <rlaager@wiktel.com>
parents: 12080
diff changeset
393
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
394 static GtkWidget *
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
395 create_saved_status_list(StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
396 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
397 GtkWidget *sw;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
398 GtkWidget *treeview;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
399 GtkTreeSelection *sel;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
400 GtkTreeViewColumn *column;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
401 GtkCellRenderer *renderer;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
402
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
403 /* Create the scrolled window */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
404 sw = gtk_scrolled_window_new(0, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
405 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
406 GTK_POLICY_AUTOMATIC,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
407 GTK_POLICY_ALWAYS);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
408 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
409 GTK_SHADOW_IN);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
410 gtk_widget_show(sw);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
411
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
412 /* Create the list model */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
413 dialog->model = gtk_list_store_new(STATUS_WINDOW_NUM_COLUMNS,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
414 G_TYPE_STRING,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
415 G_TYPE_STRING,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
416 G_TYPE_STRING);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
417
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
418 /* Create the treeview */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
419 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
420 dialog->treeview = treeview;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
421 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
422 g_signal_connect(G_OBJECT(treeview), "row-activated",
12173
81c63578aa39 [gaim-migrate @ 14475]
Richard Laager <rlaager@wiktel.com>
parents: 12162
diff changeset
423 G_CALLBACK(savedstatus_activated_cb), dialog);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
424
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
425 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
426 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
427 g_signal_connect(G_OBJECT(sel), "changed",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
428 G_CALLBACK(status_selected_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
429
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
430 gtk_container_add(GTK_CONTAINER(sw), treeview);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
431 gtk_widget_show(treeview);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
432
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
433 /* Add columns */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
434 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
435 gtk_tree_view_column_set_title(column, _("Title"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
436 gtk_tree_view_column_set_resizable(column, TRUE);
11548
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
437 gtk_tree_view_column_set_min_width(column, 100);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
438 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
439 STATUS_WINDOW_COLUMN_TITLE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
440 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
441 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
442 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
443 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
444 STATUS_WINDOW_COLUMN_TITLE);
11548
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
445 #if GTK_CHECK_VERSION(2,6,0)
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
446 g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
447 #endif
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
448
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
449 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
450 gtk_tree_view_column_set_title(column, _("Type"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
451 gtk_tree_view_column_set_resizable(column, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
452 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
453 STATUS_WINDOW_COLUMN_TYPE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
454 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
455 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
456 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
457 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
458 STATUS_WINDOW_COLUMN_TYPE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
459
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
460 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
461 gtk_tree_view_column_set_title(column, _("Message"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
462 gtk_tree_view_column_set_resizable(column, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
463 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
464 STATUS_WINDOW_COLUMN_MESSAGE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
465 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
466 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
467 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
468 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
469 STATUS_WINDOW_COLUMN_MESSAGE);
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
470 #if GTK_CHECK_VERSION(2,6,0)
10502
6cd5cca9c451 [gaim-migrate @ 11794]
Sean Egan <seanegan@gmail.com>
parents: 10439
diff changeset
471 g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
472 #endif
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
473
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
474 /* Enable CTRL+F searching */
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
475 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
476 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
477
10422
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
478 /* Sort the title column by default */
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
479 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
480 STATUS_WINDOW_COLUMN_TITLE,
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
481 GTK_SORT_ASCENDING);
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
482
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
483 /* Populate list */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
484 populate_saved_status_list(dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
485
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 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
492 if (GTK_WIDGET_VISIBLE(widget)) {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
493 gaim_prefs_set_int("/gaim/gtk/status/dialog/width", event->width);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
494 gaim_prefs_set_int("/gaim/gtk/status/dialog/height", event->height);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
495 }
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 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
498 }
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 void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
501 gaim_gtk_status_window_show(void)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
502 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
503 StatusWindow *dialog;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
504 GtkWidget *bbox;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
505 GtkWidget *button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
506 GtkWidget *list;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
507 GtkWidget *vbox;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
508 GtkWidget *win;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
509 int width, height;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
510
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
511 if (status_window != NULL) {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
512 gtk_window_present(GTK_WINDOW(status_window->window));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
513 return;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
514 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
515
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
516 status_window = dialog = g_new0(StatusWindow, 1);
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 width = gaim_prefs_get_int("/gaim/gtk/status/dialog/width");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
519 height = gaim_prefs_get_int("/gaim/gtk/status/dialog/height");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
520
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
521 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
522 gtk_window_set_default_size(GTK_WINDOW(win), width, height);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
523 gtk_window_set_role(GTK_WINDOW(win), "statuses");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
524 gtk_window_set_title(GTK_WINDOW(win), _("Saved Statuses"));
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
525 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
526
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
527 g_signal_connect(G_OBJECT(win), "delete_event",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
528 G_CALLBACK(status_window_destroy_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
529 g_signal_connect(G_OBJECT(win), "configure_event",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
530 G_CALLBACK(configure_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
531
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
532 /* Setup the vbox */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
533 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
534 gtk_container_add(GTK_CONTAINER(win), vbox);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
535 gtk_widget_show(vbox);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
536
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
537 /* List of saved status states */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
538 list = create_saved_status_list(dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
539 gtk_box_pack_start(GTK_BOX(vbox), list, TRUE, TRUE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
540
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
541 /* Button box. */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
542 bbox = gtk_hbutton_box_new();
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
543 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
544 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
545 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
546 gtk_widget_show(bbox);
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 gtk_widget_show(button);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
555
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
556 g_signal_connect(G_OBJECT(button), "clicked",
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
557 G_CALLBACK(status_window_use_cb), dialog);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
558
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
559 /* Add button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
560 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
561 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
562 gtk_widget_show(button);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
563
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
564 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
565 G_CALLBACK(status_window_add_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
566
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
567 /* Modify button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
568 button = gtk_button_new_from_stock(GAIM_STOCK_MODIFY);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
569 dialog->modify_button = button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
570 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
571 gtk_widget_set_sensitive(button, FALSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
572 gtk_widget_show(button);
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 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
575 G_CALLBACK(status_window_modify_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
576
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
577 /* Delete button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
578 button = gtk_button_new_from_stock(GTK_STOCK_DELETE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
579 dialog->delete_button = button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
580 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
581 gtk_widget_set_sensitive(button, FALSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
582 gtk_widget_show(button);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
583
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
584 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
585 G_CALLBACK(status_window_delete_cb), dialog);
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 /* Close button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
588 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
589 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
590 gtk_widget_show(button);
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 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
593 G_CALLBACK(status_window_close_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
594
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
595 gtk_widget_show(win);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
596 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
597
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
598 void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
599 gaim_gtk_status_window_hide(void)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
600 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
601 if (status_window == NULL)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
602 return;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
603
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
604 if (status_window->window != NULL)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
605 gtk_widget_destroy(status_window->window);
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 g_free(status_window);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
608 status_window = NULL;
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
611
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
612 /**************************************************************************
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
613 * Status editor
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
614 **************************************************************************/
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
615
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
616 static gboolean
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
617 status_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
618 {
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
619 StatusEditor *dialog = user_data;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
620
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
621 g_free(dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
622 g_free(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
623
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
624 return FALSE;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
625 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
626
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
627 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
628 status_editor_cancel_cb(GtkButton *button, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
629 {
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
630 StatusEditor *dialog = user_data;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
631
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
632 gtk_widget_destroy(dialog->window);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
633
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
634 g_free(dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
635 g_free(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
636 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
637
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
638 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
639 status_editor_save_cb(GtkButton *button, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
640 {
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
641 StatusEditor *dialog = user_data;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
642 const char *title;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
643 GaimStatusPrimitive type;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
644 char *message, *unformatted;
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
645 GaimSavedStatus *saved_status = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
646 GtkTreeModel *model;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
647 GtkTreeIter iter;
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
648
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
649 title = gtk_entry_get_text(dialog->title);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
650
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
651 /*
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
652 * If the title is already taken then show an error dialog and
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
653 * don't do anything.
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
654 */
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
655 if ((gaim_savedstatus_find(title) != NULL) &&
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
656 ((dialog->original_title == NULL) || (strcmp(title, dialog->original_title))))
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
657 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
658 gaim_notify_error(NULL, NULL, _("Title already in use. You must "
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
659 "choose a unique title."), NULL);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
660 return;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
661 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
662
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
663 type = gtk_option_menu_get_history(dialog->type);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
664 message = gtk_imhtml_get_markup(dialog->message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
665 unformatted = gaim_markup_strip_html(message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
666
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
667 /*
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
668 * If we're editing an old status, then lookup the old status (it's
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
669 * possible that it has been deleted or renamed or something, and
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
670 * no longer exists).
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
671 */
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
672 if (dialog->original_title != NULL)
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
673 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
674 GtkTreeIter iter;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
675
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
676 saved_status = gaim_savedstatus_find(dialog->original_title);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
677
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
678 if (status_window_find_savedstatus(&iter, dialog->original_title))
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
679 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
680 gtk_list_store_remove(status_window->model, &iter);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
681 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
682 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
683
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
684 if (saved_status == NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
685 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
686 /* This is a new status */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
687 saved_status = gaim_savedstatus_new(title, type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
688 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
689 else
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
690 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
691 /* Modify the old status */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
692 if (strcmp(title, dialog->original_title))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
693 gaim_savedstatus_set_title(saved_status, title);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
694 gaim_savedstatus_set_type(saved_status, type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
695 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
696
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
697 if (*unformatted != '\0')
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
698 gaim_savedstatus_set_message(saved_status, message);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
699
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
700 /* Set any substatuses */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
701 model = GTK_TREE_MODEL(dialog->model);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
702 if (gtk_tree_model_get_iter_first(model, &iter))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
703 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
704 GaimAccount *account;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
705 gboolean enabled;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
706 char *id;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
707 char *message;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
708 GaimStatusType *type;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
709
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
710 gtk_tree_model_get(model, &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
711 STATUS_EDITOR_COLUMN_ACCOUNT, &account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
712 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, &enabled,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
713 STATUS_EDITOR_COLUMN_STATUS_ID, &id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
714 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, &message,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
715 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
716 if (enabled)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
717 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
718 type = gaim_account_get_status_type(account, id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
719 gaim_savedstatus_set_substatus(saved_status, account, type, message);
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 g_free(id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
722 g_free(message);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
723
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
724 while (gtk_tree_model_iter_next(model, &iter))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
725 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
726 gtk_tree_model_get(model, &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
727 STATUS_EDITOR_COLUMN_ACCOUNT, &account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
728 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, &enabled,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
729 STATUS_EDITOR_COLUMN_STATUS_ID, &id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
730 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, &message,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
731 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
732 if (enabled)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
733 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
734 type = gaim_account_get_status_type(account, id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
735 gaim_savedstatus_set_substatus(saved_status, account, type, message);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
736 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
737 g_free(id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
738 g_free(message);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
739 }
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
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
742 g_free(message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
743 g_free(unformatted);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
744
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
745 gtk_widget_destroy(dialog->window);
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
746 g_free(dialog->original_title);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
747 g_free(dialog);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
748
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
749 if (status_window != NULL)
12199
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
750 add_status_to_saved_status_list(status_window->model, saved_status);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
751 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
752
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
753 static void
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
754 editor_title_changed_cb(GtkWidget *widget, gpointer user_data)
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
755 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
756 StatusEditor *dialog = user_data;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
757 const gchar *text;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
758
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
759 text = gtk_entry_get_text(dialog->title);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
760
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
761 gtk_widget_set_sensitive(dialog->save_button, (*text != '\0'));
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
762 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
763
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
764 static GtkWidget *
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
765 create_status_type_menu(GaimStatusPrimitive type)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
766 {
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
767 int i;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
768 GtkWidget *dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
769 GtkWidget *menu;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
770 GtkWidget *item;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
771
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
772 dropdown = gtk_option_menu_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
773 menu = gtk_menu_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
774
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
775 for (i = 0; i < GAIM_STATUS_NUM_PRIMITIVES; i++)
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
776 {
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
777 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
778 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
779 gtk_widget_show(item);
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
780 }
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
781
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
782 gtk_menu_set_active(GTK_MENU(menu), type);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
783 gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
784 gtk_widget_show(menu);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
785
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
786 return dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
787 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
788
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
789 static void edit_substatus(StatusEditor *status_editor, GaimAccount *account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
790
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
791 static void
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
792 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
793 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
794 StatusEditor *dialog = user_data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
795 GtkTreeIter iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
796 GaimAccount *account;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
797
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
798 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
799 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
800 STATUS_EDITOR_COLUMN_ACCOUNT, &account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
801 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
802
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
803 edit_substatus(dialog, account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
804 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
805
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
806 static void
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
807 status_editor_substatus_cb(GtkCellRendererToggle *renderer, gchar *path_str, gpointer data)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
808 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
809 StatusEditor *dialog = (StatusEditor *)data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
810 GtkTreeIter iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
811 gboolean enabled;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
812 GaimAccount *account;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
813
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
814 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
815 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
816 STATUS_EDITOR_COLUMN_ACCOUNT, &account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
817 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, &enabled,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
818 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
819
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
820 enabled = !enabled;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
821
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
822 if (enabled)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
823 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
824 edit_substatus(dialog, account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
825 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
826 else
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
827 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
828 GaimSavedStatus *saved_status;
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 /* Remove the substatus */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
831 saved_status = gaim_savedstatus_find(dialog->original_title);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
832 gaim_savedstatus_unset_substatus(saved_status, account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
833 gtk_list_store_set(dialog->model, &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
834 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, enabled,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
835 STATUS_EDITOR_COLUMN_STATUS_ID, NULL,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
836 STATUS_EDITOR_COLUMN_STATUS_NAME, NULL,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
837 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, NULL,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
838 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
839 }
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
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
842 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
843 status_editor_add_columns(StatusEditor *dialog)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
844 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
845 GtkCellRenderer *renderer;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
846 GtkTreeViewColumn *column;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
847
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
848 /* Enable Different status column */
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
849 renderer = gtk_cell_renderer_toggle_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
850 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
851 -1, _("Different"),
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
852 renderer,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
853 "active", STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
854 NULL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
855 column = gtk_tree_view_get_column(GTK_TREE_VIEW(dialog->treeview), 1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
856 g_signal_connect(G_OBJECT(renderer), "toggled",
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
857 G_CALLBACK(status_editor_substatus_cb), dialog);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
858
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
859 /* Screen Name column */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
860 column = gtk_tree_view_column_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
861 gtk_tree_view_column_set_resizable(column, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
862 gtk_tree_view_column_set_title(column, _("Screen Name"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
863 gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
864 gtk_tree_view_column_set_resizable(column, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
865
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
866 /* Icon */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
867 renderer = gtk_cell_renderer_pixbuf_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
868 gtk_tree_view_column_pack_start(column, renderer, FALSE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
869 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
870 STATUS_EDITOR_COLUMN_ICON);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
871
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
872 /* Screen Name */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
873 renderer = gtk_cell_renderer_text_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
874 gtk_tree_view_column_pack_start(column, renderer, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
875 gtk_tree_view_column_add_attribute(column, renderer, "text",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
876 STATUS_EDITOR_COLUMN_SCREENNAME);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
877
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
878 /* Status column */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
879 column = gtk_tree_view_column_new();
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
880 gtk_tree_view_column_set_resizable(column, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
881 gtk_tree_view_column_set_title(column, _("Status"));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
882 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
883 gtk_tree_view_column_set_resizable(column, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
884 renderer = gtk_cell_renderer_text_new();
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
885 gtk_tree_view_column_pack_start(column, renderer, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
886 gtk_tree_view_column_add_attribute(column, renderer, "text",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
887 STATUS_EDITOR_COLUMN_STATUS_NAME);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
888
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
889 /* Message column */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
890 column = gtk_tree_view_column_new();
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
891 gtk_tree_view_column_set_resizable(column, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
892 gtk_tree_view_column_set_title(column, _("Message"));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
893 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
894 gtk_tree_view_column_set_resizable(column, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
895 renderer = gtk_cell_renderer_text_new();
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
896 gtk_tree_view_column_pack_start(column, renderer, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
897 gtk_tree_view_column_add_attribute(column, renderer, "text",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
898 STATUS_EDITOR_COLUMN_STATUS_MESSAGE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
899
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
900 g_signal_connect(G_OBJECT(dialog->treeview), "row-activated",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
901 G_CALLBACK(edit_substatus_cb), dialog);
10418
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
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
904 static void
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
905 status_editor_set_account(GtkListStore *store, GaimAccount *account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
906 GtkTreeIter *iter, GaimSavedStatusSub *substatus)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
907 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
908 GdkPixbuf *pixbuf;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
909 GdkPixbuf *scale;
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
910 const char *id = NULL, *name = NULL, *message = NULL;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
911
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
912 scale = NULL;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
913
10884
5cda52915a1f [gaim-migrate @ 12582]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10814
diff changeset
914 pixbuf = gaim_gtk_create_prpl_icon(account);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
915
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
916 if (pixbuf != NULL)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
917 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
918 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
919
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
920 if (gaim_account_is_disconnected(account))
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
921 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
922 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
923
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
924 if (substatus != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
925 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
926 const GaimStatusType *type;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
927
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
928 type = gaim_savedstatus_substatus_get_type(substatus);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
929 id = gaim_status_type_get_id(type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
930 name = gaim_status_type_get_name(type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
931 if (gaim_status_type_get_attr(type, "message"))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
932 message = gaim_savedstatus_substatus_get_message(substatus);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
933 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
934
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
935 gtk_list_store_set(store, iter,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
936 STATUS_EDITOR_COLUMN_ACCOUNT, account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
937 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, (substatus != NULL),
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
938 STATUS_EDITOR_COLUMN_ICON, scale,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
939 STATUS_EDITOR_COLUMN_SCREENNAME, gaim_account_get_username(account),
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
940 STATUS_EDITOR_COLUMN_STATUS_ID, id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
941 STATUS_EDITOR_COLUMN_STATUS_NAME, name,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
942 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, message,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
943 -1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
944
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
945 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
946 if (scale != NULL) g_object_unref(G_OBJECT(scale));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
947 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
948
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
949 static void
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
950 status_editor_add_account(StatusEditor *dialog, GaimAccount *account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
951 GaimSavedStatusSub *substatus)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
952 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
953 GtkTreeIter iter;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
954
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
955 gtk_list_store_append(dialog->model, &iter);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
956
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
957 status_editor_set_account(dialog->model, account, &iter, substatus);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
958 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
959
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
960 static void
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
961 status_editor_populate_list(StatusEditor *dialog, GaimSavedStatus *saved_status)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
962 {
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
963 GList *iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
964 GaimSavedStatusSub *substatus;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
965
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
966 gtk_list_store_clear(dialog->model);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
967
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
968 for (iter = gaim_accounts_get_all(); iter != NULL; iter = iter->next)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
969 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
970 GaimAccount *account = (GaimAccount *)iter->data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
971
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
972 if (saved_status != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
973 substatus = gaim_savedstatus_get_substatus(saved_status, account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
974 else
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
975 substatus = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
976
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
977 status_editor_add_account(dialog, account, substatus);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
978 }
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
979 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
980
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
981 void
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
982 gaim_gtk_status_editor_show(GaimSavedStatus *saved_status)
10418
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 StatusEditor *dialog;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
985 GtkSizeGroup *sg;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
986 GtkWidget *bbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
987 GtkWidget *button;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
988 GtkWidget *dbox;
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
989 GtkWidget *expander;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
990 GtkWidget *dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
991 GtkWidget *entry;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
992 GtkWidget *frame;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
993 GtkWidget *hbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
994 GtkWidget *label;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
995 GtkWidget *sw;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
996 GtkWidget *text;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
997 GtkWidget *toolbar;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
998 GtkWidget *vbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
999 GtkWidget *win;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1000
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1001 dialog = g_new0(StatusEditor, 1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1002
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1003 if (saved_status != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1004 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
1005
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1006 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1007 gtk_window_set_role(GTK_WINDOW(win), "status");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1008 gtk_window_set_title(GTK_WINDOW(win), _("Status"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1009 gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1010 gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1011
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1012 g_signal_connect(G_OBJECT(win), "delete_event",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1013 G_CALLBACK(status_editor_destroy_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1014
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1015 /* Setup the vbox */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1016 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1017 gtk_container_add(GTK_CONTAINER(win), vbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1018 gtk_widget_show(vbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1019
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1020 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1021
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1022 /* Title */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1023 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1024 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1025 gtk_widget_show(hbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1026
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1027 label = gtk_label_new_with_mnemonic(_("_Title:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1028 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1029 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1030 gtk_widget_show(label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1031 gtk_size_group_add_widget(sg, label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1032
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1033 entry = gtk_entry_new();
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1034 dialog->title = GTK_ENTRY(entry);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1035 if (dialog->original_title != NULL)
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1036 gtk_entry_set_text(GTK_ENTRY(entry), dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1037 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1038 gtk_widget_show(entry);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1039 g_signal_connect(G_OBJECT(entry), "changed",
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1040 G_CALLBACK(editor_title_changed_cb), dialog);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1041
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1042 /* Status type */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1043 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1044 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1045 gtk_widget_show(hbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1046
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1047 label = gtk_label_new_with_mnemonic(_("_Status:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1048 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1049 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1050 gtk_widget_show(label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1051 gtk_size_group_add_widget(sg, label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1052
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1053 if (saved_status != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1054 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
1055 else
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
1056 dropdown = create_status_type_menu(GAIM_STATUS_AWAY);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1057 dialog->type = GTK_OPTION_MENU(dropdown);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1058 gtk_box_pack_start(GTK_BOX(hbox), dropdown, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1059 gtk_widget_show(dropdown);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1060
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1061 /* Status message */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1062 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1063 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1064 gtk_widget_show(hbox);
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 label = gtk_label_new_with_mnemonic(_("_Message:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1067 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1068 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1069 gtk_widget_show(label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1070 gtk_size_group_add_widget(sg, label);
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 frame = gaim_gtk_create_imhtml(TRUE, &text, &toolbar);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1073 dialog->message = GTK_IMHTML(text);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1074 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1075 gtk_widget_show(frame);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1076
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1077 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
1078 gtk_imhtml_append_text(GTK_IMHTML(text),
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1079 gaim_savedstatus_get_message(saved_status), 0);
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
1080
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1081 /* Different status message expander */
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
1082 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
1083 gtk_box_pack_start(GTK_BOX(vbox), expander, FALSE, FALSE, 0);
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
1084 gtk_widget_show(expander);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1085
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
1086 /* Setup the box that the expander will cover */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1087 dbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE);
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
1088 gtk_container_add(GTK_CONTAINER(expander), dbox);
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
1089 gtk_widget_show(dbox);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1090
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1091 /* Different status message treeview */
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1092 sw = gtk_scrolled_window_new(NULL, NULL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1093 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1094 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1095 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1096 GTK_SHADOW_IN);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1097 gtk_box_pack_start(GTK_BOX(dbox), sw, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1098 gtk_widget_show(sw);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1099
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1100 /* Create the list model */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1101 dialog->model = gtk_list_store_new(STATUS_EDITOR_NUM_COLUMNS,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1102 G_TYPE_POINTER,
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1103 G_TYPE_BOOLEAN,
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1104 GDK_TYPE_PIXBUF,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1105 G_TYPE_STRING,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1106 G_TYPE_STRING,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1107 G_TYPE_STRING,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1108 G_TYPE_STRING);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1109
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1110 /* Create the treeview */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1111 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
1112 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(dialog->treeview), TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1113 gtk_widget_set_size_request(dialog->treeview, 400, 250);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1114 gtk_container_add(GTK_CONTAINER(sw), dialog->treeview);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1115 gtk_widget_show(dialog->treeview);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1116
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1117 /* Add columns */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1118 status_editor_add_columns(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1119
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1120 /* Populate list */
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1121 status_editor_populate_list(dialog, saved_status);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1122
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1123 /* Button box */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1124 bbox = gtk_hbutton_box_new();
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
1125 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1126 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1127 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1128 gtk_widget_show(bbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1129
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1130 /* Cancel button */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1131 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1132 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1133 gtk_widget_show(button);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1134
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1135 g_signal_connect(G_OBJECT(button), "clicked",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1136 G_CALLBACK(status_editor_cancel_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1137
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1138 /* Save button */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1139 button = gtk_button_new_from_stock(GTK_STOCK_SAVE);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
1140 dialog->save_button = button;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1141 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1142 if (dialog->title == NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1143 gtk_widget_set_sensitive(button, FALSE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1144 gtk_widget_show(button);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1145
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1146 g_signal_connect(G_OBJECT(button), "clicked",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1147 G_CALLBACK(status_editor_save_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1148
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1149 gtk_widget_show(win);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1150 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1151
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1152
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
1153 /**************************************************************************
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1154 * SubStatus editor
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1155 **************************************************************************/
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1156
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1157 static void
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1158 substatus_selection_changed_cb(GtkComboBox *box, gpointer user_data)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1159 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1160 SubStatusEditor *select = user_data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1161 GtkTreeIter iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1162 GaimAccount *account;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1163 char *id;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1164 GaimStatusType *type;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1165
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1166 if (!gtk_combo_box_get_active_iter(box, &iter))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1167 return;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1168 gtk_tree_model_get(GTK_TREE_MODEL(select->model), &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1169 SUBSTATUS_COLUMN_ACCOUNT, &account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1170 SUBSTATUS_COLUMN_STATUS_ID, &id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1171 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1172 type = gaim_account_get_status_type(account, id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1173 g_free(id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1174
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1175 if (gaim_status_type_get_attr(type, "message") == NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1176 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1177 gtk_widget_set_sensitive(GTK_WIDGET(select->message), FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1178 gtk_widget_set_sensitive(GTK_WIDGET(select->toolbar), FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1179 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1180 else
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1181 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1182 gtk_widget_set_sensitive(GTK_WIDGET(select->message), TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1183 gtk_widget_set_sensitive(GTK_WIDGET(select->toolbar), TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1184 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1185 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1186
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1187 static gboolean
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1188 substatus_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1189 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1190 SubStatusEditor *dialog = user_data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1191
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1192 g_free(dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1193
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1194 return FALSE;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1195 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1196
12246
b7a51e68d0b8 [gaim-migrate @ 14548]
Mark Doliner <mark@kingant.net>
parents: 12238
diff changeset
1197 static void
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1198 substatus_editor_cancel_cb(GtkButton *button, gpointer user_data)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1199 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1200 SubStatusEditor *dialog = user_data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1201
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1202 gtk_widget_destroy(dialog->window);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1203
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1204 g_free(dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1205 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1206
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1207 static gboolean
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1208 status_editor_find_account_in_treemodel(GtkTreeIter *iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1209 StatusEditor *status_editor,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1210 GaimAccount *account)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1211 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1212 GtkTreeModel *model;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1213 GaimAccount *cur;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1214
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1215 g_return_val_if_fail(status_editor != NULL, FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1216 g_return_val_if_fail(account != NULL, FALSE);
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 model = GTK_TREE_MODEL(status_editor->model);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1219
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1220 if (!gtk_tree_model_get_iter_first(model, iter))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1221 return FALSE;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1222
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1223 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
1224 if (cur == account)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1225 return TRUE;
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 while (gtk_tree_model_iter_next(model, iter))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1228 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1229 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
1230 if (cur == account)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1231 return TRUE;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1232 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1233
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1234 return FALSE;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1235 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1236
12246
b7a51e68d0b8 [gaim-migrate @ 14548]
Mark Doliner <mark@kingant.net>
parents: 12238
diff changeset
1237 static void
12080
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1238 substatus_editor_ok_cb(GtkButton *button, gpointer user_data)
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 SubStatusEditor *dialog = user_data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1241 StatusEditor *status_editor;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1242 GtkTreeIter iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1243 GaimAccount *account;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1244 GaimStatusType *type;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1245 char *id = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1246 char *message = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1247 const char *name = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1248
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1249 gtk_combo_box_get_active_iter(dialog->box, &iter);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1250 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1251 SUBSTATUS_COLUMN_ACCOUNT, &account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1252 SUBSTATUS_COLUMN_STATUS_ID, &id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1253 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1254 type = gaim_account_get_status_type(account, id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1255 if (gaim_status_type_get_attr(type, "message") != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1256 message = gtk_imhtml_get_text(GTK_IMHTML(dialog->message), NULL, NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1257 name = gaim_status_type_get_name(type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1258
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1259 status_editor = dialog->status_editor;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1260
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1261 if (status_editor_find_account_in_treemodel(&iter, status_editor, account))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1262 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1263 gtk_list_store_set(status_editor->model, &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1264 STATUS_EDITOR_COLUMN_ENABLE_SUBSTATUS, TRUE,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1265 STATUS_EDITOR_COLUMN_STATUS_ID, id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1266 STATUS_EDITOR_COLUMN_STATUS_NAME, name,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1267 STATUS_EDITOR_COLUMN_STATUS_MESSAGE, message,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1268 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1269 }
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 gtk_widget_destroy(dialog->window);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1272 g_free(id);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1273 g_free(message);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1274 g_free(dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1275 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1276
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1277 static void
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1278 edit_substatus(StatusEditor *status_editor, GaimAccount *account)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1279 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1280 char *tmp;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1281 SubStatusEditor *dialog;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1282 GtkSizeGroup *sg;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1283 GtkWidget *bbox;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1284 GtkWidget *button;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1285 GtkWidget *combo;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1286 GtkWidget *hbox;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1287 GtkWidget *frame;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1288 GtkWidget *label;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1289 GtkWidget *text;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1290 GtkWidget *toolbar;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1291 GtkWidget *vbox;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1292 GtkWidget *win;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1293 GtkTreeIter iter;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1294 GtkCellRenderer *rend;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1295 const char *id = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1296 const GList *list;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1297 gboolean select = FALSE;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1298
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1299 g_return_if_fail(status_editor != NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1300 g_return_if_fail(account != NULL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1301
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1302 dialog = g_new0(SubStatusEditor, 1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1303 dialog->status_editor = status_editor;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1304
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1305 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1306 gtk_window_set_role(GTK_WINDOW(win), "substatus");
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1307 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
1308 gtk_window_set_title(GTK_WINDOW(win), tmp);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1309 g_free(tmp);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1310 gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1311 gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1312
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1313 g_signal_connect(G_OBJECT(win), "delete_event",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1314 G_CALLBACK(substatus_editor_destroy_cb), dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1315
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1316 /* Setup the vbox */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1317 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1318 gtk_container_add(GTK_CONTAINER(win), vbox);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1319 gtk_widget_show(vbox);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1320
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1321 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1322
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1323 /* Status type */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1324 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1325 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1326 gtk_widget_show(hbox);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1327
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1328 label = gtk_label_new_with_mnemonic(_("_Status:"));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1329 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1330 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1331 gtk_widget_show(label);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1332 gtk_size_group_add_widget(sg, label);
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 dialog->model = gtk_list_store_new(SUBSTATUS_NUM_COLUMNS,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1335 G_TYPE_POINTER,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1336 GDK_TYPE_PIXBUF,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1337 G_TYPE_STRING,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1338 G_TYPE_STRING);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1339 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
1340 dialog->box = GTK_COMBO_BOX(combo);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1341
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1342 rend = GTK_CELL_RENDERER(gtk_cell_renderer_pixbuf_new());
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1343 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), rend, FALSE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1344 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), rend,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1345 "pixbuf", SUBSTATUS_COLUMN_ICON, NULL);
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 rend = GTK_CELL_RENDERER(gtk_cell_renderer_text_new());
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1348 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo), rend, TRUE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1349 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo), rend,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1350 "text", SUBSTATUS_COLUMN_STATUS_NAME, NULL);
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 g_signal_connect(G_OBJECT(combo), "changed",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1353 G_CALLBACK(substatus_selection_changed_cb), dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1354
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1355 gtk_box_pack_start(GTK_BOX(hbox), combo, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1356 gtk_widget_show(combo);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1357
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1358 /* Status mesage */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1359 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1360 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1361 gtk_widget_show(hbox);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1362
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1363 label = gtk_label_new_with_mnemonic(_("_Message:"));
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1364 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1365 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1366 gtk_widget_show(label);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1367 gtk_size_group_add_widget(sg, label);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1368
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1369 frame = gaim_gtk_create_imhtml(TRUE, &text, &toolbar);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1370 dialog->message = GTK_IMHTML(text);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1371 dialog->toolbar = GTK_IMHTMLTOOLBAR(toolbar);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1372 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1373 gtk_widget_show(frame);
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 /* Button box */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1376 bbox = gtk_hbutton_box_new();
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1377 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1378 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
1379 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1380 gtk_widget_show(bbox);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1381
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1382 /* Cancel button */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1383 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1384 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1385 gtk_widget_show(button);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1386
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1387 g_signal_connect(G_OBJECT(button), "clicked",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1388 G_CALLBACK(substatus_editor_cancel_cb), dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1389
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1390 /* OK button */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1391 button = gtk_button_new_from_stock(GTK_STOCK_OK);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1392 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1393 gtk_widget_show(button);
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 g_signal_connect(G_OBJECT(button), "clicked",
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1396 G_CALLBACK(substatus_editor_ok_cb), dialog);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1397
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1398 /* Seed the input widgets with the current values */
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1399 /* 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
1400 if (status_editor->original_title != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1401 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1402 GaimSavedStatus *saved_status = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1403 GaimSavedStatusSub *substatus = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1404
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1405 saved_status = gaim_savedstatus_find(status_editor->original_title);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1406 if (saved_status != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1407 substatus = gaim_savedstatus_get_substatus(saved_status, account);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1408
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1409 if (substatus != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1410 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1411 gtk_imhtml_append_text(dialog->message,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1412 gaim_savedstatus_substatus_get_message(substatus),
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1413 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1414 id = gaim_status_type_get_id(gaim_savedstatus_substatus_get_type(substatus));
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 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1417
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1418 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
1419 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1420 GaimStatusType *status_type;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1421 GdkPixbuf *pixbuf, *scale = NULL;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1422 const char *id, *name;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1423
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1424 status_type = list->data;
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1425 id = gaim_status_type_get_id(status_type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1426 pixbuf = gaim_gtk_create_prpl_icon_with_status(account, status_type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1427 if (pixbuf != NULL)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1428 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1429 name = gaim_status_type_get_name(status_type);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1430
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1431 gtk_list_store_append(dialog->model, &iter);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1432 gtk_list_store_set(dialog->model, &iter,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1433 SUBSTATUS_COLUMN_ACCOUNT, account,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1434 SUBSTATUS_COLUMN_ICON, scale,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1435 SUBSTATUS_COLUMN_STATUS_ID, id,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1436 SUBSTATUS_COLUMN_STATUS_NAME, name,
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1437 -1);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1438 if (id && !strcmp(id, gaim_status_type_get_id(status_type)))
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1439 {
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1440 gtk_combo_box_set_active_iter(GTK_COMBO_BOX(combo), &iter);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1441 select = TRUE;
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 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1444
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1445 if (!select)
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1446 gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1447
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1448 gtk_widget_show(win);
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1449 }
3b52d94437f3 [gaim-migrate @ 14377]
Mark Doliner <mark@kingant.net>
parents: 11954
diff changeset
1450
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1451 /**************************************************************************
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1452 * Utilities *
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1453 **************************************************************************/
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1454
12246
b7a51e68d0b8 [gaim-migrate @ 14548]
Mark Doliner <mark@kingant.net>
parents: 12238
diff changeset
1455 static void
b7a51e68d0b8 [gaim-migrate @ 14548]
Mark Doliner <mark@kingant.net>
parents: 12238
diff changeset
1456 status_menu_cb(GtkComboBox *widget, void(*callback)(GaimSavedStatus*))
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1457 {
12237
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1458 GtkTreeIter iter;
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1459 gchar *title = NULL;
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1460
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1461 if (!gtk_combo_box_get_active_iter(widget, &iter))
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1462 return;
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1463
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1464 gtk_tree_model_get(gtk_combo_box_get_model(widget), &iter,
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1465 STATUS_WINDOW_COLUMN_TITLE, &title, -1);
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1466 callback(gaim_savedstatus_find(title));
3294e27cb54a [gaim-migrate @ 14539]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12199
diff changeset
1467 g_free(title);
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1468 }
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1469
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1470 GtkWidget *gaim_gtk_status_menu(GaimSavedStatus *current_status, GCallback callback)
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1471 {
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1472 GtkWidget *combobox;
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1473 const GList *saved_statuses;
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1474 int i;
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1475 int index = -1;
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1476
12199
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1477 combobox = gtk_combo_box_new_text();
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1478
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1479 for (saved_statuses = gaim_savedstatuses_get_all(), i = 0;
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1480 saved_statuses != NULL;
12199
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1481 saved_statuses = g_list_next(saved_statuses)) {
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1482 GaimSavedStatus *status = (GaimSavedStatus*)saved_statuses->data;
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1483 if (!gaim_savedstatus_is_transient(status)) {
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1484 gtk_combo_box_append_text(GTK_COMBO_BOX(combobox),
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1485 gaim_savedstatus_get_title(status));
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1486 if (status == current_status)
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1487 index = i;
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1488 i++;
0a549a454d8e [gaim-migrate @ 14501]
Sean Egan <seanegan@gmail.com>
parents: 12195
diff changeset
1489 }
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1490 }
12246
b7a51e68d0b8 [gaim-migrate @ 14548]
Mark Doliner <mark@kingant.net>
parents: 12238
diff changeset
1491
12195
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1492 gtk_combo_box_set_active(GTK_COMBO_BOX(combobox), index);
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1493 g_signal_connect(G_OBJECT(combobox), "changed", G_CALLBACK(status_menu_cb), callback);
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1494 return combobox;
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1495 }
d040123d2b69 [gaim-migrate @ 14497]
Sean Egan <seanegan@gmail.com>
parents: 12173
diff changeset
1496
12080
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 /**************************************************************************
10814
364a2ef907ae [gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents: 10732
diff changeset
1499 * GTK+ saved status glue
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
1500 **************************************************************************/
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1501
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1502 void *
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1503 gaim_gtk_status_get_handle()
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1504 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1505 static int handle;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1506
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1507 return &handle;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1508 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1509
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1510 void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1511 gaim_gtk_status_init(void)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1512 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1513 gaim_prefs_add_none("/gaim/gtk/status");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1514 gaim_prefs_add_none("/gaim/gtk/status/dialog");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1515 gaim_prefs_add_int("/gaim/gtk/status/dialog/width", 550);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1516 gaim_prefs_add_int("/gaim/gtk/status/dialog/height", 250);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1517 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1518
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1519 void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1520 gaim_gtk_status_uninit(void)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1521 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1522 gaim_gtk_status_window_hide();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
1523 }