From 5f2235b45d9afc8906c96e18e0d11dc422754dcb Mon Sep 17 00:00:00 2001 From: Daniel Carl Date: Thu, 13 Jun 2013 13:26:44 +0200 Subject: [PATCH] Moved content of destroy client function to destroy_window_cb (#34). --- src/main.c | 56 ++++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/src/main.c b/src/main.c index fc84477..8853d8b 100644 --- a/src/main.c +++ b/src/main.c @@ -74,7 +74,6 @@ static void init_files(void); static gboolean hide_message(); static void set_status(const StatusType status); static void inputbox_print(gboolean force, const MessageType type, gboolean hide, const char *message); -static void destroy_client(); void vb_echo_force(const MessageType type, gboolean hide, const char *error, ...) { @@ -446,7 +445,31 @@ static void webview_load_status_cb(WebKitWebView *view, GParamSpec *pspec) static void destroy_window_cb(GtkWidget *widget) { - destroy_client(); + const char *uri = GET_URI(); + /* write last URL into file for recreation */ + if (uri) { + g_file_set_contents(vb.files[FILES_CLOSED], uri, -1, NULL); + } + + completion_clean(); + + webkit_web_view_stop_loading(vb.gui.webview); + gtk_widget_destroy(GTK_WIDGET(vb.gui.webview)); + gtk_widget_destroy(GTK_WIDGET(vb.gui.scroll)); + gtk_widget_destroy(GTK_WIDGET(vb.gui.box)); + gtk_widget_destroy(GTK_WIDGET(vb.gui.window)); + + command_cleanup(); + setting_cleanup(); + keybind_cleanup(); + shortcut_cleanup(); + history_cleanup(); + + for (int i = 0; i < FILES_LAST; i++) { + g_free(vb.files[i]); + } + + gtk_main_quit(); } static void inputbox_activate_cb(GtkEntry *entry) @@ -985,35 +1008,6 @@ static void download_progress_cp(WebKitDownload *download, GParamSpec *pspec) vb_update_statusbar(); } -static void destroy_client() -{ - const char *uri = GET_URI(); - /* write last URL into file for recreation */ - if (uri) { - g_file_set_contents(vb.files[FILES_CLOSED], uri, -1, NULL); - } - - completion_clean(); - - webkit_web_view_stop_loading(vb.gui.webview); - gtk_widget_destroy(GTK_WIDGET(vb.gui.webview)); - gtk_widget_destroy(GTK_WIDGET(vb.gui.scroll)); - gtk_widget_destroy(GTK_WIDGET(vb.gui.box)); - gtk_widget_destroy(GTK_WIDGET(vb.gui.window)); - - command_cleanup(); - setting_cleanup(); - keybind_cleanup(); - shortcut_cleanup(); - history_cleanup(); - - for (int i = 0; i < FILES_LAST; i++) { - g_free(vb.files[i]); - } - - gtk_main_quit(); -} - int main(int argc, char *argv[]) { static char *winid = NULL; -- 2.20.1