1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-09-22 19:45:54 -04:00

libgtk is now optional

Having the lib is no more needed.
This commit is contained in:
David 2016-03-30 22:18:45 +02:00
parent bdad30b2d9
commit 1e60d17d7c
6 changed files with 43 additions and 24 deletions

View File

@ -62,6 +62,8 @@ AC_ARG_WITH([xscreensaver],
[AS_HELP_STRING([--with-xscreensaver], [use libXScrnSaver to determine idle time])]) [AS_HELP_STRING([--with-xscreensaver], [use libXScrnSaver to determine idle time])])
AC_ARG_WITH([themes], AC_ARG_WITH([themes],
[AS_HELP_STRING([--with-themes[[=PATH]]], [install themes (default yes)])]) [AS_HELP_STRING([--with-themes[[=PATH]]], [install themes (default yes)])])
AC_ARG_ENABLE([icons],
[AS_HELP_STRING([--enable-icons], [enable icons])])
### plugins ### plugins
@ -153,8 +155,11 @@ PKG_CHECK_MODULES([curl], [libcurl], [],
[AC_MSG_ERROR([libcurl is required for profanity])]) [AC_MSG_ERROR([libcurl is required for profanity])])
# Checks GTK+ 2.0 # Checks GTK+ 2.0
PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.24.10], [], PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.24.10],
[AC_MSG_ERROR([gtk+-2.0 or higher is required for profanity])]) [AC_DEFINE([HAVE_GTK], [1], [libgtk module])],
[AS_IF([test "x$enable_icons" = xyes],
[AC_MSG_ERROR([gtk+-2.0 or higher is required for icons])],
[AC_MSG_NOTICE([gtk+-2.0 not found, icons not enabled])])])
AS_IF([test "x$PLATFORM" != xosx], AS_IF([test "x$PLATFORM" != xosx],
[AC_CHECK_LIB([readline], [main], [], [AC_CHECK_LIB([readline], [main], [],

View File

@ -34,7 +34,9 @@
#include "prof_config.h" #include "prof_config.h"
#ifdef PROF_HAVE_GTK
#include <gtk/gtk.h> #include <gtk/gtk.h>
#endif
#include <string.h> #include <string.h>
#include <glib.h> #include <glib.h>
#include <assert.h> #include <assert.h>
@ -50,7 +52,6 @@
static gboolean version = FALSE; static gboolean version = FALSE;
static char *log = "INFO"; static char *log = "INFO";
static char *account_name = NULL; static char *account_name = NULL;
static gboolean use_gtk = FALSE;
int int
main(int argc, char **argv) main(int argc, char **argv)
@ -139,14 +140,21 @@ main(int argc, char **argv)
g_print("Python plugins: Disabled\n"); g_print("Python plugins: Disabled\n");
#endif #endif
#ifdef PROF_HAVE_GTK
g_print("GTK icons: Enabled\n");
#else
g_print("GTK icons: Disabled\n");
#endif
return 0; return 0;
} }
use_gtk = gtk_init_check(&argc, &argv); #ifdef PROF_HAVE_GTK
if (use_gtk) { if (gtk_init_check(&argc, &argv)) {
gtk_init(&argc, &argv); gtk_init(&argc, &argv);
} }
prof_run(log, account_name, use_gtk); #endif
prof_run(log, account_name);
return 0; return 0;
} }

View File

@ -37,7 +37,9 @@
#include "gitversion.h" #include "gitversion.h"
#endif #endif
#ifdef PROF_HAVE_GTK
#include <gtk/gtk.h> #include <gtk/gtk.h>
#endif
#include <locale.h> #include <locale.h>
#include <signal.h> #include <signal.h>
#include <stdlib.h> #include <stdlib.h>
@ -73,7 +75,9 @@
#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" #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);
@ -94,17 +98,15 @@ char *saved_status;
static gboolean cont = TRUE; static gboolean cont = TRUE;
static gboolean force_quit = FALSE; static gboolean force_quit = FALSE;
static gboolean gtk_enabled = FALSE;
void void
prof_run(char *log_level, char *account_name, gboolean use_gtk) prof_run(char *log_level, char *account_name)
{ {
gtk_enabled = use_gtk;
_init(log_level); _init(log_level);
plugins_on_start(); plugins_on_start();
if (gtk_enabled) { #ifdef PROF_HAVE_GTK
gtk_main_iteration_do(false); gtk_main_iteration_do(false);
} #endif
_connect_default(account_name); _connect_default(account_name);
ui_update(); ui_update();
@ -137,9 +139,9 @@ prof_run(char *log_level, char *account_name, gboolean use_gtk)
jabber_process_events(10); jabber_process_events(10);
iq_autoping_check(); iq_autoping_check();
ui_update(); ui_update();
if (gtk_enabled) { #ifdef PROF_HAVE_GTK
gtk_main_iteration_do(false); gtk_main_iteration_do(false);
} #endif
} }
} }
@ -362,9 +364,9 @@ _init(char *log_level)
#endif #endif
atexit(_shutdown); atexit(_shutdown);
plugins_init(); plugins_init();
if (gtk_enabled) { #ifdef PROF_HAVE_GTK
create_tray(); create_tray();
} #endif
inp_nonblocking(TRUE); inp_nonblocking(TRUE);
} }
@ -383,9 +385,9 @@ _shutdown(void)
if (conn_status == JABBER_CONNECTED) { if (conn_status == JABBER_CONNECTED) {
cl_ev_disconnect(); cl_ev_disconnect();
} }
if (gtk_enabled) { #ifdef PROF_HAVE_GTK
destroy_tray(); destroy_tray();
} #endif
jabber_shutdown(); jabber_shutdown();
plugins_on_shutdown(); plugins_on_shutdown();
muc_close(); muc_close();

View File

@ -38,7 +38,7 @@
#include "resource.h" #include "resource.h"
#include "xmpp/xmpp.h" #include "xmpp/xmpp.h"
void prof_run(char *log_level, char *account_name, gboolean use_gtk); void prof_run(char *log_level, char *account_name);
void prof_handle_idle(void); void prof_handle_idle(void);
void prof_handle_activity(void); void prof_handle_activity(void);

View File

@ -1,7 +1,7 @@
/* /*
* tray.c * tray.c
* *
* Copyright (C) 2012 - 2016 David Petroni <petrodavi@gmail.com> * Copyright (C) 2012 - 2016 James Booth <boothj5@gmail.com>
* *
* This file is part of Profanity. * This file is part of Profanity.
* *
@ -32,6 +32,9 @@
* *
*/ */
#include "prof_config.h"
#ifdef PROF_HAVE_GTK
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <glib.h> #include <glib.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
@ -156,3 +159,4 @@ void destroy_tray(void)
} }
/* }}} */ /* }}} */
#endif

View File

@ -1,7 +1,7 @@
/* /*
* tray.h * tray.h
* *
* Copyright (C) 2012 - 2016 David Petroni <petrodavi@gmail.com> * Copyright (C) 2012 - 2016 James Booth <boothj5@gmail.com>
* *
* This file is part of Profanity. * This file is part of Profanity.
* *