From 028d24283ecf601af925224d71731f3cdfb32a02 Mon Sep 17 00:00:00 2001 From: David Date: Sun, 13 Mar 2016 17:50:42 +0100 Subject: [PATCH] fix no gtk init --- src/main.c | 9 ++++++--- src/profanity.c | 17 ++++++++++++----- src/profanity.h | 2 +- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/main.c b/src/main.c index 4f032913..f080e063 100644 --- a/src/main.c +++ b/src/main.c @@ -50,6 +50,7 @@ static gboolean version = FALSE; static char *log = "INFO"; static char *account_name = NULL; +static gboolean use_gtk = FALSE; int main(int argc, char **argv) @@ -141,9 +142,11 @@ main(int argc, char **argv) return 0; } - assert (gtk_init_check(&argc, &argv) == true); - gtk_init(&argc, &argv); - prof_run(log, account_name); + use_gtk = gtk_init_check(&argc, &argv); + if (use_gtk) { + gtk_init(&argc, &argv); + } + prof_run(log, account_name, use_gtk); return 0; } diff --git a/src/profanity.c b/src/profanity.c index b6b61d64..44ca90bd 100644 --- a/src/profanity.c +++ b/src/profanity.c @@ -94,13 +94,17 @@ char *saved_status; static gboolean cont = TRUE; static gboolean force_quit = FALSE; +static gboolean gtk_enabled = FALSE; void -prof_run(char *log_level, char *account_name) +prof_run(char *log_level, char *account_name, gboolean use_gtk) { + gtk_enabled = use_gtk; _init(log_level); plugins_on_start(); - gtk_main_iteration_do(false); + if (gtk_enabled) { + gtk_main_iteration_do(false); + } _connect_default(account_name); ui_update(); @@ -356,7 +360,9 @@ _init(char *log_level) #endif atexit(_shutdown); plugins_init(); - create_tray(); + if (gtk_enabled) { + create_tray(); + } inp_nonblocking(TRUE); } @@ -375,8 +381,9 @@ _shutdown(void) if (conn_status == JABBER_CONNECTED) { cl_ev_disconnect(); } - - destroy_tray(); + if (gtk_enabled) { + destroy_tray(); + } jabber_shutdown(); plugins_on_shutdown(); muc_close(); diff --git a/src/profanity.h b/src/profanity.h index 7e128dc8..b32bbf17 100644 --- a/src/profanity.h +++ b/src/profanity.h @@ -38,7 +38,7 @@ #include "resource.h" #include "xmpp/xmpp.h" -void prof_run(char *log_level, char *account_name); +void prof_run(char *log_level, char *account_name, gboolean use_gtk); void prof_handle_idle(void); void prof_handle_activity(void);