1
1
mirror of https://github.com/profanity-im/profanity.git synced 2025-02-02 15:08:15 -05:00

Make tray icon configurable using /tray cmd

This commit is contained in:
Dominik Heidler 2016-04-16 16:29:32 +02:00
parent 6cc04bc3ba
commit 4cb1d73a83
8 changed files with 72 additions and 2 deletions

View File

@ -1253,6 +1253,21 @@ static struct cmd_t command_defs[] =
CMD_NOEXAMPLES CMD_NOEXAMPLES
}, },
#ifdef HAVE_GTK
{ "/tray",
cmd_tray, parse_args, 1, 1, &cons_tray_setting,
CMD_TAGS(
CMD_TAG_UI)
CMD_SYN(
"/tray on|off")
CMD_DESC(
"Display an icon in the tray that will indicate new messages.")
CMD_ARGS(
{ "on|off", "Enable or disable tray icon." })
CMD_NOEXAMPLES
},
#endif
{ "/intype", { "/intype",
cmd_intype, parse_args, 1, 1, &cons_intype_setting, cmd_intype, parse_args, 1, 1, &cons_intype_setting,
CMD_TAGS( CMD_TAGS(

View File

@ -77,6 +77,9 @@
#include "ui/ui.h" #include "ui/ui.h"
#include "window_list.h" #include "window_list.h"
#include "event/client_events.h" #include "event/client_events.h"
#ifdef HAVE_GTK
#include "tray.h"
#endif
static void _update_presence(const resource_presence_t presence, static void _update_presence(const resource_presence_t presence,
const char *const show, gchar **args); const char *const show, gchar **args);
@ -5525,6 +5528,24 @@ cmd_flash(ProfWin *window, const char *const command, gchar **args)
return _cmd_set_boolean_preference(args[0], command, "Screen flash", PREF_FLASH); return _cmd_set_boolean_preference(args[0], command, "Screen flash", PREF_FLASH);
} }
#ifdef HAVE_GTK
gboolean
cmd_tray(ProfWin *window, const char *const command, gchar **args)
{
gboolean old = prefs_get_boolean(PREF_TRAY);
gboolean ret = _cmd_set_boolean_preference(args[0], command, "Tray icon", PREF_TRAY);
gboolean new = prefs_get_boolean(PREF_TRAY);
if (old != new) {
if (new) {
create_tray();
} else {
destroy_tray();
}
}
return ret;
}
#endif
gboolean gboolean
cmd_intype(ProfWin *window, const char *const command, gchar **args) cmd_intype(ProfWin *window, const char *const command, gchar **args)
{ {

View File

@ -89,6 +89,9 @@ gboolean cmd_lastactivity(ProfWin *window, const char *const command, gchar **ar
gboolean cmd_disconnect(ProfWin *window, const char *const command, gchar **args); gboolean cmd_disconnect(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_dnd(ProfWin *window, const char *const command, gchar **args); gboolean cmd_dnd(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_flash(ProfWin *window, const char *const command, gchar **args); gboolean cmd_flash(ProfWin *window, const char *const command, gchar **args);
#ifdef HAVE_GTK
gboolean cmd_tray(ProfWin *window, const char *const command, gchar **args);
#endif
gboolean cmd_gone(ProfWin *window, const char *const command, gchar **args); gboolean cmd_gone(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_grlog(ProfWin *window, const char *const command, gchar **args); gboolean cmd_grlog(ProfWin *window, const char *const command, gchar **args);
gboolean cmd_group(ProfWin *window, const char *const command, gchar **args); gboolean cmd_group(ProfWin *window, const char *const command, gchar **args);

View File

@ -47,6 +47,10 @@
#include "tools/autocomplete.h" #include "tools/autocomplete.h"
#include "config/conflists.h" #include "config/conflists.h"
#ifdef HAVE_GTK
#include "tray.h"
#endif
// preference groups refer to the sections in .profrc, for example [ui] // preference groups refer to the sections in .profrc, for example [ui]
#define PREF_GROUP_LOGGING "logging" #define PREF_GROUP_LOGGING "logging"
#define PREF_GROUP_CHATSTATES "chatstates" #define PREF_GROUP_CHATSTATES "chatstates"
@ -1171,6 +1175,9 @@ _get_group(preference_t pref)
case PREF_TITLEBAR_SHOW: case PREF_TITLEBAR_SHOW:
case PREF_TITLEBAR_GOODBYE: case PREF_TITLEBAR_GOODBYE:
case PREF_FLASH: case PREF_FLASH:
#ifdef HAVE_GTK
case PREF_TRAY:
#endif
case PREF_INTYPE: case PREF_INTYPE:
case PREF_HISTORY: case PREF_HISTORY:
case PREF_OCCUPANTS: case PREF_OCCUPANTS:
@ -1289,6 +1296,10 @@ _get_key(preference_t pref)
return "titlebar.goodbye"; return "titlebar.goodbye";
case PREF_FLASH: case PREF_FLASH:
return "flash"; return "flash";
#ifdef HAVE_GTK
case PREF_TRAY:
return "tray";
#endif
case PREF_INTYPE: case PREF_INTYPE:
return "intype"; return "intype";
case PREF_HISTORY: case PREF_HISTORY:

View File

@ -52,6 +52,9 @@ typedef enum {
PREF_TITLEBAR_SHOW, PREF_TITLEBAR_SHOW,
PREF_TITLEBAR_GOODBYE, PREF_TITLEBAR_GOODBYE,
PREF_FLASH, PREF_FLASH,
#ifdef HAVE_GTK
PREF_TRAY,
#endif
PREF_INTYPE, PREF_INTYPE,
PREF_HISTORY, PREF_HISTORY,
PREF_CARBONS, PREF_CARBONS,

View File

@ -373,7 +373,7 @@ _init(char *log_level)
atexit(_shutdown); atexit(_shutdown);
plugins_init(); plugins_init();
#ifdef HAVE_GTK #ifdef HAVE_GTK
if (gtk_ready) { if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
log_debug("Building GTK icon"); log_debug("Building GTK icon");
create_tray(); create_tray();
} }
@ -397,7 +397,7 @@ _shutdown(void)
cl_ev_disconnect(); cl_ev_disconnect();
} }
#ifdef HAVE_GTK #ifdef HAVE_GTK
if (gtk_ready) { if (gtk_ready && prefs_get_boolean(PREF_TRAY)) {
destroy_tray(); destroy_tray();
} }
#endif #endif

View File

@ -1182,6 +1182,17 @@ cons_flash_setting(void)
cons_show("Terminal flash (/flash) : OFF"); cons_show("Terminal flash (/flash) : OFF");
} }
#ifdef HAVE_GTK
void
cons_tray_setting(void)
{
if (prefs_get_boolean(PREF_TRAY))
cons_show("Tray icon (/tray) : ON");
else
cons_show("Tray icon (/tray) : OFF");
}
#endif
void void
cons_splash_setting(void) cons_splash_setting(void)
{ {
@ -1497,6 +1508,9 @@ cons_show_ui_prefs(void)
cons_theme_setting(); cons_theme_setting();
cons_beep_setting(); cons_beep_setting();
cons_flash_setting(); cons_flash_setting();
#ifdef HAVE_GTK
cons_tray_setting();
#endif
cons_splash_setting(); cons_splash_setting();
cons_wrap_setting(); cons_wrap_setting();
cons_winstidy_setting(); cons_winstidy_setting();

View File

@ -284,6 +284,9 @@ void cons_privileges_setting(void);
void cons_beep_setting(void); void cons_beep_setting(void);
void cons_console_setting(void); void cons_console_setting(void);
void cons_flash_setting(void); void cons_flash_setting(void);
#ifdef HAVE_GTK
void cons_tray_setting(void);
#endif
void cons_splash_setting(void); void cons_splash_setting(void);
void cons_encwarn_setting(void); void cons_encwarn_setting(void);
void cons_tlsshow_setting(void); void cons_tlsshow_setting(void);