aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorGravatar Tom Willemsen2012-10-24 00:01:06 +0200
committerGravatar Tom Willemsen2012-10-24 00:01:06 +0200
commit15c7c143680175d37419d36b271b17d49a0991e3 (patch)
treea0b70f86176aee67784a7ec73476a2724899052a /src/data.c
parentfd7f0ec9a302a8e9060af9aa8fbdf7a031c93760 (diff)
downloadeye-on-manga-15c7c143680175d37419d36b271b17d49a0991e3.tar.gz
eye-on-manga-15c7c143680175d37419d36b271b17d49a0991e3.zip
Add updating of data for manga
The title and total numbers can now be changed. * src/data.c (data_add_manga): Change `name' to `const gchar*', we're not changing it. (data_update_manga): New function, updates a manga's information. * src/eom-detail-window.c (eom_detail_window_load): New function, prepares the tables to show the right data. (add_menu): New function, adds a menu to the window. (eom_detail_window_init): Call `add_menu' and prepare the other widgets for showing. (on_edit): New function, opens an edit dialog and reloads the screen afterwards. (set_manga_id): Move data filling to `eom_detail_window_load' and widget preparation to `eom_detail_window_init' and call `eom_detail_window_load'. * src/eom-detail-window.h (EomDetailWindow): Add `ctable' and `rtable' members, these are the tables that show the data. * src/eom-main-window.c (on_new): No need to save and copy the name of a manga, just destroy the widget later and destroy it always. * src/eom-new-item-dialog.c (eom_new_item_dialog_class_init): Add write-only `manga-id' property. (EOM_NEW_PROP_MID): New enum. (finalize): New function. Free the associated manga. (get_property): New function. Get a property, has no properties to get for now. (set_manga_id): New function. Show a manga's information in the entries. (set_property): New function. Set a property. Calls `set_manga_id' for the `manga-id' property. * src/eom-new-item-dialog.h (EomNewItemDialog): Add a `Manga' as member.
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/data.c b/src/data.c
index e357f2e..94e4735 100644
--- a/src/data.c
+++ b/src/data.c
@@ -17,7 +17,7 @@ static GList *get_manga_for_query(const gchar*);
static Manga *get_manga_from_statement(sqlite3_stmt*);
gboolean
-data_add_manga(gchar *name, gint total_qty)
+data_add_manga(const gchar *name, gint total_qty)
{
gchar *sql =
g_strdup_printf(" INSERT INTO manga (name, current_qty, "
@@ -217,6 +217,19 @@ data_remove_volume_from_manga(gint manga_id, gint volume)
return ret;
}
+gboolean
+data_update_manga(gint manga_id, const gchar *name, gint total_qty)
+{
+ gchar *sql =
+ g_strdup_printf("UPDATE manga SET name = '%s', total_qty = %d "
+ "WHERE id = %d", name, total_qty, manga_id);
+ gboolean ret = execute_non_query(sql);
+
+ g_free(sql);
+
+ return ret;
+}
+
static gboolean
check_and_create_database(gchar *data_file)
{