Translating the project
This commit is contained in:
parent
ff438c54cf
commit
85bb56d79c
8
Makefile
8
Makefile
|
@ -1,6 +1,6 @@
|
|||
PACKAGE = Todo
|
||||
VERSION = 0.0.0
|
||||
SUBDIRS = data src
|
||||
SUBDIRS = data po src
|
||||
RM = rm -f
|
||||
LN = ln -f
|
||||
TAR = tar -czvf
|
||||
|
@ -24,6 +24,11 @@ dist:
|
|||
$(PACKAGE)-$(VERSION)/data/Makefile \
|
||||
$(PACKAGE)-$(VERSION)/data/todo.desktop \
|
||||
$(PACKAGE)-$(VERSION)/data/project.conf \
|
||||
$(PACKAGE)-$(VERSION)/po/Makefile \
|
||||
$(PACKAGE)-$(VERSION)/po/gettext.sh \
|
||||
$(PACKAGE)-$(VERSION)/po/POTFILES \
|
||||
$(PACKAGE)-$(VERSION)/po/fr.po \
|
||||
$(PACKAGE)-$(VERSION)/po/project.conf \
|
||||
$(PACKAGE)-$(VERSION)/src/todo.c \
|
||||
$(PACKAGE)-$(VERSION)/src/callbacks.c \
|
||||
$(PACKAGE)-$(VERSION)/src/main.c \
|
||||
|
@ -34,6 +39,7 @@ dist:
|
|||
$(PACKAGE)-$(VERSION)/Makefile \
|
||||
$(PACKAGE)-$(VERSION)/COPYING \
|
||||
$(PACKAGE)-$(VERSION)/config.h \
|
||||
$(PACKAGE)-$(VERSION)/config.sh \
|
||||
$(PACKAGE)-$(VERSION)/project.conf
|
||||
$(RM) $(PACKAGE)-$(VERSION)
|
||||
|
||||
|
|
5
config.sh
Normal file
5
config.sh
Normal file
|
@ -0,0 +1,5 @@
|
|||
PACKAGE="Todo"
|
||||
VERSION="0.0.0"
|
||||
|
||||
PREFIX="/usr/local"
|
||||
LIBDIR="${PREFIX}/lib"
|
30
po/Makefile
Normal file
30
po/Makefile
Normal file
|
@ -0,0 +1,30 @@
|
|||
TARGETS = Todo.pot fr.mo
|
||||
PREFIX = /usr/local
|
||||
DESTDIR =
|
||||
RM = rm -f
|
||||
LN = ln -f
|
||||
MKDIR = mkdir -p
|
||||
INSTALL = install
|
||||
|
||||
|
||||
all: $(TARGETS)
|
||||
|
||||
Todo.pot: POTFILES
|
||||
./gettext.sh "Todo.pot"
|
||||
|
||||
fr.mo: Todo.pot fr.po
|
||||
./gettext.sh "fr.mo"
|
||||
|
||||
clean:
|
||||
$(RM) $(Todo.pot_OBJS) $(fr.mo_OBJS)
|
||||
|
||||
distclean: clean
|
||||
$(RM) $(TARGETS)
|
||||
|
||||
install: all
|
||||
./gettext.sh -p "$(PREFIX)" install "fr.mo"
|
||||
|
||||
uninstall:
|
||||
./gettext.sh -p "$(PREFIX)" uninstall "fr.mo"
|
||||
|
||||
.PHONY: all clean distclean install uninstall
|
2
po/POTFILES
Normal file
2
po/POTFILES
Normal file
|
@ -0,0 +1,2 @@
|
|||
../src/main.c
|
||||
../src/todo.c
|
97
po/fr.po
Normal file
97
po/fr.po
Normal file
|
@ -0,0 +1,97 @@
|
|||
# $Id$
|
||||
# Copyright (c) 2010 Pierre Pronchery <khorben@defora.org>
|
||||
# This file is distributed under the same license as the Todo package.
|
||||
# Pierre Pronchery <khorben@defora.org>, 2010.
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Todo 0.0.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2010-04-23 14:45+0200\n"
|
||||
"PO-Revision-Date: 2010-04-23 14:35+0200\n"
|
||||
"Last-Translator: Pierre Pronchery <khorben@defora.org>\n"
|
||||
"Language-Team: French\n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
|
||||
#: ../src/main.c:43
|
||||
msgid "Usage: todo\n"
|
||||
msgstr "Usage: todo\n"
|
||||
|
||||
#: ../src/todo.c:64
|
||||
msgid "Done"
|
||||
msgstr "Effectuée"
|
||||
|
||||
#: ../src/todo.c:66
|
||||
msgid "Title"
|
||||
msgstr "Titre"
|
||||
|
||||
#: ../src/todo.c:68
|
||||
msgid "Beginning"
|
||||
msgstr "Départ"
|
||||
|
||||
#: ../src/todo.c:69
|
||||
msgid "Completion"
|
||||
msgstr "Fin"
|
||||
|
||||
#: ../src/todo.c:85
|
||||
msgid "_New"
|
||||
msgstr "_Nouvelle"
|
||||
|
||||
#: ../src/todo.c:86 ../src/todo.c:119
|
||||
msgid "_Edit"
|
||||
msgstr "Modifier"
|
||||
|
||||
#: ../src/todo.c:88
|
||||
msgid "_Close"
|
||||
msgstr "_Fermer"
|
||||
|
||||
#: ../src/todo.c:94 ../src/todo.c:97
|
||||
msgid "_Select all"
|
||||
msgstr "Tout sélectionner"
|
||||
|
||||
#: ../src/todo.c:101
|
||||
msgid "_Delete"
|
||||
msgstr "Supprimer"
|
||||
|
||||
#: ../src/todo.c:103
|
||||
msgid "_Preferences"
|
||||
msgstr "_Préférences"
|
||||
|
||||
#: ../src/todo.c:110 ../src/todo.c:112
|
||||
msgid "_About"
|
||||
msgstr "À _propos"
|
||||
|
||||
#: ../src/todo.c:118
|
||||
msgid "_File"
|
||||
msgstr "_Fichier"
|
||||
|
||||
#: ../src/todo.c:120
|
||||
msgid "_Help"
|
||||
msgstr "_Aide"
|
||||
|
||||
#: ../src/todo.c:128 ../src/todo.c:283
|
||||
msgid "New task"
|
||||
msgstr "Nouvelle tâche"
|
||||
|
||||
#: ../src/todo.c:129
|
||||
msgid "Edit task"
|
||||
msgstr "Modifier la tâche"
|
||||
|
||||
#: ../src/todo.c:132 ../src/todo.c:135
|
||||
msgid "Select all"
|
||||
msgstr "Tout sélectionner"
|
||||
|
||||
#: ../src/todo.c:138
|
||||
msgid "Delete task"
|
||||
msgstr "Supprimer la tâche"
|
||||
|
||||
#: ../src/todo.c:141
|
||||
msgid "Preferences"
|
||||
msgstr "Préférences"
|
||||
|
||||
#: ../src/todo.c:171
|
||||
msgid "Todo"
|
||||
msgstr "Todo"
|
100
po/gettext.sh
Executable file
100
po/gettext.sh
Executable file
|
@ -0,0 +1,100 @@
|
|||
#!/bin/sh
|
||||
#$Id$
|
||||
|
||||
|
||||
|
||||
#variables
|
||||
. "../config.sh"
|
||||
DEBUG="_debug"
|
||||
INSTALL="install -m 0644"
|
||||
LOCALEDIR="$PREFIX/share/locale"
|
||||
MKDIR="mkdir -p"
|
||||
MSGFMT="msgfmt"
|
||||
MSGINIT="msginit"
|
||||
MSGMERGE="msgmerge"
|
||||
RM="rm -f"
|
||||
POTFILES="POTFILES"
|
||||
XGETTEXT="xgettext --force-po"
|
||||
|
||||
|
||||
#functions
|
||||
#usage
|
||||
_usage()
|
||||
{
|
||||
echo "Usage: ./gettext.sh <target>" 1>&2
|
||||
echo " ./gettext.sh -p <prefix> install <target>" 1>&2
|
||||
echo " ./gettext.sh -p <prefix> uninstall <target>" 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
#debug
|
||||
_debug()
|
||||
{
|
||||
echo $@
|
||||
$@
|
||||
}
|
||||
|
||||
|
||||
#gettext_mo
|
||||
_gettext_mo()
|
||||
{
|
||||
package="$1"
|
||||
lang="$2"
|
||||
|
||||
if [ -f "$lang.po" ]; then
|
||||
$DEBUG $MSGMERGE -U "$lang.po" "$package.pot" || return 1
|
||||
else
|
||||
$DEBUG $MSGINIT -l "$lang" -o "$lang.po" -i "$package.pot" \
|
||||
|| return 1
|
||||
fi
|
||||
$DEBUG $MSGFMT -c -v -o "$lang.mo" "$lang.po" || return 1
|
||||
}
|
||||
|
||||
|
||||
#gettext_pot
|
||||
_gettext_pot()
|
||||
{
|
||||
package="$1"
|
||||
|
||||
$DEBUG $XGETTEXT -d "$package" -o "$package.pot" --keyword="_" \
|
||||
--keyword="N_" -f "$POTFILES" || return 1
|
||||
}
|
||||
|
||||
|
||||
#main
|
||||
if [ $# -eq 4 -a "$1" = "-p" ]; then
|
||||
PREFIX="$2"
|
||||
LOCALEDIR="$PREFIX/share/locale"
|
||||
lang="${4%%.mo}"
|
||||
|
||||
if [ "$3" = "install" ]; then
|
||||
$DEBUG $MKDIR "$LOCALEDIR/$lang/LC_MESSAGES" || exit 2
|
||||
$DEBUG $INSTALL "$4" \
|
||||
"$LOCALEDIR/$lang/LC_MESSAGES/$PACKAGE.mo" \
|
||||
|| exit 2
|
||||
exit 0
|
||||
elif [ "$3" = "uninstall" ]; then
|
||||
$DEBUG $RM "$LOCALEDIR/$lang/LC_MESSAGES/$PACKAGE.mo" \
|
||||
|| exit 2
|
||||
exit 0
|
||||
else
|
||||
echo "gettext.sh: $3: Unknown operation" 1>&2
|
||||
fi
|
||||
fi
|
||||
if [ $# -ne 1 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
case "$1" in
|
||||
*.mo)
|
||||
_gettext_mo "$PACKAGE" "${1%%.mo}" || exit 2
|
||||
;;
|
||||
*.pot)
|
||||
_gettext_pot "${1%%.pot}" || exit 2
|
||||
;;
|
||||
*)
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
exit 0
|
13
po/project.conf
Normal file
13
po/project.conf
Normal file
|
@ -0,0 +1,13 @@
|
|||
targets=Todo.pot,fr.mo
|
||||
dist=Makefile,gettext.sh,POTFILES,fr.po
|
||||
|
||||
[Todo.pot]
|
||||
type=script
|
||||
script=./gettext.sh
|
||||
depends=POTFILES
|
||||
|
||||
[fr.mo]
|
||||
type=script
|
||||
script=./gettext.sh
|
||||
install=
|
||||
depends=Todo.pot,fr.po
|
|
@ -1,6 +1,6 @@
|
|||
package=Todo
|
||||
version=0.0.0
|
||||
config=h
|
||||
config=h,sh
|
||||
|
||||
subdirs=data,src
|
||||
dist=Makefile,COPYING,config.h
|
||||
subdirs=data,po,src
|
||||
dist=Makefile,COPYING,config.h,config.sh
|
||||
|
|
|
@ -7,7 +7,7 @@ CPPFLAGSF= -I $(PREFIX)/include
|
|||
CPPFLAGS=
|
||||
CFLAGSF = -W `pkg-config gtk+-2.0 --cflags`
|
||||
CFLAGS = -Wall -g -O2 -pedantic
|
||||
LDFLAGSF= `pkg-config gtk+-2.0 --libs`
|
||||
LDFLAGSF= -L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib -lSystem -lDesktop `pkg-config gtk+-2.0 --libs`
|
||||
RM = rm -f
|
||||
LN = ln -f
|
||||
MKDIR = mkdir -p
|
||||
|
@ -18,7 +18,7 @@ all: $(TARGETS)
|
|||
|
||||
todo_OBJS = todo.o callbacks.o main.o
|
||||
todo_CFLAGS = $(CPPFLAGSF) $(CPPFLAGS) $(CFLAGSF) $(CFLAGS)
|
||||
todo_LDFLAGS = $(LDFLAGSF) $(LDFLAGS) -L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib -lSystem -lDesktop
|
||||
todo_LDFLAGS = $(LDFLAGSF) $(LDFLAGS)
|
||||
|
||||
todo: $(todo_OBJS)
|
||||
$(CC) -o todo $(todo_OBJS) $(todo_LDFLAGS)
|
||||
|
@ -29,7 +29,7 @@ todo.o: todo.c callbacks.h todo.h ../config.h
|
|||
callbacks.o: callbacks.c todo.h callbacks.h
|
||||
$(CC) $(todo_CFLAGS) -c callbacks.c
|
||||
|
||||
main.o: main.c todo.h
|
||||
main.o: main.c todo.h ../config.h
|
||||
$(CC) $(todo_CFLAGS) -c main.c
|
||||
|
||||
clean:
|
||||
|
|
23
src/main.c
23
src/main.c
|
@ -1,5 +1,5 @@
|
|||
/* $Id$ */
|
||||
/* Copyright (c) 2009 Pierre Pronchery <khorben@defora.org> */
|
||||
/* Copyright (c) 2010 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
|
||||
|
@ -17,14 +17,30 @@
|
|||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <locale.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include "todo.h"
|
||||
#include "../config.h"
|
||||
#define _(string) gettext(string)
|
||||
|
||||
|
||||
/* constants */
|
||||
#ifndef PREFIX
|
||||
# define PREFIX "/usr/local"
|
||||
#endif
|
||||
#ifndef DATADIR
|
||||
# define DATADIR PREFIX "/share"
|
||||
#endif
|
||||
#ifndef LOCALEDIR
|
||||
# define LOCALEDIR DATADIR "/locale"
|
||||
#endif
|
||||
|
||||
|
||||
/* usage */
|
||||
static int _usage(void)
|
||||
{
|
||||
fputs("Usage: todo\n", stderr);
|
||||
fputs(_("Usage: todo\n"), stderr);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -35,6 +51,9 @@ int main(int argc, char * argv[])
|
|||
int o;
|
||||
Todo * todo;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
gtk_init(&argc, &argv);
|
||||
while((o = getopt(argc, argv, "")) != -1)
|
||||
switch(o)
|
||||
|
|
|
@ -3,12 +3,11 @@ cppflags_force=-I $(PREFIX)/include
|
|||
#cppflags=-D EMBEDDED
|
||||
cflags_force=-W `pkg-config gtk+-2.0 --cflags`
|
||||
cflags=-Wall -g -O2 -pedantic
|
||||
ldflags_force=`pkg-config gtk+-2.0 --libs`
|
||||
ldflags_force=-L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib -lSystem -lDesktop `pkg-config gtk+-2.0 --libs`
|
||||
dist=Makefile,todo.h,callbacks.h
|
||||
|
||||
[todo]
|
||||
type=binary
|
||||
ldflags=-L $(PREFIX)/lib -Wl,-rpath,$(PREFIX)/lib -lSystem -lDesktop
|
||||
sources=todo.c,callbacks.c,main.c
|
||||
install=$(BINDIR)
|
||||
|
||||
|
@ -19,4 +18,4 @@ depends=callbacks.h,todo.h,../config.h
|
|||
depends=todo.h,callbacks.h
|
||||
|
||||
[main.c]
|
||||
depends=todo.h
|
||||
depends=todo.h,../config.h
|
||||
|
|
92
src/todo.c
92
src/todo.c
|
@ -1,6 +1,6 @@
|
|||
/* $Id$ */
|
||||
static char _copyright[] =
|
||||
"Copyright (c) 2009 Pierre Pronchery <khorben@defora.org>";
|
||||
"Copyright (c) 2010 Pierre Pronchery <khorben@defora.org>";
|
||||
/* This file is part of DeforaOS Desktop Todo */
|
||||
static char const _license[] =
|
||||
"This program is free software: you can redistribute it and/or modify\n"
|
||||
|
@ -20,6 +20,7 @@ static char const _license[] =
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <libintl.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <System.h>
|
||||
|
@ -27,6 +28,8 @@ static char const _license[] =
|
|||
#include "callbacks.h"
|
||||
#include "todo.h"
|
||||
#include "../config.h"
|
||||
#define _(string) gettext(string)
|
||||
#define N_(string) (string)
|
||||
|
||||
|
||||
/* Todo */
|
||||
|
@ -56,11 +59,14 @@ static struct
|
|||
char const * title;
|
||||
int sort;
|
||||
GCallback callback;
|
||||
} _todo_columns[] = {
|
||||
{ TD_COL_DONE, "Done", TD_COL_DONE, G_CALLBACK(on_task_done_toggled) },
|
||||
{ TD_COL_TITLE, "Title", TD_COL_TITLE, G_CALLBACK(on_task_title_edited) },
|
||||
{ TD_COL_DISPLAY_START, "Beginning", TD_COL_START, NULL },
|
||||
{ TD_COL_DISPLAY_END, "Completion", TD_COL_END, NULL },
|
||||
} _todo_columns[] =
|
||||
{
|
||||
{ TD_COL_DONE, N_("Done"), TD_COL_DONE, G_CALLBACK(
|
||||
on_task_done_toggled) },
|
||||
{ TD_COL_TITLE, N_("Title"), TD_COL_TITLE, G_CALLBACK(
|
||||
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 }
|
||||
};
|
||||
|
||||
|
@ -76,41 +82,42 @@ static char const * _authors[] =
|
|||
/* menubar */
|
||||
static DesktopMenu _file_menu[] =
|
||||
{
|
||||
{ "_New", G_CALLBACK(on_file_new), GTK_STOCK_NEW, GDK_N },
|
||||
{ "_Edit", G_CALLBACK(on_file_edit), GTK_STOCK_EDIT, GDK_E },
|
||||
{ N_("_New"), G_CALLBACK(on_file_new), GTK_STOCK_NEW, GDK_N },
|
||||
{ N_("_Edit"), G_CALLBACK(on_file_edit), GTK_STOCK_EDIT, GDK_E },
|
||||
{ "", NULL, NULL, 0 },
|
||||
{ "_Close", G_CALLBACK(on_file_close), GTK_STOCK_CLOSE, GDK_W },
|
||||
{ N_("_Close"), G_CALLBACK(on_file_close), GTK_STOCK_CLOSE, GDK_W },
|
||||
{ NULL, NULL, NULL, 0 }
|
||||
};
|
||||
static DesktopMenu _edit_menu[] =
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2, 10, 0)
|
||||
{ "_Select all", G_CALLBACK(on_edit_select_all), GTK_STOCK_SELECT_ALL,
|
||||
{ N_("_Select all"), G_CALLBACK(on_edit_select_all),
|
||||
GTK_STOCK_SELECT_ALL,
|
||||
#else
|
||||
{ "_Select all", G_CALLBACK(on_edit_select_all), "edit-select-all",
|
||||
{ N_("_Select all"), G_CALLBACK(on_edit_select_all), "edit-select-all",
|
||||
#endif
|
||||
GDK_A },
|
||||
{ "", NULL, NULL, 0 },
|
||||
{ "_Delete", G_CALLBACK(on_edit_delete), GTK_STOCK_DELETE, 0 },
|
||||
{ N_("_Delete"), G_CALLBACK(on_edit_delete), GTK_STOCK_DELETE, 0 },
|
||||
{ "", NULL, NULL, 0 },
|
||||
{ "_Preferences", G_CALLBACK(on_edit_preferences), GTK_STOCK_PREFERENCES,
|
||||
GDK_P },
|
||||
{ N_("_Preferences"), G_CALLBACK(on_edit_preferences),
|
||||
GTK_STOCK_PREFERENCES, GDK_P },
|
||||
{ NULL, NULL, NULL, 0 }
|
||||
};
|
||||
static DesktopMenu _help_menu[] =
|
||||
{
|
||||
#if GTK_CHECK_VERSION(2, 6, 0)
|
||||
{ "_About", G_CALLBACK(on_help_about), GTK_STOCK_ABOUT, 0 },
|
||||
{ N_("_About"), G_CALLBACK(on_help_about), GTK_STOCK_ABOUT, 0 },
|
||||
#else
|
||||
{ "_About", G_CALLBACK(on_help_about), NULL, 0 },
|
||||
{ N_("_About"), G_CALLBACK(on_help_about), NULL, 0 },
|
||||
#endif
|
||||
{ NULL, NULL, NULL, 0 }
|
||||
};
|
||||
static DesktopMenubar _menubar[] =
|
||||
{
|
||||
{ "_File", _file_menu },
|
||||
{ "_Edit", _edit_menu },
|
||||
{ "_Help", _help_menu },
|
||||
{ N_("_File"), _file_menu },
|
||||
{ N_("_Edit"), _edit_menu },
|
||||
{ N_("_Help"), _help_menu },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
#endif
|
||||
|
@ -118,18 +125,21 @@ static DesktopMenubar _menubar[] =
|
|||
/* toolbar */
|
||||
static DesktopToolbar _toolbar[] =
|
||||
{
|
||||
{ "New task", G_CALLBACK(on_new), GTK_STOCK_NEW, 0, NULL },
|
||||
{ "Edit task", G_CALLBACK(on_edit), GTK_STOCK_EDIT, 0, NULL },
|
||||
{ N_("New task"), G_CALLBACK(on_new), GTK_STOCK_NEW, 0, NULL },
|
||||
{ N_("Edit task"), G_CALLBACK(on_edit), GTK_STOCK_EDIT, 0, NULL },
|
||||
{ "", NULL, NULL, 0, NULL },
|
||||
#if GTK_CHECK_VERSION(2, 10, 0)
|
||||
{ "Select all", G_CALLBACK(on_select_all), GTK_STOCK_SELECT_ALL, 0, NULL },
|
||||
{ N_("Select all"), G_CALLBACK(on_select_all), GTK_STOCK_SELECT_ALL, 0,
|
||||
NULL },
|
||||
#else
|
||||
{ "Select all", G_CALLBACK(on_select_all), "edit-select-all", 0, NULL },
|
||||
{ N_("Select all"), G_CALLBACK(on_select_all), "edit-select-all", 0,
|
||||
NULL },
|
||||
#endif
|
||||
{ "Delete task", G_CALLBACK(on_delete), GTK_STOCK_DELETE, 0, NULL },
|
||||
{ N_("Delete task"), G_CALLBACK(on_delete), GTK_STOCK_DELETE, 0, NULL },
|
||||
#ifdef EMBEDDED
|
||||
{ "", NULL, NULL, 0, NULL },
|
||||
{ "Preferences", G_CALLBACK(on_preferences), GTK_STOCK_PREFERENCES, 0, NULL },
|
||||
{ N_("Preferences"), G_CALLBACK(on_preferences), GTK_STOCK_PREFERENCES,
|
||||
0, NULL },
|
||||
#endif
|
||||
{ NULL, NULL, NULL, 0, NULL }
|
||||
};
|
||||
|
@ -158,7 +168,7 @@ Todo * todo_new(void)
|
|||
gtk_window_add_accel_group(GTK_WINDOW(todo->window), group);
|
||||
gtk_window_set_default_size(GTK_WINDOW(todo->window), 300, 400);
|
||||
gtk_window_set_icon_name(GTK_WINDOW(todo->window), "stock_todo");
|
||||
gtk_window_set_title(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), todo);
|
||||
vbox = gtk_vbox_new(FALSE, 0);
|
||||
|
@ -192,18 +202,20 @@ static void _new_view(Todo * todo)
|
|||
GtkCellRenderer * renderer;
|
||||
GtkTreeViewColumn * column;
|
||||
|
||||
todo->store = gtk_list_store_new(TD_NUM_COLS, G_TYPE_BOOLEAN, G_TYPE_STRING,
|
||||
G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING,
|
||||
G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING);
|
||||
todo->store = gtk_list_store_new(TD_NUM_COLS, G_TYPE_BOOLEAN,
|
||||
G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_UINT,
|
||||
G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_STRING);
|
||||
todo->view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(todo->store));
|
||||
if((sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(todo->view))) != NULL)
|
||||
if((sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(todo->view)))
|
||||
!= NULL)
|
||||
gtk_tree_selection_set_mode(sel, GTK_SELECTION_MULTIPLE);
|
||||
/* done column */
|
||||
renderer = gtk_cell_renderer_toggle_new();
|
||||
g_signal_connect(G_OBJECT(renderer), "toggled", G_CALLBACK(
|
||||
_todo_columns[0].callback), todo);
|
||||
column = gtk_tree_view_column_new_with_attributes(_todo_columns[0].title,
|
||||
renderer, "active", _todo_columns[0].col, NULL);
|
||||
column = gtk_tree_view_column_new_with_attributes(
|
||||
_(_todo_columns[0].title), renderer, "active",
|
||||
_todo_columns[0].col, NULL);
|
||||
gtk_tree_view_column_set_sizing(GTK_TREE_VIEW_COLUMN(column),
|
||||
GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_fixed_width(GTK_TREE_VIEW_COLUMN(column), 50);
|
||||
|
@ -215,12 +227,14 @@ static void _new_view(Todo * todo)
|
|||
renderer = gtk_cell_renderer_text_new();
|
||||
if(_todo_columns[i].callback != NULL)
|
||||
{
|
||||
g_object_set(G_OBJECT(renderer), "editable", TRUE, NULL);
|
||||
g_signal_connect(G_OBJECT(renderer), "edited", G_CALLBACK(
|
||||
_todo_columns[i].callback), todo);
|
||||
g_object_set(G_OBJECT(renderer), "editable", TRUE,
|
||||
NULL);
|
||||
g_signal_connect(G_OBJECT(renderer), "edited",
|
||||
G_CALLBACK(_todo_columns[i].callback),
|
||||
todo);
|
||||
}
|
||||
column = gtk_tree_view_column_new_with_attributes(
|
||||
_todo_columns[i].title, renderer, "text",
|
||||
_(_todo_columns[i].title), renderer, "text",
|
||||
_todo_columns[i].col, NULL);
|
||||
gtk_tree_view_column_set_sort_column_id(column,
|
||||
_todo_columns[i].sort);
|
||||
|
@ -266,7 +280,7 @@ void todo_task_add(Todo * todo)
|
|||
GtkTreeIter iter;
|
||||
|
||||
gtk_list_store_insert(todo->store, &iter, 0);
|
||||
gtk_list_store_set(todo->store, &iter, TD_COL_TITLE, "New task", -1);
|
||||
gtk_list_store_set(todo->store, &iter, TD_COL_TITLE, _("New task"), -1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -311,8 +325,8 @@ void todo_task_toggle_done(Todo * todo, GtkTreePath * path)
|
|||
gboolean done;
|
||||
|
||||
gtk_tree_model_get_iter(GTK_TREE_MODEL(todo->store), &iter, path);
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(todo->store), &iter, TD_COL_DONE, &done,
|
||||
-1);
|
||||
gtk_tree_model_get(GTK_TREE_MODEL(todo->store), &iter, TD_COL_DONE,
|
||||
&done, -1);
|
||||
done = !done;
|
||||
gtk_list_store_set(todo->store, &iter, TD_COL_DONE, done, -1);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user