Mercurial > pidgin.yaz
comparison src/gtkaccount.c @ 5581:3a9b54f260e3
[gaim-migrate @ 5985]
Commit'em if you got'em.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sat, 31 May 2003 04:35:54 +0000 |
parents | 5e7de337a053 |
children | 57165429ed73 |
comparison
equal
deleted
inserted
replaced
5580:86456ec3ca25 | 5581:3a9b54f260e3 |
---|---|
27 #include "gtkblist.h" | 27 #include "gtkblist.h" |
28 | 28 |
29 enum | 29 enum |
30 { | 30 { |
31 COLUMN_ICON, | 31 COLUMN_ICON, |
32 COLUMN_PROTOCOL, | |
32 COLUMN_SCREENNAME, | 33 COLUMN_SCREENNAME, |
33 COLUMN_ONLINE, | 34 COLUMN_ONLINE, |
34 COLUMN_AUTOLOGIN, | 35 COLUMN_AUTOLOGIN, |
35 COLUMN_PROTOCOL, | 36 COLUMN_FILLER, |
36 COLUMN_DATA, | 37 COLUMN_DATA, |
37 NUM_COLUMNS | 38 NUM_COLUMNS |
38 }; | 39 }; |
39 | 40 |
40 typedef struct | 41 typedef struct |
41 { | 42 { |
42 GtkWidget *window; | 43 GtkWidget *window; |
43 | 44 |
44 GtkListStore *model; | 45 GtkListStore *model; |
45 | 46 |
47 GtkTreeViewColumn *screenname_col; | |
48 | |
46 } AccountsDialog; | 49 } AccountsDialog; |
47 | 50 |
48 static AccountsDialog *accounts_dialog = NULL; | 51 static AccountsDialog *accounts_dialog = NULL; |
49 | 52 |
50 static char * | 53 static char * |
66 | 69 |
67 static gboolean | 70 static gboolean |
68 __configure_cb(GtkWidget *w, GdkEventConfigure *event, AccountsDialog *dialog) | 71 __configure_cb(GtkWidget *w, GdkEventConfigure *event, AccountsDialog *dialog) |
69 { | 72 { |
70 if (GTK_WIDGET_VISIBLE(w)) { | 73 if (GTK_WIDGET_VISIBLE(w)) { |
74 int old_width = gaim_prefs_get_int("/gaim/gtk/accounts/dialog/width"); | |
75 int col_width; | |
76 int difference; | |
77 | |
71 gaim_prefs_set_int("/gaim/gtk/accounts/dialog/width", event->width); | 78 gaim_prefs_set_int("/gaim/gtk/accounts/dialog/width", event->width); |
72 gaim_prefs_set_int("/gaim/gtk/accounts/dialog/height", event->height); | 79 gaim_prefs_set_int("/gaim/gtk/accounts/dialog/height", event->height); |
80 | |
81 col_width = gtk_tree_view_column_get_width(dialog->screenname_col); | |
82 | |
83 if (col_width == 0) | |
84 return FALSE; | |
85 | |
86 difference = (MAX(old_width, event->width) - | |
87 MIN(old_width, event->width)); | |
88 | |
89 if (difference == 0) | |
90 return FALSE; | |
91 | |
92 if (old_width < event->width) | |
93 gtk_tree_view_column_set_min_width(dialog->screenname_col, | |
94 col_width + difference); | |
95 else | |
96 gtk_tree_view_column_set_max_width(dialog->screenname_col, | |
97 col_width - difference); | |
73 } | 98 } |
74 | 99 |
75 return FALSE; | 100 return FALSE; |
76 } | 101 } |
77 | 102 |
114 | 139 |
115 static void | 140 static void |
116 __add_columns(GtkWidget *treeview, AccountsDialog *dialog) | 141 __add_columns(GtkWidget *treeview, AccountsDialog *dialog) |
117 { | 142 { |
118 GtkCellRenderer *renderer; | 143 GtkCellRenderer *renderer; |
119 | 144 GtkTreeViewColumn *column; |
120 /* Protocol Icon */ | 145 |
146 /* Protocol */ | |
147 column = gtk_tree_view_column_new(); | |
148 gtk_tree_view_column_set_title(column, _("Protocol")); | |
149 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | |
150 | |
151 /* Icon text */ | |
121 renderer = gtk_cell_renderer_pixbuf_new(); | 152 renderer = gtk_cell_renderer_pixbuf_new(); |
122 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), | 153 gtk_tree_view_column_pack_start(column, renderer, FALSE); |
123 -1, "", | 154 gtk_tree_view_column_add_attribute(column, renderer, |
124 renderer, | 155 "pixbuf", COLUMN_ICON); |
125 "pixbuf", COLUMN_ICON, | 156 |
126 NULL); | 157 /* Protocol name */ |
158 renderer = gtk_cell_renderer_text_new(); | |
159 gtk_tree_view_column_pack_start(column, renderer, TRUE); | |
160 gtk_tree_view_column_add_attribute(column, renderer, | |
161 "text", COLUMN_PROTOCOL); | |
127 | 162 |
128 /* Screennames */ | 163 /* Screennames */ |
129 renderer = gtk_cell_renderer_text_new(); | 164 renderer = gtk_cell_renderer_text_new(); |
130 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), | 165 column = gtk_tree_view_column_new_with_attributes(_("Screenname"), |
131 -1, _("Screenname"), | 166 renderer, "text", COLUMN_SCREENNAME, NULL); |
132 renderer, | 167 dialog->screenname_col = column; |
133 "text", COLUMN_SCREENNAME, | 168 |
134 NULL); | 169 gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
170 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); | |
135 | 171 |
136 /* Online? */ | 172 /* Online? */ |
137 renderer = gtk_cell_renderer_toggle_new(); | 173 renderer = gtk_cell_renderer_toggle_new(); |
138 | 174 |
139 g_signal_connect(G_OBJECT(renderer), "toggled", | 175 g_signal_connect(G_OBJECT(renderer), "toggled", |
143 -1, _("Online"), | 179 -1, _("Online"), |
144 renderer, | 180 renderer, |
145 "active", COLUMN_ONLINE, | 181 "active", COLUMN_ONLINE, |
146 NULL); | 182 NULL); |
147 | 183 |
148 | |
149 /* Auto-login? */ | 184 /* Auto-login? */ |
150 renderer = gtk_cell_renderer_toggle_new(); | 185 renderer = gtk_cell_renderer_toggle_new(); |
151 | 186 |
152 g_signal_connect(G_OBJECT(renderer), "toggled", | 187 g_signal_connect(G_OBJECT(renderer), "toggled", |
153 G_CALLBACK(__autologin_cb), dialog); | 188 G_CALLBACK(__autologin_cb), dialog); |
154 | 189 |
155 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), | 190 column = gtk_tree_view_column_new_with_attributes(_("Auto-login"), |
156 -1, _("Auto-login"), | 191 renderer, "active", COLUMN_AUTOLOGIN, NULL); |
157 renderer, | 192 |
158 "active", COLUMN_AUTOLOGIN, | 193 gtk_tree_view_insert_column(GTK_TREE_VIEW(treeview), column, -1); |
159 NULL); | 194 |
160 | 195 /* Filler */ |
161 | |
162 /* Protocol description */ | |
163 renderer = gtk_cell_renderer_text_new(); | 196 renderer = gtk_cell_renderer_text_new(); |
164 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), | 197 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), |
165 -1, _("Protocol"), | 198 -1, "", renderer, |
166 renderer, | 199 "visible", COLUMN_FILLER, |
167 "text", COLUMN_PROTOCOL, | |
168 NULL); | 200 NULL); |
169 } | 201 } |
170 | 202 |
171 static void | 203 static void |
172 __populate_accounts_list(AccountsDialog *dialog) | 204 __populate_accounts_list(AccountsDialog *dialog) |
196 COLUMN_SCREENNAME, gaim_account_get_username(account), | 228 COLUMN_SCREENNAME, gaim_account_get_username(account), |
197 COLUMN_ONLINE, gaim_account_is_connected(account), | 229 COLUMN_ONLINE, gaim_account_is_connected(account), |
198 COLUMN_AUTOLOGIN, FALSE, | 230 COLUMN_AUTOLOGIN, FALSE, |
199 COLUMN_PROTOCOL, proto_name(gaim_account_get_protocol(account)), | 231 COLUMN_PROTOCOL, proto_name(gaim_account_get_protocol(account)), |
200 COLUMN_DATA, account, | 232 COLUMN_DATA, account, |
233 COLUMN_FILLER, FALSE, | |
201 -1); | 234 -1); |
202 | 235 |
203 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); | 236 if (pixbuf != NULL) g_object_unref(G_OBJECT(pixbuf)); |
204 if (scale != NULL) g_object_unref(G_OBJECT(scale)); | 237 if (scale != NULL) g_object_unref(G_OBJECT(scale)); |
205 } | 238 } |
220 GTK_SHADOW_IN); | 253 GTK_SHADOW_IN); |
221 gtk_widget_show(sw); | 254 gtk_widget_show(sw); |
222 | 255 |
223 /* Create the list model. */ | 256 /* Create the list model. */ |
224 dialog->model = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, | 257 dialog->model = gtk_list_store_new(NUM_COLUMNS, GDK_TYPE_PIXBUF, |
225 G_TYPE_STRING, G_TYPE_BOOLEAN, | 258 G_TYPE_STRING, G_TYPE_STRING, |
226 G_TYPE_BOOLEAN, G_TYPE_STRING, | 259 G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, |
227 G_TYPE_POINTER); | 260 G_TYPE_BOOLEAN, G_TYPE_POINTER); |
228 | 261 |
229 /* And now the actual treeview */ | 262 /* And now the actual treeview */ |
230 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model)); | 263 treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(dialog->model)); |
231 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); | 264 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); |
232 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(treeview), TRUE); | 265 gtk_tree_view_set_reorderable(GTK_TREE_VIEW(treeview), TRUE); |
233 gtk_tree_selection_set_mode( | 266 gtk_tree_selection_set_mode( |
234 gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), | 267 gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)), |
235 GTK_SELECTION_MULTIPLE); | 268 GTK_SELECTION_MULTIPLE); |
236 | 269 |
237 __add_columns(treeview, dialog); | |
238 | |
239 gtk_container_add(GTK_CONTAINER(sw), treeview); | 270 gtk_container_add(GTK_CONTAINER(sw), treeview); |
240 gtk_widget_show(treeview); | 271 gtk_widget_show(treeview); |
272 | |
273 __add_columns(treeview, dialog); | |
241 | 274 |
242 __populate_accounts_list(dialog); | 275 __populate_accounts_list(dialog); |
243 | 276 |
244 return sw; | 277 return sw; |
245 } | 278 } |