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
27 #include <glib/gi18n.h>
36 #include <ui_projecttree.h>
37 #include <ui_taskpanel.h>
38 #include <ui_tasktree.h>
40 static const char *program_name;
41 static struct task **tasks;
43 static struct option long_options[] = {
44 {"version", no_argument, 0, 'v'},
45 {"help", no_argument, 0, 'h'},
46 {"debug", required_argument, 0, 'd'},
50 static void print_version()
52 printf("ptask %s\n", VERSION);
53 printf(_("Copyright (C) %s jeanfi@gmail.com\n"
54 "License GPLv2: GNU GPL version 2 or later "
55 "<http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>\n"
56 "This is free software: you are free to change and "
58 "There is NO WARRANTY, to the extent permitted by law.\n"),
62 static void print_help()
64 printf(_("Usage: %s [OPTION]...\n"), program_name);
66 puts(_("ptask is a task management user interface based"
71 puts(_(" -h, --help display this help and exit\n"
72 " -v, --version display version information and exit"));
76 puts(_(" -d, --debug=LEVEL "
77 "set the debug level, integer between 0 and 3"));
81 printf(_("Report bugs to: %s\n"), PACKAGE_BUGREPORT);
83 printf(_("%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
89 const char *current_prj, *current_uuid;
90 struct task **old_tasks;
93 ui_taskpanel_update(NULL);
97 current_prj = ui_projecttree_get_project();
98 current_uuid = ui_tasktree_get_task_uuid();
99 ui_tasktree_update(NULL, NULL);
106 tasks = tw_get_all_tasks(ui_get_status_filter());
109 ui_projecttree_update(tasks);
110 ui_tasktree_update(tasks, current_prj);
112 ui_tasktree_set_selected_task(current_uuid);
114 dialog = gtk_message_dialog_new(NULL,
115 GTK_DIALOG_DESTROY_WITH_PARENT,
118 _("Error loading tasks, verify "
119 "that a supported version of "
120 "taskwarrior is installed "));
121 gtk_dialog_run(GTK_DIALOG(dialog));
122 gtk_widget_destroy(dialog);
126 tw_task_list_free(old_tasks);
131 static void log_init()
133 char *home, *path, *dir;
135 home = getenv("HOME");
140 dir = malloc(strlen(home)+1+strlen(".ptask")+1);
141 sprintf(dir, "%s/%s", home, ".ptask");
144 path = malloc(strlen(dir)+1+strlen("log")+1);
145 sprintf(path, "%s/%s", dir, "log");
153 int main(int argc, char **argv)
157 int optc, cmdok, opti;
159 program_name = argv[0];
161 setlocale(LC_ALL, "");
164 bindtextdomain(PACKAGE, LOCALEDIR);
169 while ((optc = getopt_long(argc, argv, "vhd:", long_options,
179 log_level = atoi(optarg);
180 log_info(_("Enables debug mode."));
188 if (!cmdok || optind != argc) {
189 fprintf(stderr, _("Try `%s --help' for more information.\n"),
196 gtk_init(NULL, NULL);
200 builder = gtk_builder_new();
201 gtk_builder_add_from_file
203 PACKAGE_DATA_DIR G_DIR_SEPARATOR_S "ptask.glade",
205 window = create_window(builder);
207 gtk_builder_connect_signals(builder, NULL);
209 g_object_unref(G_OBJECT(builder));
213 gtk_widget_show_all(GTK_WIDGET(window));