annotate src/gtksavedstatuses.c @ 11933:1b0c83666f98

[gaim-migrate @ 14224] The mixed whitespace in this file was confusing Evan. I also cleaned up a couple other stylistic things. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 31 Oct 2005 20:33:13 +0000
parents 04c2c3d84849
children 351f4dd75718
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
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
43 enum
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
44 {
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
45 /* A hidden column containing a pointer to the GaimStatusType */
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
46 STATUS_WINDOW_COLUMN_STATUS,
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
47
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
48 STATUS_WINDOW_COLUMN_TITLE,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
49 STATUS_WINDOW_COLUMN_TYPE,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
50 STATUS_WINDOW_COLUMN_MESSAGE,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
51 STATUS_WINDOW_NUM_COLUMNS
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
52 };
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
53
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
54 enum
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
55 {
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
56 STATUS_EDITOR_COLUMN_CUSTOM_STATUS,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
57 STATUS_EDITOR_COLUMN_ICON,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
58 STATUS_EDITOR_COLUMN_SCREENNAME,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
59 STATUS_EDITOR_NUM_COLUMNS
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
60 };
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
61
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
62 typedef struct
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
63 {
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
64 GtkWidget *window;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
65 GtkListStore *model;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
66 GtkWidget *treeview;
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
67 GtkWidget *use_button;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
68 GtkWidget *modify_button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
69 GtkWidget *delete_button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
70 } StatusWindow;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
71
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
72 typedef struct
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
73 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
74 GtkWidget *window;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
75 GtkListStore *model;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
76 GtkWidget *treeview;
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
77 GtkWidget *save_button;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
78
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
79 gchar *original_title;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
80 GtkEntry *title;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
81 GtkOptionMenu *type;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
82 GtkIMHtml *message;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
83 } StatusEditor;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
84
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
85 static StatusWindow *status_window = NULL;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
86
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
87
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
88 /**************************************************************************
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
89 * Status window
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
90 **************************************************************************/
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
91
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
92 static gboolean
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
93 status_window_find_savedstatus(GtkTreeIter *iter, const char *title)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
94 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
95 GtkTreeModel *model = GTK_TREE_MODEL(status_window->model);
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
96 char *cur;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
97
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
98 if (!gtk_tree_model_get_iter_first(model, iter))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
99 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
100
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
101 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
102 if (!strcmp(title, cur))
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
103 {
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
104 g_free(cur);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
105 return TRUE;
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
106 }
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
107 g_free(cur);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
108
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
109 while (gtk_tree_model_iter_next(model, iter))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
110 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
111 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
112 if (!strcmp(title, cur))
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
113 {
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
114 g_free(cur);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
115 return TRUE;
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
116 }
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
117 g_free(cur);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
118 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
119
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
120 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
121 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
122
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
123 static gboolean
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
124 status_window_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
125 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
126 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
127
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
128 dialog->window = NULL;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
129 gaim_gtk_status_window_hide();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
130
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
131 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
132 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
133
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
134 #if !GTK_CHECK_VERSION(2,2,0)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
135 static void
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
136 count_selected_helper(GtkTreeModel *model, GtkTreePath *path,
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
137 GtkTreeIter *iter, gpointer user_data)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
138 {
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
139 (*(gint *)user_data)++;
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
140 }
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
141
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
142 static void
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
143 list_selected_helper(GtkTreeModel *model, GtkTreePath *path,
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
144 GtkTreeIter *iter, gpointer user_data)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
145 {
11889
04c2c3d84849 [gaim-migrate @ 14180]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11888
diff changeset
146 GList **list = (GList **)user_data;
04c2c3d84849 [gaim-migrate @ 14180]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11888
diff changeset
147 *list = g_list_append(*list, gtk_tree_path_copy(path));
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
148 }
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
149 #endif
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
150
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
151 static void
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
152 status_window_use_cb(GtkButton *button, StatusWindow *dialog)
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
153 {
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
154 GtkTreeSelection *selection;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
155 GtkTreeIter iter;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
156 GaimSavedStatus *saved_status;
11889
04c2c3d84849 [gaim-migrate @ 14180]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11888
diff changeset
157 GList *list = NULL;
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
158 int num_selected = 0;
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
159
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
160 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
161
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
162 #if GTK_CHECK_VERSION(2,2,0)
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
163 num_selected = gtk_tree_selection_count_selected_rows(selection);
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
164 #else
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
165 gtk_tree_selection_selected_foreach(selection, count_selected_helper, &num_selected);
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
166 #endif
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
167 if (num_selected != 1)
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
168 /*
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
169 * This shouldn't happen because the "Use" button should have
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
170 * been grayed out. Oh well.
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
171 */
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
172 return;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
173
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
174 #if GTK_CHECK_VERSION(2,2,0)
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
175 list = gtk_tree_selection_get_selected_rows(selection, NULL);
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
176 #else
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
177 gtk_tree_selection_selected_foreach(selection, list_selected_helper, &list);
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
178 #endif
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
179
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
180 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model),
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
181 &iter, list->data))
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
182 {
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
183 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
184 STATUS_WINDOW_COLUMN_STATUS, &saved_status,
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
185 -1);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
186
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
187 gaim_savedstatus_activate(saved_status);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
188 }
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
189
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
190 g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
191 g_list_free(list);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
192 }
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
193
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
194 static void
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
195 status_window_add_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
196 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
197 gaim_gtk_status_editor_show(NULL);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
198 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
199
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
200 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
201 status_window_modify_foreach(GtkTreeModel *model, GtkTreePath *path,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
202 GtkTreeIter *iter, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
203 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
204 GaimSavedStatus *status;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
205
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
206 gtk_tree_model_get(model, iter, STATUS_WINDOW_COLUMN_STATUS, &status, -1);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
207 gaim_gtk_status_editor_show(status);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
208 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
209
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
210 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
211 status_window_modify_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
212 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
213 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
214 GtkTreeSelection *selection;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
215
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
216 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
217
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
218 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
219 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
220
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
221 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
222 status_window_delete_confirm_cb(char *title)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
223 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
224 GtkTreeIter iter;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
225
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
226 if (status_window_find_savedstatus(&iter, title))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
227 gtk_list_store_remove(status_window->model, &iter);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
228
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
229 gaim_savedstatus_delete(title);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
230
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
231 g_free(title);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
232 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
233
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
234 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
235 status_window_delete_foreach(GtkTreeModel *model, GtkTreePath *path,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
236 GtkTreeIter *iter, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
237 {
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
238 char *title;
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
239 char *title_escaped, *buf;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
240
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
241 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
242
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10591
diff changeset
243 title_escaped = g_markup_escape_text(title, -1);
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
244 buf = g_strdup_printf(_("Are you sure you want to delete %s?"), title_escaped);
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
245 free(title_escaped);
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
246 gaim_request_action(NULL, NULL, buf, NULL, 0, title, 2,
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
247 _("Delete"), status_window_delete_confirm_cb,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
248 _("Cancel"), g_free);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
249 g_free(buf);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
250 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
251
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
252 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
253 status_window_delete_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
254 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
255 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
256 GtkTreeSelection *selection;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
257
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
258 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
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 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
261 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
262
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
263 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
264 status_window_close_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
265 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
266 gaim_gtk_status_window_hide();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
267 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
268
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
269 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
270 status_selected_cb(GtkTreeSelection *sel, gpointer user_data)
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 StatusWindow *dialog = user_data;
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
273 int num_selected = 0;
10421
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 #if GTK_CHECK_VERSION(2,2,0)
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
276 num_selected = gtk_tree_selection_count_selected_rows(sel);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
277 #else
11888
7d2d926704aa [gaim-migrate @ 14179]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11832
diff changeset
278 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
279 #endif
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
280
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
281 gtk_widget_set_sensitive(dialog->use_button, (num_selected == 1));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
282 gtk_widget_set_sensitive(dialog->modify_button, (num_selected > 0));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
283 gtk_widget_set_sensitive(dialog->delete_button, (num_selected > 0));
10421
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
286 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
287 add_status_to_saved_status_list(GtkListStore *model, GaimSavedStatus *saved_status)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
288 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
289 GtkTreeIter iter;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
290 const char *title;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
291 const char *type;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
292 char *message;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
293
11651
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
294 if (gaim_savedstatus_is_transient(saved_status))
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
295 return;
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
296
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
297 title = gaim_savedstatus_get_title(saved_status);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
298 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
299 message = gaim_markup_strip_html(gaim_savedstatus_get_message(saved_status));
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 gtk_list_store_append(model, &iter);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
302 gtk_list_store_set(model, &iter,
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
303 STATUS_WINDOW_COLUMN_STATUS, saved_status,
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
304 STATUS_WINDOW_COLUMN_TITLE, title,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
305 STATUS_WINDOW_COLUMN_TYPE, type,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
306 STATUS_WINDOW_COLUMN_MESSAGE, message,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
307 -1);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
308 free(message);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
309 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
310
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
311 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
312 populate_saved_status_list(StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
313 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
314 const GList *saved_statuses;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
315
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
316 gtk_list_store_clear(dialog->model);
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 for (saved_statuses = gaim_savedstatuses_get_all(); saved_statuses != NULL;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
319 saved_statuses = g_list_next(saved_statuses))
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 add_status_to_saved_status_list(dialog->model, saved_statuses->data);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
322 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
323 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
324
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
325 static gboolean
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
326 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
327 {
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
328 gboolean result;
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
329 char *haystack;
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
330
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
331 gtk_tree_model_get(model, iter, column, &haystack, -1);
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
332
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
333 result = (gaim_strcasestr(haystack, key) == NULL);
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
334
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
335 g_free(haystack);
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
336
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
337 return result;
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
338 }
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
339
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
340 static GtkWidget *
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
341 create_saved_status_list(StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
342 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
343 GtkWidget *sw;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
344 GtkWidget *treeview;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
345 GtkTreeSelection *sel;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
346 GtkTreeViewColumn *column;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
347 GtkCellRenderer *renderer;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
348
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
349 /* Create the scrolled window */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
350 sw = gtk_scrolled_window_new(0, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
351 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
352 GTK_POLICY_AUTOMATIC,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
353 GTK_POLICY_ALWAYS);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
354 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
355 GTK_SHADOW_IN);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
356 gtk_widget_show(sw);
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 /* Create the list model */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
359 dialog->model = gtk_list_store_new(STATUS_WINDOW_NUM_COLUMNS,
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
360 G_TYPE_POINTER,
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
361 G_TYPE_STRING,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
362 G_TYPE_STRING,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
363 G_TYPE_STRING);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
364
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
365 /* Create the treeview */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
366 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
367 dialog->treeview = treeview;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
368 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
369
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
370 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
371 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
372 g_signal_connect(G_OBJECT(sel), "changed",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
373 G_CALLBACK(status_selected_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
374
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
375 gtk_container_add(GTK_CONTAINER(sw), treeview);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
376 gtk_widget_show(treeview);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
377
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
378 /* Add columns */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
379 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
380 gtk_tree_view_column_set_title(column, _("Title"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
381 gtk_tree_view_column_set_resizable(column, TRUE);
11548
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
382 gtk_tree_view_column_set_min_width(column, 100);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
383 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
384 STATUS_WINDOW_COLUMN_TITLE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
385 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
386 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
387 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
388 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
389 STATUS_WINDOW_COLUMN_TITLE);
11548
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
390 #if GTK_CHECK_VERSION(2,6,0)
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
391 g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
392 #endif
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
393
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
394 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
395 gtk_tree_view_column_set_title(column, _("Type"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
396 gtk_tree_view_column_set_resizable(column, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
397 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
398 STATUS_WINDOW_COLUMN_TYPE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
399 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
400 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
401 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
402 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
403 STATUS_WINDOW_COLUMN_TYPE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
404
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
405 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
406 gtk_tree_view_column_set_title(column, _("Message"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
407 gtk_tree_view_column_set_resizable(column, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
408 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
409 STATUS_WINDOW_COLUMN_MESSAGE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
410 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
411 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
412 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
413 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
414 STATUS_WINDOW_COLUMN_MESSAGE);
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
415 #if GTK_CHECK_VERSION(2,6,0)
10502
6cd5cca9c451 [gaim-migrate @ 11794]
Sean Egan <seanegan@gmail.com>
parents: 10439
diff changeset
416 g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
417 #endif
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
418
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
419 /* Enable CTRL+F searching */
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
420 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
421 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
422
10422
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
423 /* Sort the title column by default */
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
424 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
425 STATUS_WINDOW_COLUMN_TITLE,
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
426 GTK_SORT_ASCENDING);
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
427
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
428 /* Populate list */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
429 populate_saved_status_list(dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
430
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
431 return sw;
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
434 static gboolean
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
435 configure_cb(GtkWidget *widget, GdkEventConfigure *event, StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
436 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
437 if (GTK_WIDGET_VISIBLE(widget)) {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
438 gaim_prefs_set_int("/gaim/gtk/status/dialog/width", event->width);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
439 gaim_prefs_set_int("/gaim/gtk/status/dialog/height", event->height);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
440 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
441
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
442 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
443 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
444
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
445 void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
446 gaim_gtk_status_window_show(void)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
447 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
448 StatusWindow *dialog;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
449 GtkWidget *bbox;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
450 GtkWidget *button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
451 GtkWidget *list;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
452 GtkWidget *vbox;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
453 GtkWidget *win;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
454 int width, height;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
455
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
456 if (status_window != NULL) {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
457 gtk_window_present(GTK_WINDOW(status_window->window));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
458 return;
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
461 status_window = dialog = g_new0(StatusWindow, 1);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
462
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
463 width = gaim_prefs_get_int("/gaim/gtk/status/dialog/width");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
464 height = gaim_prefs_get_int("/gaim/gtk/status/dialog/height");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
465
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
466 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
467 gtk_window_set_default_size(GTK_WINDOW(win), width, height);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
468 gtk_window_set_role(GTK_WINDOW(win), "statuses");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
469 gtk_window_set_title(GTK_WINDOW(win), _("Saved Statuses"));
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
470 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
471
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
472 g_signal_connect(G_OBJECT(win), "delete_event",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
473 G_CALLBACK(status_window_destroy_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
474 g_signal_connect(G_OBJECT(win), "configure_event",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
475 G_CALLBACK(configure_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
476
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
477 /* Setup the vbox */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
478 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
479 gtk_container_add(GTK_CONTAINER(win), vbox);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
480 gtk_widget_show(vbox);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
481
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
482 /* List of saved status states */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
483 list = create_saved_status_list(dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
484 gtk_box_pack_start(GTK_BOX(vbox), list, TRUE, TRUE, 0);
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 /* Button box. */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
487 bbox = gtk_hbutton_box_new();
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
488 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
489 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
490 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
491 gtk_widget_show(bbox);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
492
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
493 /* Use button */
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
494 /* TODO: It might be better if the button said "Use" or "Activate" */
11832
9ca386c15ffe [gaim-migrate @ 14123]
Mark Doliner <mark@kingant.net>
parents: 11811
diff changeset
495 button = gaim_pixbuf_button_from_stock(_("_Use"), GTK_STOCK_EXECUTE,
9ca386c15ffe [gaim-migrate @ 14123]
Mark Doliner <mark@kingant.net>
parents: 11811
diff changeset
496 GAIM_BUTTON_HORIZONTAL);
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
497 dialog->use_button = button;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
498 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
499 gtk_widget_set_sensitive(button, FALSE);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
500 gtk_widget_show(button);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
501
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
502 g_signal_connect(G_OBJECT(button), "clicked",
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
503 G_CALLBACK(status_window_use_cb), dialog);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
504
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
505 /* Add button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
506 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
507 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
508 gtk_widget_show(button);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
509
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
510 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
511 G_CALLBACK(status_window_add_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
512
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
513 /* Modify button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
514 button = gtk_button_new_from_stock(GAIM_STOCK_MODIFY);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
515 dialog->modify_button = button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
516 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
517 gtk_widget_set_sensitive(button, FALSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
518 gtk_widget_show(button);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
519
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
520 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
521 G_CALLBACK(status_window_modify_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
522
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
523 /* Delete button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
524 button = gtk_button_new_from_stock(GTK_STOCK_DELETE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
525 dialog->delete_button = button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
526 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
527 gtk_widget_set_sensitive(button, FALSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
528 gtk_widget_show(button);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
529
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
530 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
531 G_CALLBACK(status_window_delete_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
532
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
533 /* Close button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
534 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
535 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
536 gtk_widget_show(button);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
537
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
538 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
539 G_CALLBACK(status_window_close_cb), dialog);
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 gtk_widget_show(win);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
542 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
543
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
544 void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
545 gaim_gtk_status_window_hide(void)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
546 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
547 if (status_window == NULL)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
548 return;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
549
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
550 if (status_window->window != NULL)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
551 gtk_widget_destroy(status_window->window);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
552
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
553 g_free(status_window);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
554 status_window = NULL;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
555 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
556
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
557
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
558 /**************************************************************************
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
559 * Status editor
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
560 **************************************************************************/
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
561
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
562 static gboolean
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
563 status_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
564 {
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
565 StatusEditor *dialog = user_data;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
566
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
567 g_free(dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
568 g_free(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
569
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
570 return FALSE;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
571 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
572
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
573 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
574 status_editor_cancel_cb(GtkButton *button, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
575 {
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
576 StatusEditor *dialog = user_data;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
577
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
578 gtk_widget_destroy(dialog->window);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
579
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
580 g_free(dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
581 g_free(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
582 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
583
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
584 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
585 status_editor_save_cb(GtkButton *button, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
586 {
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
587 StatusEditor *dialog = user_data;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
588 const char *title;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
589 GaimStatusPrimitive type;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
590 char *message, *unformatted;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
591 GaimSavedStatus *status;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
592
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
593 title = gtk_entry_get_text(dialog->title);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
594
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
595 /*
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
596 * 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
597 * don't do anything.
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
598 */
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
599 if ((gaim_savedstatus_find(title) != NULL) &&
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
600 ((dialog->original_title == NULL) || (strcmp(title, dialog->original_title))))
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
601 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
602 gaim_notify_error(NULL, NULL, _("Title already in use. You must "
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
603 "choose a unique title."), NULL);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
604 return;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
605 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
606
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
607 type = gtk_option_menu_get_history(dialog->type);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
608 message = gtk_imhtml_get_markup(dialog->message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
609 unformatted = gaim_markup_strip_html(message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
610
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
611 /*
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
612 * If we're editing an existing status, remove the old one to
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
613 * make way for the modified one.
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
614 */
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
615 if (dialog->original_title != NULL)
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
616 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
617 GtkTreeIter iter;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
618
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
619 gaim_savedstatus_delete(dialog->original_title);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
620
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
621 if (status_window_find_savedstatus(&iter, dialog->original_title))
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
622 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
623 gtk_list_store_remove(status_window->model, &iter);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
624 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
625 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
626
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
627 status = gaim_savedstatus_new(title, type);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
628 if (*unformatted != '\0')
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
629 gaim_savedstatus_set_message(status, message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
630 g_free(message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
631 g_free(unformatted);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
632
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
633 gtk_widget_destroy(dialog->window);
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
634 g_free(dialog->original_title);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
635 g_free(dialog);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
636
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
637 add_status_to_saved_status_list(status_window->model, status);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
638 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
639
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
640 static void
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
641 status_editor_custom_status_cb(GtkCellRendererToggle *renderer, gchar *path_str, gpointer data)
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
642 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
643 /* StatusEditor *dialog = (StatusEditor *)data; */
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
644
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
645 /* TODO: Need to allow user to set a custom status for the highlighted account, somehow */
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
646 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
647
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
648 static void
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
649 editor_title_changed_cb(GtkWidget *widget, gpointer user_data)
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 StatusEditor *dialog = user_data;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
652 const gchar *text;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
653
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
654 text = gtk_entry_get_text(dialog->title);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
655
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
656 gtk_widget_set_sensitive(dialog->save_button, (*text != '\0'));
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
657 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
658
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
659 static GtkWidget *
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
660 create_status_type_menu(GaimStatusPrimitive type)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
661 {
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
662 int i;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
663 GtkWidget *dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
664 GtkWidget *menu;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
665 GtkWidget *item;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
666
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
667 dropdown = gtk_option_menu_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
668 menu = gtk_menu_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
669
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
670 for (i = 0; i < GAIM_STATUS_NUM_PRIMITIVES; i++)
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
671 {
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
672 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
673 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
674 gtk_widget_show(item);
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
675 }
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
676
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
677 gtk_menu_set_active(GTK_MENU(menu), type);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
678 gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
679 gtk_widget_show(menu);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
680
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
681 return dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
682 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
683
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
684 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
685 status_editor_add_columns(StatusEditor *dialog)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
686 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
687 GtkCellRenderer *renderer;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
688 GtkTreeViewColumn *column;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
689
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
690 /* Custom status column */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
691 renderer = gtk_cell_renderer_toggle_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
692 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(dialog->treeview),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
693 -1, _("Custom status"),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
694 renderer,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
695 "active", STATUS_EDITOR_COLUMN_CUSTOM_STATUS,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
696 NULL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
697 column = gtk_tree_view_get_column(GTK_TREE_VIEW(dialog->treeview), 1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
698 g_signal_connect(G_OBJECT(renderer), "toggled",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
699 G_CALLBACK(status_editor_custom_status_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
700
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
701 /* Screen Name column */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
702 column = gtk_tree_view_column_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
703 gtk_tree_view_column_set_resizable(column, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
704 gtk_tree_view_column_set_title(column, _("Screen Name"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
705 gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
706 gtk_tree_view_column_set_resizable(column, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
707
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
708 /* Icon */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
709 renderer = gtk_cell_renderer_pixbuf_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
710 gtk_tree_view_column_pack_start(column, renderer, FALSE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
711 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
712 STATUS_EDITOR_COLUMN_ICON);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
713
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
714 /* Screen Name */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
715 renderer = gtk_cell_renderer_text_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
716 gtk_tree_view_column_pack_start(column, renderer, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
717 gtk_tree_view_column_add_attribute(column, renderer, "text",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
718 STATUS_EDITOR_COLUMN_SCREENNAME);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
719 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
720
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
721 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
722 status_editor_set_account(GtkListStore *store, GaimAccount *account, GtkTreeIter *iter)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
723 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
724 GdkPixbuf *pixbuf;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
725 GdkPixbuf *scale;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
726
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
727 scale = NULL;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
728
10884
5cda52915a1f [gaim-migrate @ 12582]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10814
diff changeset
729 pixbuf = gaim_gtk_create_prpl_icon(account);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
730
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
731 if (pixbuf != NULL)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
732 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
733 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
734
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
735 if (gaim_account_is_disconnected(account))
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
736 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
737 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
738
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
739 gtk_list_store_set(store, iter,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
740 STATUS_EDITOR_COLUMN_ICON, scale,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
741 STATUS_EDITOR_COLUMN_SCREENNAME, gaim_account_get_username(account),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
742 -1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
743
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
744 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
745 if (scale != NULL) g_object_unref(G_OBJECT(scale));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
746 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
747
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
748 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
749 status_editor_add_account(StatusEditor *dialog, GaimAccount *account)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
750 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
751 GtkTreeIter iter;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
752
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
753 gtk_list_store_append(dialog->model, &iter);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
754
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
755 status_editor_set_account(dialog->model, account, &iter);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
756 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
757
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
758 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
759 status_editor_populate_list(StatusEditor *dialog)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
760 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
761 GList *l;
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 gtk_list_store_clear(dialog->model);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
764
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
765 for (l = gaim_accounts_get_all(); l != NULL; l = l->next)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
766 status_editor_add_account(dialog, (GaimAccount *)l->data);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
767 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
768
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
769 void
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
770 gaim_gtk_status_editor_show(GaimSavedStatus *status)
10418
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 StatusEditor *dialog;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
773 GtkSizeGroup *sg;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
774 GtkWidget *bbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
775 GtkWidget *button;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
776 GtkWidget *dbox;
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
777 GtkWidget *expander;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
778 GtkWidget *dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
779 GtkWidget *entry;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
780 GtkWidget *frame;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
781 GtkWidget *hbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
782 GtkWidget *label;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
783 GtkWidget *sw;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
784 GtkWidget *text;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
785 GtkWidget *toolbar;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
786 GtkWidget *vbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
787 GtkWidget *win;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
788
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
789 dialog = g_new0(StatusEditor, 1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
790
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
791 if (status != NULL)
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
792 dialog->original_title = g_strdup(gaim_savedstatus_get_title(status));
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
793
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
794 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
795 gtk_window_set_role(GTK_WINDOW(win), "status");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
796 gtk_window_set_title(GTK_WINDOW(win), _("Status"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
797 gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
798 gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
799
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
800 g_signal_connect(G_OBJECT(win), "delete_event",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
801 G_CALLBACK(status_editor_destroy_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
802
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
803 /* Setup the vbox */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
804 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
805 gtk_container_add(GTK_CONTAINER(win), vbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
806 gtk_widget_show(vbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
807
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
808 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
809
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
810 /* Title */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
811 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
812 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
813 gtk_widget_show(hbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
814
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
815 label = gtk_label_new_with_mnemonic(_("_Title:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
816 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
817 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
818 gtk_widget_show(label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
819 gtk_size_group_add_widget(sg, label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
820
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
821 entry = gtk_entry_new();
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
822 dialog->title = GTK_ENTRY(entry);
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
823 if (status != NULL)
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
824 gtk_entry_set_text(GTK_ENTRY(entry), dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
825 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
826 gtk_widget_show(entry);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
827 g_signal_connect(G_OBJECT(entry), "changed",
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
828 G_CALLBACK(editor_title_changed_cb), dialog);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
829
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
830 /* Status type */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
831 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
832 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
833 gtk_widget_show(hbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
834
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
835 label = gtk_label_new_with_mnemonic(_("_Status:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
836 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
837 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
838 gtk_widget_show(label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
839 gtk_size_group_add_widget(sg, label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
840
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
841 if (status != NULL)
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
842 dropdown = create_status_type_menu(gaim_savedstatus_get_type(status));
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
843 else
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
844 dropdown = create_status_type_menu(GAIM_STATUS_AWAY);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
845 dialog->type = GTK_OPTION_MENU(dropdown);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
846 gtk_box_pack_start(GTK_BOX(hbox), dropdown, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
847 gtk_widget_show(dropdown);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
848
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
849 /* Status message */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
850 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
851 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
852 gtk_widget_show(hbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
853
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
854 label = gtk_label_new_with_mnemonic(_("_Message:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
855 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
856 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
857 gtk_widget_show(label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
858 gtk_size_group_add_widget(sg, label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
859
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
860 frame = gaim_gtk_create_imhtml(TRUE, &text, &toolbar);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
861 dialog->message = GTK_IMHTML(text);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
862 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
863 gtk_widget_show(frame);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
864
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
865 if ((status != NULL) && (gaim_savedstatus_get_message(status) != NULL))
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
866 gtk_imhtml_append_text(GTK_IMHTML(text),
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
867 gaim_savedstatus_get_message(status), 0);
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
868
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
869 /* Custom status message expander */
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
870 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
871 gtk_box_pack_start(GTK_BOX(vbox), expander, FALSE, FALSE, 0);
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
872 gtk_widget_show(expander);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
873
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
874 /* Setup the box that the expander will cover */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
875 dbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE);
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
876 gtk_container_add(GTK_CONTAINER(expander), dbox);
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
877 gtk_widget_show(dbox);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
878
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
879 /* Custom status message treeview */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
880 sw = gtk_scrolled_window_new(NULL, NULL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
881 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
882 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
883 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
884 GTK_SHADOW_IN);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
885 gtk_box_pack_start(GTK_BOX(dbox), sw, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
886 gtk_widget_show(sw);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
887
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
888 /* Create the list model */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
889 dialog->model = gtk_list_store_new(STATUS_EDITOR_NUM_COLUMNS,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
890 G_TYPE_BOOLEAN,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
891 GDK_TYPE_PIXBUF, G_TYPE_STRING);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
892
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
893 /* Create the treeview */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
894 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
895 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(dialog->treeview), TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
896 gtk_widget_set_size_request(dialog->treeview, 400, 250);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
897 gtk_container_add(GTK_CONTAINER(sw), dialog->treeview);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
898 gtk_widget_show(dialog->treeview);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
899
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
900 /* Add columns */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
901 status_editor_add_columns(dialog);
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 /* Populate list */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
904 status_editor_populate_list(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
905
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
906 /* Button box */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
907 bbox = gtk_hbutton_box_new();
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
908 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
909 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
910 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
911 gtk_widget_show(bbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
912
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
913 /* Cancel button */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
914 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
915 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
916 gtk_widget_show(button);
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 g_signal_connect(G_OBJECT(button), "clicked",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
919 G_CALLBACK(status_editor_cancel_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
920
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
921 /* Save button */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
922 button = gtk_button_new_from_stock(GTK_STOCK_SAVE);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
923 dialog->save_button = button;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
924 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
925 gtk_widget_show(button);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
926
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
927 g_signal_connect(G_OBJECT(button), "clicked",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
928 G_CALLBACK(status_editor_save_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
929
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
930 gtk_widget_show(win);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
931 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
932
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
933
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
934 /**************************************************************************
10814
364a2ef907ae [gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents: 10732
diff changeset
935 * GTK+ saved status glue
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
936 **************************************************************************/
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
937
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
938 void *
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
939 gaim_gtk_status_get_handle()
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
940 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
941 static int handle;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
942
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
943 return &handle;
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
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
946 void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
947 gaim_gtk_status_init(void)
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 gaim_prefs_add_none("/gaim/gtk/status");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
950 gaim_prefs_add_none("/gaim/gtk/status/dialog");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
951 gaim_prefs_add_int("/gaim/gtk/status/dialog/width", 550);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
952 gaim_prefs_add_int("/gaim/gtk/status/dialog/height", 250);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
953 }
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 void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
956 gaim_gtk_status_uninit(void)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
957 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
958 gaim_gtk_status_window_hide();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
959 }