From 98d42ed3ce019398d00d6f623c1a1664760b4418 Mon Sep 17 00:00:00 2001 From: Moritz Lipp Date: Fri, 12 Nov 2010 13:48:18 +0100 Subject: [PATCH] Begin to test config structure --- callbacks.c | 14 ++++++++++++++ callbacks.h | 4 ++++ config.c | 12 ++++++++++++ config.h | 2 ++ shortcuts.c | 9 +++++++++ zathura.c | 9 +++++++++ 6 files changed, 50 insertions(+) diff --git a/callbacks.c b/callbacks.c index 6c3efe1..0b5f007 100644 --- a/callbacks.c +++ b/callbacks.c @@ -1 +1,15 @@ /* See LICENSE file for license and copyright information */ + +#include +#include + +#include "zathura.h" + +gboolean +cb_destroy(GtkWidget* widget, gpointer data) +{ + if(Zathura.UI.session) + girara_session_destroy(Zathura.UI.session); + + return TRUE; +} diff --git a/callbacks.h b/callbacks.h index 5e6ddf9..bc544f1 100644 --- a/callbacks.h +++ b/callbacks.h @@ -3,4 +3,8 @@ #ifndef CALLBACKS_H #define CALLBACKS_H +#include + +gboolean cb_destroy(GtkWidget* widget, gpointer data); + #endif // CALLBACKS_H diff --git a/config.c b/config.c index 6c3efe1..b3c9f38 100644 --- a/config.c +++ b/config.c @@ -1 +1,13 @@ /* See LICENSE file for license and copyright information */ + +#include "shortcuts.h" +#include "zathura.h" + +void +config_load_default() +{ + if(!Zathura.UI.session) + return; + + girara_shortcut_add(Zathura.UI.session, GDK_CONTROL_MASK, GDK_q, NULL, sc_quit, 0, 0, NULL); +} diff --git a/config.h b/config.h index 8f118bf..f9f46b8 100644 --- a/config.h +++ b/config.h @@ -3,4 +3,6 @@ #ifndef CONFIG_H #define CONFIG_H +void config_load_default(); + #endif // CONFIG_H diff --git a/shortcuts.c b/shortcuts.c index fc7c936..50f7a6d 100644 --- a/shortcuts.c +++ b/shortcuts.c @@ -1,5 +1,9 @@ /* See LICENSE file for license and copyright information */ +#include +#include + +#include "callbacks.h" #include "shortcuts.h" void @@ -113,7 +117,12 @@ sc_toggle_statusbar(girara_session_t* session, girara_argument_t* argument) void sc_quit(girara_session_t* session, girara_argument_t* argument) { + girara_argument_t arg = { GIRARA_HIDE, NULL }; + girara_isc_completion(session, &arg); + cb_destroy(NULL, NULL); + + gtk_main_quit(); } void diff --git a/zathura.c b/zathura.c index cd40790..d8656e7 100644 --- a/zathura.c +++ b/zathura.c @@ -1,5 +1,8 @@ /* See LICENSE file for license and copyright information */ +#include "callbacks.h" +#include "config.h" +#include "shortcuts.h" #include "zathura.h" /* function implementation */ @@ -12,6 +15,12 @@ init_zathura() if(!girara_session_init(Zathura.UI.session)) return false; + /* signals */ + g_signal_connect(G_OBJECT(Zathura.UI.session->gtk.window), "destroy", G_CALLBACK(cb_destroy), NULL); + + /* configuration */ + config_load_default(); + return true; }