annotate console/gntstatus.c @ 15136:31603a03cc02

[gaim-migrate @ 17921] Etan had changed the account notify stuff so that the prpl decides if the person is a buddy or not; I totally wiped that out with my authorization stuff. This brings it back. Additionally, I added a googletalk flag to JabberStream which can determine at runtime if you're connected to Google Talk. All of the Google Talk extensions can be detected individually with disco, but this might be used for working with perfectly standard XMPP that's implemented in what might be considered a quirky way in Google Talk. For instance, Google Talk automatically adds buddies to your roster when you authorize them to add you. I was going to use this flag so that the Jabber prpl would never ask me to add a Google Talk buddy who's just been automatically added anyway. I decided to keep it, though, since I may still want to specify what group he's in. This opens the door for more Google Talk customization though >:) committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Fri, 08 Dec 2006 02:51:47 +0000
parents 34e049e6ce10
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14558
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
1 /**
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
2 * @file gntstatus.c GNT Status API
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
3 * @ingroup gntui
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
4 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
5 * gaim
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
6 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
9 * source distribution.
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
10 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
11 * This program is free software; you can redistribute it and/or modify
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
12 * it under the terms of the GNU General Public License as published by
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
14 * (at your option) any later version.
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
15 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
16 * This program is distributed in the hope that it will be useful,
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
19 * GNU General Public License for more details.
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
20 *
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
21 * You should have received a copy of the GNU General Public License
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
22 * along with this program; if not, write to the Free Software
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
81650a27f253 [gaim-migrate @ 17281]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14189
diff changeset
24 */
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
25 #include <gnt.h>
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
26 #include <gntbox.h>
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
27 #include <gntbutton.h>
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
28 #include <gntcombobox.h>
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
29 #include <gntentry.h>
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
30 #include <gntlabel.h>
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
31 #include <gntline.h>
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
32 #include <gnttree.h>
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
33
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
34 #include <notify.h>
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
35 #include <request.h>
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
36
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
37 #include "gntgaim.h"
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
38 #include "gntstatus.h"
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
39
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
40 static struct
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
41 {
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
42 GntWidget *window;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
43 GntWidget *tree;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
44 } statuses;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
45
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
46 typedef struct
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
47 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
48 GaimSavedStatus *saved;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
49 GntWidget *window;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
50 GntWidget *title;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
51 GntWidget *type;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
52 GntWidget *message;
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
53 GntWidget *tree;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
54 GHashTable *hash; /* list of windows for substatuses */
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
55 } EditStatus;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
56
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
57 typedef struct
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
58 {
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
59 GaimAccount *account;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
60 const GaimStatusType *type;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
61 char *message;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
62 } RowInfo;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
63
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
64 typedef struct
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
65 {
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
66 GntWidget *window;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
67 GntWidget *type;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
68 GntWidget *message;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
69
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
70 EditStatus *parent;
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
71 RowInfo *key;
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
72 } EditSubStatus;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
73
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
74 static GList *edits; /* List of opened edit-status dialogs */
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
75
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
76 static void
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
77 reset_status_window(GntWidget *widget, gpointer null)
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
78 {
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
79 statuses.window = NULL;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
80 statuses.tree = NULL;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
81 }
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
82
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
83 static void
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
84 populate_statuses(GntTree *tree)
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
85 {
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
86 const GList *list;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
87
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
88 for (list = gaim_savedstatuses_get_all(); list; list = list->next)
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
89 {
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
90 GaimSavedStatus *saved = list->data;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
91 const char *title, *type, *message;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
92
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
93 if (gaim_savedstatus_is_transient(saved))
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
94 continue;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
95
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
96 title = gaim_savedstatus_get_title(saved);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
97 type = gaim_primitive_get_name_from_type(gaim_savedstatus_get_type(saved));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
98 message = gaim_savedstatus_get_message(saved); /* XXX: Strip possible markups */
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
99
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
100 gnt_tree_add_row_last(tree, saved,
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
101 gnt_tree_create_row(tree, title, type, message), NULL);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
102 }
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
103 }
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
104
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
105 static void
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
106 really_delete_status(GaimSavedStatus *saved)
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
107 {
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
108 GList *iter;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
109
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
110 for (iter = edits; iter; iter = iter->next)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
111 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
112 EditStatus *edit = iter->data;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
113 if (edit->saved == saved)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
114 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
115 gnt_widget_destroy(edit->window);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
116 break;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
117 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
118 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
119
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
120 if (statuses.tree)
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
121 gnt_tree_remove(GNT_TREE(statuses.tree), saved);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
122
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
123 gaim_savedstatus_delete(gaim_savedstatus_get_title(saved));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
124 }
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
125
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
126 static void
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
127 ask_before_delete(GntWidget *button, gpointer null)
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
128 {
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
129 char *ask;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
130 GaimSavedStatus *saved;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
131
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
132 g_return_if_fail(statuses.tree != NULL);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
133
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
134 saved = gnt_tree_get_selection_data(GNT_TREE(statuses.tree));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
135 ask = g_strdup_printf(_("Are you sure you want to delete \"%s\""),
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
136 gaim_savedstatus_get_title(saved));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
137
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
138 gaim_request_action(saved, _("Delete Status"), ask, NULL, 0, saved, 2,
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
139 _("Delete"), really_delete_status, _("Cancel"), NULL);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
140 g_free(ask);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
141 }
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
142
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
143 static void
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
144 use_savedstatus_cb(GntWidget *widget, gpointer null)
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
145 {
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
146 g_return_if_fail(statuses.tree != NULL);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
147
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
148 gaim_savedstatus_activate(gnt_tree_get_selection_data(GNT_TREE(statuses.tree)));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
149 }
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
150
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
151 static void
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
152 edit_savedstatus_cb(GntWidget *widget, gpointer null)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
153 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
154 g_return_if_fail(statuses.tree != NULL);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
155
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
156 gg_savedstatus_edit(gnt_tree_get_selection_data(GNT_TREE(statuses.tree)));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
157 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
158
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
159 void gg_savedstatus_show_all()
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
160 {
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
161 GntWidget *window, *tree, *box, *button;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
162 if (statuses.window)
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
163 return;
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
164
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
165 statuses.window = window = gnt_vbox_new(FALSE);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
166 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
167 gnt_box_set_title(GNT_BOX(window), _("Saved Statuses"));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
168 gnt_box_set_fill(GNT_BOX(window), FALSE);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
169 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
170 gnt_box_set_pad(GNT_BOX(window), 0);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
171
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
172 /* XXX: Add some sorting function to sort alphabetically, perhaps */
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
173 statuses.tree = tree = gnt_tree_new_with_columns(3);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
174 gnt_tree_set_column_titles(GNT_TREE(tree), _("Title"), _("Type"), _("Message"));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
175 gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
176 gnt_tree_set_col_width(GNT_TREE(tree), 0, 25);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
177 gnt_tree_set_col_width(GNT_TREE(tree), 1, 12);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
178 gnt_tree_set_col_width(GNT_TREE(tree), 2, 35);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
179 gnt_box_add_widget(GNT_BOX(window), tree);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
180
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
181 populate_statuses(GNT_TREE(tree));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
182
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
183 box = gnt_hbox_new(FALSE);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
184 gnt_box_add_widget(GNT_BOX(window), box);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
185
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
186 button = gnt_button_new(_("Use"));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
187 gnt_box_add_widget(GNT_BOX(box), button);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
188 g_signal_connect(G_OBJECT(button), "activate",
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
189 G_CALLBACK(use_savedstatus_cb), NULL);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
190
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
191 button = gnt_button_new(_("Add"));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
192 gnt_box_add_widget(GNT_BOX(box), button);
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
193 g_signal_connect_swapped(G_OBJECT(button), "activate",
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
194 G_CALLBACK(gg_savedstatus_edit), NULL);
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
195
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
196 button = gnt_button_new(_("Edit"));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
197 gnt_box_add_widget(GNT_BOX(box), button);
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
198 g_signal_connect(G_OBJECT(button), "activate",
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
199 G_CALLBACK(edit_savedstatus_cb), NULL);
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
200
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
201 button = gnt_button_new(_("Delete"));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
202 gnt_box_add_widget(GNT_BOX(box), button);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
203 g_signal_connect(G_OBJECT(button), "activate",
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
204 G_CALLBACK(ask_before_delete), NULL);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
205
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
206 button = gnt_button_new(_("Close"));
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
207 gnt_box_add_widget(GNT_BOX(box), button);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
208 g_signal_connect_swapped(G_OBJECT(button), "activate",
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
209 G_CALLBACK(gnt_widget_destroy), window);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
210
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
211 g_signal_connect(G_OBJECT(window), "destroy",
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
212 G_CALLBACK(reset_status_window), NULL);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
213 gnt_widget_show(window);
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
214 }
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
215
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
216 static void
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
217 destroy_substatus_win(GaimAccount *account, EditSubStatus *sub, gpointer null)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
218 {
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
219 gnt_widget_destroy(sub->window); /* the "destroy" callback will remove entry from the hashtable */
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
220 }
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
221
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
222 static void
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
223 free_key(gpointer key, gpointer n)
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
224 {
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
225 RowInfo *row = key;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
226 g_free(row->message);
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
227 g_free(key);
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
228 }
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
229
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
230
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
231 static void
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
232 update_edit_list(GntWidget *widget, EditStatus *edit)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
233 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
234 edits = g_list_remove(edits, edit);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
235 gaim_notify_close_with_handle(edit);
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
236 g_hash_table_foreach(edit->hash, (GHFunc)destroy_substatus_win, NULL);
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
237 g_list_foreach((GList*)gnt_tree_get_rows(GNT_TREE(edit->tree)), free_key, NULL);
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
238 g_free(edit);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
239 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
240
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
241 static void
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
242 set_substatuses(EditStatus *edit)
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
243 {
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
244 const GList *iter;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
245 for (iter = gnt_tree_get_rows(GNT_TREE(edit->tree)); iter; iter = iter->next) {
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
246 RowInfo *key = iter->data;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
247 if (gnt_tree_get_choice(GNT_TREE(edit->tree), key)) {
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
248 gaim_savedstatus_set_substatus(edit->saved, key->account, key->type, key->message);
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
249 }
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
250 }
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
251 }
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
252
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
253
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
254 static void
14695
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
255 use_trans_status_cb(GntWidget *button, EditStatus *edit)
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
256 {
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
257 const char *message;
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
258 GaimStatusPrimitive prim;
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
259 GaimSavedStatus *saved;
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
260
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
261 message = gnt_entry_get_text(GNT_ENTRY(edit->message));
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
262 prim = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(edit->type)));
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
263
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
264 saved = gaim_savedstatus_find_transient_by_type_and_message(prim, message);
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
265 if (saved == NULL) {
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
266 saved = gaim_savedstatus_new(NULL, prim);
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
267 edit->saved = saved;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
268 set_substatuses(edit);
14695
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
269 }
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
270 gaim_savedstatus_set_message(saved, message);
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
271 gaim_savedstatus_activate(saved);
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
272 gnt_widget_destroy(edit->window);
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
273 }
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
274
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
275 static void
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
276 save_savedstatus_cb(GntWidget *button, EditStatus *edit)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
277 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
278 const char *title, *message;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
279 GaimStatusPrimitive prim;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
280 GaimSavedStatus *find;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
281
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
282 title = gnt_entry_get_text(GNT_ENTRY(edit->title));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
283 message = gnt_entry_get_text(GNT_ENTRY(edit->message));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
284 if (!message || !*message)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
285 message = NULL;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
286
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
287 prim = GPOINTER_TO_INT(gnt_combo_box_get_selected_data(GNT_COMBO_BOX(edit->type)));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
288
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
289 if (!title || !*title)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
290 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
291 gaim_notify_error(edit, _("Error"), _("Invalid title"),
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
292 _("Please enter a non-empty title for the status."));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
293 return;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
294 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
295
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
296 find = gaim_savedstatus_find(title);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
297 if (find && find != edit->saved)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
298 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
299 gaim_notify_error(edit, _("Error"), _("Duplicate title"),
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
300 _("Please enter a different title for the status."));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
301 return;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
302 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
303
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
304 if (edit->saved == NULL)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
305 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
306 edit->saved = gaim_savedstatus_new(title, prim);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
307 gaim_savedstatus_set_message(edit->saved, message);
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
308 set_substatuses(edit);
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
309 if (statuses.tree)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
310 gnt_tree_add_row_last(GNT_TREE(statuses.tree), edit->saved,
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
311 gnt_tree_create_row(GNT_TREE(statuses.tree), title,
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
312 gaim_primitive_get_name_from_type(prim), message), NULL);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
313 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
314 else
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
315 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
316 gaim_savedstatus_set_title(edit->saved, title);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
317 gaim_savedstatus_set_type(edit->saved, prim);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
318 gaim_savedstatus_set_message(edit->saved, message);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
319 if (statuses.tree)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
320 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
321 gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 0, title);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
322 gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 1,
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
323 gaim_primitive_get_name_from_type(prim));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
324 gnt_tree_change_text(GNT_TREE(statuses.tree), edit->saved, 2, message);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
325 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
326 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
327
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
328 if (g_object_get_data(G_OBJECT(button), "use"))
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
329 gaim_savedstatus_activate(edit->saved);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
330
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
331 gnt_widget_destroy(edit->window);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
332 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
333
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
334 static void
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
335 add_substatus(EditStatus *edit, GaimAccount *account)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
336 {
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
337 char *name;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
338 const char *type = NULL, *message = NULL;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
339 GaimSavedStatusSub *sub = NULL;
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
340 RowInfo *key;
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
341
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
342 if (!edit || !edit->tree)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
343 return;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
344
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
345 if (edit->saved)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
346 sub = gaim_savedstatus_get_substatus(edit->saved, account);
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
347
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
348 key = g_new0(RowInfo, 1);
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
349 key->account = account;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
350
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
351 if (sub)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
352 {
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
353 key->type = gaim_savedstatus_substatus_get_type(sub);
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
354 type = gaim_status_type_get_name(key->type);
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
355 message = gaim_savedstatus_substatus_get_message(sub);
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
356 key->message = g_strdup(message);
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
357 }
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
358
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
359 name = g_strdup_printf("%s (%s)", gaim_account_get_username(account),
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
360 gaim_account_get_protocol_name(account));
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
361 gnt_tree_add_choice(GNT_TREE(edit->tree), key,
15052
34e049e6ce10 [gaim-migrate @ 17835]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14755
diff changeset
362 gnt_tree_create_row(GNT_TREE(edit->tree),
34e049e6ce10 [gaim-migrate @ 17835]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14755
diff changeset
363 name, type ? type : "", message ? message : ""), NULL, NULL);
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
364
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
365 if (sub)
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
366 gnt_tree_set_choice(GNT_TREE(edit->tree), key, TRUE);
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
367 g_free(name);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
368 }
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
369
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
370 static void
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
371 substatus_window_destroy_cb(GntWidget *window, EditSubStatus *sub)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
372 {
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
373 g_hash_table_remove(sub->parent->hash, sub->key->account);
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
374 g_free(sub);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
375 }
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
376
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
377 static void
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
378 save_substatus_cb(GntWidget *widget, EditSubStatus *sub)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
379 {
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
380 GaimSavedStatus *saved = sub->parent->saved;
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
381 RowInfo *row = sub->key;
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
382 const char *message;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
383 GaimStatusType *type;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
384
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
385 type = gnt_combo_box_get_selected_data(GNT_COMBO_BOX(sub->type));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
386 message = gnt_entry_get_text(GNT_ENTRY(sub->message));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
387
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
388 row->type = type;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
389 row->message = g_strdup(message);
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
390
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
391 if (saved) /* Save the substatus if the savedstatus actually exists. */
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
392 gaim_savedstatus_set_substatus(saved, row->account, type, message);
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
393
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
394 gnt_tree_set_choice(GNT_TREE(sub->parent->tree), row, TRUE);
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
395 gnt_tree_change_text(GNT_TREE(sub->parent->tree), row, 1,
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
396 gaim_status_type_get_name(type));
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
397 gnt_tree_change_text(GNT_TREE(sub->parent->tree), row, 2, message);
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
398
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
399 gnt_widget_destroy(sub->window);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
400 }
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
401
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
402 static gboolean
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
403 popup_substatus(GntTree *tree, const char *key, EditStatus *edit)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
404 {
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
405 if (key[0] == ' ' && key[1] == 0)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
406 {
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
407 EditSubStatus *sub;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
408 GntWidget *window, *combo, *entry, *box, *button, *l;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
409 GaimSavedStatusSub *substatus = NULL;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
410 const GList *iter;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
411 char *name;
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
412 RowInfo *selected = gnt_tree_get_selection_data(tree);
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
413 GaimAccount *account = selected->account;
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
414
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
415 if (gnt_tree_get_choice(tree, selected))
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
416 {
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
417 /* There was a savedstatus for this account. Now remove it. */
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
418 g_free(selected->message);
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
419 selected->type = NULL;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
420 selected->message = NULL;
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
421 /* XXX: should we really be saving it right now? */
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
422 gaim_savedstatus_unset_substatus(edit->saved, account);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
423 gnt_tree_change_text(tree, account, 1, NULL);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
424 gnt_tree_change_text(tree, account, 2, NULL);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
425 return FALSE;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
426 }
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
427
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
428 if (g_hash_table_lookup(edit->hash, account))
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
429 return TRUE;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
430
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
431 if (edit->saved)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
432 substatus = gaim_savedstatus_get_substatus(edit->saved, account);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
433
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
434 sub = g_new0(EditSubStatus, 1);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
435 sub->parent = edit;
14755
811464ba52de [gaim-migrate @ 17512]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14695
diff changeset
436 sub->key = selected;
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
437
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
438 sub->window = window = gnt_vbox_new(FALSE);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
439 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
440 gnt_box_set_title(GNT_BOX(window), _("Substatus")); /* XXX: a better title */
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
441
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
442 box = gnt_hbox_new(FALSE);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
443 gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Account:")));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
444 name = g_strdup_printf("%s (%s)", gaim_account_get_username(account),
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
445 gaim_account_get_protocol_name(account));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
446 gnt_box_add_widget(GNT_BOX(box), gnt_label_new(name));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
447 g_free(name);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
448 gnt_box_add_widget(GNT_BOX(window), box);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
449
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
450 box = gnt_hbox_new(FALSE);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
451 gnt_box_add_widget(GNT_BOX(box), (l = gnt_label_new(_("Status:"))));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
452 gnt_widget_set_size(l, 0, 1); /* I don't like having to do this */
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
453 sub->type = combo = gnt_combo_box_new();
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
454 gnt_box_add_widget(GNT_BOX(box), combo);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
455 gnt_box_add_widget(GNT_BOX(window), box);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
456
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
457 for (iter = gaim_account_get_status_types(account); iter; iter = iter->next)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
458 {
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
459 GaimStatusType *type = iter->data;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
460 if (!gaim_status_type_is_user_settable(type))
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
461 continue;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
462 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), type, gaim_status_type_get_name(type));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
463 }
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
464
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
465 box = gnt_hbox_new(FALSE);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
466 gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Message:")));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
467 sub->message = entry = gnt_entry_new(substatus ? gaim_savedstatus_substatus_get_message(substatus) : NULL);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
468 gnt_box_add_widget(GNT_BOX(box), entry);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
469 gnt_box_add_widget(GNT_BOX(window), box);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
470
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
471 box = gnt_hbox_new(FALSE);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
472 button = gnt_button_new(_("Cancel"));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
473 g_signal_connect_swapped(G_OBJECT(button), "activate", G_CALLBACK(gnt_widget_destroy), window);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
474 gnt_box_add_widget(GNT_BOX(box), button);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
475 button = gnt_button_new(_("Save"));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
476 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_substatus_cb), sub);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
477 gnt_box_add_widget(GNT_BOX(box), button);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
478 gnt_box_add_widget(GNT_BOX(window), box);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
479
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
480 gnt_widget_show(window);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
481
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
482 g_hash_table_insert(edit->hash, account, sub);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
483
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
484 g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(substatus_window_destroy_cb), sub);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
485
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
486 return TRUE;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
487 }
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
488 return FALSE;
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
489 }
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
490
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
491 void gg_savedstatus_edit(GaimSavedStatus *saved)
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
492 {
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
493 EditStatus *edit;
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
494 GntWidget *window, *box, *button, *entry, *combo, *label, *tree;
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
495 GaimStatusPrimitive prims[] = {GAIM_STATUS_AVAILABLE, GAIM_STATUS_AWAY,
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
496 GAIM_STATUS_INVISIBLE, GAIM_STATUS_OFFLINE, GAIM_STATUS_UNSET}, current;
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
497 GList *iter;
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
498 int i;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
499
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
500 if (saved)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
501 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
502 GList *iter;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
503 for (iter = edits; iter; iter = iter->next)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
504 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
505 edit = iter->data;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
506 if (edit->saved == saved)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
507 return;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
508 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
509 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
510
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
511 edit = g_new0(EditStatus, 1);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
512 edit->saved = saved;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
513 edit->window = window = gnt_vbox_new(FALSE);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
514 gnt_box_set_toplevel(GNT_BOX(window), TRUE);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
515 gnt_box_set_title(GNT_BOX(window), _("Edit Status"));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
516 gnt_box_set_fill(GNT_BOX(window), TRUE);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
517 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_LEFT);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
518 gnt_box_set_pad(GNT_BOX(window), 0);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
519
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
520 edits = g_list_append(edits, edit);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
521
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
522 /* Title */
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
523 box = gnt_hbox_new(FALSE);
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
524 gnt_box_set_alignment(GNT_BOX(box), GNT_ALIGN_LEFT);
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
525 gnt_box_add_widget(GNT_BOX(window), box);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
526 gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Title")));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
527
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
528 edit->title = entry = gnt_entry_new(saved ? gaim_savedstatus_get_title(saved) : NULL);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
529 gnt_box_add_widget(GNT_BOX(box), entry);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
530
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
531 /* Type */
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
532 box = gnt_hbox_new(FALSE);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
533 gnt_box_add_widget(GNT_BOX(window), box);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
534 gnt_box_add_widget(GNT_BOX(box), label = gnt_label_new(_("Status")));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
535 gnt_widget_set_size(label, 0, 1);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
536
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
537 edit->type = combo = gnt_combo_box_new();
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
538 gnt_box_add_widget(GNT_BOX(box), combo);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
539 current = saved ? gaim_savedstatus_get_type(saved) : GAIM_STATUS_UNSET;
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
540 for (i = 0; prims[i] != GAIM_STATUS_UNSET; i++)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
541 {
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
542 gnt_combo_box_add_data(GNT_COMBO_BOX(combo), GINT_TO_POINTER(prims[i]),
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
543 gaim_primitive_get_name_from_type(prims[i]));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
544 if (prims[i] == current)
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
545 gnt_combo_box_set_selected(GNT_COMBO_BOX(combo), GINT_TO_POINTER(current));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
546 }
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
547
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
548 /* Message */
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
549 box = gnt_hbox_new(FALSE);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
550 gnt_box_add_widget(GNT_BOX(window), box);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
551 gnt_box_add_widget(GNT_BOX(box), gnt_label_new(_("Message")));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
552
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
553 edit->message = entry = gnt_entry_new(saved ? gaim_savedstatus_get_message(saved) : NULL);
14189
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
554 gnt_box_add_widget(GNT_BOX(window), entry);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
555
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
556 gnt_box_add_widget(GNT_BOX(window), gnt_hline_new());
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
557 gnt_box_add_widget(GNT_BOX(window), gnt_label_new(_("Use different status for following accounts")));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
558
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
559 edit->hash = g_hash_table_new(g_direct_hash, g_direct_equal);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
560 edit->tree = tree = gnt_tree_new_with_columns(3);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
561 gnt_box_add_widget(GNT_BOX(window), tree);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
562 gnt_tree_set_show_title(GNT_TREE(tree), TRUE);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
563 gnt_tree_set_column_titles(GNT_TREE(tree), _("Account"), _("Status"), _("Message"));
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
564 gnt_tree_set_col_width(GNT_TREE(tree), 0, 30);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
565 gnt_tree_set_col_width(GNT_TREE(tree), 1, 10);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
566 gnt_tree_set_col_width(GNT_TREE(tree), 2, 30);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
567
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
568 for (iter = gaim_accounts_get_all(); iter; iter = iter->next)
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
569 {
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
570 add_substatus(edit, iter->data);
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
571 }
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
572
789d80a6b9d9 [gaim-migrate @ 16853]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14132
diff changeset
573 g_signal_connect(G_OBJECT(tree), "key_pressed", G_CALLBACK(popup_substatus), edit);
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
574
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
575 /* The buttons */
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
576 box = gnt_hbox_new(FALSE);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
577 gnt_box_add_widget(GNT_BOX(window), box);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
578
14695
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
579 /* Use */
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
580 button = gnt_button_new(_("Use"));
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
581 gnt_box_add_widget(GNT_BOX(box), button);
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
582 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(use_trans_status_cb), edit);
fa0c8fa2b5a7 [gaim-migrate @ 17447]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14558
diff changeset
583
14132
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
584 /* Save */
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
585 button = gnt_button_new(_("Save"));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
586 gnt_box_add_widget(GNT_BOX(box), button);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
587 g_object_set_data(G_OBJECT(button), "use", NULL);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
588 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_savedstatus_cb), edit);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
589
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
590 /* Save & Use */
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
591 button = gnt_button_new(_("Save & Use"));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
592 gnt_box_add_widget(GNT_BOX(box), button);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
593 g_object_set_data(G_OBJECT(button), "use", GINT_TO_POINTER(TRUE));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
594 g_signal_connect(G_OBJECT(button), "activate", G_CALLBACK(save_savedstatus_cb), edit);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
595
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
596 /* Cancel */
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
597 button = gnt_button_new(_("Cancel"));
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
598 gnt_box_add_widget(GNT_BOX(box), button);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
599 g_signal_connect_swapped(G_OBJECT(button), "activate",
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
600 G_CALLBACK(gnt_widget_destroy), window);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
601
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
602 g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(update_edit_list), edit);
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
603
2c85b0f97dd0 [gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents: 14126
diff changeset
604 gnt_widget_show(window);
14126
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
605 }
b71bfeaaed58 [gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff changeset
606