Mercurial > pidgin.yaz
annotate console/gntstatus.c @ 14132:2c85b0f97dd0
[gaim-migrate @ 16774]
Add a new custom status dialog, and a corresponding entry in the status-selector in the buddylist.
But you cannot set any per-account status yet.
committer: Tailor Script <tailor@pidgin.im>
author | Sadrul Habib Chowdhury <imadil@gmail.com> |
---|---|
date | Tue, 15 Aug 2006 20:23:58 +0000 |
parents | b71bfeaaed58 |
children | 789d80a6b9d9 |
rev | line source |
---|---|
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
1 #include <gnt.h> |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
2 #include <gntbox.h> |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
3 #include <gntbutton.h> |
14132
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
4 #include <gntcombobox.h> |
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
5 #include <gntentry.h> |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
6 #include <gntlabel.h> |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
7 #include <gnttree.h> |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
8 |
14132
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
9 #include <notify.h> |
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
10 #include <request.h> |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
11 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
12 #include "gntgaim.h" |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
13 #include "gntstatus.h" |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
14 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
15 static struct |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
16 { |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
17 GntWidget *window; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
18 GntWidget *tree; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
19 } statuses; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
20 |
14132
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
21 typedef struct |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
22 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
23 GaimSavedStatus *saved; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
24 GntWidget *window; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
25 GntWidget *title; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
26 GntWidget *type; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
27 GntWidget *message; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
28 /* XXX: Stuff needed for per-account statuses */ |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
29 } EditStatus; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
30 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
31 static GList *edits; /* List of opened edit-status dialogs */ |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
32 |
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
33 static void |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
34 reset_status_window(GntWidget *widget, gpointer null) |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
35 { |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
36 statuses.window = NULL; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
37 statuses.tree = NULL; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
38 } |
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 void |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
41 populate_statuses(GntTree *tree) |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
42 { |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
43 const GList *list; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
44 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
45 for (list = gaim_savedstatuses_get_all(); list; list = list->next) |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
46 { |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
47 GaimSavedStatus *saved = list->data; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
48 const char *title, *type, *message; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
49 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
50 if (gaim_savedstatus_is_transient(saved)) |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
51 continue; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
52 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
53 title = gaim_savedstatus_get_title(saved); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
54 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
|
55 message = gaim_savedstatus_get_message(saved); /* XXX: Strip possible markups */ |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
56 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
57 gnt_tree_add_row_last(tree, saved, |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
58 gnt_tree_create_row(tree, title, type, message), NULL); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
59 } |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
60 } |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
61 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
62 static void |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
63 really_delete_status(GaimSavedStatus *saved) |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
64 { |
14132
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
65 GList *iter; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
66 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
67 for (iter = edits; iter; iter = iter->next) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
68 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
69 EditStatus *edit = iter->data; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
70 if (edit->saved == saved) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
71 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
72 gnt_widget_destroy(edit->window); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
73 break; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
74 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
75 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
76 |
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
77 if (statuses.tree) |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
78 gnt_tree_remove(GNT_TREE(statuses.tree), saved); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
79 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
80 gaim_savedstatus_delete(gaim_savedstatus_get_title(saved)); |
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 ask_before_delete(GntWidget *button, gpointer null) |
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 char *ask; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
87 GaimSavedStatus *saved; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
88 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
89 g_return_if_fail(statuses.tree != NULL); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
90 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
91 saved = gnt_tree_get_selection_data(GNT_TREE(statuses.tree)); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
92 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
|
93 gaim_savedstatus_get_title(saved)); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
94 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
95 gaim_request_action(saved, _("Delete Status"), ask, NULL, 0, saved, 2, |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
96 _("Delete"), really_delete_status, _("Cancel"), NULL); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
97 g_free(ask); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
98 } |
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 static void |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
101 use_savedstatus_cb(GntWidget *widget, gpointer 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 g_return_if_fail(statuses.tree != NULL); |
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 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
|
106 } |
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 static void |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
109 edit_savedstatus_cb(GntWidget *widget, gpointer null) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
110 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
111 g_return_if_fail(statuses.tree != NULL); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
112 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
113 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
|
114 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
115 |
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
116 void gg_savedstatus_show_all() |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
117 { |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
118 GntWidget *window, *tree, *box, *button; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
119 if (statuses.window) |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
120 return; |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
121 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
122 statuses.window = window = gnt_vbox_new(FALSE); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
123 gnt_box_set_toplevel(GNT_BOX(window), TRUE); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
124 gnt_box_set_title(GNT_BOX(window), _("Saved Statuses")); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
125 gnt_box_set_fill(GNT_BOX(window), FALSE); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
126 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_MID); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
127 gnt_box_set_pad(GNT_BOX(window), 0); |
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 /* XXX: Add some sorting function to sort alphabetically, perhaps */ |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
130 statuses.tree = tree = gnt_tree_new_with_columns(3); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
131 gnt_tree_set_column_titles(GNT_TREE(tree), _("Title"), _("Type"), _("Message")); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
132 gnt_tree_set_show_title(GNT_TREE(tree), TRUE); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
133 gnt_tree_set_col_width(GNT_TREE(tree), 0, 25); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
134 gnt_tree_set_col_width(GNT_TREE(tree), 1, 12); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
135 gnt_tree_set_col_width(GNT_TREE(tree), 2, 35); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
136 gnt_box_add_widget(GNT_BOX(window), tree); |
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 populate_statuses(GNT_TREE(tree)); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
139 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
140 box = gnt_hbox_new(FALSE); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
141 gnt_box_add_widget(GNT_BOX(window), box); |
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 button = gnt_button_new(_("Use")); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
144 gnt_box_add_widget(GNT_BOX(box), button); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
145 g_signal_connect(G_OBJECT(button), "activate", |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
146 G_CALLBACK(use_savedstatus_cb), 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 button = gnt_button_new(_("Add")); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
149 gnt_box_add_widget(GNT_BOX(box), button); |
14132
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
150 g_signal_connect_swapped(G_OBJECT(button), "activate", |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
151 G_CALLBACK(gg_savedstatus_edit), NULL); |
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
152 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
153 button = gnt_button_new(_("Edit")); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
154 gnt_box_add_widget(GNT_BOX(box), button); |
14132
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
155 g_signal_connect(G_OBJECT(button), "activate", |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
156 G_CALLBACK(edit_savedstatus_cb), NULL); |
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
157 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
158 button = gnt_button_new(_("Delete")); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
159 gnt_box_add_widget(GNT_BOX(box), button); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
160 g_signal_connect(G_OBJECT(button), "activate", |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
161 G_CALLBACK(ask_before_delete), NULL); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
162 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
163 button = gnt_button_new(_("Close")); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
164 gnt_box_add_widget(GNT_BOX(box), button); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
165 g_signal_connect_swapped(G_OBJECT(button), "activate", |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
166 G_CALLBACK(gnt_widget_destroy), window); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
167 |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
168 g_signal_connect(G_OBJECT(window), "destroy", |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
169 G_CALLBACK(reset_status_window), NULL); |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
170 gnt_widget_show(window); |
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 |
14132
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
173 static void |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
174 update_edit_list(GntWidget *widget, EditStatus *edit) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
175 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
176 edits = g_list_remove(edits, edit); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
177 gaim_notify_close_with_handle(edit); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
178 g_free(edit); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
179 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
180 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
181 static void |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
182 save_savedstatus_cb(GntWidget *button, EditStatus *edit) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
183 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
184 const char *title, *message; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
185 GaimStatusPrimitive prim; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
186 GaimSavedStatus *find; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
187 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
188 title = gnt_entry_get_text(GNT_ENTRY(edit->title)); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
189 message = gnt_entry_get_text(GNT_ENTRY(edit->message)); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
190 if (!message || !*message) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
191 message = NULL; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
192 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
193 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
|
194 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
195 if (!title || !*title) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
196 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
197 gaim_notify_error(edit, _("Error"), _("Invalid title"), |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
198 _("Please enter a non-empty title for the status.")); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
199 return; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
200 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
201 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
202 find = gaim_savedstatus_find(title); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
203 if (find && find != edit->saved) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
204 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
205 gaim_notify_error(edit, _("Error"), _("Duplicate title"), |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
206 _("Please enter a different title for the status.")); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
207 return; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
208 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
209 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
210 if (edit->saved == NULL) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
211 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
212 edit->saved = gaim_savedstatus_new(title, prim); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
213 gaim_savedstatus_set_message(edit->saved, message); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
214 if (statuses.tree) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
215 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
|
216 gnt_tree_create_row(GNT_TREE(statuses.tree), title, |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
217 gaim_primitive_get_name_from_type(prim), message), NULL); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
218 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
219 else |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
220 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
221 gaim_savedstatus_set_title(edit->saved, title); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
222 gaim_savedstatus_set_type(edit->saved, prim); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
223 gaim_savedstatus_set_message(edit->saved, message); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
224 if (statuses.tree) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
225 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
226 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
|
227 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
|
228 gaim_primitive_get_name_from_type(prim)); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
229 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
|
230 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
231 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
232 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
233 if (g_object_get_data(G_OBJECT(button), "use")) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
234 gaim_savedstatus_activate(edit->saved); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
235 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
236 gnt_widget_destroy(edit->window); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
237 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
238 |
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
239 void gg_savedstatus_edit(GaimSavedStatus *saved) |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
240 { |
14132
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
241 EditStatus *edit; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
242 GntWidget *window, *box, *button, *entry, *combo, *label; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
243 GaimStatusPrimitive prims[] = {GAIM_STATUS_AVAILABLE, GAIM_STATUS_AWAY, |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
244 GAIM_STATUS_INVISIBLE, GAIM_STATUS_OFFLINE, GAIM_STATUS_UNSET}, current; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
245 int i; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
246 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
247 if (saved) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
248 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
249 GList *iter; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
250 for (iter = edits; iter; iter = iter->next) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
251 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
252 edit = iter->data; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
253 if (edit->saved == saved) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
254 return; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
255 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
256 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
257 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
258 edit = g_new0(EditStatus, 1); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
259 edit->saved = saved; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
260 edit->window = window = gnt_vbox_new(FALSE); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
261 gnt_box_set_toplevel(GNT_BOX(window), TRUE); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
262 gnt_box_set_title(GNT_BOX(window), _("Edit Status")); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
263 gnt_box_set_fill(GNT_BOX(window), TRUE); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
264 gnt_box_set_alignment(GNT_BOX(window), GNT_ALIGN_LEFT); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
265 gnt_box_set_pad(GNT_BOX(window), 0); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
266 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
267 edits = g_list_append(edits, edit); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
268 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
269 /* Title */ |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
270 box = gnt_hbox_new(FALSE); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
271 gnt_box_add_widget(GNT_BOX(window), box); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
272 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
|
273 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
274 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
|
275 gnt_box_add_widget(GNT_BOX(box), entry); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
276 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
277 /* Type */ |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
278 box = gnt_hbox_new(FALSE); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
279 gnt_box_add_widget(GNT_BOX(window), box); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
280 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
|
281 gnt_widget_set_size(label, 0, 1); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
282 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
283 edit->type = combo = gnt_combo_box_new(); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
284 gnt_box_add_widget(GNT_BOX(box), combo); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
285 current = saved ? gaim_savedstatus_get_type(saved) : GAIM_STATUS_UNSET; |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
286 for (i = 0; prims[i] != GAIM_STATUS_UNSET; i++) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
287 { |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
288 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
|
289 gaim_primitive_get_name_from_type(prims[i])); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
290 if (prims[i] == current) |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
291 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
|
292 } |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
293 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
294 /* Message */ |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
295 box = gnt_hbox_new(FALSE); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
296 gnt_box_add_widget(GNT_BOX(window), box); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
297 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
|
298 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
299 edit->message = entry = gnt_entry_new(saved ? gaim_savedstatus_get_message(saved) : NULL); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
300 gnt_box_add_widget(GNT_BOX(box), entry); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
301 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
302 /* The buttons */ |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
303 box = gnt_hbox_new(FALSE); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
304 gnt_box_add_widget(GNT_BOX(window), box); |
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 /* Save */ |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
307 button = gnt_button_new(_("Save")); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
308 gnt_box_add_widget(GNT_BOX(box), button); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
309 g_object_set_data(G_OBJECT(button), "use", NULL); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
310 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
|
311 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
312 /* Save & Use */ |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
313 button = gnt_button_new(_("Save & Use")); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
314 gnt_box_add_widget(GNT_BOX(box), button); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
315 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
|
316 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
|
317 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
318 /* Cancel */ |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
319 button = gnt_button_new(_("Cancel")); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
320 gnt_box_add_widget(GNT_BOX(box), button); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
321 g_signal_connect_swapped(G_OBJECT(button), "activate", |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
322 G_CALLBACK(gnt_widget_destroy), window); |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
323 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
324 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
|
325 |
2c85b0f97dd0
[gaim-migrate @ 16774]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
14126
diff
changeset
|
326 gnt_widget_show(window); |
14126
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
327 } |
b71bfeaaed58
[gaim-migrate @ 16764]
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
diff
changeset
|
328 |