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
21 #include <glib/gi18n.h>
25 #include <ui_newtask_diag.h>
26 #include <ui_projecttree.h>
27 #include <ui_taskpanel.h>
28 #include <ui_tasktree.h>
30 static GtkComboBox *w_status;
31 static GSettings *gsettings;
32 static GtkWindow *window;
33 static GtkPaned *vpaned;
34 static GtkPaned *hpaned;
36 int newtask_clicked_cbk(GtkButton *btn, gpointer data)
43 static void save_settings(GtkWindow *window, GSettings *settings)
47 gtk_window_get_size(window, &w, &h);
48 gtk_window_get_position(window, &x, &y);
50 log_fct("x=%d, y=%d, w=%d, h=%d", x, y, w, h);
52 g_settings_set_int(settings, "window-width", w);
53 g_settings_set_int(settings, "window-height", h);
54 g_settings_set_int(settings, "window-x", x);
55 g_settings_set_int(settings, "window-y", y);
57 pos = gtk_paned_get_position(vpaned);
58 g_settings_set_int(settings, "spliter-vertical-pos", pos);
60 pos = gtk_paned_get_position(hpaned);
61 g_settings_set_int(settings, "spliter-horizontal-pos", pos);
63 ui_tasktree_save_settings(settings);
68 int refresh_clicked_cbk(GtkButton *btn, gpointer data)
79 save_settings(window, gsettings);
80 gtk_widget_destroy(GTK_WIDGET(window));
84 static gboolean delete_event_cbk(GtkWidget *w, GdkEvent *evt, gpointer data)
95 static int status_changed_cbk(GtkComboBox *w, gpointer data)
106 GtkWindow *create_window(GtkBuilder *builder, GSettings *settings)
110 gsettings = settings;
112 window = GTK_WINDOW(gtk_builder_get_object(builder, "window"));
114 w_status = GTK_COMBO_BOX(gtk_builder_get_object(builder, "status"));
115 g_signal_connect(w_status,
116 "changed", (GCallback)status_changed_cbk,
119 w = g_settings_get_int(settings, "window-width");
120 h = g_settings_get_int(settings, "window-height");
121 gtk_window_set_default_size(window, w, h);
123 x = g_settings_get_int(settings, "window-x");
124 y = g_settings_get_int(settings, "window-y");
125 gtk_window_move(window, x, y);
127 vpaned = GTK_PANED(gtk_builder_get_object(builder, "vpaned"));
128 pos = g_settings_get_int(settings, "spliter-vertical-pos");
129 gtk_paned_set_position(vpaned, pos);
131 hpaned = GTK_PANED(gtk_builder_get_object(builder, "hpaned"));
132 pos = g_settings_get_int(settings, "spliter-horizontal-pos");
133 gtk_paned_set_position(hpaned, pos);
135 g_signal_connect(window, "delete_event",
136 G_CALLBACK(delete_event_cbk), settings);
138 ui_taskpanel_init(builder);
139 ui_tasktree_init(builder);
140 ui_projecttree_init(builder);
142 ui_tasktree_load_settings(settings);
147 const char *ui_get_status_filter()
153 status = gtk_combo_box_get_active_id(w_status);
154 log_fct("status: %d", status);
161 void quit_activate_cbk(GtkWidget *menu_item, gpointer data)
168 void about_activate_cbk(GtkWidget *menu_item, gpointer data)
172 gtk_show_about_dialog
175 _("ptask is a GTK+ task management application"),
177 _("Copyright(c) 2010-2013\njeanfi@gmail.com"),
178 "logo-icon-name", "ptask",
179 "program-name", "ptask",
180 "title", _("About ptask"),
182 "website", PACKAGE_URL,
183 "website-label", _("ptask Homepage"),