Changed name from Collections to Eye on Manga

This commit is contained in:
Tom Willemsen 2010-10-21 21:00:26 +02:00
parent 4b153e25e4
commit 8a45361b4f
19 changed files with 419 additions and 414 deletions

1
src/.#eom.h Symbolic link
View file

@ -0,0 +1 @@
tom@tom-laptop.14670:1287677918

View file

@ -1,15 +1,15 @@
CFLAGS=`pkg-config hildon-1 sqlite3 --cflags --libs` CFLAGS=`pkg-config hildon-1 sqlite3 --cflags --libs`
all: all:
$(CC) -Wall -Wextra -pedantic \ $(CC) -Wall -pedantic \
collections.c \ eom.c \
interface.c \ interface.c \
c-main-window.c \ eom-main-window.c \
c-edit-window.c \ eom-edit-window.c \
c-new-item-dialog.c \ eom-new-item-dialog.c \
data.c \ data.c \
$(CFLAGS) \ $(CFLAGS) \
-o collections -o eye-on-manga
.PHONY: check-syntax .PHONY: check-syntax
check-syntax: check-syntax:

View file

@ -1,59 +0,0 @@
#ifndef __C_EDIT_WINDOW_H__
#define __C_EDIT_WINDOW_H__
#include <hildon/hildon-stackable-window.h>
G_BEGIN_DECLS
#define C_TYPE_EDIT_WINDOW \
(c_edit_window_get_type())
#define C_EDIT_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
C_TYPE_EDIT_WINDOW, \
CEditWindow))
#define C_EDIT_WINDOW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
C_TYPE_EDIT_WINDOW, \
CEditWindowClass))
#define C_IS_EDIT_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
C_TYPE_EDIT_WINDOW))
#define C_IS_EDIT_WINDOW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
C_TYPE_EDIT_WINDOW))
#define C_EDIT_WINDOW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
C_TYPE_EDIT_WINDOW, \
CEditWindowClass))
typedef struct _CEditWindow CEditWindow;
typedef struct _CEditWindowClass CEditWindowClass;
struct _CEditWindowClass
{
HildonStackableWindowClass parent_class;
};
struct _CEditWindow
{
HildonStackableWindow parent;
GtkWidget *name_label;
GtkWidget *have_label;
GtkWidget *total_label;
gint collection_id;
};
GType c_edit_window_get_type(void);
GtkWidget *c_edit_window_new(gint collection_id);
G_END_DECLS
#endif /* __C_EDIT_WINDOW_H__ */

View file

@ -1,70 +0,0 @@
#ifndef __C_MAIN_WINDOW_H__
#define __C_MAIN_WINDOW_H__
#include <hildon/hildon-stackable-window.h>
G_BEGIN_DECLS
#define C_TYPE_MAIN_WINDOW \
(c_main_window_get_type())
#define C_MAIN_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
C_TYPE_MAIN_WINDOW, \
CMainWindow))
#define C_MAIN_WINDOW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
C_TYPE_MAIN_WINDOW, \
CMainWindowClass))
#define C_IS_MAIN_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
C_TYPE_MAIN_WINDOW))
#define C_IS_MAIN_WINDOW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
C_TYPE_MAIN_WINDOW))
#define C_MAIN_WINDOW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
C_TYPE_MAIN_WINDOW, \
CMainWindowClass))
typedef struct _CMainWindow CMainWindow;
typedef struct _CMainWindowClass CMainWindowClass;
struct _CMainWindowClass
{
HildonStackableWindowClass parent_class;
};
struct _CMainWindow
{
HildonStackableWindow parent;
GtkTreeIter iter;
GtkListStore *store;
GtkTreeSelection *selection;
GtkWidget *add_button;
GtkWidget *remove_button;
GtkWidget *edit_button;
};
GType c_main_window_get_type(void);
GtkWidget *c_main_window_new(void);
void c_main_window_load(CMainWindow *self);
void c_main_window_add_line(CMainWindow *window,
gint id,
const gchar *name,
gint current_qty,
gint total_qty);
void c_main_window_set_no_select(CMainWindow *self);
void c_main_window_set_has_select(CMainWindow *self);
G_END_DECLS
#endif /* __C_MAIN_WINDOW_H__ */

View file

@ -1,60 +0,0 @@
#ifndef __C_NEW_ITEM_DIALOG_H__
#define __C_NEW_ITEM_DIALOG_H__
#include <gtk/gtkdialog.h>
G_BEGIN_DECLS
#define C_TYPE_NEW_ITEM_DIALOG \
(c_new_item_dialog_get_type())
#define C_NEW_ITEM_DIALOG(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
C_TYPE_NEW_ITEM_DIALOG, \
CNewItemDialog))
#define C_NEW_ITEM_DIALOG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
C_TYPE_NEW_ITEM_DIALOG, \
CNewItemDialogClass))
#define C_IS_NEW_ITEM_DIALOG(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
C_TYPE_NEW_ITEM_DIALOG))
#define C_IS_NEW_ITEM_DIALOG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
C_TYPE_NEW_ITEM_DIALOG))
#define C_NEW_ITEM_DIALOG_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
C_TYPE_NEW_ITEM_DIALOG, \
CNewItemDialogClass))
typedef struct _CNewItemDialog CNewItemDialog;
typedef struct _CNewItemDialogClass CNewItemDialogClass;
struct _CNewItemDialogClass
{
GtkDialogClass parent_class;
};
struct _CNewItemDialog
{
GtkDialog parent;
GtkWidget *name_entry;
GtkWidget *qty_entry;
};
GType c_new_item_dialog_get_type(void);
GtkWidget *c_new_item_dialog_new(void);
const gchar *c_new_item_dialog_get_name(CNewItemDialog *dialog);
gint c_new_item_dialog_get_total_qty(CNewItemDialog *dialog);
G_END_DECLS
#endif /* __C_NEW_ITEM_DIALOG_H__ */

View file

@ -1,2 +0,0 @@
gchar *collections_get_data_file(void);
gchar *collections_get_config_dir(void);

View file

