9 Commits

5 changed files with 90 additions and 12 deletions

View File

@@ -17,11 +17,9 @@
"--filesystem=~/.icons:ro", "--filesystem=~/.icons:ro",
"--filesystem=xdg-run/tray-icon:create", "--filesystem=xdg-run/tray-icon:create",
"--env=GTK_CSD=1", "--env=GTK_CSD=1",
"--talk-name=org.freedesktop.Notifications", "--talk-name=org.freedesktop.Notifications",
"--talk-name=org.kde.StatusNotifierWatcher", "--talk-name=org.kde.StatusNotifierWatcher",
"--talk-name=com.canonical.AppMenu.Registrar", "--talk-name=com.canonical.AppMenu.Registrar",
"--talk-name=org.mpris.MediaPlayer2.*" "--talk-name=org.mpris.MediaPlayer2.*"
], ],
"add-extensions": { "add-extensions": {
@@ -41,6 +39,7 @@
"shared-modules/libcanberra/libcanberra.json", "shared-modules/libcanberra/libcanberra.json",
"shared-modules/libayatana-appindicator/libayatana-appindicator-gtk3.json", "shared-modules/libayatana-appindicator/libayatana-appindicator-gtk3.json",
"python3-cffi.json", "python3-cffi.json",
"perl.json",
{ {
"name": "lgi", "name": "lgi",
"buildsystem": "meson", "buildsystem": "meson",
@@ -57,8 +56,8 @@
"buildsystem": "meson", "buildsystem": "meson",
"config-opts": [ "config-opts": [
"-Ddbus-service-use-appid=true", "-Ddbus-service-use-appid=true",
"-Dwith-perl=false", "-Dwith-perl=perl",
"-Dwith-python=false", "-Dwith-python=python3",
"-Dwith-lua=lua" "-Dwith-lua=lua"
], ],
"build-options": { "build-options": {

20
flatpak/perl.json Normal file
View File

@@ -0,0 +1,20 @@
{
"name": "perl",
"buildsystem": "simple",
"build-commands": [
"./Configure -des -Dprefix=/app -Dvendorprefix=/app -Duseshrplib -Dman1dir=none -Dman3dir=none",
"make -j${FLATPAK_BUILDER_N_JOBS}",
"make install"
],
"cleanup": [
"/share/man",
"/lib/perl5/*/*/CORE/*.a"
],
"sources": [
{
"type": "archive",
"url": "https://www.cpan.org/src/5.0/perl-5.40.1.tar.xz",
"sha256": "dfa20c2eef2b4af133525610bbb65dd13777ecf998c9c5b1ccf0d308e732ee3f"
}
]
}

View File

@@ -7,13 +7,13 @@
"sources": [ "sources": [
{ {
"type": "file", "type": "file",
"url": "https://files.pythonhosted.org/packages/0f/86/e19659527668d70be91d0369aeaa055b4eb396b0f387a4f92293a20035bd/pycparser-2.20.tar.gz", "url": "https://files.pythonhosted.org/packages/1d/b2/31537cf4b1ca988837256c910a668b553fceb8f069bedc4b1c826024b52c/pycparser-2.22.tar.gz",
"sha256": "2d475327684562c3a96cc71adf7dc8c4f0565175cf86b6d7a404ff4c771f15f0" "sha256": "491c8be9c040f5390f5bf44a5b07752bd07f56edf992381b05c701439eec10f6"
}, },
{ {
"type": "file", "type": "file",
"url": "https://files.pythonhosted.org/packages/a8/20/025f59f929bbcaa579704f443a438135918484fffaacfaddba776b374563/cffi-1.14.5.tar.gz", "url": "https://files.pythonhosted.org/packages/fc/97/c783634659c2920c3fc70419e3af40972dbaf758daa229a7d6ea6135c90d/cffi-1.17.1.tar.gz",
"sha256": "fd78e5fee591709f32ef6edb9a015b4aa1a5022598e36227500c8f4e02328d9c" "sha256": "1c39c6016c32bc48dd54561950ebd6836e1670f2ae46128f67cf49e789c52824"
} }
] ]
} }

View File

@@ -32,6 +32,7 @@
#include <stdbool.h> #include <stdbool.h>
#else #else
#include <dirent.h> #include <dirent.h>
#include <strings.h>
#endif #endif
#include <glib.h> #include <glib.h>

View File

@@ -122,6 +122,9 @@ static void tray_init (void);
static void tray_set_icon_state (TrayIcon icon, TrayIconState state); static void tray_set_icon_state (TrayIcon icon, TrayIconState state);
static void tray_menu_restore_cb (GtkWidget *item, gpointer userdata); static void tray_menu_restore_cb (GtkWidget *item, gpointer userdata);
static void tray_menu_notify_cb (GObject *tray, GParamSpec *pspec, gpointer user_data); static void tray_menu_notify_cb (GObject *tray, GParamSpec *pspec, gpointer user_data);
static void tray_update_toggle_item_label (void);
static gboolean tray_window_state_cb (GtkWidget *widget, GdkEventWindowState *event, gpointer userdata);
static void tray_window_visibility_cb (GtkWidget *widget, gpointer userdata);
#if HAVE_APPINDICATOR_BACKEND #if HAVE_APPINDICATOR_BACKEND
static void tray_menu_show_cb (GtkWidget *menu, gpointer userdata) G_GNUC_UNUSED; static void tray_menu_show_cb (GtkWidget *menu, gpointer userdata) G_GNUC_UNUSED;
#endif #endif
@@ -165,6 +168,7 @@ static int tray_pub_count = 0;
static int tray_hilight_count = 0; static int tray_hilight_count = 0;
static int tray_file_count = 0; static int tray_file_count = 0;
static int tray_restore_timer = 0; static int tray_restore_timer = 0;
static GtkWidget *tray_toggle_item = NULL;
#if HAVE_APPINDICATOR_BACKEND #if HAVE_APPINDICATOR_BACKEND
static TrayCustomIcon static TrayCustomIcon
@@ -890,6 +894,8 @@ tray_toggle_visibility (gboolean force_hide)
gtk_window_present (win); gtk_window_present (win);
} }
tray_update_toggle_item_label ();
return TRUE; return TRUE;
} }
@@ -1083,10 +1089,8 @@ tray_menu_populate (GtkWidget *menu)
/* ph may have an invalid context now */ /* ph may have an invalid context now */
zoitechat_set_context (ph, zoitechat_find_context (ph, NULL, NULL)); zoitechat_set_context (ph, zoitechat_find_context (ph, NULL, NULL));
if (tray_get_window_status () == WS_HIDDEN) tray_toggle_item = tray_make_item (menu, _("_Hide Window"), tray_menu_restore_cb, NULL);
tray_make_item (menu, _("_Restore Window"), tray_menu_restore_cb, NULL); tray_update_toggle_item_label ();
else
tray_make_item (menu, _("_Hide Window"), tray_menu_restore_cb, NULL);
tray_make_item (menu, NULL, tray_menu_quit_cb, NULL); tray_make_item (menu, NULL, tray_menu_quit_cb, NULL);
#ifndef WIN32 /* submenus are buggy on win32 */ #ifndef WIN32 /* submenus are buggy on win32 */
@@ -1128,8 +1132,28 @@ tray_menu_clear (GtkWidget *menu)
for (iter = children; iter; iter = iter->next) for (iter = children; iter; iter = iter->next)
gtk_widget_destroy (GTK_WIDGET (iter->data)); gtk_widget_destroy (GTK_WIDGET (iter->data));
g_list_free (children); g_list_free (children);
tray_toggle_item = NULL;
}
#endif
static void
tray_update_toggle_item_label (void)
{
const char *label;
if (!tray_toggle_item)
return;
if (tray_get_window_status () == WS_HIDDEN)
label = _("_Restore Window");
else
label = _("_Hide Window");
gtk_menu_item_set_label (GTK_MENU_ITEM (tray_toggle_item), label);
gtk_menu_item_set_use_underline (GTK_MENU_ITEM (tray_toggle_item), TRUE);
} }
#if !defined(WIN32)
static void G_GNUC_UNUSED static void G_GNUC_UNUSED
tray_menu_show_cb (GtkWidget *menu, gpointer userdata) tray_menu_show_cb (GtkWidget *menu, gpointer userdata)
{ {
@@ -1140,6 +1164,27 @@ tray_menu_show_cb (GtkWidget *menu, gpointer userdata)
} }
#endif #endif
static gboolean
tray_window_state_cb (GtkWidget *widget, GdkEventWindowState *event, gpointer userdata)
{
(void)widget;
(void)event;
(void)userdata;
tray_update_toggle_item_label ();
return FALSE;
}
static void
tray_window_visibility_cb (GtkWidget *widget, gpointer userdata)
{
(void)widget;
(void)userdata;
tray_update_toggle_item_label ();
}
#if !HAVE_APPINDICATOR_BACKEND #if !HAVE_APPINDICATOR_BACKEND
static void static void
tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata) tray_menu_cb (GtkWidget *widget, guint button, guint time, gpointer userdata)
@@ -1381,6 +1426,19 @@ tray_plugin_init (zoitechat_plugin *plugin_handle, char **plugin_name,
zoitechat_hook_print (ph, "Focus Window", -1, tray_focus_cb, NULL); zoitechat_hook_print (ph, "Focus Window", -1, tray_focus_cb, NULL);
GtkWindow *window = GTK_WINDOW(zoitechat_get_info (ph, "gtkwin_ptr")); GtkWindow *window = GTK_WINDOW(zoitechat_get_info (ph, "gtkwin_ptr"));
GtkWidget *window_widget;
if (window)
{
window_widget = GTK_WIDGET (window);
g_signal_connect (G_OBJECT (window_widget), "window-state-event",
G_CALLBACK (tray_window_state_cb), NULL);
g_signal_connect (G_OBJECT (window_widget), "show",
G_CALLBACK (tray_window_visibility_cb), NULL);
g_signal_connect (G_OBJECT (window_widget), "hide",
G_CALLBACK (tray_window_visibility_cb), NULL);
}
if (prefs.hex_gui_tray && gtkutil_tray_icon_supported (window)) if (prefs.hex_gui_tray && gtkutil_tray_icon_supported (window))
tray_init (); tray_init ();