Added a plug-in for Mailer
This commit is contained in:
parent
e281991bde
commit
3650233f2d
9
Makefile
9
Makefile
|
@ -1,6 +1,6 @@
|
|||
PACKAGE = Todo
|
||||
VERSION = 0.1.2
|
||||
SUBDIRS = data po src
|
||||
SUBDIRS = data po src tools
|
||||
RM ?= rm -f
|
||||
LN ?= ln -f
|
||||
TAR ?= tar -czvf
|
||||
|
@ -41,14 +41,17 @@ dist:
|
|||
$(PACKAGE)-$(VERSION)/src/task.c \
|
||||
$(PACKAGE)-$(VERSION)/src/taskedit.c \
|
||||
$(PACKAGE)-$(VERSION)/src/todo.c \
|
||||
$(PACKAGE)-$(VERSION)/src/callbacks.c \
|
||||
$(PACKAGE)-$(VERSION)/src/window.c \
|
||||
$(PACKAGE)-$(VERSION)/src/main.c \
|
||||
$(PACKAGE)-$(VERSION)/src/Makefile \
|
||||
$(PACKAGE)-$(VERSION)/src/task.h \
|
||||
$(PACKAGE)-$(VERSION)/src/taskedit.h \
|
||||
$(PACKAGE)-$(VERSION)/src/todo.h \
|
||||
$(PACKAGE)-$(VERSION)/src/callbacks.h \
|
||||
$(PACKAGE)-$(VERSION)/src/window.h \
|
||||
$(PACKAGE)-$(VERSION)/src/project.conf \
|
||||
$(PACKAGE)-$(VERSION)/tools/todo.c \
|
||||
$(PACKAGE)-$(VERSION)/tools/Makefile \
|
||||
$(PACKAGE)-$(VERSION)/tools/project.conf \
|
||||
$(PACKAGE)-$(VERSION)/Makefile \
|
||||
$(PACKAGE)-$(VERSION)/COPYING \
|
||||
$(PACKAGE)-$(VERSION)/config.h \
|
||||
|
|
|
@ -2,5 +2,5 @@ package=Todo
|
|||
version=0.1.2
|
||||
config=h,sh
|
||||
|
||||
subdirs=data,po,src
|
||||
subdirs=data,po,src,tools
|
||||
dist=Makefile,COPYING,config.h,config.sh
|
||||
|
|
15
src/Makefile
15
src/Makefile
|
@ -2,6 +2,7 @@ TARGETS = todo
|
|||
PREFIX = /usr/local
|
||||
DESTDIR =
|
||||
BINDIR = $(PREFIX)/bin
|
||||
SBINDIR = $(PREFIX)/sbin
|
||||
CC ?= cc
|
||||
CPPFLAGSF?=
|
||||
CPPFLAGS?=
|
||||
|
@ -17,7 +18,7 @@ INSTALL ?= install
|
|||
|
||||
all: $(TARGETS)
|
||||
|
||||
todo_OBJS = task.o taskedit.o todo.o callbacks.o main.o
|
||||
todo_OBJS = task.o taskedit.o todo.o window.o main.o
|
||||
todo_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||
todo_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||
|
||||
|
@ -25,16 +26,16 @@ todo: $(todo_OBJS)
|
|||
$(CC) -o todo $(todo_OBJS) $(todo_LDFLAGS)
|
||||
|
||||
task.o: task.c task.h
|
||||
$(CC) $(todo_CFLAGS) -c task.c
|
||||
$(CC) $(todo_CFLAGS) -fPIC -c task.c
|
||||
|
||||
taskedit.o: taskedit.c
|
||||
$(CC) $(todo_CFLAGS) -c taskedit.c
|
||||
$(CC) $(todo_CFLAGS) -fPIC -c taskedit.c
|
||||
|
||||
todo.o: todo.c callbacks.h task.h todo.h ../config.h
|
||||
$(CC) $(todo_CFLAGS) -c todo.c
|
||||
todo.o: todo.c task.h todo.h ../config.h
|
||||
$(CC) $(todo_CFLAGS) -fPIC -c todo.c
|
||||
|
||||
callbacks.o: callbacks.c task.h todo.h callbacks.h
|
||||
$(CC) $(todo_CFLAGS) -c callbacks.c
|
||||
window.o: window.c todo.h window.h
|
||||
$(CC) $(todo_CFLAGS) -c window.c
|
||||
|
||||
main.o: main.c task.h todo.h ../config.h
|
||||
$(CC) $(todo_CFLAGS) -c main.c
|
||||
|
|
245
src/callbacks.c
245
src/callbacks.c
|
@ -1,245 +0,0 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Todo */
|
||||
/* 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, version 3 of the License.
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
|
||||
#include "todo.h"
|
||||
#include "callbacks.h"
|
||||
|
||||
|
||||
/* callbacks */
|
||||
/* on_close */
|
||||
void on_close(gpointer data)
|
||||
{
|
||||
on_closex();
|
||||
}
|
||||
|
||||
|
||||
/* on_closex */
|
||||
gboolean on_closex(void)
|
||||
{
|
||||
gtk_main_quit();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/* file menu */
|
||||
/* on_file_close */
|
||||
void on_file_close(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
on_close(todo);
|
||||
}
|
||||
|
||||
|
||||
/* on_file_edit */
|
||||
void on_file_edit(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_edit(todo);
|
||||
}
|
||||
|
||||
|
||||
/* on_file_new */
|
||||
void on_file_new(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_add(todo, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* edit menu */
|
||||
/* on_edit_delete */
|
||||
void on_edit_delete(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_delete_selected(todo);
|
||||
}
|
||||
|
||||
|
||||
/* on_edit_preferences */
|
||||
void on_edit_preferences(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
on_preferences(todo);
|
||||
}
|
||||
|
||||
|
||||
/* on_edit_select_all */
|
||||
void on_edit_select_all(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_select_all(todo);
|
||||
}
|
||||
|
||||
|
||||
/* view menu */
|
||||
/* on_view_all_tasks */
|
||||
void on_view_all_tasks(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_set_view(todo, TODO_VIEW_ALL_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* on_view_completed_tasks */
|
||||
void on_view_completed_tasks(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_set_view(todo, TODO_VIEW_COMPLETED_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* on_view_remaining_tasks */
|
||||
void on_view_remaining_tasks(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_set_view(todo, TODO_VIEW_REMAINING_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* help menu */
|
||||
/* on_help_about */
|
||||
void on_help_about(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_about(todo);
|
||||
}
|
||||
|
||||
|
||||
/* toolbar */
|
||||
/* on_delete */
|
||||
void on_delete(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_delete_selected(todo);
|
||||
}
|
||||
|
||||
|
||||
/* on_edit */
|
||||
void on_edit(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_edit(todo);
|
||||
}
|
||||
|
||||
|
||||
/* on_new */
|
||||
void on_new(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_add(todo, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* on_preferences */
|
||||
void on_preferences(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
/* FIXME implement */
|
||||
}
|
||||
|
||||
|
||||
/* on_view_as */
|
||||
void on_view_as(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
TodoView view;
|
||||
|
||||
view = todo_get_view(todo);
|
||||
view = (view + 1) % TODO_VIEW_COUNT;
|
||||
todo_set_view(todo, view);
|
||||
}
|
||||
|
||||
|
||||
/* on_select_all */
|
||||
void on_select_all(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_select_all(todo);
|
||||
}
|
||||
|
||||
|
||||
/* view */
|
||||
/* on_task_activated */
|
||||
void on_task_activated(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_edit(todo);
|
||||
}
|
||||
|
||||
|
||||
/* on_task_cursor_changed */
|
||||
void on_task_cursor_changed(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_cursor_changed(todo);
|
||||
}
|
||||
|
||||
|
||||
/* on_task_done_toggled */
|
||||
void on_task_done_toggled(GtkCellRendererToggle * renderer, gchar * path,
|
||||
gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
GtkTreePath * treepath;
|
||||
|
||||
treepath = gtk_tree_path_new_from_string(path);
|
||||
todo_task_toggle_done(todo, treepath);
|
||||
gtk_tree_path_free(treepath);
|
||||
}
|
||||
|
||||
|
||||
/* on_task_priority_edited */
|
||||
void on_task_priority_edited(GtkCellRendererText * renderer, gchar * path,
|
||||
gchar * priority, gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
GtkTreePath * treepath;
|
||||
|
||||
treepath = gtk_tree_path_new_from_string(path);
|
||||
todo_task_set_priority(todo, treepath, priority);
|
||||
gtk_tree_path_free(treepath);
|
||||
}
|
||||
|
||||
|
||||
/* on_task_title_edited */
|
||||
void on_task_title_edited(GtkCellRendererText * renderer, gchar * path,
|
||||
gchar * title, gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
GtkTreePath * treepath;
|
||||
|
||||
treepath = gtk_tree_path_new_from_string(path);
|
||||
todo_task_set_title(todo, treepath, title);
|
||||
gtk_tree_path_free(treepath);
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Todo */
|
||||
/* 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, version 3 of the License.
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
|
||||
#ifndef TODO_CALLBACKS_H
|
||||
# define TODO_CALLBACKS_H
|
||||
|
||||
# include <gtk/gtk.h>
|
||||
|
||||
|
||||
/* callbacks */
|
||||
void on_close(gpointer data);
|
||||
gboolean on_closex(void);
|
||||
|
||||
/* menus */
|
||||
/* file menu */
|
||||
void on_file_new(gpointer data);
|
||||
void on_file_edit(gpointer data);
|
||||
void on_file_close(gpointer data);
|
||||
|
||||
/* edit menu */
|
||||
void on_edit_select_all(gpointer data);
|
||||
void on_edit_delete(gpointer data);
|
||||
void on_edit_preferences(gpointer data);
|
||||
|
||||
/* view menu */
|
||||
void on_view_all_tasks(gpointer data);
|
||||
void on_view_completed_tasks(gpointer data);
|
||||
void on_view_remaining_tasks(gpointer data);
|
||||
|
||||
/* help menu */
|
||||
void on_help_about(gpointer data);
|
||||
|
||||
/* toolbar */
|
||||
void on_new(gpointer data);
|
||||
void on_edit(gpointer data);
|
||||
void on_select_all(gpointer data);
|
||||
void on_delete(gpointer data);
|
||||
void on_preferences(gpointer data);
|
||||
void on_view_as(gpointer data);
|
||||
|
||||
/* view */
|
||||
void on_task_activated(gpointer data);
|
||||
void on_task_cursor_changed(gpointer data);
|
||||
void on_task_done_toggled(GtkCellRendererToggle * renderer, gchar * path,
|
||||
gpointer data);
|
||||
void on_task_priority_edited(GtkCellRendererText * renderer, gchar * path,
|
||||
gchar * priority, gpointer data);
|
||||
void on_task_title_edited(GtkCellRendererText * renderer, gchar * path,
|
||||
gchar * title, gpointer data);
|
||||
|
||||
#endif /* !TODO_CALLBACKS_H */
|
23
src/main.c
23
src/main.c
|
@ -20,7 +20,8 @@
|
|||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "todo.h"
|
||||
#include <System.h>
|
||||
#include "window.h"
|
||||
#include "../config.h"
|
||||
#define _(string) gettext(string)
|
||||
|
||||
|
@ -38,6 +39,19 @@
|
|||
|
||||
/* private */
|
||||
/* functions */
|
||||
/* todo */
|
||||
static int _todo(void)
|
||||
{
|
||||
TodoWindow * todo;
|
||||
|
||||
if((todo = todowindow_new()) == NULL)
|
||||
return error_print(PACKAGE);
|
||||
gtk_main();
|
||||
todowindow_delete(todo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
|
@ -52,7 +66,6 @@ static int _usage(void)
|
|||
int main(int argc, char * argv[])
|
||||
{
|
||||
int o;
|
||||
Todo * todo;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
|
@ -66,9 +79,5 @@ int main(int argc, char * argv[])
|
|||
}
|
||||
if(optind != argc)
|
||||
return _usage();
|
||||
if((todo = todo_new()) == NULL)
|
||||
return 2;
|
||||
gtk_main();
|
||||
todo_delete(todo);
|
||||
return 0;
|
||||
return (_todo() == 0) ? 0 : 2;
|
||||
}
|
||||
|
|
|
@ -4,21 +4,26 @@ cflags_force=-W `pkg-config --cflags libSystem libDesktop`
|
|||
cflags=-Wall -g -O2 -pedantic
|
||||
ldflags_force=`pkg-config --libs libSystem libDesktop`
|
||||
ldflags=
|
||||
dist=Makefile,task.h,taskedit.h,todo.h,callbacks.h
|
||||
dist=Makefile,task.h,taskedit.h,todo.h,window.h
|
||||
|
||||
[todo]
|
||||
type=binary
|
||||
sources=task.c,taskedit.c,todo.c,callbacks.c,main.c
|
||||
sources=task.c,taskedit.c,todo.c,window.c,main.c
|
||||
install=$(BINDIR)
|
||||
|
||||
[task.c]
|
||||
depends=task.h
|
||||
|
||||
[todo.c]
|
||||
depends=callbacks.h,task.h,todo.h,../config.h
|
||||
|
||||
[callbacks.c]
|
||||
depends=task.h,todo.h,callbacks.h
|
||||
|
||||
[main.c]
|
||||
depends=task.h,todo.h,../config.h
|
||||
|
||||
[task.c]
|
||||
depends=task.h
|
||||
cflags=-fPIC
|
||||
|
||||
[taskedit.c]
|
||||
cflags=-fPIC
|
||||
|
||||
[todo.c]
|
||||
depends=task.h,todo.h,../config.h
|
||||
cflags=-fPIC
|
||||
|
||||
[window.c]
|
||||
depends=todo.h,window.h
|
||||
|
|
353
src/todo.c
353
src/todo.c
|
@ -30,10 +30,8 @@ static char const _license[] =
|
|||
#include <errno.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <System.h>
|
||||
#include <Desktop.h>
|
||||
#include "callbacks.h"
|
||||
#include "taskedit.h"
|
||||
#include "todo.h"
|
||||
#include "../config.h"
|
||||
|
@ -47,6 +45,7 @@ static char const _license[] =
|
|||
struct _Todo
|
||||
{
|
||||
GtkWidget * window;
|
||||
GtkWidget * widget;
|
||||
GtkWidget * scrolled;
|
||||
GtkListStore * store;
|
||||
GtkListStore * priorities;
|
||||
|
@ -54,11 +53,47 @@ struct _Todo
|
|||
GtkTreeModel * filter_sort;
|
||||
TodoView filter_view;
|
||||
GtkWidget * view;
|
||||
GtkWidget * statusbar;
|
||||
GtkWidget * about;
|
||||
};
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static int _todo_confirm(GtkWidget * window, char const * message);
|
||||
static gboolean _todo_get_iter(Todo * todo, GtkTreeIter * iter,
|
||||
GtkTreePath * path);
|
||||
static char * _todo_task_get_directory(void);
|
||||
static char * _todo_task_get_filename(char const * filename);
|
||||
static char * _todo_task_get_new_filename(void);
|
||||
static void _todo_task_save(Todo * todo, GtkTreeIter * iter);
|
||||
|
||||
/* callbacks */
|
||||
/* toolbar */
|
||||
static void _todo_on_new(gpointer data);
|
||||
static void _todo_on_edit(gpointer data);
|
||||
static void _todo_on_select_all(gpointer data);
|
||||
static void _todo_on_delete(gpointer data);
|
||||
#ifdef EMBEDDED
|
||||
static void _todo_on_preferences(gpointer data);
|
||||
#endif
|
||||
static void _todo_on_view_as(gpointer data);
|
||||
|
||||
/* view */
|
||||
static void _todo_on_task_activated(gpointer data);
|
||||
static void _todo_on_task_cursor_changed(gpointer data);
|
||||
static void _todo_on_task_done_toggled(GtkCellRendererToggle * renderer,
|
||||
gchar * path, gpointer data);
|
||||
static void _todo_on_task_priority_edited(GtkCellRendererText * renderer,
|
||||
gchar * path, gchar * priority, gpointer data);
|
||||
static void _todo_on_task_title_edited(GtkCellRendererText * renderer,
|
||||
gchar * path, gchar * title, gpointer data);
|
||||
static void _todo_on_view_all_tasks(gpointer data);
|
||||
static void _todo_on_view_completed_tasks(gpointer data);
|
||||
static void _todo_on_view_remaining_tasks(gpointer data);
|
||||
|
||||
static gboolean _todo_on_filter_view(GtkTreeModel * model, GtkTreeIter * iter,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* constants */
|
||||
enum { TD_COL_TASK, TD_COL_DONE, TD_COL_TITLE, TD_COL_START,
|
||||
TD_COL_DISPLAY_START, TD_COL_END, TD_COL_DISPLAY_END, TD_COL_PRIORITY,
|
||||
|
@ -75,9 +110,9 @@ static const struct
|
|||
} _todo_columns[] =
|
||||
{
|
||||
{ TD_COL_DONE, N_("Done"), TD_COL_DONE, G_CALLBACK(
|
||||
on_task_done_toggled) },
|
||||
_todo_on_task_done_toggled) },
|
||||
{ TD_COL_TITLE, N_("Title"), TD_COL_TITLE, G_CALLBACK(
|
||||
on_task_title_edited) },
|
||||
_todo_on_task_title_edited) },
|
||||
{ TD_COL_DISPLAY_START, N_("Beginning"), TD_COL_START, NULL },
|
||||
{ TD_COL_DISPLAY_END, N_("Completion"), TD_COL_END, NULL },
|
||||
{ 0, NULL, 0, NULL }
|
||||
|
@ -104,125 +139,41 @@ static char const * _authors[] =
|
|||
NULL
|
||||
};
|
||||
|
||||
/* accelerators */
|
||||
static const DesktopAccel _todo_accel[] =
|
||||
{
|
||||
#ifdef EMBEDDED
|
||||
{ G_CALLBACK(on_close), GDK_CONTROL_MASK, GDK_KEY_W },
|
||||
{ G_CALLBACK(on_edit), GDK_CONTROL_MASK, GDK_KEY_E },
|
||||
{ G_CALLBACK(on_new), GDK_CONTROL_MASK, GDK_KEY_N },
|
||||
{ G_CALLBACK(on_preferences), GDK_CONTROL_MASK, GDK_KEY_P },
|
||||
#endif
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
#ifndef EMBEDDED
|
||||
/* menubar */
|
||||
static const DesktopMenu _file_menu[] =
|
||||
{
|
||||
{ N_("_New"), G_CALLBACK(on_file_new), GTK_STOCK_NEW, GDK_CONTROL_MASK,
|
||||
GDK_KEY_N },
|
||||
{ N_("_Edit"), G_CALLBACK(on_file_edit), GTK_STOCK_EDIT,
|
||||
GDK_CONTROL_MASK, GDK_KEY_E },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Close"), G_CALLBACK(on_file_close), GTK_STOCK_CLOSE,
|
||||
GDK_CONTROL_MASK, GDK_KEY_W },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
static const DesktopMenu _edit_menu[] =
|
||||
{
|
||||
{ N_("Select _all"), G_CALLBACK(on_edit_select_all),
|
||||
#if GTK_CHECK_VERSION(2, 10, 0)
|
||||
GTK_STOCK_SELECT_ALL,
|
||||
#else
|
||||
"edit-select-all",
|
||||
#endif
|
||||
GDK_CONTROL_MASK, GDK_KEY_A },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Delete"), G_CALLBACK(on_edit_delete), GTK_STOCK_DELETE, 0, 0 },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Preferences"), G_CALLBACK(on_edit_preferences),
|
||||
GTK_STOCK_PREFERENCES, GDK_CONTROL_MASK, GDK_KEY_P },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
static const DesktopMenu _view_menu[] =
|
||||
{
|
||||
{ N_("_All tasks"), G_CALLBACK(on_view_all_tasks), NULL, 0, 0 },
|
||||
{ N_("_Completed tasks"), G_CALLBACK(on_view_completed_tasks), NULL, 0,
|
||||
0 },
|
||||
{ N_("_Remaining tasks"), G_CALLBACK(on_view_remaining_tasks), NULL, 0,
|
||||
0 },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
static const DesktopMenu _help_menu[] =
|
||||
{
|
||||
{ N_("_About"), G_CALLBACK(on_help_about),
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
GTK_STOCK_ABOUT, 0, 0 },
|
||||
#else
|
||||
NULL, 0, 0 },
|
||||
#endif
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
static const DesktopMenubar _menubar[] =
|
||||
{
|
||||
{ N_("_File"), _file_menu },
|
||||
{ N_("_Edit"), _edit_menu },
|
||||
{ N_("_View"), _view_menu },
|
||||
{ N_("_Help"), _help_menu },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
#endif
|
||||
|
||||
/* toolbar */
|
||||
static DesktopToolbar _toolbar[] =
|
||||
{
|
||||
{ N_("New task"), G_CALLBACK(on_new), GTK_STOCK_NEW, 0, 0, NULL },
|
||||
{ N_("Edit task"), G_CALLBACK(on_edit), GTK_STOCK_EDIT, 0, 0, NULL },
|
||||
{ N_("New task"), G_CALLBACK(_todo_on_new), GTK_STOCK_NEW, 0, 0, NULL },
|
||||
{ N_("Edit task"), G_CALLBACK(_todo_on_edit), GTK_STOCK_EDIT, 0, 0,
|
||||
NULL },
|
||||
{ "", NULL, NULL, 0, 0, NULL },
|
||||
#if GTK_CHECK_VERSION(2, 10, 0)
|
||||
{ N_("Select all"), G_CALLBACK(on_select_all), GTK_STOCK_SELECT_ALL, 0,
|
||||
0, NULL },
|
||||
{ N_("Select all"), G_CALLBACK(_todo_on_select_all),
|
||||
GTK_STOCK_SELECT_ALL, 0, 0, NULL },
|
||||
#else
|
||||
{ N_("Select all"), G_CALLBACK(on_select_all), "edit-select-all", 0, 0,
|
||||
NULL },
|
||||
{ N_("Select all"), G_CALLBACK(_todo_on_select_all), "edit-select-all",
|
||||
0, 0, NULL },
|
||||
#endif
|
||||
{ N_("Delete task"), G_CALLBACK(on_delete), GTK_STOCK_DELETE, 0, 0,
|
||||
NULL },
|
||||
{ N_("Delete task"), G_CALLBACK(_todo_on_delete), GTK_STOCK_DELETE, 0,
|
||||
0, NULL },
|
||||
#ifdef EMBEDDED
|
||||
{ "", NULL, NULL, 0, 0, NULL },
|
||||
{ N_("Preferences"), G_CALLBACK(on_preferences), GTK_STOCK_PREFERENCES,
|
||||
0, 0, NULL },
|
||||
{ N_("Preferences"), G_CALLBACK(_todo_on_preferences),
|
||||
GTK_STOCK_PREFERENCES, 0, 0, NULL },
|
||||
#endif
|
||||
{ "", NULL, NULL, 0, 0, NULL },
|
||||
{ NULL, NULL, NULL, 0, 0, NULL }
|
||||
};
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static int _todo_confirm(GtkWidget * window, char const * message);
|
||||
static gboolean _todo_get_iter(Todo * todo, GtkTreeIter * iter,
|
||||
GtkTreePath * path);
|
||||
static char * _todo_task_get_directory(void);
|
||||
static char * _todo_task_get_filename(char const * filename);
|
||||
static char * _todo_task_get_new_filename(void);
|
||||
static void _todo_task_save(Todo * todo, GtkTreeIter * iter);
|
||||
|
||||
/* callbacks */
|
||||
static gboolean _on_todo_filter_view(GtkTreeModel * model, GtkTreeIter * iter,
|
||||
gpointer data);
|
||||
|
||||
|
||||
/* public */
|
||||
/* functions */
|
||||
/* todo_new */
|
||||
static void _new_view(Todo * todo);
|
||||
static gboolean _new_idle(gpointer data);
|
||||
|
||||
Todo * todo_new(void)
|
||||
Todo * todo_new(GtkWidget * window, GtkAccelGroup * group)
|
||||
{
|
||||
Todo * todo;
|
||||
GtkAccelGroup * group;
|
||||
GtkWidget * vbox;
|
||||
GtkWidget * widget;
|
||||
GtkToolItem * toolitem;
|
||||
|
@ -232,38 +183,26 @@ Todo * todo_new(void)
|
|||
if((todo = object_new(sizeof(*todo))) == NULL)
|
||||
return NULL;
|
||||
/* main window */
|
||||
group = gtk_accel_group_new();
|
||||
todo->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
gtk_window_add_accel_group(GTK_WINDOW(todo->window), group);
|
||||
gtk_window_set_default_size(GTK_WINDOW(todo->window), 640, 480);
|
||||
gtk_window_set_icon_name(GTK_WINDOW(todo->window), "todo");
|
||||
gtk_window_set_title(GTK_WINDOW(todo->window), _("Todo"));
|
||||
g_signal_connect_swapped(G_OBJECT(todo->window), "delete-event",
|
||||
G_CALLBACK(on_closex), NULL);
|
||||
todo->window = window;
|
||||
vbox = gtk_vbox_new(FALSE, 0);
|
||||
desktop_accel_create(_todo_accel, todo, group);
|
||||
#ifndef EMBEDDED
|
||||
/* menubar */
|
||||
widget = desktop_menubar_create(_menubar, todo, group);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, TRUE, 0);
|
||||
#endif
|
||||
todo->widget = vbox;
|
||||
/* toolbar */
|
||||
widget = desktop_toolbar_create(_toolbar, todo, group);
|
||||
toolitem = gtk_menu_tool_button_new(NULL, _("View as..."));
|
||||
g_signal_connect_swapped(G_OBJECT(toolitem), "clicked", G_CALLBACK(
|
||||
on_view_as), todo);
|
||||
_todo_on_view_as), todo);
|
||||
menu = gtk_menu_new();
|
||||
menuitem = gtk_menu_item_new_with_label(_("All tasks"));
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
|
||||
on_view_all_tasks), todo);
|
||||
_todo_on_view_all_tasks), todo);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
menuitem = gtk_menu_item_new_with_label(_("Completed tasks"));
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
|
||||
on_view_completed_tasks), todo);
|
||||
_todo_on_view_completed_tasks), todo);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
menuitem = gtk_menu_item_new_with_label(_("Remaining tasks"));
|
||||
g_signal_connect_swapped(G_OBJECT(menuitem), "activate", G_CALLBACK(
|
||||
on_view_remaining_tasks), todo);
|
||||
_todo_on_view_remaining_tasks), todo);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
|
||||
gtk_widget_show_all(menu);
|
||||
gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(toolitem), menu);
|
||||
|
@ -275,12 +214,7 @@ Todo * todo_new(void)
|
|||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
_new_view(todo);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), todo->scrolled, TRUE, TRUE, 0);
|
||||
/* statusbar */
|
||||
todo->statusbar = gtk_statusbar_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox), todo->statusbar, FALSE, TRUE, 0);
|
||||
todo->about = NULL;
|
||||
gtk_container_add(GTK_CONTAINER(todo->window), vbox);
|
||||
gtk_widget_show_all(todo->window);
|
||||
g_idle_add(_new_idle, todo);
|
||||
return todo;
|
||||
}
|
||||
|
@ -316,7 +250,7 @@ static void _new_view(Todo * todo)
|
|||
NULL);
|
||||
todo->filter_view = TODO_VIEW_ALL_TASKS;
|
||||
gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(
|
||||
todo->filter), _on_todo_filter_view, todo,
|
||||
todo->filter), _todo_on_filter_view, todo,
|
||||
NULL);
|
||||
todo->filter_sort = gtk_tree_model_sort_new_with_model(todo->filter);
|
||||
todo->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(
|
||||
|
@ -326,9 +260,9 @@ static void _new_view(Todo * todo)
|
|||
!= NULL)
|
||||
gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
|
||||
g_signal_connect_swapped(G_OBJECT(todo->view), "cursor-changed",
|
||||
G_CALLBACK(on_task_cursor_changed), todo);
|
||||
G_CALLBACK(_todo_on_task_cursor_changed), todo);
|
||||
g_signal_connect_swapped(G_OBJECT(todo->view), "row-activated",
|
||||
G_CALLBACK(on_task_activated), todo);
|
||||
G_CALLBACK(_todo_on_task_activated), todo);
|
||||
/* done column */
|
||||
renderer = gtk_cell_renderer_toggle_new();
|
||||
g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(
|
||||
|
@ -370,7 +304,7 @@ static void _new_view(Todo * todo)
|
|||
"model", todo->priorities, "text-column", 1,
|
||||
"editable", TRUE, NULL);
|
||||
g_signal_connect(renderer, "edited", G_CALLBACK(
|
||||
on_task_priority_edited), todo);
|
||||
_todo_on_task_priority_edited), todo);
|
||||
column = gtk_tree_view_column_new_with_attributes(_("Priority"),
|
||||
renderer, "text", TD_COL_DISPLAY_PRIORITY, NULL);
|
||||
#if GTK_CHECK_VERSION(2, 4, 0)
|
||||
|
@ -409,6 +343,13 @@ TodoView todo_get_view(Todo * todo)
|
|||
}
|
||||
|
||||
|
||||
/* todo_get_widget */
|
||||
GtkWidget * todo_get_widget(Todo * todo)
|
||||
{
|
||||
return todo->widget;
|
||||
}
|
||||
|
||||
|
||||
/* todo_set_view */
|
||||
void todo_set_view(Todo * todo, TodoView view)
|
||||
{
|
||||
|
@ -489,6 +430,13 @@ static int _error_text(char const * message, int ret)
|
|||
}
|
||||
|
||||
|
||||
/* todo_show_preferences */
|
||||
void todo_show_preferences(Todo * todo, gboolean show)
|
||||
{
|
||||
/* FIXME implement */
|
||||
}
|
||||
|
||||
|
||||
/* tasks */
|
||||
/* todo_task_add */
|
||||
Task * todo_task_add(Todo * todo, Task * task)
|
||||
|
@ -1154,8 +1102,153 @@ static void _todo_task_save(Todo * todo, GtkTreeIter * iter)
|
|||
|
||||
|
||||
/* callbacks */
|
||||
/* on_todo_filter_view */
|
||||
static gboolean _on_todo_filter_view(GtkTreeModel * model, GtkTreeIter * iter,
|
||||
/* todo_on_view_all_tasks */
|
||||
static void _todo_on_view_all_tasks(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_set_view(todo, TODO_VIEW_ALL_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* todo_on_view_completed_tasks */
|
||||
static void _todo_on_view_completed_tasks(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_set_view(todo, TODO_VIEW_COMPLETED_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* todo_on_view_remaining_tasks */
|
||||
static void _todo_on_view_remaining_tasks(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_set_view(todo, TODO_VIEW_REMAINING_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* toolbar */
|
||||
/* todo_on_delete */
|
||||
static void _todo_on_delete(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_delete_selected(todo);
|
||||
}
|
||||
|
||||
|
||||
/* todo_on_edit */
|
||||
static void _todo_on_edit(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_edit(todo);
|
||||
}
|
||||
|
||||
|
||||
/* todo_on_new */
|
||||
static void _todo_on_new(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_add(todo, NULL);
|
||||
}
|
||||
|
||||
|
||||
#ifdef EMBEDDED
|
||||
/* todo_on_preferences */
|
||||
static void _todo_on_preferences(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_show_preferences(todo, TRUE);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* todo_on_view_as */
|
||||
static void _todo_on_view_as(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
TodoView view;
|
||||
|
||||
view = todo_get_view(todo);
|
||||
view = (view + 1) % TODO_VIEW_COUNT;
|
||||
todo_set_view(todo, view);
|
||||
}
|
||||
|
||||
|
||||
/* todo_on_select_all */
|
||||
static void _todo_on_select_all(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_select_all(todo);
|
||||
}
|
||||
|
||||
|
||||
/* view */
|
||||
/* todo_on_task_activated */
|
||||
static void _todo_on_task_activated(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_edit(todo);
|
||||
}
|
||||
|
||||
|
||||
/* todo_on_task_cursor_changed */
|
||||
static void _todo_on_task_cursor_changed(gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
||||
todo_task_cursor_changed(todo);
|
||||
}
|
||||
|
||||
|
||||
/* todo_on_task_done_toggled */
|
||||
static void _todo_on_task_done_toggled(GtkCellRendererToggle * renderer,
|
||||
gchar * path, gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
GtkTreePath * treepath;
|
||||
|
||||
treepath = gtk_tree_path_new_from_string(path);
|
||||
todo_task_toggle_done(todo, treepath);
|
||||
gtk_tree_path_free(treepath);
|
||||
}
|
||||
|
||||
|
||||
/* todo_on_task_priority_edited */
|
||||
static void _todo_on_task_priority_edited(GtkCellRendererText * renderer,
|
||||
gchar * path, gchar * priority, gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
GtkTreePath * treepath;
|
||||
|
||||
treepath = gtk_tree_path_new_from_string(path);
|
||||
todo_task_set_priority(todo, treepath, priority);
|
||||
gtk_tree_path_free(treepath);
|
||||
}
|
||||
|
||||
|
||||
/* todo_on_task_title_edited */
|
||||
static void _todo_on_task_title_edited(GtkCellRendererText * renderer,
|
||||
gchar * path, gchar * title, gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
GtkTreePath * treepath;
|
||||
|
||||
treepath = gtk_tree_path_new_from_string(path);
|
||||
todo_task_set_title(todo, treepath, title);
|
||||
gtk_tree_path_free(treepath);
|
||||
}
|
||||
|
||||
|
||||
/* todo_on_filter_view */
|
||||
static gboolean _todo_on_filter_view(GtkTreeModel * model, GtkTreeIter * iter,
|
||||
gpointer data)
|
||||
{
|
||||
Todo * todo = data;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2011 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2009-2012 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Todo */
|
||||
/* 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
|
||||
|
@ -46,17 +46,20 @@ typedef enum _TodoView
|
|||
|
||||
|
||||
/* functions */
|
||||
Todo * todo_new(void);
|
||||
Todo * todo_new(GtkWidget * window, GtkAccelGroup * group);
|
||||
void todo_delete(Todo * todo);
|
||||
|
||||
/* accessors */
|
||||
TodoView todo_get_view(Todo * todo);
|
||||
GtkWidget * todo_get_widget(Todo * todo);
|
||||
void todo_set_view(Todo * todo, TodoView view);
|
||||
|
||||
/* useful */
|
||||
void todo_about(Todo * todo);
|
||||
int todo_error(Todo * todo, char const * message, int ret);
|
||||
|
||||
void todo_show_preferences(Todo * todo, gboolean show);
|
||||
|
||||
/* tasks */
|
||||
Task * todo_task_add(Todo * todo, Task * task);
|
||||
void todo_task_delete_selected(Todo * todo);
|
||||
|
|
313
src/window.c
Normal file
313
src/window.c
Normal file
|
@ -0,0 +1,313 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Todo */
|
||||
/* 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, version 3 of the License.
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <Desktop.h>
|
||||
#include "todo.h"
|
||||
#include "window.h"
|
||||
#include "../config.h"
|
||||
#define _(string) gettext(string)
|
||||
#define N_(string) (string)
|
||||
|
||||
|
||||
/* TodoWindow */
|
||||
/* private */
|
||||
/* types */
|
||||
struct _TodoWindow
|
||||
{
|
||||
Todo * todo;
|
||||
|
||||
/* widgets */
|
||||
GtkWidget * window;
|
||||
GtkWidget * statusbar;
|
||||
};
|
||||
|
||||
|
||||
/* prototypes */
|
||||
/* callbacks */
|
||||
static void _todowindow_on_close(gpointer data);
|
||||
static gboolean _todowindow_on_closex(gpointer data);
|
||||
|
||||
/* menus */
|
||||
/* file menu */
|
||||
static void _todowindow_on_file_new(gpointer data);
|
||||
static void _todowindow_on_file_edit(gpointer data);
|
||||
static void _todowindow_on_file_close(gpointer data);
|
||||
|
||||
/* edit menu */
|
||||
static void _todowindow_on_edit_select_all(gpointer data);
|
||||
static void _todowindow_on_edit_delete(gpointer data);
|
||||
static void _todowindow_on_edit_preferences(gpointer data);
|
||||
|
||||
/* view menu */
|
||||
static void _todowindow_on_view_all_tasks(gpointer data);
|
||||
static void _todowindow_on_view_completed_tasks(gpointer data);
|
||||
static void _todowindow_on_view_remaining_tasks(gpointer data);
|
||||
|
||||
/* help menu */
|
||||
static void _todowindow_on_help_about(gpointer data);
|
||||
|
||||
/* constants */
|
||||
/* accelerators */
|
||||
static const DesktopAccel _todo_accel[] =
|
||||
{
|
||||
#ifdef EMBEDDED
|
||||
{ G_CALLBACK(_todowindow_on_close), GDK_CONTROL_MASK, GDK_KEY_W },
|
||||
{ G_CALLBACK(_todowindow_on_edit), GDK_CONTROL_MASK, GDK_KEY_E },
|
||||
{ G_CALLBACK(_todowindow_on_new), GDK_CONTROL_MASK, GDK_KEY_N },
|
||||
{ G_CALLBACK(_todowindow_on_preferences), GDK_CONTROL_MASK, GDK_KEY_P },
|
||||
#endif
|
||||
{ NULL, 0, 0 }
|
||||
};
|
||||
|
||||
#ifndef EMBEDDED
|
||||
/* menubar */
|
||||
static const DesktopMenu _file_menu[] =
|
||||
{
|
||||
{ N_("_New"), G_CALLBACK(_todowindow_on_file_new), GTK_STOCK_NEW,
|
||||
GDK_CONTROL_MASK, GDK_KEY_N },
|
||||
{ N_("_Edit"), G_CALLBACK(_todowindow_on_file_edit), GTK_STOCK_EDIT,
|
||||
GDK_CONTROL_MASK, GDK_KEY_E },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Close"), G_CALLBACK(_todowindow_on_file_close), GTK_STOCK_CLOSE,
|
||||
GDK_CONTROL_MASK, GDK_KEY_W },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
static const DesktopMenu _edit_menu[] =
|
||||
{
|
||||
{ N_("Select _all"), G_CALLBACK(_todowindow_on_edit_select_all),
|
||||
#if GTK_CHECK_VERSION(2, 10, 0)
|
||||
GTK_STOCK_SELECT_ALL,
|
||||
#else
|
||||
"edit-select-all",
|
||||
#endif
|
||||
GDK_CONTROL_MASK, GDK_KEY_A },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Delete"), G_CALLBACK(_todowindow_on_edit_delete),
|
||||
GTK_STOCK_DELETE, 0, 0 },
|
||||
{ "", NULL, NULL, 0, 0 },
|
||||
{ N_("_Preferences"), G_CALLBACK(_todowindow_on_edit_preferences),
|
||||
GTK_STOCK_PREFERENCES, GDK_CONTROL_MASK, GDK_KEY_P },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
static const DesktopMenu _view_menu[] =
|
||||
{
|
||||
{ N_("_All tasks"), G_CALLBACK(_todowindow_on_view_all_tasks), NULL, 0,
|
||||
0 },
|
||||
{ N_("_Completed tasks"), G_CALLBACK(
|
||||
_todowindow_on_view_completed_tasks), NULL, 0, 0 },
|
||||
{ N_("_Remaining tasks"), G_CALLBACK(
|
||||
_todowindow_on_view_remaining_tasks), NULL, 0, 0 },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
static const DesktopMenu _help_menu[] =
|
||||
{
|
||||
{ N_("_About"), G_CALLBACK(_todowindow_on_help_about),
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
GTK_STOCK_ABOUT, 0, 0 },
|
||||
#else
|
||||
NULL, 0, 0 },
|
||||
#endif
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
static const DesktopMenubar _menubar[] =
|
||||
{
|
||||
{ N_("_File"), _file_menu },
|
||||
{ N_("_Edit"), _edit_menu },
|
||||
{ N_("_View"), _view_menu },
|
||||
{ N_("_Help"), _help_menu },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
/* public */
|
||||
/* functions */
|
||||
/* todowindow_new */
|
||||
TodoWindow * todowindow_new(void)
|
||||
{
|
||||
TodoWindow * todo;
|
||||
GtkAccelGroup * group;
|
||||
GtkWidget * vbox;
|
||||
GtkWidget * widget;
|
||||
|
||||
if((todo = malloc(sizeof(*todo))) == NULL)
|
||||
return NULL;
|
||||
todo->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||
group = gtk_accel_group_new();
|
||||
todo->todo = todo_new(todo->window, group);
|
||||
/* check for errors */
|
||||
if(todo->todo == NULL)
|
||||
{
|
||||
todowindow_delete(todo);
|
||||
g_object_unref(group);
|
||||
return NULL;
|
||||
}
|
||||
desktop_accel_create(_todo_accel, todo, group);
|
||||
gtk_window_add_accel_group(GTK_WINDOW(todo->window), group);
|
||||
gtk_window_set_default_size(GTK_WINDOW(todo->window), 640, 480);
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
gtk_window_set_icon_name(GTK_WINDOW(todo->window), "todo");
|
||||
#endif
|
||||
gtk_window_set_title(GTK_WINDOW(todo->window), _("Todo"));
|
||||
g_signal_connect_swapped(G_OBJECT(todo->window), "delete-event",
|
||||
G_CALLBACK(_todowindow_on_closex), todo);
|
||||
vbox = gtk_vbox_new(FALSE, 0);
|
||||
#ifndef EMBEDDED
|
||||
/* menubar */
|
||||
widget = desktop_menubar_create(_menubar, todo, group);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), widget, FALSE, TRUE, 0);
|
||||
#endif
|
||||
widget = todo_get_widget(todo->todo);
|
||||
gtk_box_pack_start(GTK_BOX(vbox), widget, TRUE, TRUE, 0);
|
||||
/* statusbar */
|
||||
todo->statusbar = gtk_statusbar_new();
|
||||
gtk_box_pack_start(GTK_BOX(vbox), todo->statusbar, FALSE, TRUE, 0);
|
||||
gtk_container_add(GTK_CONTAINER(todo->window), vbox);
|
||||
gtk_widget_show_all(todo->window);
|
||||
return todo;
|
||||
}
|
||||
|
||||
|
||||
/* todowindow_delete */
|
||||
void todowindow_delete(TodoWindow * todo)
|
||||
{
|
||||
if(todo->todo != NULL)
|
||||
todo_delete(todo->todo);
|
||||
gtk_widget_destroy(todo->window);
|
||||
free(todo);
|
||||
}
|
||||
|
||||
|
||||
/* private */
|
||||
/* functions */
|
||||
/* callbacks */
|
||||
/* todowindow_on_close */
|
||||
static void _todowindow_on_close(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
_todowindow_on_closex(todo);
|
||||
}
|
||||
|
||||
|
||||
/* todowindow_on_closex */
|
||||
static gboolean _todowindow_on_closex(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
gtk_widget_hide(todo->window);
|
||||
gtk_main_quit();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/* file menu */
|
||||
/* todowindow_on_file_close */
|
||||
static void _todowindow_on_file_close(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
_todowindow_on_close(todo);
|
||||
}
|
||||
|
||||
|
||||
/* todowindow_on_file_edit */
|
||||
static void _todowindow_on_file_edit(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
todo_task_edit(todo->todo);
|
||||
}
|
||||
|
||||
|
||||
/* todowindow_on_file_new */
|
||||
static void _todowindow_on_file_new(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
todo_task_add(todo->todo, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* edit menu */
|
||||
/* todowindow_on_edit_delete */
|
||||
static void _todowindow_on_edit_delete(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
todo_task_delete_selected(todo->todo);
|
||||
}
|
||||
|
||||
|
||||
/* todowindow_on_edit_preferences */
|
||||
static void _todowindow_on_edit_preferences(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
todo_show_preferences(todo->todo, TRUE);
|
||||
}
|
||||
|
||||
|
||||
/* todowindow_on_edit_select_all */
|
||||
static void _todowindow_on_edit_select_all(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
todo_task_select_all(todo->todo);
|
||||
}
|
||||
|
||||
|
||||
/* view menu */
|
||||
/* todowindow_on_view_all_tasks */
|
||||
static void _todowindow_on_view_all_tasks(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
todo_set_view(todo->todo, TODO_VIEW_ALL_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* todowindow_on_view_completed_tasks */
|
||||
static void _todowindow_on_view_completed_tasks(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
todo_set_view(todo->todo, TODO_VIEW_COMPLETED_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* todowindow_on_view_remaining_tasks */
|
||||
static void _todowindow_on_view_remaining_tasks(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
todo_set_view(todo->todo, TODO_VIEW_REMAINING_TASKS);
|
||||
}
|
||||
|
||||
|
||||
/* help menu */
|
||||
/* todowindow_on_help_about */
|
||||
static void _todowindow_on_help_about(gpointer data)
|
||||
{
|
||||
TodoWindow * todo = data;
|
||||
|
||||
todo_about(todo->todo);
|
||||
}
|
32
src/window.h
Normal file
32
src/window.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Todo */
|
||||
/* 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, version 3 of the License.
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
|
||||
#ifndef TODO_WINDOW_H
|
||||
# define TODO_WINDOW_H
|
||||
|
||||
|
||||
/* TodoWindow */
|
||||
/* public */
|
||||
/* types */
|
||||
typedef struct _TodoWindow TodoWindow;
|
||||
|
||||
|
||||
/* functions */
|
||||
TodoWindow * todowindow_new(void);
|
||||
void todowindow_delete(TodoWindow * todo);
|
||||
|
||||
#endif /* !TODO_WINDOW_H */
|
45
tools/Makefile
Normal file
45
tools/Makefile
Normal file
|
@ -0,0 +1,45 @@
|
|||
TARGETS = todo.so
|
||||
PREFIX = /usr/local
|
||||
DESTDIR =
|
||||
LIBDIR = $(PREFIX)/lib
|
||||
CC ?= cc
|
||||
CPPFLAGSF?=
|
||||
CPPFLAGS?=
|
||||
CFLAGSF = -W -fPIC `pkg-config --cflags libDesktop Mailer`
|
||||
CFLAGS = -Wall -g -O2 -pedantic
|
||||
LDFLAGSF= `pkg-config --libs libDesktop`
|
||||
AR ?= ar
|
||||
RANLIB ?= ranlib
|
||||
CCSHARED?= $(CC) -shared
|
||||
RM ?= rm -f
|
||||
LN ?= ln -f
|
||||
MKDIR ?= mkdir -p
|
||||
INSTALL ?= install
|
||||
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
todo_OBJS = todo.o
|
||||
todo_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||
todo_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) ../src/task.o ../src/taskedit.o ../src/todo.o ../src/callbacks.o
|
||||
|
||||
todo.so: $(todo_OBJS)
|
||||
$(CCSHARED) -o todo.so $(todo_OBJS) $(todo_LDFLAGS)
|
||||
|
||||
todo.o: todo.c
|
||||
$(CC) $(todo_CFLAGS) -c todo.c
|
||||
|
||||
clean:
|
||||
$(RM) -- $(todo_OBJS)
|
||||
|
||||
distclean: clean
|
||||
$(RM) -- $(TARGETS)
|
||||
|
||||
install: $(TARGETS)
|
||||
$(MKDIR) $(DESTDIR)$(LIBDIR)/Mailer/plugins
|
||||
$(INSTALL) -m 0644 -- todo.so $(DESTDIR)$(LIBDIR)/Mailer/plugins/todo.so
|
||||
|
||||
uninstall:
|
||||
$(RM) -- $(DESTDIR)$(LIBDIR)/Mailer/plugins/todo.so
|
||||
|
||||
.PHONY: all clean distclean install uninstall
|
11
tools/project.conf
Normal file
11
tools/project.conf
Normal file
|
@ -0,0 +1,11 @@
|
|||
targets=todo
|
||||
cflags_force=-W -fPIC `pkg-config --cflags libDesktop Mailer`
|
||||
cflags=-Wall -g -O2 -pedantic
|
||||
ldflags_force=`pkg-config --libs libDesktop`
|
||||
dist=Makefile
|
||||
|
||||
[todo]
|
||||
type=plugin
|
||||
sources=todo.c
|
||||
ldflags=../src/task.o ../src/taskedit.o ../src/todo.o ../src/callbacks.o
|
||||
install=$(LIBDIR)/Mailer/plugins
|
107
tools/todo.c
Normal file
107
tools/todo.c
Normal file
|
@ -0,0 +1,107 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2012 Pierre Pronchery <khorben@defora.org> */
|
||||
/* This file is part of DeforaOS Desktop Todo */
|
||||
/* 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, version 3 of the License.
|
||||
*
|
||||
* 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, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <Desktop/Mailer/plugin.h>
|
||||
#include "../src/todo.h"
|
||||
|
||||
|
||||
/* Mailing-lists */
|
||||
/* private */
|
||||
/* types */
|
||||
typedef struct _MailerPlugin TodoPlugin;
|
||||
|
||||
struct _MailerPlugin
|
||||
{
|
||||
MailerPluginHelper * helper;
|
||||
|
||||
Todo * todo;
|
||||
|
||||
/* widgets */
|
||||
GtkWidget * widget;
|
||||
GtkWidget * view;
|
||||
};
|
||||
|
||||
|
||||
/* protected */
|
||||
/* prototypes */
|
||||
/* plug-in */
|
||||
static MailerPlugin * _todo_init(MailerPluginHelper * helper);
|
||||
static void _todo_destroy(TodoPlugin * todo);
|
||||
static GtkWidget * _todo_get_widget(TodoPlugin * todo);
|
||||
|
||||
|
||||
/* public */
|
||||
/* variables */
|
||||
/* plug-in */
|
||||
MailerPluginDefinition plugin =
|
||||
{
|
||||
"Todo",
|
||||
"todo",
|
||||
NULL,
|
||||
_todo_init,
|
||||
_todo_destroy,
|
||||
_todo_get_widget,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
/* protected */
|
||||
/* functions */
|
||||
/* plug-in */
|
||||
/* todo_init */
|
||||
static MailerPlugin * _todo_init(MailerPluginHelper * helper)
|
||||
{
|
||||
TodoPlugin * todo;
|
||||
GtkWidget * widget;
|
||||
|
||||
if((todo = malloc(sizeof(*todo))) == NULL)
|
||||
return NULL;
|
||||
if((todo->todo = todo_new(NULL, NULL)) == NULL)
|
||||
{
|
||||
_todo_destroy(todo);
|
||||
return NULL;
|
||||
}
|
||||
todo->helper = helper;
|
||||
todo->widget = gtk_vbox_new(FALSE, 4);
|
||||
widget = todo_get_widget(todo->todo);
|
||||
gtk_box_pack_start(GTK_BOX(todo->widget), widget, TRUE, TRUE, 0);
|
||||
widget = gtk_scrolled_window_new(NULL, NULL);
|
||||
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(widget),
|
||||
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
todo->view = gtk_tree_view_new();
|
||||
gtk_container_add(GTK_CONTAINER(widget), todo->view);
|
||||
gtk_box_pack_start(GTK_BOX(todo->widget), widget, TRUE, TRUE, 0);
|
||||
gtk_widget_show_all(todo->widget);
|
||||
return todo;
|
||||
}
|
||||
|
||||
|
||||
/* todo_destroy */
|
||||
static void _todo_destroy(TodoPlugin * todo)
|
||||
{
|
||||
if(todo->todo != NULL)
|
||||
todo_delete(todo->todo);
|
||||
free(todo);
|
||||
}
|
||||
|
||||
|
||||
/* todo_get_widget */
|
||||
static GtkWidget * _todo_get_widget(TodoPlugin * todo)
|
||||
{
|
||||
return todo->widget;
|
||||
}
|
Loading…
Reference in New Issue
Block a user