@ -6,41 +6,41 @@
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include "collections.h" #include "eom.h"
static gboolean data_check_and_create_database(gchar *data_file); static gboolean data_check_and_create_database(gchar *data_file);
static gint data_create_new_database(const gchar *filename); static gint data_create_new_database(const gchar *filename);
static struct collection *data_get_collection_from_stmt(sqlite3_stmt *stmt); static Manga *data_get_manga_from_statement(sqlite3_stmt *stmt);
GList *data_get_series(void) GList *data_get_manga(void)
{ {
sqlite3 *database; sqlite3 *database;
sqlite3_stmt *statement; sqlite3_stmt *statement;
gchar *data_file; gchar *data_file;
GList *list = NULL; GList *list = NULL;
data_file = collections_get_data_file(); data_file = eom_get_data_file();
if (data_check_and_create_database(data_file)) { if (data_check_and_create_database(data_file)) {
if (sqlite3_open(data_file, &database) == SQLITE_OK) { if (sqlite3_open(data_file, &database) == SQLITE_OK) {
int res; int res;
const char *sqlStatement = const char *sql =
" SELECT id, " " SELECT id, "
" name, " " name, "
" current_qty, " " current_qty, "
" total_qty " " total_qty "
" FROM collection " " FROM manga "
" ORDER BY name " " ORDER BY name "
" COLLATE NOCASE "; " COLLATE NOCASE ";
res = sqlite3_prepare_v2(database, res = sqlite3_prepare_v2(database,
sqlStatement, sql,
strlen(sqlStatement), strlen(sql),
&statement, NULL); &statement, NULL);
if (res == SQLITE_OK) { if (res == SQLITE_OK) {
while (sqlite3_step(statement) == SQLITE_ROW) { while (sqlite3_step(statement) == SQLITE_ROW) {
struct collection *col = data_get_collection_from_stmt(statement); Manga *manga = data_get_manga_from_statement(statement);
list = g_list_append(list, (gpointer)col); list = g_list_append(list, (gpointer)manga);
} }
} }
else else
@ -54,14 +54,14 @@ GList *data_get_series(void)
return list; return list;
} }
struct collection *data_get_series_by_id(gint collection_id) Manga *data_get_manga_by_id(gint manga_id)
{ {
sqlite3 *database; sqlite3 *database;
sqlite3_stmt *statement; sqlite3_stmt *statement;
gchar *data_file; gchar *data_file;
struct collection *col = NULL; Manga *manga = NULL;
data_file = collections_get_data_file(); data_file = eom_get_data_file();
if (data_check_and_create_database(data_file)) { if (data_check_and_create_database(data_file)) {
if (sqlite3_open(data_file, &database) == SQLITE_OK) { if (sqlite3_open(data_file, &database) == SQLITE_OK) {
@ -71,13 +71,13 @@ struct collection *data_get_series_by_id(gint collection_id)
" name, " " name, "
" current_qty, " " current_qty, "
" total_qty " " total_qty "
" FROM collection " " FROM manga "
" WHERE id = %d ", collection_id); " WHERE id = %d ", manga_id);
res = sqlite3_prepare_v2(database, sql, strlen(sql), &statement, NULL); res = sqlite3_prepare_v2(database, sql, strlen(sql), &statement, NULL);
if (res == SQLITE_OK) { if (res == SQLITE_OK) {
if (sqlite3_step(statement) == SQLITE_ROW) { if (sqlite3_step(statement) == SQLITE_ROW) {
col = data_get_collection_from_stmt(statement); manga = data_get_manga_from_statement(statement);
} }
} }
sqlite3_finalize(statement); sqlite3_finalize(statement);
@ -85,10 +85,10 @@ struct collection *data_get_series_by_id(gint collection_id)
sqlite3_close(database); sqlite3_close(database);
} }
return col; return manga;
} }
gint *data_get_items_by_collection_id(gint collection_id) gint *data_get_volumes_by_manga_id(gint manga_id)
{ {
gint count; gint count;
gint *volumes; gint *volumes;
@ -96,16 +96,16 @@ gint *data_get_items_by_collection_id(gint collection_id)
sqlite3_stmt *statement; sqlite3_stmt *statement;
gchar *data_file; gchar *data_file;
data_file = collections_get_data_file(); data_file = eom_get_data_file();
count = 0; count = 0;
if (data_check_and_create_database(data_file)) { if (data_check_and_create_database(data_file)) {
if (sqlite3_open(data_file, &database) == SQLITE_OK) { if (sqlite3_open(data_file, &database) == SQLITE_OK) {
int res; int res;
const char *sql = g_strdup_printf( const char *sql = g_strdup_printf(
" SELECT COUNT(id) " " SELECT COUNT(number) "
" FROM items " " FROM volume "
" WHERE collection_id = %d ", collection_id); " WHERE collection_id = %d ", manga_id);
res = sqlite3_prepare_v2(database, sql, strlen(sql), &statement, NULL); res = sqlite3_prepare_v2(database, sql, strlen(sql), &statement, NULL);
if (res == SQLITE_OK) { if (res == SQLITE_OK) {
@ -117,9 +117,9 @@ gint *data_get_items_by_collection_id(gint collection_id)
if (count > 0) { if (count > 0) {
sql = g_strdup_printf( sql = g_strdup_printf(
" SELECT id " " SELECT number "
" FROM items " " FROM volume "
" WHERE collection_id = %d ", collection_id); " WHERE collection_id = %d ", manga_id);
res = sqlite3_prepare_v2(database, sql, strlen(sql), &statement, NULL); res = sqlite3_prepare_v2(database, sql, strlen(sql), &statement, NULL);
if (res == SQLITE_OK) { if (res == SQLITE_OK) {
@ -136,7 +136,7 @@ gint *data_get_items_by_collection_id(gint collection_id)
return volumes; return volumes;
} }
gboolean data_add_series(gchar *name, gint total_qty) gboolean data_add_manga(gchar *name, gint total_qty)
{ {
sqlite3 *database; sqlite3 *database;
sqlite3_stmt *statement; sqlite3_stmt *statement;
@ -144,18 +144,18 @@ gboolean data_add_series(gchar *name, gint total_qty)
gboolean result; gboolean result;
result = FALSE; result = FALSE;
data_file = collections_get_data_file(); data_file = eom_get_data_file();
if (data_check_and_create_database(data_file)) { if (data_check_and_create_database(data_file)) {
if (sqlite3_open(data_file, &database) == SQLITE_OK) { if (sqlite3_open(data_file, &database) == SQLITE_OK) {
int res; int res;
const char *sqlStatement = const char *sql = g_strdup_printf(
g_strdup_printf("INSERT INTO collection (name, current_qty, total_qty) " " INSERT INTO manga (name, current_qty, total_qty) "
" VALUES ('%s', 0, %d)", name, total_qty); " VALUES ('%s', 0, %d)", name, total_qty);
res = sqlite3_prepare_v2(database, res = sqlite3_prepare_v2(database,
sqlStatement, sql,
strlen(sqlStatement), strlen(sql),
&statement, NULL); &statement, NULL);
if (res == SQLITE_OK) { if (res == SQLITE_OK) {
if (sqlite3_step(statement) == SQLITE_DONE) if (sqlite3_step(statement) == SQLITE_DONE)
@ -169,27 +169,27 @@ gboolean data_add_series(gchar *name, gint total_qty)
return result; return result;
} }
gboolean data_add_to_series(gint collection_id, gint count) gboolean data_add_to_manga(gint manga_id, gint count)
{ {
sqlite3 *database; sqlite3 *database;
sqlite3_stmt *statement; sqlite3_stmt *statement;
gchar *data_file; gchar *data_file;
gboolean result; gboolean result;
data_file = collections_get_data_file(); data_file = eom_get_data_file();
result = FALSE; result = FALSE;
if (data_check_and_create_database(data_file)) { if (data_check_and_create_database(data_file)) {
if (sqlite3_open(data_file, &database) == SQLITE_OK) { if (sqlite3_open(data_file, &database) == SQLITE_OK) {
int res; int res;
const char *sqlStatement = const char *sql = g_strdup_printf(
g_strdup_printf("UPDATE collection " " UPDATE manga "
" SET current_qty = current_qty + %d " " SET current_qty = current_qty + %d "
" WHERE id = %d", count, collection_id); " WHERE id = %d", count, manga_id);
res = sqlite3_prepare_v2(database, res = sqlite3_prepare_v2(database,
sqlStatement, sql,
strlen(sqlStatement), strlen(sql),
&statement, NULL); &statement, NULL);
if (res == SQLITE_OK) { if (res == SQLITE_OK) {
if (sqlite3_step(statement) == SQLITE_DONE) if (sqlite3_step(statement) == SQLITE_DONE)
@ -220,8 +220,8 @@ static gint data_create_new_database(const gchar *filename)
char *zErrMsg = 0; char *zErrMsg = 0;
int rc; int rc;
if (access(collections_get_config_dir(), R_OK) == -1) { if (access(eom_get_config_dir(), R_OK) == -1) {
if (mkdir(collections_get_config_dir(), S_IRWXU) == -1) if (mkdir(eom_get_config_dir(), S_IRWXU) == -1)
g_printerr("Can't create directory: %s\n", strerror(errno)); g_printerr("Can't create directory: %s\n", strerror(errno));
} }
@ -235,30 +235,30 @@ static gint data_create_new_database(const gchar *filename)
} }
/* Create collections table */ /* Create collections table */
rc = sqlite3_exec(db, "CREATE TABLE collection(" rc = sqlite3_exec(db, "CREATE TABLE manga("
"id INTEGER PRIMARY KEY," "id INTEGER PRIMARY KEY,"
"name VARCHAR(100)," "name VARCHAR(100),"
"current_qty INTEGER," "current_qty INTEGER,"
"total_qty INTEGER" "total_qty INTEGER"
")", NULL, NULL, &zErrMsg); ")", NULL, NULL, &zErrMsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
g_printerr("Can't create collection table: %s\n", zErrMsg); g_printerr("Can't create manga table: %s\n", zErrMsg);
sqlite3_free(zErrMsg); sqlite3_free(zErrMsg);
sqlite3_close(db); sqlite3_close(db);
return -1; return -1;
} }
/* Create items table */ /* Create items table */
rc = sqlite3_exec(db, "CREATE TABLE item(" rc = sqlite3_exec(db,
" CREATE TABLE volume( "
" collection_id INTEGER, " " collection_id INTEGER, "
" id INTEGER, " " id INTEGER, "
"title VARCHAR(100),"
" PRIMARY KEY(collection_id, id), " " PRIMARY KEY(collection_id, id), "
" FOREIGN KEY(collection_id) " " FOREIGN KEY(collection_id) "
" REFERENCES collection(id)" " REFERENCES collection(id)) ",
")", NULL, NULL, &zErrMsg); NULL, NULL, &zErrMsg);
if (rc != SQLITE_OK) { if (rc != SQLITE_OK) {
g_printerr("Can't create item table: %s\n", zErrMsg); g_printerr("Can't create volume table: %s\n", zErrMsg);
sqlite3_free(zErrMsg); sqlite3_free(zErrMsg);
sqlite3_close(db); sqlite3_close(db);
return -1; return -1;
@ -268,15 +268,15 @@ static gint data_create_new_database(const gchar *filename)
return 0; return 0;
} }
static struct collection *data_get_collection_from_stmt(sqlite3_stmt *stmt) static Manga *data_get_manga_from_statement(sqlite3_stmt *stmt)
{ {
struct collection *collection = Manga *manga =
(struct collection *)malloc(sizeof(struct collection)); (Manga *)malloc(sizeof(Manga));
collection->id = sqlite3_column_int(stmt, 0); manga->id = sqlite3_column_int(stmt, 0);
collection->name = g_strdup(sqlite3_column_text(stmt, 1)); manga->name = g_strdup(sqlite3_column_text(stmt, 1));
collection->current_qty = sqlite3_column_int(stmt, 2); manga->current_qty = sqlite3_column_int(stmt, 2);
collection->total_qty = sqlite3_column_int(stmt, 3); manga->total_qty = sqlite3_column_int(stmt, 3);
return collection; return manga;
} }

View file

@ -1,6 +1,8 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
struct collection typedef struct _manga Manga;
struct _manga
{ {
int id; int id;
int current_qty; int current_qty;
@ -8,8 +10,8 @@ struct collection
char *name; char *name;
}; };
GList *data_get_series(void); GList *data_get_manga(void);
struct collection *data_get_series_by_id(gint collection_id); Manga *data_get_manga_by_id(gint manga_id);
gint *data_get_items_by_collection_id(gint collection_id); gint *data_get_volumes_by_manga_id(gint manga_id);
gboolean data_add_series(gchar *name, gint total_qty); gboolean data_add_manga(gchar *name, gint total_qty);
gboolean data_add_to_series(gint id, gint count); gboolean data_add_to_manga(gint id, gint count);

View file

@ -1,35 +1,35 @@
#include "c-edit-window.h" #include "eom-edit-window.h"
#include <hildon/hildon.h> #include <hildon/hildon.h>
#include <limits.h> #include <limits.h>
#include "data.h" #include "data.h"
enum { enum {
C_EDIT_PROP_0, EOM_EDIT_PROP_0,
C_EDIT_PROP_CID EOM_EDIT_PROP_CID
}; };
static void c_edit_window_set_collection_id(CEditWindow *self, static void eom_edit_window_set_manga_id(EomEditWindow *self,
gint collection_id); gint manga_id);
G_DEFINE_TYPE(CEditWindow, c_edit_window, HILDON_TYPE_STACKABLE_WINDOW) G_DEFINE_TYPE(EomEditWindow, eom_edit_window, HILDON_TYPE_STACKABLE_WINDOW)
GtkWidget *c_edit_window_new(gint collection_id) GtkWidget *eom_edit_window_new(gint manga_id)
{ {
g_print("1: %d\n", collection_id); g_print("1: %d\n", manga_id);
return g_object_new(C_TYPE_EDIT_WINDOW, "collection-id", collection_id, NULL); return g_object_new(EOM_TYPE_EDIT_WINDOW, "manga-id", manga_id, NULL);
} }
static void c_edit_window_set_property(GObject *object, static void eom_edit_window_set_property(GObject *object,
guint property_id, guint property_id,
const GValue *value, const GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
CEditWindow *self = C_EDIT_WINDOW(object); EomEditWindow *self = EOM_EDIT_WINDOW(object);
switch (property_id) { switch (property_id) {
case C_EDIT_PROP_CID: case EOM_EDIT_PROP_CID:
g_print("2: %d\n", g_value_get_int(value)); g_print("2: %d\n", g_value_get_int(value));
self->collection_id = g_value_get_int(value); self->manga_id = g_value_get_int(value);
break; break;
default: default:
/* We don't have any other properties */ /* We don't have any other properties */
@ -38,16 +38,16 @@ static void c_edit_window_set_property(GObject *object,
} }
} }
static void c_edit_window_get_property(GObject *object, static void eom_edit_window_get_property(GObject *object,
guint property_id, guint property_id,
GValue *value, GValue *value,
GParamSpec *pspec) GParamSpec *pspec)
{ {
CEditWindow *self = C_EDIT_WINDOW(object); EomEditWindow *self = EOM_EDIT_WINDOW(object);
switch (property_id) { switch (property_id) {
case C_EDIT_PROP_CID: case EOM_EDIT_PROP_CID:
g_value_set_int(value, self->collection_id); g_value_set_int(value, self->manga_id);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
@ -55,27 +55,27 @@ static void c_edit_window_get_property(GObject *object,
} }
} }
static void c_edit_window_class_init(CEditWindowClass *klass) static void eom_edit_window_class_init(EomEditWindowClass *klass)
{ {
GObjectClass *gobject_class = G_OBJECT_CLASS(klass); GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
GParamSpec *pspec; GParamSpec *pspec;
gobject_class->set_property = c_edit_window_set_property; gobject_class->set_property = eom_edit_window_set_property;
gobject_class->get_property = c_edit_window_get_property; gobject_class->get_property = eom_edit_window_get_property;
pspec = g_param_spec_int("collection-id", pspec = g_param_spec_int("manga-id",
"ID for the collection", "ID of the manga",
"Set the collection-id", "Set the manga-id",
0, 0,
INT_MAX, INT_MAX,
0, 0,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE); G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE);
g_object_class_install_property(gobject_class, g_object_class_install_property(gobject_class,
C_EDIT_PROP_CID, EOM_EDIT_PROP_CID,
pspec); pspec);
} }
static void c_edit_window_init(CEditWindow *self) static void eom_edit_window_init(EomEditWindow *self)
{ {
GtkWidget *pannablearea; GtkWidget *pannablearea;
GtkWidget *table; GtkWidget *table;
@ -84,7 +84,7 @@ static void c_edit_window_init(CEditWindow *self)
GtkWidget *totalclabel; GtkWidget *totalclabel;
GtkWidget *vbox; GtkWidget *vbox;
g_print("3: %d\n", self->collection_id); g_print("3: %d\n", self->manga_id);
pannablearea = hildon_pannable_area_new(); pannablearea = hildon_pannable_area_new();
g_object_set(G_OBJECT(pannablearea), g_object_set(G_OBJECT(pannablearea),
@ -131,20 +131,20 @@ static void c_edit_window_init(CEditWindow *self)
GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
} }
static void c_edit_window_set_collection_id(CEditWindow *self, static void eom_edit_window_set_manga_id(EomEditWindow *self,
gint collection_id) gint manga_id)
{ {
struct collection *col; Manga *manga;
gint *items; gint *volumes;
col = data_get_series_by_id(collection_id); manga = data_get_manga_by_id(manga_id);
items = data_get_items_by_collection_id(collection_id); volumes = data_get_volumes_by_manga_id(manga_id);
gtk_label_set_text(GTK_LABEL(self->name_label), col->name); gtk_label_set_text(GTK_LABEL(self->name_label), manga->name);
gtk_label_set_text(GTK_LABEL(self->have_label), gtk_label_set_text(GTK_LABEL(self->have_label),
g_strdup_printf("%d", col->current_qty)); g_strdup_printf("%d", manga->current_qty));
gtk_label_set_text(GTK_LABEL(self->total_label), gtk_label_set_text(GTK_LABEL(self->total_label),
g_strdup_printf("%d", col->total_qty)); g_strdup_printf("%d", manga->total_qty));
g_free(col); g_free(manga);
} }

59
src/eom-edit-window.h Normal file
View file

@ -0,0 +1,59 @@
#ifndef __EOM_EDIT_WINDOW_H__
#define __EOM_EDIT_WINDOW_H__
#include <hildon/hildon-stackable-window.h>
G_BEGIN_DECLS
#define EOM_TYPE_EDIT_WINDOW \
(eom_edit_window_get_type())
#define EOM_EDIT_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
EOM_TYPE_EDIT_WINDOW, \
EomEditWindow))
#define EOM_EDIT_WINDOW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
EOM_TYPE_EDIT_WINDOW, \
EomEditWindowClass))
#define EOM_IS_EDIT_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
EOM_TYPE_EDIT_WINDOW))
#define EOM_IS_EDIT_WINDOW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
EOM_TYPE_EDIT_WINDOW))
#define EOM_EDIT_WINDOW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
EOM_TYPE_EDIT_WINDOW, \
EomEditWindowClass))
typedef struct _EomEditWindow EomEditWindow;
typedef struct _EomEditWindowClass EomEditWindowClass;
struct _EomEditWindowClass
{
HildonStackableWindowClass parent_class;
};
struct _EomEditWindow
{
HildonStackableWindow parent;
GtkWidget *name_label;
GtkWidget *have_label;
GtkWidget *total_label;
gint manga_id;
};
GType eom_edit_window_get_type(void);
GtkWidget *eom_edit_window_new(gint manga_id);
G_END_DECLS
#endif /* __EOM_EDIT_WINDOW_H__ */

View file

@ -1,13 +1,13 @@
#include "c-main-window.h" #include "eom-main-window.h"
#include <hildon/hildon.h> #include <hildon/hildon.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "c-new-item-dialog.h" #include "eom-new-item-dialog.h"
#include "data.h" #include "data.h"
#include "interface.h" #include "interface.h"
G_DEFINE_TYPE(CMainWindow, c_main_window, HILDON_TYPE_STACKABLE_WINDOW) G_DEFINE_TYPE(EomMainWindow, eom_main_window, HILDON_TYPE_STACKABLE_WINDOW)
enum { enum {
COL_ID = 0, COL_ID = 0,
@ -17,40 +17,41 @@ enum {
NUM_COLS NUM_COLS
}; };
static void c_main_window_add_menu(CMainWindow *window); static void eom_main_window_add_menu(EomMainWindow *window);
static void c_main_window_on_new(GtkWidget *widget, GtkWindow *window); static void eom_main_window_on_new(GtkWidget *widget, GtkWindow *window);
static void c_main_window_on_selection_changed(GtkTreeSelection *selection, static void eom_main_window_on_selection_changed(GtkTreeSelection *selection,
gpointer user_data); gpointer user_data);
static void c_main_window_on_add_clicked(GtkWidget *widget, gpointer user_data); static void eom_main_window_on_add_clicked(GtkWidget *widget,
static void c_main_window_on_remove_clicked(GtkWidget *widget,
gpointer user_data); gpointer user_data);
static void c_main_window_on_edit_clicked(GtkWidget *widget, static void eom_main_window_on_remove_clicked(GtkWidget *widget,
gpointer user_data);
static void eom_main_window_on_edit_clicked(GtkWidget *widget,
gpointer user_data); gpointer user_data);
GtkWidget *c_main_window_new(void) GtkWidget *eom_main_window_new(void)
{ {
return g_object_new(C_TYPE_MAIN_WINDOW, NULL); return g_object_new(EOM_TYPE_MAIN_WINDOW, NULL);
} }
void c_main_window_load(CMainWindow *self) void eom_main_window_load(EomMainWindow *self)
{ {
GList *list; GList *list;
gtk_list_store_clear(self->store); gtk_list_store_clear(self->store);
list = data_get_series(); list = data_get_manga();
while (list) { while (list) {
struct collection *col = list->data; Manga *manga = list->data;
c_main_window_add_line(self, col->id, col->name, eom_main_window_add_line(self, manga->id, manga->name,
col->current_qty, col->total_qty); manga->current_qty, manga->total_qty);
list = g_list_next(list); list = g_list_next(list);
} }
g_list_free_1(list); g_list_free_1(list);
} }
void c_main_window_add_line(CMainWindow *window, void eom_main_window_add_line(EomMainWindow *window,
gint id, gint id,
const gchar *name, const gchar *name,
gint current_qty, gint current_qty,
@ -65,7 +66,7 @@ void c_main_window_add_line(CMainWindow *window,
-1); -1);
} }
void c_main_window_set_no_select(CMainWindow *self) void eom_main_window_set_no_select(EomMainWindow *self)
{ {
if (GTK_IS_WIDGET(self->add_button)) if (GTK_IS_WIDGET(self->add_button))
gtk_widget_set_sensitive(GTK_WIDGET(self->add_button), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(self->add_button), FALSE);
@ -73,7 +74,7 @@ void c_main_window_set_no_select(CMainWindow *self)
gtk_widget_set_sensitive(GTK_WIDGET(self->remove_button), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(self->remove_button), FALSE);
} }
void c_main_window_set_has_select(CMainWindow *self) void eom_main_window_set_has_select(EomMainWindow *self)
{ {
if (GTK_IS_WIDGET(self->add_button)) if (GTK_IS_WIDGET(self->add_button))
gtk_widget_set_sensitive(GTK_WIDGET(self->add_button), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(self->add_button), TRUE);
@ -81,10 +82,10 @@ void c_main_window_set_has_select(CMainWindow *self)
gtk_widget_set_sensitive(GTK_WIDGET(self->remove_button), TRUE); gtk_widget_set_sensitive(GTK_WIDGET(self->remove_button), TRUE);
} }
static void c_main_window_class_init(CMainWindowClass *class) static void eom_main_window_class_init(EomMainWindowClass *class)
{} {}
static void c_main_window_init(CMainWindow *window) static void eom_main_window_init(EomMainWindow *window)
{ {
GtkCellRenderer *renderer; GtkCellRenderer *renderer;
GtkWidget *view; GtkWidget *view;
@ -96,7 +97,7 @@ static void c_main_window_init(CMainWindow *window)
index = -1; index = -1;
c_main_window_add_menu(window); eom_main_window_add_menu(window);
g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL); g_signal_connect(window, "delete-event", G_CALLBACK(gtk_main_quit), NULL);
@ -121,7 +122,7 @@ static void c_main_window_init(CMainWindow *window)
window->selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view)); window->selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
g_signal_connect(window->selection, "changed", g_signal_connect(window->selection, "changed",
G_CALLBACK(c_main_window_on_selection_changed), G_CALLBACK(eom_main_window_on_selection_changed),
(gpointer)window); (gpointer)window);
renderer = gtk_cell_renderer_text_new(); renderer = gtk_cell_renderer_text_new();
@ -173,7 +174,7 @@ static void c_main_window_init(CMainWindow *window)
"Add", "Add",
NULL); NULL);
g_signal_connect(window->add_button, "clicked", g_signal_connect(window->add_button, "clicked",
G_CALLBACK(c_main_window_on_add_clicked), G_CALLBACK(eom_main_window_on_add_clicked),
(gpointer)window); (gpointer)window);
gtk_box_pack_start(GTK_BOX(hbuttonbox), window->add_button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbuttonbox), window->add_button, FALSE, FALSE, 0);
@ -184,7 +185,7 @@ static void c_main_window_init(CMainWindow *window)
"Edit", "Edit",
NULL); NULL);
g_signal_connect(window->edit_button, "clicked", g_signal_connect(window->edit_button, "clicked",
G_CALLBACK(c_main_window_on_edit_clicked), G_CALLBACK(eom_main_window_on_edit_clicked),
(gpointer)window); (gpointer)window);
gtk_box_pack_start(GTK_BOX(hbuttonbox), window->edit_button, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(hbuttonbox), window->edit_button, FALSE, FALSE, 0);
@ -195,17 +196,17 @@ static void c_main_window_init(CMainWindow *window)
"Remove", "Remove",
NULL); NULL);
g_signal_connect(window->remove_button, "clicked", g_signal_connect(window->remove_button, "clicked",
G_CALLBACK(c_main_window_on_remove_clicked), G_CALLBACK(eom_main_window_on_remove_clicked),
(gpointer)window); (gpointer)window);
gtk_box_pack_start(GTK_BOX(hbuttonbox), gtk_box_pack_start(GTK_BOX(hbuttonbox),
window->remove_button, FALSE, FALSE, 0); window->remove_button, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(window), vbox); gtk_container_add(GTK_CONTAINER(window), vbox);
c_main_window_set_no_select(window); eom_main_window_set_no_select(window);
} }
static void c_main_window_add_menu(CMainWindow *window) static void eom_main_window_add_menu(EomMainWindow *window)
{ {
GtkWidget *appmenu; GtkWidget *appmenu;
GtkWidget *new_button; GtkWidget *new_button;
@ -213,10 +214,10 @@ static void c_main_window_add_menu(CMainWindow *window)
appmenu = hildon_app_menu_new(); appmenu = hildon_app_menu_new();
new_button = hildon_gtk_button_new(HILDON_SIZE_AUTO); new_button = hildon_gtk_button_new(HILDON_SIZE_AUTO);
gtk_button_set_label(GTK_BUTTON(new_button), "New Item"); gtk_button_set_label(GTK_BUTTON(new_button), "New Manga");
g_signal_connect_after(new_button, g_signal_connect_after(new_button,
"clicked", "clicked",
G_CALLBACK(c_main_window_on_new), G_CALLBACK(eom_main_window_on_new),
GTK_WINDOW(window)); GTK_WINDOW(window));
hildon_app_menu_append(HILDON_APP_MENU(appmenu), GTK_BUTTON(new_button)); hildon_app_menu_append(HILDON_APP_MENU(appmenu), GTK_BUTTON(new_button));
@ -226,7 +227,7 @@ static void c_main_window_add_menu(CMainWindow *window)
HILDON_APP_MENU(appmenu)); HILDON_APP_MENU(appmenu));
} }
static void c_main_window_on_new(GtkWidget *widget, GtkWindow *window) static void eom_main_window_on_new(GtkWidget *widget, GtkWindow *window)
{ {
GtkWidget *dialog; GtkWidget *dialog;
gint result; gint result;
@ -239,42 +240,42 @@ static void c_main_window_on_new(GtkWidget *widget, GtkWindow *window)
if (result == GTK_RESPONSE_OK) { if (result == GTK_RESPONSE_OK) {
const gchar *tmp; const gchar *tmp;
tmp = c_new_item_dialog_get_name(C_NEW_ITEM_DIALOG(dialog)); tmp = eom_new_item_dialog_get_name(EOM_NEW_ITEM_DIALOG(dialog));
name = (gchar *)malloc(strlen(tmp) + 1); name = (gchar *)malloc(strlen(tmp) + 1);
strcpy(name, tmp); strcpy(name, tmp);
strcat(name, "\0"); strcat(name, "\0");
total_qty = c_new_item_dialog_get_total_qty(C_NEW_ITEM_DIALOG(dialog)); total_qty = eom_new_item_dialog_get_total_qty(EOM_NEW_ITEM_DIALOG(dialog));
gtk_widget_destroy(dialog); gtk_widget_destroy(dialog);
} }
if (name != NULL) { if (name != NULL) {
if (data_add_series(name, total_qty)) if (data_add_manga(name, total_qty))
c_main_window_load(C_MAIN_WINDOW(window)); eom_main_window_load(EOM_MAIN_WINDOW(window));
} }
} }
static void c_main_window_on_selection_changed(GtkTreeSelection *selection, static void eom_main_window_on_selection_changed(GtkTreeSelection *selection,
gpointer user_data) gpointer user_data)
{ {
gint count; gint count;
CMainWindow *self = (CMainWindow *)user_data; EomMainWindow *self = (EomMainWindow *)user_data;
count = gtk_tree_selection_count_selected_rows(selection); count = gtk_tree_selection_count_selected_rows(selection);
if (count == 0) if (count == 0)
c_main_window_set_no_select(self); eom_main_window_set_no_select(self);
else else
c_main_window_set_has_select(self); eom_main_window_set_has_select(self);
} }
static void c_main_window_on_add_clicked(GtkWidget *widget, gpointer user_data) static void eom_main_window_on_add_clicked(GtkWidget *widget, gpointer user_data)
{ {
CMainWindow *self; EomMainWindow *self;
gint count; gint count;
self = (CMainWindow *)user_data; self = (EomMainWindow *)user_data;
count = gtk_tree_selection_count_selected_rows(self->selection); count = gtk_tree_selection_count_selected_rows(self->selection);
if (count > 0) { if (count > 0) {
@ -286,7 +287,7 @@ static void c_main_window_on_add_clicked(GtkWidget *widget, gpointer user_data)
gtk_tree_model_get(model, &self->iter, COL_ID, &id, -1); gtk_tree_model_get(model, &self->iter, COL_ID, &id, -1);
gtk_tree_model_get(model, &self->iter, COL_CURRENT, &current_count, -1); gtk_tree_model_get(model, &self->iter, COL_CURRENT, &current_count, -1);
if (data_add_to_series(id, 1)) if (data_add_to_manga(id, 1))
gtk_list_store_set(GTK_LIST_STORE(self->store), &self->iter, gtk_list_store_set(GTK_LIST_STORE(self->store), &self->iter,
COL_CURRENT, current_count + 1, -1); COL_CURRENT, current_count + 1, -1);
@ -294,13 +295,13 @@ static void c_main_window_on_add_clicked(GtkWidget *widget, gpointer user_data)
} }
} }
static void c_main_window_on_remove_clicked(GtkWidget *widget, static void eom_main_window_on_remove_clicked(GtkWidget *widget,
gpointer user_data) gpointer user_data)
{ {
CMainWindow *self; EomMainWindow *self;
gint count; gint count;
self = (CMainWindow *)user_data; self = (EomMainWindow *)user_data;
count = gtk_tree_selection_count_selected_rows(self->selection); count = gtk_tree_selection_count_selected_rows(self->selection);
if (count > 0) { if (count > 0) {
@ -313,19 +314,19 @@ static void c_main_window_on_remove_clicked(GtkWidget *widget,
gtk_tree_model_get(model, &self->iter, COL_ID, &id, -1); gtk_tree_model_get(model, &self->iter, COL_ID, &id, -1);
gtk_tree_model_get(model, &self->iter, COL_CURRENT, &current_count, -1); gtk_tree_model_get(model, &self->iter, COL_CURRENT, &current_count, -1);
if (current_count > 0 && data_add_to_series(id, -1)) if (current_count > 0 && data_add_to_manga(id, -1))
gtk_list_store_set(GTK_LIST_STORE(self->store), &self->iter, gtk_list_store_set(GTK_LIST_STORE(self->store), &self->iter,
COL_CURRENT, current_count - 1, -1); COL_CURRENT, current_count - 1, -1);
} }
} }
} }
static void c_main_window_on_edit_clicked(GtkWidget *widget, static void eom_main_window_on_edit_clicked(GtkWidget *widget,
gpointer user_data) gpointer user_data)
{ {
CMainWindow *self; EomMainWindow *self;
self = (CMainWindow *)user_data; self = (EomMainWindow *)user_data;
/* TODO: Place more code here */ /* TODO: Place more code here */
interface_show_edit_window(); interface_show_edit_window();

70
src/eom-main-window.h Normal file
View file

@ -0,0 +1,70 @@
#ifndef __EOM_MAIN_WINDOW_H__
#define __EOM_MAIN_WINDOW_H__
#include <hildon/hildon-stackable-window.h>
G_BEGIN_DECLS
#define EOM_TYPE_MAIN_WINDOW \
(eom_main_window_get_type())
#define EOM_MAIN_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
EOM_TYPE_MAIN_WINDOW, \
EomMainWindow))
#define EOM_MAIN_WINDOW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
EOM_TYPE_MAIN_WINDOW, \
EomMainWindowClass))
#define EOM_IS_MAIN_WINDOW(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
EOM_TYPE_MAIN_WINDOW))
#define EOM_IS_MAIN_WINDOW_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
EOM_TYPE_MAIN_WINDOW))
#define EOM_MAIN_WINDOW_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
EOM_TYPE_MAIN_WINDOW, \
EomMainWindowClass))
typedef struct _EomMainWindow EomMainWindow;
typedef struct _EomMainWindowClass EomMainWindowClass;
struct _EomMainWindowClass
{
HildonStackableWindowClass parent_class;
};
struct _EomMainWindow
{
HildonStackableWindow parent;
GtkTreeIter iter;
GtkListStore *store;
GtkTreeSelection *selection;
GtkWidget *add_button;
GtkWidget *remove_button;
GtkWidget *edit_button;
};
GType eom_main_window_get_type(void);
GtkWidget *eom_main_window_new(void);
void eom_main_window_load(EomMainWindow *self);
void eom_main_window_add_line(EomMainWindow *window,
gint id,
const gchar *name,
gint current_qty,
gint total_qty);
void eom_main_window_set_no_select(EomMainWindow *self);
void eom_main_window_set_has_select(EomMainWindow *self);
G_END_DECLS
#endif /* __EOM_MAIN_WINDOW_H__ */

