Move the priority titles to a separate file
This commit is contained in:
parent
a23a9accc6
commit
e6cd781ba6
31
src/priority.c
Normal file
31
src/priority.c
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Copyright (c) 2015 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 "priority.h"
|
||||||
|
#define N_(string) (string)
|
||||||
|
|
||||||
|
|
||||||
|
/* variables */
|
||||||
|
TodoPriorityTitle priorities[] =
|
||||||
|
{
|
||||||
|
{ TODO_PRIORITY_UNKNOWN,N_("Unknown") },
|
||||||
|
{ TODO_PRIORITY_LOW, N_("Low") },
|
||||||
|
{ TODO_PRIORITY_MEDIUM, N_("Medium") },
|
||||||
|
{ TODO_PRIORITY_HIGH, N_("High") },
|
||||||
|
{ TODO_PRIORITY_URGENT, N_("Urgent") },
|
||||||
|
{ 0, NULL }
|
||||||
|
};
|
35
src/priority.h
Normal file
35
src/priority.h
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/* $Id$ */
|
||||||
|
/* Copyright (c) 2015 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_PRIORITY_H
|
||||||
|
# define TODO_PRIORITY_H
|
||||||
|
|
||||||
|
# include "todo.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* types */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
TodoPriority priority;
|
||||||
|
char const * title;
|
||||||
|
} TodoPriorityTitle;
|
||||||
|
|
||||||
|
|
||||||
|
/* variables */
|
||||||
|
extern TodoPriorityTitle priorities[];
|
||||||
|
|
||||||
|
#endif /* !TODO_PRIORITY_H */
|
|
@ -4,16 +4,19 @@ cflags_force=-W `pkg-config --cflags libDesktop`
|
||||||
cflags=-Wall -g -O2 -pedantic
|
cflags=-Wall -g -O2 -pedantic
|
||||||
ldflags_force=`pkg-config --libs libDesktop` -lintl
|
ldflags_force=`pkg-config --libs libDesktop` -lintl
|
||||||
ldflags=
|
ldflags=
|
||||||
dist=Makefile,task.h,taskedit.h,todo.h,window.h
|
dist=Makefile,priority.h,task.h,taskedit.h,todo.h,window.h
|
||||||
|
|
||||||
[todo]
|
[todo]
|
||||||
type=binary
|
type=binary
|
||||||
sources=task.c,taskedit.c,todo.c,window.c,main.c
|
sources=priority.c,task.c,taskedit.c,todo.c,window.c,main.c
|
||||||
install=$(BINDIR)
|
install=$(BINDIR)
|
||||||
|
|
||||||
[main.c]
|
[main.c]
|
||||||
depends=task.h,todo.h,../config.h
|
depends=task.h,todo.h,../config.h
|
||||||
|
|
||||||
|
[priority.c]
|
||||||
|
depends=todo.h,priority.h
|
||||||
|
|
||||||
[task.c]
|
[task.c]
|
||||||
depends=task.h
|
depends=task.h
|
||||||
cflags=-fPIC
|
cflags=-fPIC
|
||||||
|
@ -22,7 +25,7 @@ cflags=-fPIC
|
||||||
cflags=-fPIC
|
cflags=-fPIC
|
||||||
|
|
||||||
[todo.c]
|
[todo.c]
|
||||||
depends=task.h,todo.h,../config.h
|
depends=priority.h,task.h,todo.h,../config.h
|
||||||
cflags=-fPIC
|
cflags=-fPIC
|
||||||
|
|
||||||
[window.c]
|
[window.c]
|
||||||
|
|
33
src/todo.c
33
src/todo.c
|
@ -32,6 +32,7 @@ static char const _license[] =
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <System.h>
|
#include <System.h>
|
||||||
#include <Desktop.h>
|
#include <Desktop.h>
|
||||||
|
#include "priority.h"
|
||||||
#include "taskedit.h"
|
#include "taskedit.h"
|
||||||
#include "todo.h"
|
#include "todo.h"
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
|
@ -119,20 +120,6 @@ static const struct
|
||||||
{ 0, NULL, 0, NULL }
|
{ 0, NULL, 0, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct
|
|
||||||
{
|
|
||||||
unsigned int priority;
|
|
||||||
char const * title;
|
|
||||||
} _todo_priorities[] =
|
|
||||||
{
|
|
||||||
{ TODO_PRIORITY_UNKNOWN,N_("Unknown") },
|
|
||||||
{ TODO_PRIORITY_LOW, N_("Low") },
|
|
||||||
{ TODO_PRIORITY_MEDIUM, N_("Medium") },
|
|
||||||
{ TODO_PRIORITY_HIGH, N_("High") },
|
|
||||||
{ TODO_PRIORITY_URGENT, N_("Urgent") },
|
|
||||||
{ 0, NULL }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static char const * _authors[] =
|
static char const * _authors[] =
|
||||||
{
|
{
|
||||||
|
@ -240,12 +227,12 @@ static void _new_view(Todo * todo)
|
||||||
G_TYPE_STRING, /* display priority */
|
G_TYPE_STRING, /* display priority */
|
||||||
G_TYPE_STRING); /* category */
|
G_TYPE_STRING); /* category */
|
||||||
todo->priorities = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING);
|
todo->priorities = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING);
|
||||||
for(i = 0; _todo_priorities[i].title != NULL; i++)
|
for(i = 0; priorities[i].title != NULL; i++)
|
||||||
{
|
{
|
||||||
gtk_list_store_append(todo->priorities, &iter);
|
gtk_list_store_append(todo->priorities, &iter);
|
||||||
gtk_list_store_set(todo->priorities, &iter,
|
gtk_list_store_set(todo->priorities, &iter,
|
||||||
0, _todo_priorities[i].priority,
|
0, priorities[i].priority,
|
||||||
1, _(_todo_priorities[i].title), -1);
|
1, _(priorities[i].title), -1);
|
||||||
}
|
}
|
||||||
todo->filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(todo->store),
|
todo->filter = gtk_tree_model_filter_new(GTK_TREE_MODEL(todo->store),
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -485,10 +472,10 @@ Task * todo_task_add(Todo * todo, Task * task)
|
||||||
strftime(completion, sizeof(completion), "%c", &t);
|
strftime(completion, sizeof(completion), "%c", &t);
|
||||||
}
|
}
|
||||||
priority = task_get_priority(task);
|
priority = task_get_priority(task);
|
||||||
for(i = 0; priority != NULL && _todo_priorities[i].title != NULL; i++)
|
for(i = 0; priority != NULL && priorities[i].title != NULL; i++)
|
||||||
if(strcmp(_(_todo_priorities[i].title), priority) == 0)
|
if(strcmp(_(priorities[i].title), priority) == 0)
|
||||||
{
|
{
|
||||||
tp = _todo_priorities[i].priority;
|
tp = priorities[i].priority;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gtk_list_store_set(todo->store, &iter, TD_COL_TASK, task,
|
gtk_list_store_set(todo->store, &iter, TD_COL_TASK, task,
|
||||||
|
@ -933,10 +920,10 @@ void todo_task_set_priority(Todo * todo, GtkTreePath * path,
|
||||||
_todo_get_iter(todo, &iter, path);
|
_todo_get_iter(todo, &iter, path);
|
||||||
gtk_tree_model_get(model, &iter, TD_COL_TASK, &task, -1);
|
gtk_tree_model_get(model, &iter, TD_COL_TASK, &task, -1);
|
||||||
task_set_priority(task, priority);
|
task_set_priority(task, priority);
|
||||||
for(i = 0; _todo_priorities[i].title != NULL; i++)
|
for(i = 0; priorities[i].title != NULL; i++)
|
||||||
if(strcmp(_(_todo_priorities[i].title), priority) == 0)
|
if(strcmp(_(priorities[i].title), priority) == 0)
|
||||||
{
|
{
|
||||||
tp = _todo_priorities[i].priority;
|
tp = priorities[i].priority;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
gtk_list_store_set(todo->store, &iter, TD_COL_PRIORITY, tp,
|
gtk_list_store_set(todo->store, &iter, TD_COL_PRIORITY, tp,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user