annotate src/gtksavedstatuses.c @ 11872:ea0f39933003

[gaim-migrate @ 14163] quit shoing a blank message when you just want to be "available" on jabber committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Fri, 28 Oct 2005 14:12:07 +0000
parents 9ca386c15ffe
children 7d2d926704aa
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
134 static void
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
135 status_window_use_cb(GtkButton *button, StatusWindow *dialog)
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
136 {
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
137 GtkTreeSelection *selection;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
138 GtkTreeIter iter;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
139 GaimSavedStatus *saved_status;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
140 GList *list;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
141
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
142 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
143
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
144 if (gtk_tree_selection_count_selected_rows(selection) != 1)
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
145 /*
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
146 * This shouldn't happen because the "Use" button should have
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
147 * been grayed out. Oh well.
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
148 */
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
149 return;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
150
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
151 list = gtk_tree_selection_get_selected_rows(selection, NULL);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
152
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
153 if (gtk_tree_model_get_iter(GTK_TREE_MODEL(dialog->model),
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
154 &iter, list->data))
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
155 {
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
156 gtk_tree_model_get(GTK_TREE_MODEL(dialog->model), &iter,
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
157 STATUS_WINDOW_COLUMN_STATUS, &saved_status,
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
158 -1);
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 gaim_savedstatus_activate(saved_status);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
161 }
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
162
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
163 g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
164 g_list_free(list);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
165 }
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
166
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
167 static void
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
168 status_window_add_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
169 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
170 gaim_gtk_status_editor_show(NULL);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
171 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
172
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
173 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
174 status_window_modify_foreach(GtkTreeModel *model, GtkTreePath *path,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
175 GtkTreeIter *iter, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
176 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
177 GaimSavedStatus *status;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
178
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
179 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
180 gaim_gtk_status_editor_show(status);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
181 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
182
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
183 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
184 status_window_modify_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
185 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
186 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
187 GtkTreeSelection *selection;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
188
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
189 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
190
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
191 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
192 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
193
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
194 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
195 status_window_delete_confirm_cb(char *title)
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 GtkTreeIter iter;
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 if (status_window_find_savedstatus(&iter, title))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
200 gtk_list_store_remove(status_window->model, &iter);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
201
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
202 gaim_savedstatus_delete(title);
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 g_free(title);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
205 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
206
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
207 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
208 status_window_delete_foreach(GtkTreeModel *model, GtkTreePath *path,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
209 GtkTreeIter *iter, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
210 {
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
211 char *title;
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
212 char *title_escaped, *buf;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
213
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
214 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
215
10732
c4cb90065e1d [gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents: 10591
diff changeset
216 title_escaped = g_markup_escape_text(title, -1);
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
217 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
218 free(title_escaped);
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
219 gaim_request_action(NULL, NULL, buf, NULL, 0, title, 2,
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
220 _("Delete"), status_window_delete_confirm_cb,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
221 _("Cancel"), g_free);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
222 g_free(buf);
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
225 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
226 status_window_delete_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
227 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
228 StatusWindow *dialog = user_data;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
229 GtkTreeSelection *selection;
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 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dialog->treeview));
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 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
234 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
235
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
236 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
237 status_window_close_cb(GtkButton *button, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
238 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
239 gaim_gtk_status_window_hide();
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
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11735
diff changeset
242 #if !GTK_CHECK_VERSION(2,2,0)
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11735
diff changeset
243 static void
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11735
diff changeset
244 get_selected_helper(GtkTreeModel *model, GtkTreePath *path,
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11735
diff changeset
245 GtkTreeIter *iter, gpointer user_data)
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11735
diff changeset
246 {
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
247 *((gboolean *)user_data)++;
11780
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11735
diff changeset
248 }
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11735
diff changeset
249 #endif
8cb75ba77f9d [gaim-migrate @ 14071]
Stu Tomlinson <stu@nosnilmot.com>
parents: 11735
diff changeset
250
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
251 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
252 status_selected_cb(GtkTreeSelection *sel, gpointer user_data)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
253 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
254 StatusWindow *dialog = user_data;
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
255 int num_selected;
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
256
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
257 #if GTK_CHECK_VERSION(2,2,0)
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
258 num_selected = gtk_tree_selection_count_selected_rows(sel);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
259 #else
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
260 gtk_tree_selection_selected_foreach(sel, get_selected_helper, &num_selected);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
261 #endif
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
262
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
263 gtk_widget_set_sensitive(dialog->use_button, (num_selected == 1));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
264 gtk_widget_set_sensitive(dialog->modify_button, (num_selected > 0));
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
265 gtk_widget_set_sensitive(dialog->delete_button, (num_selected > 0));
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
266 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
267
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
268 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
269 add_status_to_saved_status_list(GtkListStore *model, GaimSavedStatus *saved_status)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
270 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
271 GtkTreeIter iter;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
272 const char *title;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
273 const char *type;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
274 char *message;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
275
11651
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
276 if (gaim_savedstatus_is_transient(saved_status))
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
277 return;
723487d07aa0 [gaim-migrate @ 13935]
Mark Doliner <mark@kingant.net>
parents: 11548
diff changeset
278
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
279 title = gaim_savedstatus_get_title(saved_status);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
280 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
281 message = gaim_markup_strip_html(gaim_savedstatus_get_message(saved_status));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
282
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
283 gtk_list_store_append(model, &iter);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
284 gtk_list_store_set(model, &iter,
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
285 STATUS_WINDOW_COLUMN_STATUS, saved_status,
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
286 STATUS_WINDOW_COLUMN_TITLE, title,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
287 STATUS_WINDOW_COLUMN_TYPE, type,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
288 STATUS_WINDOW_COLUMN_MESSAGE, message,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
289 -1);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
290 free(message);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
291 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
292
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
293 static void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
294 populate_saved_status_list(StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
295 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
296 const GList *saved_statuses;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
297
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
298 gtk_list_store_clear(dialog->model);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
299
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
300 for (saved_statuses = gaim_savedstatuses_get_all(); saved_statuses != NULL;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
301 saved_statuses = g_list_next(saved_statuses))
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
302 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
303 add_status_to_saved_status_list(dialog->model, saved_statuses->data);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
304 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
305 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
306
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
307 static gboolean
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
308 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
309 {
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
310 gboolean result;
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
311 char *haystack;
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
312
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
313 gtk_tree_model_get(model, iter, column, &haystack, -1);
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
314
10439
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
315 result = (gaim_strcasestr(haystack, key) == NULL);
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
316
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
317 g_free(haystack);
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
318
911530134bf8 [gaim-migrate @ 11697]
Mark Doliner <mark@kingant.net>
parents: 10435
diff changeset
319 return result;
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
320 }
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
321
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
322 static GtkWidget *
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
323 create_saved_status_list(StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
324 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
325 GtkWidget *sw;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
326 GtkWidget *treeview;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
327 GtkTreeSelection *sel;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
328 GtkTreeViewColumn *column;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
329 GtkCellRenderer *renderer;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
330
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
331 /* Create the scrolled window */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
332 sw = gtk_scrolled_window_new(0, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
333 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
334 GTK_POLICY_AUTOMATIC,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
335 GTK_POLICY_ALWAYS);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
336 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
337 GTK_SHADOW_IN);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
338 gtk_widget_show(sw);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
339
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
340 /* Create the list model */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
341 dialog->model = gtk_list_store_new(STATUS_WINDOW_NUM_COLUMNS,
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
342 G_TYPE_POINTER,
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
343 G_TYPE_STRING,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
344 G_TYPE_STRING,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
345 G_TYPE_STRING);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
346
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
347 /* Create the treeview */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
348 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
349 dialog->treeview = treeview;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
350 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
351
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
352 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
353 gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
354 g_signal_connect(G_OBJECT(sel), "changed",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
355 G_CALLBACK(status_selected_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
356
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
357 gtk_container_add(GTK_CONTAINER(sw), treeview);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
358 gtk_widget_show(treeview);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
359
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
360 /* Add columns */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
361 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
362 gtk_tree_view_column_set_title(column, _("Title"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
363 gtk_tree_view_column_set_resizable(column, TRUE);
11548
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
364 gtk_tree_view_column_set_min_width(column, 100);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
365 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
366 STATUS_WINDOW_COLUMN_TITLE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
367 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
368 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
369 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
370 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
371 STATUS_WINDOW_COLUMN_TITLE);
11548
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
372 #if GTK_CHECK_VERSION(2,6,0)
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
373 g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
30ad548e8537 [gaim-migrate @ 13803]
Mark Doliner <mark@kingant.net>
parents: 11251
diff changeset
374 #endif
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
375
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
376 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
377 gtk_tree_view_column_set_title(column, _("Type"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
378 gtk_tree_view_column_set_resizable(column, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
379 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
380 STATUS_WINDOW_COLUMN_TYPE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
381 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
382 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
383 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
384 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
385 STATUS_WINDOW_COLUMN_TYPE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
386
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
387 column = gtk_tree_view_column_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
388 gtk_tree_view_column_set_title(column, _("Message"));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
389 gtk_tree_view_column_set_resizable(column, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
390 gtk_tree_view_column_set_sort_column_id(column,
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
391 STATUS_WINDOW_COLUMN_MESSAGE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
392 gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
393 renderer = gtk_cell_renderer_text_new();
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
394 gtk_tree_view_column_pack_start(column, renderer, TRUE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
395 gtk_tree_view_column_add_attribute(column, renderer, "text",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
396 STATUS_WINDOW_COLUMN_MESSAGE);
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
397 #if GTK_CHECK_VERSION(2,6,0)
10502
6cd5cca9c451 [gaim-migrate @ 11794]
Sean Egan <seanegan@gmail.com>
parents: 10439
diff changeset
398 g_object_set(renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
10435
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
399 #endif
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
400
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
401 /* Enable CTRL+F searching */
341d4932f89e [gaim-migrate @ 11692]
Mark Doliner <mark@kingant.net>
parents: 10422
diff changeset
402 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
403 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
404
10422
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
405 /* Sort the title column by default */
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
406 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
407 STATUS_WINDOW_COLUMN_TITLE,
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
408 GTK_SORT_ASCENDING);
e0cf2f3f9929 [gaim-migrate @ 11673]
Mark Doliner <mark@kingant.net>
parents: 10421
diff changeset
409
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
410 /* Populate list */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
411 populate_saved_status_list(dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
412
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
413 return sw;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
414 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
415
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
416 static gboolean
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
417 configure_cb(GtkWidget *widget, GdkEventConfigure *event, StatusWindow *dialog)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
418 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
419 if (GTK_WIDGET_VISIBLE(widget)) {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
420 gaim_prefs_set_int("/gaim/gtk/status/dialog/width", event->width);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
421 gaim_prefs_set_int("/gaim/gtk/status/dialog/height", event->height);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
422 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
423
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
424 return FALSE;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
425 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
426
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
427 void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
428 gaim_gtk_status_window_show(void)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
429 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
430 StatusWindow *dialog;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
431 GtkWidget *bbox;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
432 GtkWidget *button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
433 GtkWidget *list;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
434 GtkWidget *vbox;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
435 GtkWidget *win;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
436 int width, height;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
437
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
438 if (status_window != NULL) {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
439 gtk_window_present(GTK_WINDOW(status_window->window));
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
440 return;
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
443 status_window = dialog = g_new0(StatusWindow, 1);
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 width = gaim_prefs_get_int("/gaim/gtk/status/dialog/width");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
446 height = gaim_prefs_get_int("/gaim/gtk/status/dialog/height");
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 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
449 gtk_window_set_default_size(GTK_WINDOW(win), width, height);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
450 gtk_window_set_role(GTK_WINDOW(win), "statuses");
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
451 gtk_window_set_title(GTK_WINDOW(win), _("Saved Statuses"));
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
452 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
453
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
454 g_signal_connect(G_OBJECT(win), "delete_event",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
455 G_CALLBACK(status_window_destroy_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
456 g_signal_connect(G_OBJECT(win), "configure_event",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
457 G_CALLBACK(configure_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
458
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
459 /* Setup the vbox */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
460 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
461 gtk_container_add(GTK_CONTAINER(win), vbox);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
462 gtk_widget_show(vbox);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
463
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
464 /* List of saved status states */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
465 list = create_saved_status_list(dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
466 gtk_box_pack_start(GTK_BOX(vbox), list, TRUE, TRUE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
467
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
468 /* Button box. */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
469 bbox = gtk_hbutton_box_new();
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
470 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
471 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
472 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
473 gtk_widget_show(bbox);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
474
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
475 /* Use button */
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
476 /* 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
477 button = gaim_pixbuf_button_from_stock(_("_Use"), GTK_STOCK_EXECUTE,
9ca386c15ffe [gaim-migrate @ 14123]
Mark Doliner <mark@kingant.net>
parents: 11811
diff changeset
478 GAIM_BUTTON_HORIZONTAL);
11811
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
479 dialog->use_button = button;
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
480 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
481 gtk_widget_set_sensitive(button, FALSE);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
482 gtk_widget_show(button);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
483
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
484 g_signal_connect(G_OBJECT(button), "clicked",
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
485 G_CALLBACK(status_window_use_cb), dialog);
924c6ba240e6 [gaim-migrate @ 14102]
Mark Doliner <mark@kingant.net>
parents: 11780
diff changeset
486
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
487 /* Add button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
488 button = gtk_button_new_from_stock(GTK_STOCK_ADD);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
489 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
490 gtk_widget_show(button);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
491
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
492 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
493 G_CALLBACK(status_window_add_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
494
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
495 /* Modify button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
496 button = gtk_button_new_from_stock(GAIM_STOCK_MODIFY);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
497 dialog->modify_button = button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
498 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
499 gtk_widget_set_sensitive(button, FALSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
500 gtk_widget_show(button);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
501
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
502 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
503 G_CALLBACK(status_window_modify_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
504
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
505 /* Delete button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
506 button = gtk_button_new_from_stock(GTK_STOCK_DELETE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
507 dialog->delete_button = button;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
508 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
509 gtk_widget_set_sensitive(button, FALSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
510 gtk_widget_show(button);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
511
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
512 g_signal_connect(G_OBJECT(button), "clicked",
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
513 G_CALLBACK(status_window_delete_cb), dialog);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
514
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
515 /* Close button */
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
516 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
517 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
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_close_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 gtk_widget_show(win);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
524 }
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
525
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
526 void
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
527 gaim_gtk_status_window_hide(void)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
528 {
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
529 if (status_window == NULL)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
530 return;
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
531
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
532 if (status_window->window != NULL)
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
533 gtk_widget_destroy(status_window->window);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
534
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
535 g_free(status_window);
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
536 status_window = NULL;
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
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
539
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 * Status editor
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
542 **************************************************************************/
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
543
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
544 static gboolean
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
545 status_editor_destroy_cb(GtkWidget *widget, GdkEvent *event, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
546 {
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
547 StatusEditor *dialog = user_data;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
548
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
549 g_free(dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
550 g_free(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
551
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
552 return FALSE;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
553 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
554
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
555 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
556 status_editor_cancel_cb(GtkButton *button, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
557 {
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
558 StatusEditor *dialog = user_data;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
559
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
560 gtk_widget_destroy(dialog->window);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
561
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
562 g_free(dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
563 g_free(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
564 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
565
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
566 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
567 status_editor_save_cb(GtkButton *button, gpointer user_data)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
568 {
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
569 StatusEditor *dialog = user_data;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
570 const char *title;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
571 GaimStatusPrimitive type;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
572 char *message, *unformatted;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
573 GaimSavedStatus *status;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
574
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
575 title = gtk_entry_get_text(dialog->title);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
576
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
577 /*
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
578 * 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
579 * don't do anything.
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
580 */
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
581 if ((gaim_savedstatus_find(title) != NULL) &&
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
582 ((dialog->original_title == NULL) || (strcmp(title, dialog->original_title))))
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
583 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
584 gaim_notify_error(NULL, NULL, _("Title already in use. You must "
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
585 "choose a unique title."), NULL);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
586 return;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
587 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
588
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
589 type = gtk_option_menu_get_history(dialog->type);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
590 message = gtk_imhtml_get_markup(dialog->message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
591 unformatted = gaim_markup_strip_html(message);
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 /*
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
594 * 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
595 * make way for the modified one.
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
596 */
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
597 if (dialog->original_title != NULL)
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 GtkTreeIter iter;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
600
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
601 gaim_savedstatus_delete(dialog->original_title);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
602
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
603 if (status_window_find_savedstatus(&iter, dialog->original_title))
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
604 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
605 gtk_list_store_remove(status_window->model, &iter);
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 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
608
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
609 status = gaim_savedstatus_new(title, type);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
610 if (*unformatted != '\0')
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
611 gaim_savedstatus_set_message(status, message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
612 g_free(message);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
613 g_free(unformatted);
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 gtk_widget_destroy(dialog->window);
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
616 g_free(dialog->original_title);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
617 g_free(dialog);
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 add_status_to_saved_status_list(status_window->model, status);
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
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
622 static void
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
623 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
624 {
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
625 /* StatusEditor *dialog = (StatusEditor *)data; */
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 /* 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
628 }
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
629
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
630 static void
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
631 editor_title_changed_cb(GtkWidget *widget, gpointer user_data)
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 StatusEditor *dialog = user_data;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
634 const gchar *text;
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
635
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
636 text = gtk_entry_get_text(dialog->title);
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
637
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
638 gtk_widget_set_sensitive(dialog->save_button, (*text != '\0'));
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
639 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
640
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
641 static GtkWidget *
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
642 create_status_type_menu(GaimStatusPrimitive type)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
643 {
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
644 int i;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
645 GtkWidget *dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
646 GtkWidget *menu;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
647 GtkWidget *item;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
648
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
649 dropdown = gtk_option_menu_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
650 menu = gtk_menu_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
651
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
652 for (i = 0; i < GAIM_STATUS_NUM_PRIMITIVES; i++)
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
653 {
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
654 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
655 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
656 gtk_widget_show(item);
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
657 }
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
658
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
659 gtk_menu_set_active(GTK_MENU(menu), type);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
660 gtk_option_menu_set_menu(GTK_OPTION_MENU(dropdown), menu);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
661 gtk_widget_show(menu);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
662
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
663 return dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
664 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
665
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
666 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
667 status_editor_add_columns(StatusEditor *dialog)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
668 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
669 GtkCellRenderer *renderer;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
670 GtkTreeViewColumn *column;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
671
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
672 /* Custom status column */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
673 renderer = gtk_cell_renderer_toggle_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
674 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(dialog->treeview),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
675 -1, _("Custom status"),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
676 renderer,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
677 "active", STATUS_EDITOR_COLUMN_CUSTOM_STATUS,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
678 NULL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
679 column = gtk_tree_view_get_column(GTK_TREE_VIEW(dialog->treeview), 1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
680 g_signal_connect(G_OBJECT(renderer), "toggled",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
681 G_CALLBACK(status_editor_custom_status_cb), dialog);
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 /* Screen Name column */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
684 column = gtk_tree_view_column_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
685 gtk_tree_view_column_set_resizable(column, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
686 gtk_tree_view_column_set_title(column, _("Screen Name"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
687 gtk_tree_view_insert_column(GTK_TREE_VIEW(dialog->treeview), column, -1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
688 gtk_tree_view_column_set_resizable(column, TRUE);
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 /* Icon */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
691 renderer = gtk_cell_renderer_pixbuf_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
692 gtk_tree_view_column_pack_start(column, renderer, FALSE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
693 gtk_tree_view_column_add_attribute(column, renderer, "pixbuf",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
694 STATUS_EDITOR_COLUMN_ICON);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
695
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
696 /* Screen Name */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
697 renderer = gtk_cell_renderer_text_new();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
698 gtk_tree_view_column_pack_start(column, renderer, TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
699 gtk_tree_view_column_add_attribute(column, renderer, "text",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
700 STATUS_EDITOR_COLUMN_SCREENNAME);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
701 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
702
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
703 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
704 status_editor_set_account(GtkListStore *store, GaimAccount *account, GtkTreeIter *iter)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
705 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
706 GdkPixbuf *pixbuf;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
707 GdkPixbuf *scale;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
708
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
709 scale = NULL;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
710
10884
5cda52915a1f [gaim-migrate @ 12582]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10814
diff changeset
711 pixbuf = gaim_gtk_create_prpl_icon(account);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
712
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
713 if (pixbuf != NULL)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
714 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
715 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
716
11251
ad9a61894d9b [gaim-migrate @ 13420]
Mark Doliner <mark@kingant.net>
parents: 11243
diff changeset
717 if (gaim_account_is_disconnected(account))
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
718 gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.0, FALSE);
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 gtk_list_store_set(store, iter,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
722 STATUS_EDITOR_COLUMN_ICON, scale,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
723 STATUS_EDITOR_COLUMN_SCREENNAME, gaim_account_get_username(account),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
724 -1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
725
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
726 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
727 if (scale != NULL) g_object_unref(G_OBJECT(scale));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
728 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
729
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
730 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
731 status_editor_add_account(StatusEditor *dialog, GaimAccount *account)
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 GtkTreeIter iter;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
734
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
735 gtk_list_store_append(dialog->model, &iter);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
736
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
737 status_editor_set_account(dialog->model, account, &iter);
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
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
740 static void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
741 status_editor_populate_list(StatusEditor *dialog)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
742 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
743 GList *l;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
744
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
745 gtk_list_store_clear(dialog->model);
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 for (l = gaim_accounts_get_all(); l != NULL; l = l->next)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
748 status_editor_add_account(dialog, (GaimAccount *)l->data);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
749 }
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 void
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
752 gaim_gtk_status_editor_show(GaimSavedStatus *status)
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
753 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
754 StatusEditor *dialog;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
755 GtkSizeGroup *sg;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
756 GtkWidget *bbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
757 GtkWidget *button;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
758 GtkWidget *dbox;
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
759 GtkWidget *expander;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
760 GtkWidget *dropdown;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
761 GtkWidget *entry;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
762 GtkWidget *frame;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
763 GtkWidget *hbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
764 GtkWidget *label;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
765 GtkWidget *sw;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
766 GtkWidget *text;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
767 GtkWidget *toolbar;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
768 GtkWidget *vbox;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
769 GtkWidget *win;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
770
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
771 dialog = g_new0(StatusEditor, 1);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
772
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
773 if (status != NULL)
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
774 dialog->original_title = g_strdup(gaim_savedstatus_get_title(status));
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
775
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
776 dialog->window = win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
777 gtk_window_set_role(GTK_WINDOW(win), "status");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
778 gtk_window_set_title(GTK_WINDOW(win), _("Status"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
779 gtk_window_set_resizable(GTK_WINDOW(win), FALSE);
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
780 gtk_container_set_border_width(GTK_CONTAINER(win), GAIM_HIG_BORDER);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
781
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
782 g_signal_connect(G_OBJECT(win), "delete_event",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
783 G_CALLBACK(status_editor_destroy_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
784
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
785 /* Setup the vbox */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
786 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BORDER);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
787 gtk_container_add(GTK_CONTAINER(win), vbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
788 gtk_widget_show(vbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
789
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
790 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
791
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
792 /* Title */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
793 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
794 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
795 gtk_widget_show(hbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
796
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
797 label = gtk_label_new_with_mnemonic(_("_Title:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
798 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
799 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
800 gtk_widget_show(label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
801 gtk_size_group_add_widget(sg, label);
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 entry = gtk_entry_new();
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
804 dialog->title = GTK_ENTRY(entry);
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
805 if (status != NULL)
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
806 gtk_entry_set_text(GTK_ENTRY(entry), dialog->original_title);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
807 gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
808 gtk_widget_show(entry);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
809 g_signal_connect(G_OBJECT(entry), "changed",
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
810 G_CALLBACK(editor_title_changed_cb), dialog);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
811
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
812 /* Status type */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
813 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
814 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
815 gtk_widget_show(hbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
816
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
817 label = gtk_label_new_with_mnemonic(_("_Status:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
818 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
819 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
820 gtk_widget_show(label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
821 gtk_size_group_add_widget(sg, label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
822
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
823 if (status != NULL)
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
824 dropdown = create_status_type_menu(gaim_savedstatus_get_type(status));
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
825 else
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
826 dropdown = create_status_type_menu(GAIM_STATUS_AWAY);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
827 dialog->type = GTK_OPTION_MENU(dropdown);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
828 gtk_box_pack_start(GTK_BOX(hbox), dropdown, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
829 gtk_widget_show(dropdown);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
830
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
831 /* Status message */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
832 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
833 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
834 gtk_widget_show(hbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
835
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
836 label = gtk_label_new_with_mnemonic(_("_Message:"));
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
837 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
838 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
839 gtk_widget_show(label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
840 gtk_size_group_add_widget(sg, label);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
841
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
842 frame = gaim_gtk_create_imhtml(TRUE, &text, &toolbar);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
843 dialog->message = GTK_IMHTML(text);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
844 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
845 gtk_widget_show(frame);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
846
10574
77ef3f2f0df8 [gaim-migrate @ 11966]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10535
diff changeset
847 if ((status != NULL) && (gaim_savedstatus_get_message(status) != NULL))
10419
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
848 gtk_imhtml_append_text(GTK_IMHTML(text),
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
849 gaim_savedstatus_get_message(status), 0);
c9b1f3fac753 [gaim-migrate @ 11670]
Mark Doliner <mark@kingant.net>
parents: 10418
diff changeset
850
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
851 /* Custom status message expander */
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
852 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
853 gtk_box_pack_start(GTK_BOX(vbox), expander, FALSE, FALSE, 0);
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
854 gtk_widget_show(expander);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
855
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
856 /* Setup the box that the expander will cover */
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
857 dbox = gtk_vbox_new(FALSE, GAIM_HIG_CAT_SPACE);
11735
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
858 gtk_container_add(GTK_CONTAINER(expander), dbox);
8d7c99f20e4c [gaim-migrate @ 14026]
Mark Doliner <mark@kingant.net>
parents: 11651
diff changeset
859 gtk_widget_show(dbox);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
860
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
861 /* Custom status message treeview */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
862 sw = gtk_scrolled_window_new(NULL, NULL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
863 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
864 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
865 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
866 GTK_SHADOW_IN);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
867 gtk_box_pack_start(GTK_BOX(dbox), sw, TRUE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
868 gtk_widget_show(sw);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
869
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
870 /* Create the list model */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
871 dialog->model = gtk_list_store_new(STATUS_EDITOR_NUM_COLUMNS,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
872 G_TYPE_BOOLEAN,
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
873 GDK_TYPE_PIXBUF, G_TYPE_STRING);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
874
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
875 /* Create the treeview */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
876 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
877 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(dialog->treeview), TRUE);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
878 gtk_widget_set_size_request(dialog->treeview, 400, 250);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
879 gtk_container_add(GTK_CONTAINER(sw), dialog->treeview);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
880 gtk_widget_show(dialog->treeview);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
881
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
882 /* Add columns */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
883 status_editor_add_columns(dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
884
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
885 /* Populate list */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
886 status_editor_populate_list(dialog);
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 /* Button box */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
889 bbox = gtk_hbutton_box_new();
11243
a511b77a368b [gaim-migrate @ 13408]
Mark Doliner <mark@kingant.net>
parents: 10884
diff changeset
890 gtk_box_set_spacing(GTK_BOX(bbox), GAIM_HIG_BOX_SPACE);
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
891 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
892 gtk_box_pack_end(GTK_BOX(vbox), bbox, FALSE, TRUE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
893 gtk_widget_show(bbox);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
894
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
895 /* Cancel button */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
896 button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
897 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
898 gtk_widget_show(button);
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 g_signal_connect(G_OBJECT(button), "clicked",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
901 G_CALLBACK(status_editor_cancel_cb), 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 /* Save button */
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
904 button = gtk_button_new_from_stock(GTK_STOCK_SAVE);
10420
854c972ea863 [gaim-migrate @ 11671]
Mark Doliner <mark@kingant.net>
parents: 10419
diff changeset
905 dialog->save_button = button;
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
906 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
907 gtk_widget_show(button);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
908
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
909 g_signal_connect(G_OBJECT(button), "clicked",
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
910 G_CALLBACK(status_editor_save_cb), dialog);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
911
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
912 gtk_widget_show(win);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
913 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
914
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
915
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
916 /**************************************************************************
10814
364a2ef907ae [gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents: 10732
diff changeset
917 * GTK+ saved status glue
10421
ee56a3e54fbd [gaim-migrate @ 11672]
Mark Doliner <mark@kingant.net>
parents: 10420
diff changeset
918 **************************************************************************/
10418
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
919
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
920 void *
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
921 gaim_gtk_status_get_handle()
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
922 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
923 static int handle;
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
924
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
925 return &handle;
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
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
928 void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
929 gaim_gtk_status_init(void)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
930 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
931 gaim_prefs_add_none("/gaim/gtk/status");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
932 gaim_prefs_add_none("/gaim/gtk/status/dialog");
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
933 gaim_prefs_add_int("/gaim/gtk/status/dialog/width", 550);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
934 gaim_prefs_add_int("/gaim/gtk/status/dialog/height", 250);
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
935 }
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
936
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
937 void
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
938 gaim_gtk_status_uninit(void)
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
939 {
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
940 gaim_gtk_status_window_hide();
bed2c96bc1fb [gaim-migrate @ 11669]
Mark Doliner <mark@kingant.net>
parents:
diff changeset
941 }