2 * Copyright (C) 2012-2013 jeanfi@gmail.com
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 #include <ui_newtask_diag.h>
24 static GtkTreeView *w_treeview;
26 int newtask_clicked_cbk(GtkButton *btn, gpointer data)
33 static void save_settings(GtkWindow *window, GSettings *settings)
35 int w, h, x, y, sort_col_id;
37 GtkSortType sort_order;
39 model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
40 gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(model),
43 log_debug("save_settings(): sort_col_id=%d", sort_col_id);
44 log_debug("save_settings(): sort_col_order=%d", sort_order);
46 g_settings_set_int(settings, "tasks-sort-col", sort_col_id);
47 g_settings_set_int(settings, "tasks-sort-order", sort_order);
49 gtk_window_get_size(window, &w, &h);
50 gtk_window_get_position(window, &x, &y);
52 log_debug("save_settings(): x=%d, y=%d, w=%d, h=%d", x, y, w, h);
54 g_settings_set_int(settings, "window-width", w);
55 g_settings_set_int(settings, "window-height", h);
56 g_settings_set_int(settings, "window-x", x);
57 g_settings_set_int(settings, "window-y", y);
62 static gboolean delete_event_cbk(GtkWidget *w, GdkEvent *evt, gpointer data)
64 log_debug("delete_event_cbk");
66 save_settings(GTK_WINDOW(w), (GSettings *)data);
67 gtk_widget_destroy(w);
73 GtkWindow *create_window(GtkBuilder *builder, GSettings *settings)
76 int x, y, h, w, sort_col_id;
77 GtkSortType sort_order;
80 window = GTK_WINDOW(gtk_builder_get_object(builder, "window"));
82 w = g_settings_get_int(settings, "window-width");
83 h = g_settings_get_int(settings, "window-height");
84 gtk_window_set_default_size(window, w, h);
86 x = g_settings_get_int(settings, "window-x");
87 y = g_settings_get_int(settings, "window-y");
88 gtk_window_move(window, x, y);
90 g_signal_connect(window, "delete_event",
91 G_CALLBACK(delete_event_cbk), settings);
93 w_treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
95 sort_col_id = g_settings_get_int(settings, "tasks-sort-col");
96 sort_order = g_settings_get_int(settings, "tasks-sort-order");
97 model = gtk_tree_view_get_model(GTK_TREE_VIEW(w_treeview));
98 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model),
99 sort_col_id, sort_order);