View file

@ -1,29 +1,29 @@
#include "c-new-item-dialog.h" #include "eom-new-item-dialog.h"
#include <hildon/hildon-entry.h> #include <hildon/hildon-entry.h>
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <stdlib.h> #include <stdlib.h>
G_DEFINE_TYPE(CNewItemDialog, c_new_item_dialog, GTK_TYPE_DIALOG) G_DEFINE_TYPE(EomNewItemDialog, eom_new_item_dialog, GTK_TYPE_DIALOG)
GtkWidget *c_new_item_dialog_new(void) GtkWidget *eom_new_item_dialog_new(void)
{ {
return g_object_new(C_TYPE_NEW_ITEM_DIALOG, NULL); return g_object_new(EOM_TYPE_NEW_ITEM_DIALOG, NULL);
} }
const gchar *c_new_item_dialog_get_name(CNewItemDialog *dialog) const gchar *eom_new_item_dialog_get_name(EomNewItemDialog *dialog)
{ {
return hildon_entry_get_text(HILDON_ENTRY(dialog->name_entry)); return hildon_entry_get_text(HILDON_ENTRY(dialog->name_entry));
} }
gint c_new_item_dialog_get_total_qty(CNewItemDialog *dialog) gint eom_new_item_dialog_get_total_qty(EomNewItemDialog *dialog)
{ {
return atoi(hildon_entry_get_text(HILDON_ENTRY(dialog->qty_entry))); return atoi(hildon_entry_get_text(HILDON_ENTRY(dialog->qty_entry)));
} }
static void c_new_item_dialog_class_init(CNewItemDialogClass *class) static void eom_new_item_dialog_class_init(EomNewItemDialogClass *class)
{} {}
static void c_new_item_dialog_init(CNewItemDialog *dialog) static void eom_new_item_dialog_init(EomNewItemDialog *dialog)
{ {
GtkWidget *content_area; GtkWidget *content_area;
GtkWidget *hbox; GtkWidget *hbox;

60
src/eom-new-item-dialog.h Normal file
View file

@ -0,0 +1,60 @@
#ifndef __EOM_NEW_ITEM_DIALOG_H__
#define __EOM_NEW_ITEM_DIALOG_H__
#include <gtk/gtkdialog.h>
G_BEGIN_DECLS
#define EOM_TYPE_NEW_ITEM_DIALOG \
(eom_new_item_dialog_get_type())
#define EOM_NEW_ITEM_DIALOG(obj) \
(G_TYPE_CHECK_INSTANCE_CAST ((obj), \
EOM_TYPE_NEW_ITEM_DIALOG, \
EomNewItemDialog))
#define EOM_NEW_ITEM_DIALOG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST ((klass), \
EOM_TYPE_NEW_ITEM_DIALOG, \
EomNewItemDialogClass))
#define EOM_IS_NEW_ITEM_DIALOG(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
EOM_TYPE_NEW_ITEM_DIALOG))
#define EOM_IS_NEW_ITEM_DIALOG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE ((klass), \
EOM_TYPE_NEW_ITEM_DIALOG))
#define EOM_NEW_ITEM_DIALOG_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS ((obj), \
EOM_TYPE_NEW_ITEM_DIALOG, \
EomNewItemDialogClass))
typedef struct _EomNewItemDialog EomNewItemDialog;
typedef struct _EomNewItemDialogClass EomNewItemDialogClass;
struct _EomNewItemDialogClass
{
GtkDialogClass parent_class;
};
struct _EomNewItemDialog
{
GtkDialog parent;
GtkWidget *name_entry;
GtkWidget *qty_entry;
};
GType eom_new_item_dialog_get_type(void);
GtkWidget *eom_new_item_dialog_new(void);
const gchar *eom_new_item_dialog_get_name(EomNewItemDialog *dialog);
gint eom_new_item_dialog_get_total_qty(EomNewItemDialog *dialog);
G_END_DECLS
#endif /* __EOM_NEW_ITEM_DIALOG_H__ */

