root / src / prefs_summary_column.c @ 237
History | View | Annotate | Download (15.4 kB)
| 1 | /*
|
|---|---|
| 2 | * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client |
| 3 | * Copyright (C) 1999-2005 Hiroyuki Yamamoto |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | */ |
| 19 | |
| 20 | #ifdef HAVE_CONFIG_H
|
| 21 | # include "config.h" |
| 22 | #endif
|
| 23 | |
| 24 | #include "defs.h" |
| 25 | |
| 26 | #include <glib.h> |
| 27 | #include <glib/gi18n.h> |
| 28 | #include <gdk/gdkkeysyms.h> |
| 29 | #include <gtk/gtkmain.h> |
| 30 | #include <gtk/gtkwindow.h> |
| 31 | #include <gtk/gtkvbox.h> |
| 32 | #include <gtk/gtkhbox.h> |
| 33 | #include <gtk/gtkclist.h> |
| 34 | #include <gtk/gtkbutton.h> |
| 35 | #include <gtk/gtkstock.h> |
| 36 | |
| 37 | #include "prefs.h" |
| 38 | #include "prefs_common.h" |
| 39 | #include "prefs_summary_column.h" |
| 40 | #include "manage_window.h" |
| 41 | #include "summaryview.h" |
| 42 | #include "mainwindow.h" |
| 43 | #include "inc.h" |
| 44 | #include "gtkutils.h" |
| 45 | #include "utils.h" |
| 46 | |
| 47 | static struct _SummaryColumnDialog |
| 48 | {
|
| 49 | GtkWidget *window; |
| 50 | |
| 51 | GtkWidget *stock_clist; |
| 52 | GtkWidget *shown_clist; |
| 53 | |
| 54 | GtkWidget *add_btn; |
| 55 | GtkWidget *remove_btn; |
| 56 | GtkWidget *up_btn; |
| 57 | GtkWidget *down_btn; |
| 58 | |
| 59 | GtkWidget *default_btn; |
| 60 | |
| 61 | GtkWidget *ok_btn; |
| 62 | GtkWidget *cancel_btn; |
| 63 | |
| 64 | gboolean finished; |
| 65 | } summary_col; |
| 66 | |
| 67 | static const gchar *const col_name[N_SUMMARY_VISIBLE_COLS] = { |
| 68 | N_("Mark"), /* S_COL_MARK */ |
| 69 | N_("Unread"), /* S_COL_UNREAD */ |
| 70 | N_("Attachment"), /* S_COL_MIME */ |
| 71 | N_("Subject"), /* S_COL_SUBJECT */ |
| 72 | N_("From"), /* S_COL_FROM */ |
| 73 | N_("Date"), /* S_COL_DATE */ |
| 74 | N_("Size"), /* S_COL_SIZE */ |
| 75 | N_("Number") /* S_COL_NUMBER */ |
| 76 | }; |
| 77 | |
| 78 | static SummaryColumnState default_state[N_SUMMARY_VISIBLE_COLS] = {
|
| 79 | { S_COL_MARK , TRUE },
|
| 80 | { S_COL_UNREAD , TRUE },
|
| 81 | { S_COL_MIME , TRUE },
|
| 82 | { S_COL_SUBJECT, TRUE },
|
| 83 | { S_COL_FROM , TRUE },
|
| 84 | { S_COL_DATE , TRUE },
|
| 85 | { S_COL_SIZE , TRUE },
|
| 86 | { S_COL_NUMBER , FALSE }
|
| 87 | }; |
| 88 | |
| 89 | static void prefs_summary_column_create (void); |
| 90 | |
| 91 | static void prefs_summary_column_set_dialog (SummaryColumnState *state); |
| 92 | static void prefs_summary_column_set_view (void); |
| 93 | |
| 94 | /* callback functions */
|
| 95 | static void prefs_summary_column_add (void); |
| 96 | static void prefs_summary_column_remove (void); |
| 97 | |
| 98 | static void prefs_summary_column_up (void); |
| 99 | static void prefs_summary_column_down (void); |
| 100 | |
| 101 | static void prefs_summary_column_set_to_default (void); |
| 102 | |
| 103 | static void prefs_summary_column_ok (void); |
| 104 | static void prefs_summary_column_cancel (void); |
| 105 | |
| 106 | static gint prefs_summary_column_delete_event (GtkWidget *widget,
|
| 107 | GdkEventAny *event, |
| 108 | gpointer data); |
| 109 | static gboolean prefs_summary_column_key_pressed(GtkWidget *widget,
|
| 110 | GdkEventKey *event, |
| 111 | gpointer data); |
| 112 | |
| 113 | void prefs_summary_column_open(void) |
| 114 | {
|
| 115 | inc_lock(); |
| 116 | |
| 117 | if (!summary_col.window)
|
| 118 | prefs_summary_column_create(); |
| 119 | |
| 120 | manage_window_set_transient(GTK_WINDOW(summary_col.window)); |
| 121 | gtk_widget_grab_focus(summary_col.ok_btn); |
| 122 | |
| 123 | prefs_summary_column_set_dialog(NULL);
|
| 124 | |
| 125 | gtk_widget_show(summary_col.window); |
| 126 | |
| 127 | summary_col.finished = FALSE; |
| 128 | while (summary_col.finished == FALSE)
|
| 129 | gtk_main_iteration(); |
| 130 | |
| 131 | gtk_widget_hide(summary_col.window); |
| 132 | |
| 133 | inc_unlock(); |
| 134 | } |
| 135 | |
| 136 | static void prefs_summary_column_create(void) |
| 137 | {
|
| 138 | GtkWidget *window; |
| 139 | GtkWidget *vbox; |
| 140 | |
| 141 | GtkWidget *label_hbox; |
| 142 | GtkWidget *label; |
| 143 | |
| 144 | GtkWidget *vbox1; |
| 145 | |
| 146 | GtkWidget *hbox1; |
| 147 | GtkWidget *clist_hbox; |
| 148 | GtkWidget *scrolledwin; |
| 149 | GtkWidget *stock_clist; |
| 150 | GtkWidget *shown_clist; |
| 151 | |
| 152 | GtkWidget *btn_vbox; |
| 153 | GtkWidget *btn_vbox1; |
| 154 | GtkWidget *add_btn; |
| 155 | GtkWidget *remove_btn; |
| 156 | GtkWidget *up_btn; |
| 157 | GtkWidget *down_btn; |
| 158 | |
| 159 | GtkWidget *btn_hbox; |
| 160 | GtkWidget *default_btn; |
| 161 | GtkWidget *confirm_area; |
| 162 | GtkWidget *ok_btn; |
| 163 | GtkWidget *cancel_btn; |
| 164 | |
| 165 | gchar *title[1];
|
| 166 | |
| 167 | debug_print(_("Creating summary column setting window...\n"));
|
| 168 | |
| 169 | window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 170 | gtk_container_set_border_width(GTK_CONTAINER(window), 8);
|
| 171 | gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); |
| 172 | gtk_window_set_modal(GTK_WINDOW(window), TRUE); |
| 173 | gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); |
| 174 | gtk_window_set_title(GTK_WINDOW(window), |
| 175 | _("Summary display item setting"));
|
| 176 | g_signal_connect(G_OBJECT(window), "delete_event",
|
| 177 | G_CALLBACK(prefs_summary_column_delete_event), NULL);
|
| 178 | g_signal_connect(G_OBJECT(window), "key_press_event",
|
| 179 | G_CALLBACK(prefs_summary_column_key_pressed), NULL);
|
| 180 | |
| 181 | vbox = gtk_vbox_new(FALSE, 6);
|
| 182 | gtk_widget_show(vbox); |
| 183 | gtk_container_add(GTK_CONTAINER(window), vbox); |
| 184 | |
| 185 | label_hbox = gtk_hbox_new(FALSE, 0);
|
| 186 | gtk_widget_show(label_hbox); |
| 187 | gtk_box_pack_start(GTK_BOX(vbox), label_hbox, FALSE, FALSE, 4);
|
| 188 | |
| 189 | label = gtk_label_new |
| 190 | (_("Select items to be displayed on the summary view. You can modify\n"
|
| 191 | "the order by using the Up / Down button, or dragging the items."));
|
| 192 | gtk_widget_show(label); |
| 193 | gtk_box_pack_start(GTK_BOX(label_hbox), label, FALSE, FALSE, 4);
|
| 194 | gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); |
| 195 | |
| 196 | vbox1 = gtk_vbox_new(FALSE, VSPACING); |
| 197 | gtk_widget_show(vbox1); |
| 198 | gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
|
| 199 | gtk_container_set_border_width(GTK_CONTAINER(vbox1), 2);
|
| 200 | |
| 201 | hbox1 = gtk_hbox_new(FALSE, 8);
|
| 202 | gtk_widget_show(hbox1); |
| 203 | gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, TRUE, 0);
|
| 204 | |
| 205 | clist_hbox = gtk_hbox_new(FALSE, 8);
|
| 206 | gtk_widget_show(clist_hbox); |
| 207 | gtk_box_pack_start(GTK_BOX(hbox1), clist_hbox, TRUE, TRUE, 0);
|
| 208 | |
| 209 | scrolledwin = gtk_scrolled_window_new(NULL, NULL); |
| 210 | gtk_widget_set_size_request(scrolledwin, 180, 210); |
| 211 | gtk_widget_show(scrolledwin); |
| 212 | gtk_box_pack_start(GTK_BOX(clist_hbox), scrolledwin, TRUE, TRUE, 0);
|
| 213 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin), |
| 214 | GTK_POLICY_AUTOMATIC, |
| 215 | GTK_POLICY_AUTOMATIC); |
| 216 | |
| 217 | title[0] = _("Available items"); |
| 218 | stock_clist = gtk_clist_new_with_titles(1, title);
|
| 219 | gtk_widget_show(stock_clist); |
| 220 | gtk_container_add(GTK_CONTAINER(scrolledwin), stock_clist); |
| 221 | gtk_clist_set_selection_mode(GTK_CLIST(stock_clist), |
| 222 | GTK_SELECTION_BROWSE); |
| 223 | GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(stock_clist)->column[0].button,
|
| 224 | GTK_CAN_FOCUS); |
| 225 | |
| 226 | /* add/remove button */
|
| 227 | btn_vbox = gtk_vbox_new(FALSE, 0);
|
| 228 | gtk_widget_show(btn_vbox); |
| 229 | gtk_box_pack_start(GTK_BOX(hbox1), btn_vbox, FALSE, FALSE, 0);
|
| 230 | |
| 231 | btn_vbox1 = gtk_vbox_new(FALSE, 8);
|
| 232 | gtk_widget_show(btn_vbox1); |
| 233 | gtk_box_pack_start(GTK_BOX(btn_vbox), btn_vbox1, TRUE, FALSE, 0);
|
| 234 | |
| 235 | add_btn = gtk_button_new_with_label(_(" -> "));
|
| 236 | gtk_widget_show(add_btn); |
| 237 | gtk_box_pack_start(GTK_BOX(btn_vbox1), add_btn, FALSE, FALSE, 0);
|
| 238 | |
| 239 | remove_btn = gtk_button_new_with_label(_(" <- "));
|
| 240 | gtk_widget_show(remove_btn); |
| 241 | gtk_box_pack_start(GTK_BOX(btn_vbox1), remove_btn, FALSE, FALSE, 0);
|
| 242 | |
| 243 | g_signal_connect(G_OBJECT(add_btn), "clicked",
|
| 244 | G_CALLBACK(prefs_summary_column_add), NULL);
|
| 245 | g_signal_connect(G_OBJECT(remove_btn), "clicked",
|
| 246 | G_CALLBACK(prefs_summary_column_remove), NULL);
|
| 247 | |
| 248 | clist_hbox = gtk_hbox_new(FALSE, 8);
|
| 249 | gtk_widget_show(clist_hbox); |
| 250 | gtk_box_pack_start(GTK_BOX(hbox1), clist_hbox, TRUE, TRUE, 0);
|
| 251 | |
| 252 | scrolledwin = gtk_scrolled_window_new(NULL, NULL); |
| 253 | gtk_widget_set_size_request(scrolledwin, 180, 210); |
| 254 | gtk_widget_show(scrolledwin); |
| 255 | gtk_box_pack_start(GTK_BOX(clist_hbox), scrolledwin, TRUE, TRUE, 0);
|
| 256 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin), |
| 257 | GTK_POLICY_AUTOMATIC, |
| 258 | GTK_POLICY_AUTOMATIC); |
| 259 | |
| 260 | title[0] = _("Displayed items"); |
| 261 | shown_clist = gtk_clist_new_with_titles(1, title);
|
| 262 | gtk_widget_show(shown_clist); |
| 263 | gtk_container_add(GTK_CONTAINER(scrolledwin), shown_clist); |
| 264 | gtk_clist_set_selection_mode(GTK_CLIST(shown_clist), |
| 265 | GTK_SELECTION_BROWSE); |
| 266 | gtk_clist_set_reorderable(GTK_CLIST(shown_clist), TRUE); |
| 267 | gtk_clist_set_use_drag_icons(GTK_CLIST(shown_clist), FALSE); |
| 268 | GTK_WIDGET_UNSET_FLAGS(GTK_CLIST(shown_clist)->column[0].button,
|
| 269 | GTK_CAN_FOCUS); |
| 270 | |
| 271 | /* up/down button */
|
| 272 | btn_vbox = gtk_vbox_new(FALSE, 0);
|
| 273 | gtk_widget_show(btn_vbox); |
| 274 | gtk_box_pack_start(GTK_BOX(hbox1), btn_vbox, FALSE, FALSE, 0);
|
| 275 | |
| 276 | btn_vbox1 = gtk_vbox_new(FALSE, 8);
|
| 277 | gtk_widget_show(btn_vbox1); |
| 278 | gtk_box_pack_start(GTK_BOX(btn_vbox), btn_vbox1, TRUE, FALSE, 0);
|
| 279 | |
| 280 | up_btn = gtk_button_new_with_label(_("Up"));
|
| 281 | gtk_widget_show(up_btn); |
| 282 | gtk_box_pack_start(GTK_BOX(btn_vbox1), up_btn, FALSE, FALSE, 0);
|
| 283 | |
| 284 | down_btn = gtk_button_new_with_label(_("Down"));
|
| 285 | gtk_widget_show(down_btn); |
| 286 | gtk_box_pack_start(GTK_BOX(btn_vbox1), down_btn, FALSE, FALSE, 0);
|
| 287 | |
| 288 | g_signal_connect(G_OBJECT(up_btn), "clicked",
|
| 289 | G_CALLBACK(prefs_summary_column_up), NULL);
|
| 290 | g_signal_connect(G_OBJECT(down_btn), "clicked",
|
| 291 | G_CALLBACK(prefs_summary_column_down), NULL);
|
| 292 | |
| 293 | btn_hbox = gtk_hbox_new(FALSE, 8);
|
| 294 | gtk_widget_show(btn_hbox); |
| 295 | gtk_box_pack_end(GTK_BOX(vbox), btn_hbox, FALSE, FALSE, 0);
|
| 296 | |
| 297 | btn_vbox = gtk_vbox_new(FALSE, 0);
|
| 298 | gtk_widget_show(btn_vbox); |
| 299 | gtk_box_pack_start(GTK_BOX(btn_hbox), btn_vbox, FALSE, FALSE, 0);
|
| 300 | |
| 301 | default_btn = gtk_button_new_with_label(_(" Revert to default "));
|
| 302 | gtk_widget_show(default_btn); |
| 303 | gtk_box_pack_start(GTK_BOX(btn_vbox), default_btn, TRUE, FALSE, 0);
|
| 304 | g_signal_connect(G_OBJECT(default_btn), "clicked",
|
| 305 | G_CALLBACK(prefs_summary_column_set_to_default), NULL);
|
| 306 | |
| 307 | gtkut_stock_button_set_create(&confirm_area, &ok_btn, GTK_STOCK_OK, |
| 308 | &cancel_btn, GTK_STOCK_CANCEL, |
| 309 | NULL, NULL); |
| 310 | gtk_widget_show(confirm_area); |
| 311 | gtk_box_pack_end(GTK_BOX(btn_hbox), confirm_area, FALSE, FALSE, 0);
|
| 312 | gtk_widget_grab_default(ok_btn); |
| 313 | |
| 314 | g_signal_connect(G_OBJECT(ok_btn), "clicked",
|
| 315 | G_CALLBACK(prefs_summary_column_ok), NULL);
|
| 316 | g_signal_connect(G_OBJECT(cancel_btn), "clicked",
|
| 317 | G_CALLBACK(prefs_summary_column_cancel), NULL);
|
| 318 | |
| 319 | summary_col.window = window; |
| 320 | summary_col.stock_clist = stock_clist; |
| 321 | summary_col.shown_clist = shown_clist; |
| 322 | summary_col.add_btn = add_btn; |
| 323 | summary_col.remove_btn = remove_btn; |
| 324 | summary_col.up_btn = up_btn; |
| 325 | summary_col.down_btn = down_btn; |
| 326 | summary_col.ok_btn = ok_btn; |
| 327 | summary_col.cancel_btn = cancel_btn; |
| 328 | } |
| 329 | |
| 330 | SummaryColumnState *prefs_summary_column_get_config(void)
|
| 331 | {
|
| 332 | static SummaryColumnState state[N_SUMMARY_VISIBLE_COLS];
|
| 333 | SummaryColumnType type; |
| 334 | gint pos; |
| 335 | |
| 336 | for (pos = 0; pos < N_SUMMARY_VISIBLE_COLS; pos++) |
| 337 | state[pos].type = -1;
|
| 338 | |
| 339 | for (type = 0; type < N_SUMMARY_VISIBLE_COLS; type++) { |
| 340 | pos = prefs_common.summary_col_pos[type]; |
| 341 | if (pos < 0 || pos >= N_SUMMARY_VISIBLE_COLS || |
| 342 | state[pos].type != -1) {
|
| 343 | g_warning("Wrong column position\n");
|
| 344 | prefs_summary_column_set_config(default_state); |
| 345 | return default_state;
|
| 346 | } |
| 347 | |
| 348 | state[pos].type = type; |
| 349 | state[pos].visible = prefs_common.summary_col_visible[type]; |
| 350 | } |
| 351 | |
| 352 | return state;
|
| 353 | } |
| 354 | |
| 355 | void prefs_summary_column_set_config(SummaryColumnState *state)
|
| 356 | {
|
| 357 | SummaryColumnType type; |
| 358 | gint pos; |
| 359 | |
| 360 | for (pos = 0; pos < N_SUMMARY_VISIBLE_COLS; pos++) { |
| 361 | type = state[pos].type; |
| 362 | prefs_common.summary_col_visible[type] = state[pos].visible; |
| 363 | prefs_common.summary_col_pos[type] = pos; |
| 364 | } |
| 365 | } |
| 366 | |
| 367 | static void prefs_summary_column_set_dialog(SummaryColumnState *state) |
| 368 | {
|
| 369 | GtkCList *stock_clist = GTK_CLIST(summary_col.stock_clist); |
| 370 | GtkCList *shown_clist = GTK_CLIST(summary_col.shown_clist); |
| 371 | gint pos; |
| 372 | SummaryColumnType type; |
| 373 | gchar *name; |
| 374 | |
| 375 | gtk_clist_clear(stock_clist); |
| 376 | gtk_clist_clear(shown_clist); |
| 377 | |
| 378 | if (!state)
|
| 379 | state = prefs_summary_column_get_config(); |
| 380 | |
| 381 | for (pos = 0; pos < N_SUMMARY_VISIBLE_COLS; pos++) { |
| 382 | gint row; |
| 383 | type = state[pos].type; |
| 384 | name = gettext(col_name[type]); |
| 385 | |
| 386 | if (state[pos].visible) {
|
| 387 | row = gtk_clist_append(shown_clist, (gchar **)&name); |
| 388 | gtk_clist_set_row_data(shown_clist, row, |
| 389 | GINT_TO_POINTER(type)); |
| 390 | } else {
|
| 391 | row = gtk_clist_append(stock_clist, (gchar **)&name); |
| 392 | gtk_clist_set_row_data(stock_clist, row, |
| 393 | GINT_TO_POINTER(type)); |
| 394 | } |
| 395 | } |
| 396 | } |
| 397 | |
| 398 | static void prefs_summary_column_set_view(void) |
| 399 | {
|
| 400 | GtkCList *stock_clist = GTK_CLIST(summary_col.stock_clist); |
| 401 | GtkCList *shown_clist = GTK_CLIST(summary_col.shown_clist); |
| 402 | SummaryColumnState state[N_SUMMARY_VISIBLE_COLS]; |
| 403 | SummaryColumnType type; |
| 404 | gint row, pos = 0;
|
| 405 | |
| 406 | g_return_if_fail(stock_clist->rows + shown_clist->rows == |
| 407 | N_SUMMARY_VISIBLE_COLS); |
| 408 | |
| 409 | for (row = 0; row < stock_clist->rows; row++) { |
| 410 | type = GPOINTER_TO_INT |
| 411 | (gtk_clist_get_row_data(stock_clist, row)); |
| 412 | state[row].type = type; |
| 413 | state[row].visible = FALSE; |
| 414 | } |
| 415 | |
| 416 | pos = row; |
| 417 | for (row = 0; row < shown_clist->rows; row++) { |
| 418 | type = GPOINTER_TO_INT |
| 419 | (gtk_clist_get_row_data(shown_clist, row)); |
| 420 | state[pos + row].type = type; |
| 421 | state[pos + row].visible = TRUE; |
| 422 | } |
| 423 | |
| 424 | prefs_summary_column_set_config(state); |
| 425 | main_window_set_summary_column(); |
| 426 | } |
| 427 | |
| 428 | static void prefs_summary_column_add(void) |
| 429 | {
|
| 430 | GtkCList *stock_clist = GTK_CLIST(summary_col.stock_clist); |
| 431 | GtkCList *shown_clist = GTK_CLIST(summary_col.shown_clist); |
| 432 | gint row; |
| 433 | SummaryColumnType type; |
| 434 | gchar *name; |
| 435 | |
| 436 | if (!stock_clist->selection) return; |
| 437 | |
| 438 | row = GPOINTER_TO_INT(stock_clist->selection->data); |
| 439 | type = GPOINTER_TO_INT(gtk_clist_get_row_data(stock_clist, row)); |
| 440 | gtk_clist_remove(stock_clist, row); |
| 441 | if (stock_clist->rows == row)
|
| 442 | gtk_clist_select_row(stock_clist, row - 1, -1); |
| 443 | |
| 444 | if (!shown_clist->selection)
|
| 445 | row = 0;
|
| 446 | else
|
| 447 | row = GPOINTER_TO_INT(shown_clist->selection->data) + 1;
|
| 448 | |
| 449 | name = gettext(col_name[type]); |
| 450 | row = gtk_clist_insert(shown_clist, row, (gchar **)&name); |
| 451 | gtk_clist_set_row_data(shown_clist, row, GINT_TO_POINTER(type)); |
| 452 | gtk_clist_select_row(shown_clist, row, -1);
|
| 453 | } |
| 454 | |
| 455 | static void prefs_summary_column_remove(void) |
| 456 | {
|
| 457 | GtkCList *stock_clist = GTK_CLIST(summary_col.stock_clist); |
| 458 | GtkCList *shown_clist = GTK_CLIST(summary_col.shown_clist); |
| 459 | gint row; |
| 460 | SummaryColumnType type; |
| 461 | gchar *name; |
| 462 | |
| 463 | if (!shown_clist->selection) return; |
| 464 | |
| 465 | row = GPOINTER_TO_INT(shown_clist->selection->data); |
| 466 | type = GPOINTER_TO_INT(gtk_clist_get_row_data(shown_clist, row)); |
| 467 | gtk_clist_remove(shown_clist, row); |
| 468 | if (shown_clist->rows == row)
|
| 469 | gtk_clist_select_row(shown_clist, row - 1, -1); |
| 470 | |
| 471 | if (!stock_clist->selection)
|
| 472 | row = 0;
|
| 473 | else
|
| 474 | row = GPOINTER_TO_INT(stock_clist->selection->data) + 1;
|
| 475 | |
| 476 | name = gettext(col_name[type]); |
| 477 | row = gtk_clist_insert(stock_clist, row, (gchar **)&name); |
| 478 | gtk_clist_set_row_data(stock_clist, row, GINT_TO_POINTER(type)); |
| 479 | gtk_clist_select_row(stock_clist, row, -1);
|
| 480 | } |
| 481 | |
| 482 | static void prefs_summary_column_up(void) |
| 483 | {
|
| 484 | GtkCList *clist = GTK_CLIST(summary_col.shown_clist); |
| 485 | gint row; |
| 486 | |
| 487 | if (!clist->selection) return; |
| 488 | |
| 489 | row = GPOINTER_TO_INT(clist->selection->data); |
| 490 | if (row > 0) |
| 491 | gtk_clist_row_move(clist, row, row - 1);
|
| 492 | } |
| 493 | |
| 494 | static void prefs_summary_column_down(void) |
| 495 | {
|
| 496 | GtkCList *clist = GTK_CLIST(summary_col.shown_clist); |
| 497 | gint row; |
| 498 | |
| 499 | if (!clist->selection) return; |
| 500 | |
| 501 | row = GPOINTER_TO_INT(clist->selection->data); |
| 502 | if (row >= 0 && row < clist->rows - 1) |
| 503 | gtk_clist_row_move(clist, row, row + 1);
|
| 504 | } |
| 505 | |
| 506 | static void prefs_summary_column_set_to_default(void) |
| 507 | {
|
| 508 | prefs_summary_column_set_dialog(default_state); |
| 509 | } |
| 510 | |
| 511 | static void prefs_summary_column_ok(void) |
| 512 | {
|
| 513 | if (!summary_col.finished) {
|
| 514 | summary_col.finished = TRUE; |
| 515 | prefs_summary_column_set_view(); |
| 516 | } |
| 517 | } |
| 518 | |
| 519 | static void prefs_summary_column_cancel(void) |
| 520 | {
|
| 521 | summary_col.finished = TRUE; |
| 522 | } |
| 523 | |
| 524 | static gint prefs_summary_column_delete_event(GtkWidget *widget,
|
| 525 | GdkEventAny *event, |
| 526 | gpointer data) |
| 527 | {
|
| 528 | summary_col.finished = TRUE; |
| 529 | return TRUE;
|
| 530 | } |
| 531 | |
| 532 | static gboolean prefs_summary_column_key_pressed(GtkWidget *widget,
|
| 533 | GdkEventKey *event, |
| 534 | gpointer data) |
| 535 | {
|
| 536 | if (event && event->keyval == GDK_Escape)
|
| 537 | summary_col.finished = TRUE; |
| 538 | return FALSE;
|
| 539 | } |