2001-10-22 10:42:36 +02:00
|
|
|
/*
|
|
|
|
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
|
2005-01-29 17:53:23 +01:00
|
|
|
* Copyright (C) 1999-2005 Hiroyuki Yamamoto
|
2001-10-22 10:42:36 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "defs.h"
|
|
|
|
|
|
|
|
#include <glib.h>
|
2005-02-10 13:06:07 +01:00
|
|
|
#include <glib/gi18n.h>
|
2001-10-22 10:42:36 +02:00
|
|
|
#include <gtk/gtkmain.h>
|
|
|
|
#include <gtk/gtkwindow.h>
|
|
|
|
#include <gtk/gtkvbox.h>
|
|
|
|
#include <gtk/gtkhbox.h>
|
|
|
|
#include <gtk/gtkbutton.h>
|
|
|
|
#include <gdk/gdkkeysyms.h>
|
|
|
|
|
2002-12-25 14:46:41 +01:00
|
|
|
#include "prefs_gtk.h"
|
2001-10-22 10:42:36 +02:00
|
|
|
#include "prefs_common.h"
|
|
|
|
#include "prefs_summary_column.h"
|
|
|
|
#include "manage_window.h"
|
|
|
|
#include "summaryview.h"
|
|
|
|
#include "mainwindow.h"
|
|
|
|
#include "inc.h"
|
|
|
|
#include "gtkutils.h"
|
|
|
|
#include "utils.h"
|
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
enum {
|
|
|
|
SUMCOL_NAME,
|
|
|
|
SUMCOL_TYPE,
|
|
|
|
N_SUMCOL_COLUMNS
|
|
|
|
};
|
|
|
|
|
|
|
|
#define TARGET_INFO_SUMCOL (0xFEEDBABE)
|
|
|
|
|
|
|
|
static const GtkTargetEntry row_targets[] = {
|
|
|
|
{ "PREFS_SUM_COL_MODEL_ROW", GTK_TARGET_SAME_APP, TARGET_INFO_SUMCOL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-10-22 10:42:36 +02:00
|
|
|
static struct _SummaryColumnDialog
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
GtkWidget *stock_list_view;
|
|
|
|
GtkWidget *shown_list_view;
|
2001-10-22 10:42:36 +02:00
|
|
|
|
|
|
|
GtkWidget *add_btn;
|
|
|
|
GtkWidget *remove_btn;
|
|
|
|
GtkWidget *up_btn;
|
|
|
|
GtkWidget *down_btn;
|
|
|
|
|
|
|
|
GtkWidget *default_btn;
|
|
|
|
|
|
|
|
GtkWidget *ok_btn;
|
|
|
|
GtkWidget *cancel_btn;
|
|
|
|
|
|
|
|
gboolean finished;
|
|
|
|
} summary_col;
|
|
|
|
|
|
|
|
static const gchar *const col_name[N_SUMMARY_COLS] = {
|
|
|
|
N_("Mark"), /* S_COL_MARK */
|
2003-01-26 13:56:56 +01:00
|
|
|
N_("Status"), /* S_COL_STATUS */
|
2001-10-22 10:42:36 +02:00
|
|
|
N_("Attachment"), /* S_COL_MIME */
|
|
|
|
N_("Subject"), /* S_COL_SUBJECT */
|
|
|
|
N_("From"), /* S_COL_FROM */
|
2005-08-05 21:57:42 +02:00
|
|
|
N_("To"), /* S_COL_TO */
|
2001-10-22 10:42:36 +02:00
|
|
|
N_("Date"), /* S_COL_DATE */
|
|
|
|
N_("Size"), /* S_COL_SIZE */
|
|
|
|
N_("Number"), /* S_COL_NUMBER */
|
2001-11-19 21:35:46 +01:00
|
|
|
N_("Score"), /* S_COL_SCORE */
|
|
|
|
N_("Locked"), /* S_COL_LOCKED */
|
2001-10-22 10:42:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static SummaryColumnState default_state[N_SUMMARY_COLS] = {
|
|
|
|
{ S_COL_MARK , TRUE },
|
2003-01-26 13:56:56 +01:00
|
|
|
{ S_COL_STATUS , TRUE },
|
2001-10-22 10:42:36 +02:00
|
|
|
{ S_COL_MIME , TRUE },
|
|
|
|
{ S_COL_SUBJECT, TRUE },
|
|
|
|
{ S_COL_FROM , TRUE },
|
2005-08-05 21:57:42 +02:00
|
|
|
{ S_COL_TO , FALSE },
|
2001-10-22 10:42:36 +02:00
|
|
|
{ S_COL_DATE , TRUE },
|
|
|
|
{ S_COL_SIZE , TRUE },
|
|
|
|
{ S_COL_NUMBER , FALSE },
|
2001-11-19 21:35:46 +01:00
|
|
|
{ S_COL_SCORE , FALSE },
|
2005-08-05 21:57:42 +02:00
|
|
|
{ S_COL_LOCKED , FALSE },
|
2001-10-22 10:42:36 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static void prefs_summary_column_create (void);
|
|
|
|
|
|
|
|
static void prefs_summary_column_set_dialog (SummaryColumnState *state);
|
|
|
|
static void prefs_summary_column_set_view (void);
|
|
|
|
|
|
|
|
/* callback functions */
|
|
|
|
static void prefs_summary_column_add (void);
|
|
|
|
static void prefs_summary_column_remove (void);
|
|
|
|
|
|
|
|
static void prefs_summary_column_up (void);
|
|
|
|
static void prefs_summary_column_down (void);
|
|
|
|
|
|
|
|
static void prefs_summary_column_set_to_default (void);
|
|
|
|
|
|
|
|
static void prefs_summary_column_ok (void);
|
|
|
|
static void prefs_summary_column_cancel (void);
|
|
|
|
|
|
|
|
static gint prefs_summary_column_delete_event (GtkWidget *widget,
|
|
|
|
GdkEventAny *event,
|
|
|
|
gpointer data);
|
2003-10-05 12:10:30 +02:00
|
|
|
static gboolean prefs_summary_column_key_pressed(GtkWidget *widget,
|
2001-10-22 10:42:36 +02:00
|
|
|
GdkEventKey *event,
|
|
|
|
gpointer data);
|
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
static GtkListStore *prefs_summary_column_create_store (void);
|
|
|
|
|
2005-05-31 21:00:21 +02:00
|
|
|
static void prefs_summary_column_insert_column (GtkListStore *store,
|
2004-12-30 15:24:30 +01:00
|
|
|
gint row,
|
|
|
|
const gchar *name,
|
|
|
|
SummaryColumnType type);
|
|
|
|
|
|
|
|
static SummaryColumnType prefs_summary_column_get_column (GtkWidget *list,
|
|
|
|
gint row);
|
|
|
|
|
|
|
|
static GtkWidget *prefs_summary_column_list_view_create (const gchar *name);
|
|
|
|
|
|
|
|
static void prefs_filtering_create_list_view_columns (GtkWidget *list_view,
|
|
|
|
const gchar *name);
|
|
|
|
|
|
|
|
static void drag_data_get (GtkTreeView *tree_view,
|
|
|
|
GdkDragContext *context,
|
|
|
|
GtkSelectionData *data,
|
|
|
|
guint info,
|
|
|
|
guint time,
|
|
|
|
GtkTreeModel *model);
|
|
|
|
|
|
|
|
static void drag_data_received (GtkTreeView *tree_view,
|
|
|
|
GdkDragContext *context,
|
|
|
|
gint x, gint y,
|
|
|
|
GtkSelectionData *data,
|
|
|
|
guint info,
|
|
|
|
guint time,
|
|
|
|
GtkTreeModel *model);
|
|
|
|
|
2001-10-22 10:42:36 +02:00
|
|
|
void prefs_summary_column_open(void)
|
|
|
|
{
|
|
|
|
inc_lock();
|
|
|
|
|
|
|
|
if (!summary_col.window)
|
|
|
|
prefs_summary_column_create();
|
|
|
|
|
|
|
|
manage_window_set_transient(GTK_WINDOW(summary_col.window));
|
|
|
|
gtk_widget_grab_focus(summary_col.ok_btn);
|
|
|
|
|
|
|
|
prefs_summary_column_set_dialog(NULL);
|
|
|
|
|
|
|
|
gtk_widget_show(summary_col.window);
|
|
|
|
|
|
|
|
summary_col.finished = FALSE;
|
|
|
|
while (summary_col.finished == FALSE)
|
|
|
|
gtk_main_iteration();
|
|
|
|
|
|
|
|
gtk_widget_hide(summary_col.window);
|
|
|
|
|
|
|
|
inc_unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_summary_column_create(void)
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
|
|
|
|
GtkWidget *label_hbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
|
|
|
|
GtkWidget *vbox1;
|
|
|
|
|
|
|
|
GtkWidget *hbox1;
|
|
|
|
GtkWidget *clist_hbox;
|
|
|
|
GtkWidget *scrolledwin;
|
2004-12-30 15:24:30 +01:00
|
|
|
GtkWidget *stock_list_view;
|
|
|
|
GtkWidget *shown_list_view;
|
2001-10-22 10:42:36 +02:00
|
|
|
|
|
|
|
GtkWidget *btn_vbox;
|
|
|
|
GtkWidget *btn_vbox1;
|
|
|
|
GtkWidget *add_btn;
|
|
|
|
GtkWidget *remove_btn;
|
|
|
|
GtkWidget *up_btn;
|
|
|
|
GtkWidget *down_btn;
|
|
|
|
|
|
|
|
GtkWidget *btn_hbox;
|
|
|
|
GtkWidget *default_btn;
|
|
|
|
GtkWidget *confirm_area;
|
|
|
|
GtkWidget *ok_btn;
|
|
|
|
GtkWidget *cancel_btn;
|
|
|
|
|
2002-08-15 09:38:17 +02:00
|
|
|
debug_print("Creating summary column setting window...\n");
|
2001-10-22 10:42:36 +02:00
|
|
|
|
2003-10-05 12:10:30 +02:00
|
|
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
2001-10-22 10:42:36 +02:00
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(window), 8);
|
2003-10-05 12:10:30 +02:00
|
|
|
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
|
2001-10-22 10:42:36 +02:00
|
|
|
gtk_window_set_modal(GTK_WINDOW(window), TRUE);
|
2004-07-28 09:51:10 +02:00
|
|
|
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
|
2001-10-22 10:42:36 +02:00
|
|
|
gtk_window_set_title(GTK_WINDOW(window),
|
2002-11-28 18:23:30 +01:00
|
|
|
_("Displayed items configuration"));
|
2003-10-05 12:10:30 +02:00
|
|
|
g_signal_connect(G_OBJECT(window), "delete_event",
|
|
|
|
G_CALLBACK(prefs_summary_column_delete_event),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect(G_OBJECT(window), "key_press_event",
|
|
|
|
G_CALLBACK(prefs_summary_column_key_pressed),
|
|
|
|
NULL);
|
2001-10-22 10:42:36 +02:00
|
|
|
|
|
|
|
vbox = gtk_vbox_new(FALSE, 6);
|
|
|
|
gtk_widget_show(vbox);
|
|
|
|
gtk_container_add(GTK_CONTAINER(window), vbox);
|
|
|
|
|
|
|
|
label_hbox = gtk_hbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(label_hbox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), label_hbox, FALSE, FALSE, 4);
|
|
|
|
|
|
|
|
label = gtk_label_new
|
2002-11-27 18:41:38 +01:00
|
|
|
(_("Select items to be displayed in the summary view. You can modify\n"
|
2002-11-28 18:23:30 +01:00
|
|
|
"the order by using the Up / Down buttons or by dragging the items."));
|
2001-10-22 10:42:36 +02:00
|
|
|
gtk_widget_show(label);
|
|
|
|
gtk_box_pack_start(GTK_BOX(label_hbox), label, FALSE, FALSE, 4);
|
|
|
|
gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
|
|
|
|
|
|
|
|
vbox1 = gtk_vbox_new(FALSE, VSPACING);
|
|
|
|
gtk_widget_show(vbox1);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox), vbox1, TRUE, TRUE, 0);
|
|
|
|
gtk_container_set_border_width(GTK_CONTAINER(vbox1), 2);
|
|
|
|
|
|
|
|
hbox1 = gtk_hbox_new(FALSE, 8);
|
|
|
|
gtk_widget_show(hbox1);
|
|
|
|
gtk_box_pack_start(GTK_BOX(vbox1), hbox1, FALSE, TRUE, 0);
|
|
|
|
|
|
|
|
clist_hbox = gtk_hbox_new(FALSE, 8);
|
|
|
|
gtk_widget_show(clist_hbox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox1), clist_hbox, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
scrolledwin = gtk_scrolled_window_new(NULL, NULL);
|
2003-10-05 12:10:30 +02:00
|
|
|
gtk_widget_set_size_request(scrolledwin, 180, 210);
|
2001-10-22 10:42:36 +02:00
|
|
|
gtk_widget_show(scrolledwin);
|
|
|
|
gtk_box_pack_start(GTK_BOX(clist_hbox), scrolledwin, TRUE, TRUE, 0);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
|
|
|
|
stock_list_view = prefs_summary_column_list_view_create
|
|
|
|
(_("Available items"));
|
|
|
|
gtk_widget_show(stock_list_view);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrolledwin), stock_list_view);
|
2001-10-22 10:42:36 +02:00
|
|
|
|
|
|
|
/* add/remove button */
|
|
|
|
btn_vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(btn_vbox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox1), btn_vbox, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
btn_vbox1 = gtk_vbox_new(FALSE, 8);
|
|
|
|
gtk_widget_show(btn_vbox1);
|
|
|
|
gtk_box_pack_start(GTK_BOX(btn_vbox), btn_vbox1, TRUE, FALSE, 0);
|
|
|
|
|
|
|
|
add_btn = gtk_button_new_with_label(_(" -> "));
|
|
|
|
gtk_widget_show(add_btn);
|
|
|
|
gtk_box_pack_start(GTK_BOX(btn_vbox1), add_btn, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
remove_btn = gtk_button_new_with_label(_(" <- "));
|
|
|
|
gtk_widget_show(remove_btn);
|
|
|
|
gtk_box_pack_start(GTK_BOX(btn_vbox1), remove_btn, FALSE, FALSE, 0);
|
|
|
|
|
2003-10-05 12:10:30 +02:00
|
|
|
g_signal_connect(G_OBJECT(add_btn), "clicked",
|
|
|
|
G_CALLBACK(prefs_summary_column_add), NULL);
|
|
|
|
g_signal_connect(G_OBJECT(remove_btn), "clicked",
|
|
|
|
G_CALLBACK(prefs_summary_column_remove), NULL);
|
2001-10-22 10:42:36 +02:00
|
|
|
|
|
|
|
clist_hbox = gtk_hbox_new(FALSE, 8);
|
|
|
|
gtk_widget_show(clist_hbox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox1), clist_hbox, TRUE, TRUE, 0);
|
|
|
|
|
|
|
|
scrolledwin = gtk_scrolled_window_new(NULL, NULL);
|
2003-10-05 12:10:30 +02:00
|
|
|
gtk_widget_set_size_request(scrolledwin, 180, 210);
|
2001-10-22 10:42:36 +02:00
|
|
|
gtk_widget_show(scrolledwin);
|
|
|
|
gtk_box_pack_start(GTK_BOX(clist_hbox), scrolledwin, TRUE, TRUE, 0);
|
|
|
|
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwin),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
shown_list_view = prefs_summary_column_list_view_create
|
|
|
|
(_("Displayed items"));
|
|
|
|
gtk_widget_show(shown_list_view);
|
|
|
|
gtk_container_add(GTK_CONTAINER(scrolledwin), shown_list_view);
|
2001-10-22 10:42:36 +02:00
|
|
|
|
|
|
|
/* up/down button */
|
|
|
|
btn_vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(btn_vbox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(hbox1), btn_vbox, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
btn_vbox1 = gtk_vbox_new(FALSE, 8);
|
|
|
|
gtk_widget_show(btn_vbox1);
|
|
|
|
gtk_box_pack_start(GTK_BOX(btn_vbox), btn_vbox1, TRUE, FALSE, 0);
|
|
|
|
|
2004-12-30 16:28:43 +01:00
|
|
|
up_btn = gtk_button_new_from_stock(GTK_STOCK_GO_UP);
|
2001-10-22 10:42:36 +02:00
|
|
|
gtk_widget_show(up_btn);
|
|
|
|
gtk_box_pack_start(GTK_BOX(btn_vbox1), up_btn, FALSE, FALSE, 0);
|
|
|
|
|
2004-12-30 16:28:43 +01:00
|
|
|
down_btn = gtk_button_new_from_stock(GTK_STOCK_GO_DOWN);
|
2001-10-22 10:42:36 +02:00
|
|
|
gtk_widget_show(down_btn);
|
|
|
|
gtk_box_pack_start(GTK_BOX(btn_vbox1), down_btn, FALSE, FALSE, 0);
|
|
|
|
|
2003-10-05 12:10:30 +02:00
|
|
|
g_signal_connect(G_OBJECT(up_btn), "clicked",
|
|
|
|
G_CALLBACK(prefs_summary_column_up), NULL);
|
|
|
|
g_signal_connect(G_OBJECT(down_btn), "clicked",
|
|
|
|
G_CALLBACK(prefs_summary_column_down), NULL);
|
2001-10-22 10:42:36 +02:00
|
|
|
|
|
|
|
btn_hbox = gtk_hbox_new(FALSE, 8);
|
|
|
|
gtk_widget_show(btn_hbox);
|
|
|
|
gtk_box_pack_end(GTK_BOX(vbox), btn_hbox, FALSE, FALSE, 0);
|
|
|
|
|
|
|
|
btn_vbox = gtk_vbox_new(FALSE, 0);
|
|
|
|
gtk_widget_show(btn_vbox);
|
|
|
|
gtk_box_pack_start(GTK_BOX(btn_hbox), btn_vbox, FALSE, FALSE, 0);
|
|
|
|
|
2002-11-28 18:23:30 +01:00
|
|
|
default_btn = gtk_button_new_with_label(_(" Use default "));
|
2001-10-22 10:42:36 +02:00
|
|
|
gtk_widget_show(default_btn);
|
|
|
|
gtk_box_pack_start(GTK_BOX(btn_vbox), default_btn, TRUE, FALSE, 0);
|
2003-10-05 12:10:30 +02:00
|
|
|
g_signal_connect(G_OBJECT(default_btn), "clicked",
|
|
|
|
G_CALLBACK(prefs_summary_column_set_to_default),
|
|
|
|
NULL);
|
2001-10-22 10:42:36 +02:00
|
|
|
|
2005-01-29 17:53:23 +01:00
|
|
|
gtkut_stock_button_set_create(&confirm_area, &ok_btn, GTK_STOCK_OK,
|
|
|
|
&cancel_btn, GTK_STOCK_CANCEL,
|
|
|
|
NULL, NULL);
|
2001-10-22 10:42:36 +02:00
|
|
|
gtk_widget_show(confirm_area);
|
|
|
|
gtk_box_pack_end(GTK_BOX(btn_hbox), confirm_area, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_grab_default(ok_btn);
|
|
|
|
|
2003-10-05 12:10:30 +02:00
|
|
|
g_signal_connect(G_OBJECT(ok_btn), "clicked",
|
|
|
|
G_CALLBACK(prefs_summary_column_ok), NULL);
|
|
|
|
g_signal_connect(G_OBJECT(cancel_btn), "clicked",
|
|
|
|
G_CALLBACK(prefs_summary_column_cancel), NULL);
|
2001-10-22 10:42:36 +02:00
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
|
2001-10-22 10:42:36 +02:00
|
|
|
summary_col.window = window;
|
|
|
|
summary_col.add_btn = add_btn;
|
|
|
|
summary_col.remove_btn = remove_btn;
|
|
|
|
summary_col.up_btn = up_btn;
|
|
|
|
summary_col.down_btn = down_btn;
|
|
|
|
summary_col.ok_btn = ok_btn;
|
|
|
|
summary_col.cancel_btn = cancel_btn;
|
2004-12-30 15:24:30 +01:00
|
|
|
summary_col.stock_list_view = stock_list_view;
|
|
|
|
summary_col.shown_list_view = shown_list_view;
|
2001-10-22 10:42:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
SummaryColumnState *prefs_summary_column_get_config(void)
|
|
|
|
{
|
|
|
|
static SummaryColumnState state[N_SUMMARY_COLS];
|
|
|
|
SummaryColumnType type;
|
|
|
|
gint pos;
|
|
|
|
|
|
|
|
for (pos = 0; pos < N_SUMMARY_COLS; pos++)
|
|
|
|
state[pos].type = -1;
|
|
|
|
|
|
|
|
for (type = 0; type < N_SUMMARY_COLS; type++) {
|
|
|
|
pos = prefs_common.summary_col_pos[type];
|
|
|
|
if (pos < 0 || pos >= N_SUMMARY_COLS ||
|
|
|
|
state[pos].type != -1) {
|
|
|
|
g_warning("Wrong column position\n");
|
|
|
|
prefs_summary_column_set_config(default_state);
|
|
|
|
return default_state;
|
|
|
|
}
|
|
|
|
|
|
|
|
state[pos].type = type;
|
|
|
|
state[pos].visible = prefs_common.summary_col_visible[type];
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
|
|
|
void prefs_summary_column_set_config(SummaryColumnState *state)
|
|
|
|
{
|
|
|
|
SummaryColumnType type;
|
|
|
|
gint pos;
|
|
|
|
|
|
|
|
for (pos = 0; pos < N_SUMMARY_COLS; pos++) {
|
|
|
|
type = state[pos].type;
|
|
|
|
prefs_common.summary_col_visible[type] = state[pos].visible;
|
|
|
|
prefs_common.summary_col_pos[type] = pos;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_summary_column_set_dialog(SummaryColumnState *state)
|
|
|
|
{
|
2004-12-30 15:24:30 +01:00
|
|
|
GtkListStore *stock_store, *shown_store;
|
2001-10-22 10:42:36 +02:00
|
|
|
gint pos;
|
|
|
|
SummaryColumnType type;
|
|
|
|
gchar *name;
|
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
stock_store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(GTK_TREE_VIEW(summary_col.stock_list_view)));
|
|
|
|
shown_store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(GTK_TREE_VIEW(summary_col.shown_list_view)));
|
|
|
|
|
|
|
|
gtk_list_store_clear(stock_store);
|
|
|
|
gtk_list_store_clear(shown_store);
|
2001-10-22 10:42:36 +02:00
|
|
|
|
|
|
|
if (!state)
|
|
|
|
state = prefs_summary_column_get_config();
|
|
|
|
|
|
|
|
for (pos = 0; pos < N_SUMMARY_COLS; pos++) {
|
|
|
|
type = state[pos].type;
|
|
|
|
name = gettext(col_name[type]);
|
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
if (state[pos].visible)
|
|
|
|
prefs_summary_column_insert_column(shown_store,
|
|
|
|
-1, name,
|
|
|
|
type);
|
|
|
|
else
|
|
|
|
prefs_summary_column_insert_column(stock_store,
|
|
|
|
-1, name,
|
|
|
|
type);
|
2001-10-22 10:42:36 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_summary_column_set_view(void)
|
|
|
|
{
|
2004-12-30 15:24:30 +01:00
|
|
|
gint stock_n_rows, shown_n_rows;
|
2001-10-22 10:42:36 +02:00
|
|
|
SummaryColumnState state[N_SUMMARY_COLS];
|
|
|
|
SummaryColumnType type;
|
|
|
|
gint row, pos = 0;
|
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
stock_n_rows = gtk_tree_model_iter_n_children
|
|
|
|
(gtk_tree_view_get_model(GTK_TREE_VIEW
|
|
|
|
(summary_col.stock_list_view)), NULL);
|
|
|
|
shown_n_rows = gtk_tree_model_iter_n_children
|
|
|
|
(gtk_tree_view_get_model(GTK_TREE_VIEW
|
|
|
|
(summary_col.shown_list_view)), NULL);
|
|
|
|
|
2001-10-22 10:42:36 +02:00
|
|
|
g_return_if_fail
|
2004-12-30 15:24:30 +01:00
|
|
|
(stock_n_rows + shown_n_rows == N_SUMMARY_COLS);
|
2001-10-22 10:42:36 +02:00
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
for (row = 0; row < stock_n_rows; row++) {
|
|
|
|
type = prefs_summary_column_get_column
|
|
|
|
(summary_col.stock_list_view, row);
|
2001-10-22 10:42:36 +02:00
|
|
|
state[row].type = type;
|
|
|
|
state[row].visible = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
pos = row;
|
2004-12-30 15:24:30 +01:00
|
|
|
for (row = 0; row < shown_n_rows; row++) {
|
|
|
|
type = prefs_summary_column_get_column
|
|
|
|
(summary_col.shown_list_view, row);
|
2001-10-22 10:42:36 +02:00
|
|
|
state[pos + row].type = type;
|
|
|
|
state[pos + row].visible = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
prefs_summary_column_set_config(state);
|
|
|
|
main_window_set_summary_column();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_summary_column_add(void)
|
|
|
|
{
|
2004-12-30 15:24:30 +01:00
|
|
|
GtkListStore *stock_store, *shown_store;
|
|
|
|
GtkTreeIter stock_sel, shown_sel, shown_add;
|
|
|
|
gboolean shown_sel_valid;
|
2001-10-22 10:42:36 +02:00
|
|
|
gchar *name;
|
2004-12-30 15:24:30 +01:00
|
|
|
SummaryColumnType type;
|
|
|
|
|
|
|
|
stock_store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(GTK_TREE_VIEW(summary_col.stock_list_view)));
|
|
|
|
shown_store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(GTK_TREE_VIEW(summary_col.shown_list_view)));
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_get_selected
|
|
|
|
(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(summary_col.stock_list_view)),
|
|
|
|
NULL,
|
|
|
|
&stock_sel))
|
|
|
|
return;
|
|
|
|
|
|
|
|
shown_sel_valid = gtk_tree_selection_get_selected
|
|
|
|
(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(summary_col.shown_list_view)),
|
|
|
|
NULL,
|
|
|
|
&shown_sel);
|
|
|
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(stock_store), &stock_sel,
|
|
|
|
SUMCOL_TYPE, &type,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
gtk_list_store_remove(stock_store, &stock_sel);
|
|
|
|
|
|
|
|
gtk_list_store_insert_after(shown_store, &shown_add,
|
|
|
|
shown_sel_valid ? &shown_sel : NULL);
|
|
|
|
|
|
|
|
name = gettext(col_name[type]);
|
|
|
|
|
|
|
|
gtk_list_store_set(shown_store, &shown_add,
|
|
|
|
SUMCOL_NAME, name,
|
|
|
|
SUMCOL_TYPE, type,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
gtk_tree_selection_select_iter(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(summary_col.shown_list_view)),
|
|
|
|
&shown_add);
|
2001-10-22 10:42:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_summary_column_remove(void)
|
|
|
|
{
|
2004-12-30 15:24:30 +01:00
|
|
|
GtkListStore *stock_store, *shown_store;
|
|
|
|
GtkTreeIter shown_sel, stock_sel, stock_add;
|
|
|
|
gboolean stock_sel_valid;
|
2001-10-22 10:42:36 +02:00
|
|
|
gchar *name;
|
2004-12-30 15:24:30 +01:00
|
|
|
SummaryColumnType type;
|
|
|
|
|
|
|
|
stock_store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(GTK_TREE_VIEW(summary_col.stock_list_view)));
|
|
|
|
shown_store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(GTK_TREE_VIEW(summary_col.shown_list_view)));
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_get_selected
|
|
|
|
(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(summary_col.shown_list_view)),
|
|
|
|
NULL,
|
|
|
|
&shown_sel))
|
|
|
|
return;
|
|
|
|
|
|
|
|
stock_sel_valid = gtk_tree_selection_get_selected
|
|
|
|
(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(summary_col.stock_list_view)),
|
|
|
|
NULL,
|
|
|
|
&stock_sel);
|
|
|
|
|
|
|
|
gtk_tree_model_get(GTK_TREE_MODEL(shown_store), &shown_sel,
|
|
|
|
SUMCOL_TYPE, &type,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
gtk_list_store_remove(shown_store, &shown_sel);
|
|
|
|
|
|
|
|
gtk_list_store_insert_after(stock_store, &stock_add,
|
|
|
|
stock_sel_valid ? &stock_sel : NULL);
|
|
|
|
|
|
|
|
name = gettext(col_name[type]);
|
|
|
|
|
|
|
|
gtk_list_store_set(stock_store, &stock_add,
|
|
|
|
SUMCOL_NAME, name,
|
|
|
|
SUMCOL_TYPE, type,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
gtk_tree_selection_select_iter(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(summary_col.stock_list_view)),
|
|
|
|
&stock_add);
|
2001-10-22 10:42:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_summary_column_up(void)
|
|
|
|
{
|
2004-12-30 15:24:30 +01:00
|
|
|
GtkTreePath *prev, *sel;
|
|
|
|
GtkTreeIter isel;
|
|
|
|
GtkListStore *shown_store;
|
|
|
|
GtkTreeIter iprev;
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_get_selected
|
|
|
|
(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(summary_col.shown_list_view)),
|
|
|
|
NULL,
|
|
|
|
&isel))
|
|
|
|
return;
|
|
|
|
|
|
|
|
shown_store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(GTK_TREE_VIEW(summary_col.shown_list_view)));
|
|
|
|
|
|
|
|
sel = gtk_tree_model_get_path(GTK_TREE_MODEL(shown_store),
|
|
|
|
&isel);
|
|
|
|
if (!sel)
|
|
|
|
return;
|
|
|
|
|
|
|
|
prev = gtk_tree_path_copy(sel);
|
|
|
|
if (!gtk_tree_path_prev(prev)) {
|
|
|
|
gtk_tree_path_free(prev);
|
|
|
|
gtk_tree_path_free(sel);
|
|
|
|
return;
|
|
|
|
}
|
2001-10-22 10:42:36 +02:00
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
gtk_tree_model_get_iter(GTK_TREE_MODEL(shown_store),
|
|
|
|
&iprev, prev);
|
|
|
|
gtk_tree_path_free(sel);
|
|
|
|
gtk_tree_path_free(prev);
|
2001-10-22 10:42:36 +02:00
|
|
|
|
2004-12-30 15:24:30 +01:00
|
|
|
gtk_list_store_swap(shown_store, &iprev, &isel);
|
2001-10-22 10:42:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_summary_column_down(void)
|
|
|
|
{
|
2004-12-30 15:24:30 +01:00
|
|
|
GtkListStore *shown_store;
|
|
|
|
GtkTreeIter next, sel;
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_get_selected
|
|
|
|
(gtk_tree_view_get_selection
|
|
|
|
(GTK_TREE_VIEW(summary_col.shown_list_view)),
|
|
|
|
NULL,
|
|
|
|
&sel))
|
|
|
|
return;
|
|
|
|
|
|
|
|
shown_store = GTK_LIST_STORE(gtk_tree_view_get_model
|
|
|
|
(GTK_TREE_VIEW(summary_col.shown_list_view)));
|
|
|
|
|
|
|
|
next = sel;
|
|
|
|
if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(shown_store), &next))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_list_store_swap(shown_store, &next, &sel);
|
2001-10-22 10:42:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_summary_column_set_to_default(void)
|
|
|
|
{
|
|
|
|
prefs_summary_column_set_dialog(default_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_summary_column_ok(void)
|
|
|
|
{
|
|
|
|
if (!summary_col.finished) {
|
|
|
|
summary_col.finished = TRUE;
|
|
|
|
prefs_summary_column_set_view();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_summary_column_cancel(void)
|
|
|
|
{
|
|
|
|
summary_col.finished = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gint prefs_summary_column_delete_event(GtkWidget *widget,
|
|
|
|
GdkEventAny *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
summary_col.finished = TRUE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2003-10-05 12:10:30 +02:00
|
|
|
static gboolean prefs_summary_column_key_pressed(GtkWidget *widget,
|
|
|
|
GdkEventKey *event,
|
|
|
|
gpointer data)
|
2001-10-22 10:42:36 +02:00
|
|
|
{
|
|
|
|
if (event && event->keyval == GDK_Escape)
|
|
|
|
summary_col.finished = TRUE;
|
2003-10-05 12:10:30 +02:00
|
|
|
return FALSE;
|
2001-10-22 10:42:36 +02:00
|
|
|
}
|
2004-12-30 15:24:30 +01:00
|
|
|
|
|
|
|
static GtkListStore *prefs_summary_column_create_store(void)
|
|
|
|
{
|
|
|
|
return gtk_list_store_new(N_SUMCOL_COLUMNS,
|
|
|
|
G_TYPE_STRING,
|
|
|
|
G_TYPE_INT,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
|
2005-05-31 21:00:21 +02:00
|
|
|
static void prefs_summary_column_insert_column(GtkListStore *store,
|
2004-12-30 15:24:30 +01:00
|
|
|
gint row,
|
|
|
|
const gchar *name,
|
|
|
|
SummaryColumnType type)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
|
|
|
|
if (row >= 0) {
|
|
|
|
if (!gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store),
|
|
|
|
&iter, NULL, row))
|
|
|
|
row = -1;
|
|
|
|
}
|
|
|
|
if (row < 0) {
|
|
|
|
/* add new */
|
|
|
|
gtk_list_store_append(store, &iter);
|
|
|
|
gtk_list_store_set(store, &iter,
|
|
|
|
SUMCOL_NAME, name,
|
|
|
|
SUMCOL_TYPE, type,
|
|
|
|
-1);
|
2005-05-31 21:00:21 +02:00
|
|
|
return;
|
2004-12-30 15:24:30 +01:00
|
|
|
} else {
|
|
|
|
/* change existing */
|
|
|
|
gtk_list_store_set(store, &iter,
|
|
|
|
SUMCOL_NAME, name,
|
|
|
|
SUMCOL_TYPE, type,
|
|
|
|
-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
*\brief Return the columnn type for a row
|
|
|
|
*/
|
|
|
|
static SummaryColumnType prefs_summary_column_get_column(GtkWidget *list, gint row)
|
|
|
|
{
|
|
|
|
GtkTreeView *list_view = GTK_TREE_VIEW(list);
|
|
|
|
GtkTreeModel *model = gtk_tree_view_get_model(list_view);
|
|
|
|
GtkTreeIter iter;
|
|
|
|
SummaryColumnType result;
|
|
|
|
|
|
|
|
if (!gtk_tree_model_iter_nth_child(model, &iter, NULL, row))
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
gtk_tree_model_get(model, &iter,
|
|
|
|
SUMCOL_TYPE, &result,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GtkWidget *prefs_summary_column_list_view_create(const gchar *name)
|
|
|
|
{
|
|
|
|
GtkWidget *list_view;
|
|
|
|
GtkTreeSelection *selector;
|
|
|
|
GtkTreeModel *model;
|
|
|
|
|
|
|
|
model = GTK_TREE_MODEL(prefs_summary_column_create_store());
|
|
|
|
list_view = gtk_tree_view_new_with_model(model);
|
|
|
|
g_object_unref(G_OBJECT(model));
|
|
|
|
|
2005-05-31 09:04:59 +02:00
|
|
|
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(list_view),
|
|
|
|
prefs_common.enable_rules_hint);
|
2004-12-30 15:24:30 +01:00
|
|
|
|
|
|
|
selector = gtk_tree_view_get_selection(GTK_TREE_VIEW(list_view));
|
|
|
|
gtk_tree_selection_set_mode(selector, GTK_SELECTION_BROWSE);
|
|
|
|
|
|
|
|
prefs_filtering_create_list_view_columns(GTK_WIDGET(list_view), name);
|
|
|
|
|
|
|
|
gtk_tree_view_enable_model_drag_source(GTK_TREE_VIEW(list_view),
|
|
|
|
GDK_BUTTON1_MASK,
|
|
|
|
row_targets,
|
|
|
|
G_N_ELEMENTS(row_targets),
|
|
|
|
GDK_ACTION_MOVE);
|
|
|
|
|
|
|
|
gtk_tree_view_enable_model_drag_dest(GTK_TREE_VIEW(list_view),
|
|
|
|
row_targets,
|
|
|
|
G_N_ELEMENTS(row_targets),
|
|
|
|
GDK_ACTION_MOVE);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(list_view), "drag_data_get",
|
|
|
|
G_CALLBACK(drag_data_get),
|
|
|
|
model);
|
|
|
|
|
|
|
|
g_signal_connect(G_OBJECT(list_view), "drag_data_received",
|
|
|
|
G_CALLBACK(drag_data_received),
|
|
|
|
model);
|
|
|
|
|
|
|
|
return list_view;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void prefs_filtering_create_list_view_columns(GtkWidget *list_view,
|
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GtkTreeViewColumn *column;
|
|
|
|
GtkCellRenderer *renderer;
|
|
|
|
|
|
|
|
renderer = gtk_cell_renderer_text_new();
|
|
|
|
column = gtk_tree_view_column_new_with_attributes
|
|
|
|
(name, renderer, "text", SUMCOL_NAME, NULL);
|
|
|
|
gtk_tree_view_append_column(GTK_TREE_VIEW(list_view), column);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drag_data_get(GtkTreeView *tree_view, GdkDragContext *context,
|
|
|
|
GtkSelectionData *data, guint info,
|
|
|
|
guint time, GtkTreeModel *model)
|
|
|
|
{
|
|
|
|
GtkTreeIter iter;
|
|
|
|
SummaryColumnType type;
|
|
|
|
GtkTreeModel *source_model;
|
|
|
|
|
|
|
|
if (info != TARGET_INFO_SUMCOL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (!gtk_tree_selection_get_selected
|
|
|
|
(gtk_tree_view_get_selection(tree_view),
|
|
|
|
&source_model, &iter))
|
|
|
|
return;
|
|
|
|
|
|
|
|
gtk_tree_model_get(source_model, &iter,
|
|
|
|
SUMCOL_TYPE, &type,
|
|
|
|
-1);
|
|
|
|
|
|
|
|
/* send the type */
|
|
|
|
gtk_selection_data_set(data, data->target, 8, (gchar *) &type, sizeof type);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drag_data_received(GtkTreeView *tree_view, GdkDragContext *context,
|
|
|
|
gint x, gint y, GtkSelectionData *data,
|
|
|
|
guint info, guint time, GtkTreeModel *model)
|
|
|
|
{
|
|
|
|
GtkWidget *source;
|
|
|
|
GtkTreePath *dst = NULL, *sel = NULL;
|
|
|
|
GtkTreeIter isel, idst;
|
|
|
|
GtkTreeViewDropPosition pos;
|
|
|
|
SummaryColumnType type;
|
|
|
|
GtkTreeModel *sel_model;
|
|
|
|
gchar *name;
|
|
|
|
|
|
|
|
source = gtk_drag_get_source_widget(context);
|
|
|
|
|
|
|
|
if (source == GTK_WIDGET(tree_view)) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Same widget: re-order
|
|
|
|
*/
|
|
|
|
|
|
|
|
gtk_tree_selection_get_selected(gtk_tree_view_get_selection(tree_view),
|
|
|
|
NULL, &isel);
|
|
|
|
sel = gtk_tree_model_get_path(model, &isel);
|
|
|
|
gtk_tree_view_get_dest_row_at_pos(tree_view, x, y,
|
|
|
|
&dst, &pos);
|
|
|
|
|
|
|
|
/* NOTE: dst is invalid if selection beyond last row, in that
|
|
|
|
* case move beyond last one (XXX_move_before(..., NULL)) */
|
|
|
|
|
|
|
|
if (dst)
|
|
|
|
gtk_tree_model_get_iter(model, &idst, dst);
|
|
|
|
else
|
|
|
|
gtk_list_store_move_before(GTK_LIST_STORE(model),
|
|
|
|
&isel,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
/* we do not drag if no valid dst and sel, and when
|
|
|
|
* dst and sel are the same (moving after or before
|
|
|
|
* itself doesn't change order...) */
|
|
|
|
if ((dst && sel) && gtk_tree_path_compare(sel, dst) != 0) {
|
|
|
|
if (pos == GTK_TREE_VIEW_DROP_BEFORE
|
|
|
|
|| pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE)
|
|
|
|
gtk_list_store_move_before(GTK_LIST_STORE(model),
|
|
|
|
&isel,
|
|
|
|
&idst);
|
|
|
|
else
|
|
|
|
gtk_list_store_move_after(GTK_LIST_STORE(model),
|
|
|
|
&isel,
|
|
|
|
&idst);
|
|
|
|
|
|
|
|
}
|
|
|
|
gtk_tree_path_free(dst);
|
|
|
|
gtk_tree_path_free(sel);
|
|
|
|
gtk_drag_finish(context, TRUE, FALSE, time);
|
|
|
|
|
|
|
|
} else if (source == summary_col.stock_list_view
|
|
|
|
|| source == summary_col.shown_list_view) {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Other widget: change and update
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* get source information and remove */
|
|
|
|
gtk_tree_selection_get_selected(gtk_tree_view_get_selection(
|
|
|
|
GTK_TREE_VIEW(source)),
|
|
|
|
&sel_model, &isel);
|
|
|
|
type = *((gint *) data->data);
|
|
|
|
name = gettext(col_name[type]);
|
|
|
|
gtk_list_store_remove(GTK_LIST_STORE(sel_model), &isel);
|
|
|
|
|
|
|
|
/* get insertion position */
|
|
|
|
gtk_tree_view_get_dest_row_at_pos(tree_view, x, y, &dst, &pos);
|
|
|
|
|
|
|
|
/* NOTE: dst is invalid if insertion point beyond last row,
|
|
|
|
* just append to list in that case (XXX_store_append()) */
|
|
|
|
|
|
|
|
if (dst) {
|
|
|
|
gtk_tree_model_get_iter(model, &idst, dst);
|
|
|
|
|
|
|
|
if (pos == GTK_TREE_VIEW_DROP_BEFORE
|
|
|
|
|| pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE)
|
|
|
|
gtk_list_store_insert_before(GTK_LIST_STORE(model),
|
|
|
|
&isel,
|
|
|
|
&idst);
|
|
|
|
else
|
|
|
|
gtk_list_store_insert_after(GTK_LIST_STORE(model),
|
|
|
|
&isel,
|
|
|
|
&idst);
|
|
|
|
} else
|
|
|
|
gtk_list_store_append(GTK_LIST_STORE(model),
|
|
|
|
&isel);
|
|
|
|
|
|
|
|
gtk_list_store_set(GTK_LIST_STORE(model), &isel,
|
|
|
|
SUMCOL_NAME, name,
|
|
|
|
SUMCOL_TYPE, type, -1);
|
|
|
|
gtk_tree_path_free(dst);
|
|
|
|
gtk_drag_finish(context, TRUE, FALSE, time);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* XXXX: should we call gtk_drag_finish() for other code paths? */
|
|
|
|
}
|
|
|
|
|