View file

@ -1,26 +1,26 @@
#include <hildon/hildon.h> #include <hildon/hildon.h>
#include <stdlib.h> #include <stdlib.h>
#include "interface.h" #include "interface.h"
#include "collections.h" #include "eom.h"
gchar *collections_get_data_file(void) gchar *eom_get_data_file(void)
{ {
static gchar *filedir = NULL; static gchar *filedir = NULL;
if (filedir == NULL) { if (filedir == NULL) {
filedir = g_strdup_printf("%s/collections.db", filedir = g_strdup_printf("%s/eye-on-manga.db",
collections_get_config_dir()); eom_get_config_dir());
} }
return filedir; return filedir;
} }
gchar *collections_get_config_dir(void) gchar *eom_get_config_dir(void)
{ {
static gchar *filedir = NULL; static gchar *filedir = NULL;
if (filedir == NULL) { if (filedir == NULL) {
filedir = g_strdup_printf("%s/.collections", getenv("HOME")); filedir = g_strdup_printf("%s/.eom", getenv("HOME"));
} }
return filedir; return filedir;
@ -30,7 +30,7 @@ int main(int argc, char *argv[])
{ {
hildon_gtk_init(&argc, &argv); hildon_gtk_init(&argc, &argv);
g_set_application_name("Collections"); g_set_application_name("Eye on Manga");
interface_show_main_window(); interface_show_main_window();

2
src/eom.h Normal file
View file

@ -0,0 +1,2 @@
gchar *eom_get_data_file(void);
gchar *eom_get_config_dir(void);

BIN
src/eye-on-manga Executable file

Binary file not shown.

View file

@ -1,18 +1,18 @@
#include <hildon/hildon.h> #include <hildon/hildon.h>
#include "interface.h" #include "interface.h"
#include "c-main-window.h" #include "eom-main-window.h"
#include "c-edit-window.h" #include "eom-edit-window.h"
#include "c-new-item-dialog.h" #include "eom-new-item-dialog.h"
#include "data.h" #include "data.h"
void interface_show_main_window(void) void interface_show_main_window(void)
{ {
GtkWidget *window; GtkWidget *window;
window = c_main_window_new(); window = eom_main_window_new();
gtk_widget_show_all(window); gtk_widget_show_all(window);
c_main_window_load(C_MAIN_WINDOW(window)); eom_main_window_load(EOM_MAIN_WINDOW(window));
} }
void interface_show_edit_window(void) void interface_show_edit_window(void)
@ -22,7 +22,7 @@ void interface_show_edit_window(void)
stack = hildon_window_stack_get_default(); stack = hildon_window_stack_get_default();
window = c_edit_window_new(1); window = eom_edit_window_new(1);
hildon_window_stack_push(stack, HILDON_STACKABLE_WINDOW(window), NULL); hildon_window_stack_push(stack, HILDON_STACKABLE_WINDOW(window), NULL);
gtk_widget_show_all(window); gtk_widget_show_all(window);
} }
@ -31,7 +31,7 @@ GtkWidget *interface_show_new_item_dialog(GtkWindow *window)
{ {
GtkWidget *dialog; GtkWidget *dialog;
dialog = c_new_item_dialog_new(); dialog = eom_new_item_dialog_new();
gtk_widget_show_all(dialog); gtk_widget_show_all(dialog);
gtk_window_set_transient_for(GTK_WINDOW(dialog), window); gtk_window_set_transient_for(GTK_WINDOW(dialog), window);

View file

@ -1,4 +1,5 @@
#include <gtk/gtkwindow.h> #include <gtk/gtkwindow.h>
void interface_show_main_window(void); void interface_show_main_window(void);
void interface_show_edit_window(void);
GtkWidget *interface_show_new_item_dialog(GtkWindow *window); GtkWidget *interface_show_new_item_dialog(GtkWindow *window);