mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-29 07:26:21 +00:00
Re-introduce gtk_use boolean
This param is still actual, in case the environemnt does not support gtk initialization. Fix a GTK assert on the way (GTKStatusIcon is not a Widget, but a plain GObject).
This commit is contained in:
@@ -34,9 +34,6 @@
|
|||||||
|
|
||||||
#include "prof_config.h"
|
#include "prof_config.h"
|
||||||
|
|
||||||
#ifdef PROF_HAVE_GTK
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#endif
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -149,11 +146,6 @@ main(int argc, char **argv)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PROF_HAVE_GTK
|
|
||||||
if (gtk_init_check(&argc, &argv)) {
|
|
||||||
gtk_init(&argc, &argv);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
prof_run(log, account_name);
|
prof_run(log, account_name);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
|
|
||||||
#ifdef PROF_HAVE_GTK
|
#ifdef PROF_HAVE_GTK
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include "tray.h"
|
||||||
#endif
|
#endif
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
@@ -75,9 +76,6 @@
|
|||||||
#include "window_list.h"
|
#include "window_list.h"
|
||||||
#include "event/client_events.h"
|
#include "event/client_events.h"
|
||||||
#include "config/tlscerts.h"
|
#include "config/tlscerts.h"
|
||||||
#ifdef PROF_HAVE_GTK
|
|
||||||
#include "tray.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void _check_autoaway(void);
|
static void _check_autoaway(void);
|
||||||
static void _init(char *log_level);
|
static void _init(char *log_level);
|
||||||
@@ -98,15 +96,21 @@ char *saved_status;
|
|||||||
|
|
||||||
static gboolean cont = TRUE;
|
static gboolean cont = TRUE;
|
||||||
static gboolean force_quit = FALSE;
|
static gboolean force_quit = FALSE;
|
||||||
|
static gboolean gtk_ready = FALSE;
|
||||||
|
|
||||||
void
|
void
|
||||||
prof_run(char *log_level, char *account_name)
|
prof_run(char *log_level, char *account_name)
|
||||||
{
|
{
|
||||||
|
#ifdef PROF_HAVE_GTK
|
||||||
|
gtk_ready = gtk_init_check(0, NULL);
|
||||||
|
log_debug("Env is GTK-ready: %s", gtk_ready ? "true" : "false");
|
||||||
|
if (gtk_ready) {
|
||||||
|
gtk_init(0, NULL);
|
||||||
|
gtk_main_iteration_do(false);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
_init(log_level);
|
_init(log_level);
|
||||||
plugins_on_start();
|
plugins_on_start();
|
||||||
#ifdef PROF_HAVE_GTK
|
|
||||||
gtk_main_iteration_do(false);
|
|
||||||
#endif
|
|
||||||
_connect_default(account_name);
|
_connect_default(account_name);
|
||||||
|
|
||||||
ui_update();
|
ui_update();
|
||||||
@@ -140,7 +144,9 @@ prof_run(char *log_level, char *account_name)
|
|||||||
iq_autoping_check();
|
iq_autoping_check();
|
||||||
ui_update();
|
ui_update();
|
||||||
#ifdef PROF_HAVE_GTK
|
#ifdef PROF_HAVE_GTK
|
||||||
gtk_main_iteration_do(false);
|
if (gtk_ready) {
|
||||||
|
gtk_main_iteration_do(false);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -365,7 +371,10 @@ _init(char *log_level)
|
|||||||
atexit(_shutdown);
|
atexit(_shutdown);
|
||||||
plugins_init();
|
plugins_init();
|
||||||
#ifdef PROF_HAVE_GTK
|
#ifdef PROF_HAVE_GTK
|
||||||
create_tray();
|
if (gtk_ready) {
|
||||||
|
log_debug("Building GTK icon");
|
||||||
|
create_tray();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
inp_nonblocking(TRUE);
|
inp_nonblocking(TRUE);
|
||||||
}
|
}
|
||||||
@@ -386,7 +395,9 @@ _shutdown(void)
|
|||||||
cl_ev_disconnect();
|
cl_ev_disconnect();
|
||||||
}
|
}
|
||||||
#ifdef PROF_HAVE_GTK
|
#ifdef PROF_HAVE_GTK
|
||||||
destroy_tray();
|
if (gtk_ready) {
|
||||||
|
destroy_tray();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
jabber_shutdown();
|
jabber_shutdown();
|
||||||
plugins_on_shutdown();
|
plugins_on_shutdown();
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ void destroy_tray(void)
|
|||||||
shutting_down = true;
|
shutting_down = true;
|
||||||
g_source_remove(timer);
|
g_source_remove(timer);
|
||||||
if (prof_tray) {
|
if (prof_tray) {
|
||||||
gtk_widget_destroy(GTK_WIDGET(prof_tray));
|
g_clear_object(&prof_tray);
|
||||||
prof_tray = NULL;
|
prof_tray = NULL;
|
||||||
}
|
}
|
||||||
g_string_free(icon_filename, true);
|
g_string_free(icon_filename, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user