From 33b73cac14f28e91cd90e0fb98579bf7690f637f Mon Sep 17 00:00:00 2001 From: Tom Willemsen Date: Fri, 26 Oct 2012 00:25:51 +0200 Subject: Add "Delete" button to detail window * src/data.c (data_delete_manga): New function, deletes a manga and its associated volumes. (data_update_manga): Extra free. * src/eom-detail-window.c (add_menu): Add a "Delete" button to the menu. (on_delete): New function. Shows a confirmation dialog and if the user pressed "Ok" tries to delete the manga and close the window. * src/eom-main-window.c (on_row_activated): Connect to the `hide' signal instead of the `delete-event' signal. I couldn't find how te emit my own `delete-event' signal, then I found that hide works both when I close a window and when the window manager does it. --- src/eom-main-window.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/eom-main-window.c') diff --git a/src/eom-main-window.c b/src/eom-main-window.c index ea3a1df..9dd2a5c 100644 --- a/src/eom-main-window.c +++ b/src/eom-main-window.c @@ -6,8 +6,8 @@ #include #include -#include "eom-new-item-dialog.h" #include "data.h" +#include "eom-new-item-dialog.h" #include "interface.h" G_DEFINE_TYPE(EomMainWindow, eom_main_window, @@ -35,7 +35,7 @@ struct filter_args { static void add_menu(EomMainWindow*); static void eom_main_window_class_init(EomMainWindowClass*); static void eom_main_window_init(EomMainWindow*); -static gboolean on_edit_closed(GtkWidget*, GdkEvent*, gpointer); +static void on_detail_hidden(GtkWidget*, gpointer); static void on_filter(GtkWidget*, struct filter_args*); static void on_new(GtkWidget*, GtkWindow*); static void on_row_activated(GtkWidget*, GtkTreePath*, GtkTreeViewColumn*, gpointer); @@ -236,14 +236,11 @@ eom_main_window_init(EomMainWindow *window) g_object_unref(window->store); } -static gboolean -on_edit_closed(GtkWidget *widget, GdkEvent *event, gpointer user_data) +static void +on_detail_hidden(GtkWidget *widget, gpointer user_data) { - EomMainWindow *self = user_data; - + EomMainWindow *self = EOM_MAIN_WINDOW(user_data); eom_main_window_load(self); - - return FALSE; } static void @@ -294,6 +291,5 @@ on_row_activated(GtkWidget *treeview, GtkTreePath *path, gtk_tree_model_get(model, &iter, COL_ID, &id, -1); window = interface_show_detail_window(id); - g_signal_connect(window, "delete-event", G_CALLBACK(on_edit_closed), - self); + g_signal_connect(window, "hide", G_CALLBACK(on_detail_hidden), self); } -- cgit v1.2.3-54-g00ecf