Skip to content

Commit

Permalink
Restore tray icon blinking, Remove broken menu items, Update Info.plist
Browse files Browse the repository at this point in the history
  • Loading branch information
AlienCowEatCake committed Jul 17, 2022
1 parent 3a4a2e1 commit c4f3c35
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 16 deletions.
58 changes: 48 additions & 10 deletions patches_sylpheed/0015-Improve-UX-for-macOS-builds.patch
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
From be9513801f246a6784869a1d0cf17f559207e27e Mon Sep 17 00:00:00 2001
From cac20cb417dec5eb67e3ad075248a2866e978229 Mon Sep 17 00:00:00 2001
From: Peter Zhigalov <[email protected]>
Date: Sat, 16 Jul 2022 03:07:10 +0700
Subject: [PATCH 15/16] Improve UX for macOS builds

---
libsylph/defs.h | 6 +++++-
libsylph/prefs_common.c | 2 +-
src/Makefile.in | 1 +
src/gtkutils.c | 8 ++++++++
src/mainwindow.c | 16 +++++++++++++++-
src/prefs_common_dialog.c | 10 ++++++++++
6 files changed, 40 insertions(+), 3 deletions(-)
libsylph/defs.h | 6 +++++-
libsylph/prefs_common.c | 2 +-
macosx/bundle/Info-sylpheed.plist | 8 ++++++++
src/Makefile.in | 1 +
src/gtkutils.c | 8 ++++++++
src/mainwindow.c | 28 +++++++++++++++++++++++++++-
src/prefs_common_dialog.c | 10 ++++++++++
7 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/libsylph/defs.h b/libsylph/defs.h
index 9e3f82b..fcb690d 100644
Expand Down Expand Up @@ -41,6 +42,24 @@ index 247d6f5..ae0fd5b 100644
{"toggle_window_on_trayicon_click", "FALSE",
#else
{"toggle_window_on_trayicon_click", "TRUE",
diff --git a/macosx/bundle/Info-sylpheed.plist b/macosx/bundle/Info-sylpheed.plist
index 9d8dfca..1beca3d 100644
--- a/macosx/bundle/Info-sylpheed.plist
+++ b/macosx/bundle/Info-sylpheed.plist
@@ -28,5 +28,13 @@
<string>10.8</string>
<key>NSUserNotificationAlertStyle</key>
<string>alert</string>
+ <key>CFBundleDisplayName</key>
+ <string>Sylpheed</string>
+ <key>CFBundleName</key>
+ <string>Sylpheed</string>
+ <key>LSApplicationCategoryType</key>
+ <string>public.app-category.productivity</string>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
</dict>
</plist>
diff --git a/src/Makefile.in b/src/Makefile.in
index 042f814..aedae12 100644
--- a/src/Makefile.in
Expand Down Expand Up @@ -80,7 +99,7 @@ index 5f49969..3e53130 100644
}

diff --git a/src/mainwindow.c b/src/mainwindow.c
index 654ec0b..833094a 100644
index 654ec0b..c5935f3 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -54,6 +54,14 @@
Expand All @@ -98,7 +117,26 @@ index 654ec0b..833094a 100644
#include "main.h"
#include "mainwindow.h"
#include "folderview.h"
@@ -3250,8 +3258,14 @@ static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
@@ -1240,6 +1248,18 @@ MainWindow *main_window_create(SeparateType type)
action_update_mainwin_menu(ifactory, mainwin);
#endif

+#if defined(__OBJC__) && defined(__APPLE__)
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ /* Remove (disable) the "Start Dictation..." menu item from the "Edit" menu */
+ [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"NSDisabledDictationMenuItem"];
+#if defined (AVAILABLE_MAC_OS_X_VERSION_10_12_AND_LATER)
+ /* Remove (don't allow) the "Show Tab Bar" menu item from the "View" menu, if supported */
+ if ([NSWindow respondsToSelector:@selector(allowsAutomaticWindowTabbing)])
+ NSWindow.allowsAutomaticWindowTabbing = NO;
+#endif
+ [pool release];
+#endif
+
#ifdef GTKOSXAPPLICATION
gtk_widget_hide(menubar);
gtkosx_application_set_menu_bar(osxapp, GTK_MENU_SHELL(menubar));
@@ -3250,8 +3270,14 @@ static gint main_window_close_cb(GtkWidget *widget, GdkEventAny *event,
{
MainWindow *mainwin = (MainWindow *)data;

Expand Down
111 changes: 105 additions & 6 deletions patches_sylpheed/0016-Use-native-macOS-tray-icon.patch
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
From 090238acb5c744048056ff576f4e47dc350e2843 Mon Sep 17 00:00:00 2001
From 2b81c42cb4526c8be033eb5f228b7e061fa51060 Mon Sep 17 00:00:00 2001
From: Peter Zhigalov <[email protected]>
Date: Sat, 16 Jul 2022 03:07:49 +0700
Subject: [PATCH 16/16] Use native macOS tray icon

---
src/trayicon.c | 245 ++++++++++++++++++++++++++++++++++++++++++++++++-
src/trayicon.c | 344 ++++++++++++++++++++++++++++++++++++++++++++++++-
src/trayicon.h | 4 +
2 files changed, 248 insertions(+), 1 deletion(-)
2 files changed, 347 insertions(+), 1 deletion(-)

diff --git a/src/trayicon.c b/src/trayicon.c
index ef56dc1..d5e6ff7 100644
index ef56dc1..f31e727 100644
--- a/src/trayicon.c
+++ b/src/trayicon.c
@@ -43,7 +43,250 @@
@@ -43,7 +43,349 @@
#include "compose.h"
#include "prefs_common.h"

Expand All @@ -29,8 +29,10 @@ index ef56dc1..d5e6ff7 100644
+#define TRAYICON_IMAGE STOCK_PIXMAP_SYLPHEED
+#define TRAYICON_NEW_IMAGE STOCK_PIXMAP_SYLPHEED_NEWMAIL
+
+#define TRAYICON_NOTIFY_PERIOD 10000
+
+@interface TrayIconDelegate : NSObject
+@property MainWindow *mainwin;
+@property (assign) MainWindow *mainwin;
+- (void)trayicon_present:(id)sender;
+- (void)trayicon_inc:(id)sender;
+- (void)trayicon_inc_all:(id)sender;
Expand Down Expand Up @@ -86,10 +88,71 @@ index ef56dc1..d5e6ff7 100644
+}
+@end
+
+@interface TrayIconBlinker : NSObject
+@property (assign) NSStatusItem *statusItem;
+@property (retain) NSImage *image;
+@property (retain) NSTimer *timer;
+- (void)startBlinking;
+- (void)stopBlinking;
+- (void)timerFired:(NSTimer *)timer;
+@end
+
+@implementation TrayIconBlinker : NSObject
+@synthesize statusItem;
+@synthesize image;
+@synthesize timer;
+
+-(id)initWithStatusItem:(NSStatusItem *)statusItem
+{
+ if (self = [super init]) {
+ [self setStatusItem:statusItem];
+ [self setImage:nil];
+ [self setTimer:nil];
+ }
+ return self;
+}
+
+- (void)startBlinking
+{
+ if ([self timer])
+ return;
+
+ [self setTimer:[NSTimer
+ scheduledTimerWithTimeInterval:0.5
+ target:self
+ selector:@selector(timerFired:)
+ userInfo:nil
+ repeats:YES
+ ]];
+}
+
+- (void)stopBlinking
+{
+ if (![self timer])
+ return;
+
+ [[self timer] invalidate];
+ [self setTimer:nil];
+
+ while ([self image])
+ [self timerFired:nil];
+}
+
+- (void)timerFired:(NSTimer *)timer
+{
+ NSImage *tmp = [self image];
+ [self setImage:[[self statusItem] image]];
+ if ([self image] && tmp)
+ tmp = nil;
+ [[self statusItem] setImage:tmp];
+}
+@end
+
+struct _TrayIcon
+{
+ NSStatusItem *status_item;
+ TrayIconDelegate *delegate;
+ TrayIconBlinker *blinker;
+};
+
+static TrayIcon trayicon;
Expand Down Expand Up @@ -151,6 +214,7 @@ index ef56dc1..d5e6ff7 100644
+
+ trayicon.status_item = status_item;
+ trayicon.delegate = delegate;
+ trayicon.blinker = [[TrayIconBlinker alloc] initWithStatusItem:status_item];
+ [pool release];
+
+ on_notify = FALSE;
Expand Down Expand Up @@ -188,6 +252,11 @@ index ef56dc1..d5e6ff7 100644
+ [tray_icon->delegate release];
+ tray_icon->delegate = nil;
+ }
+ if (tray_icon && tray_icon->blinker) {
+ [tray_icon->blinker stopBlinking];
+ [tray_icon->blinker release];
+ tray_icon->blinker = nil;
+ }
+ [pool release];
+}
+
Expand All @@ -204,6 +273,28 @@ index ef56dc1..d5e6ff7 100644
+ [pool release];
+}
+
+static void trayicon_set_blinking(gboolean blinking)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ if (blinking)
+ [trayicon.blinker startBlinking];
+ else
+ [trayicon.blinker stopBlinking];
+ [pool release];
+}
+
+static guint notify_tag = 0;
+
+static gboolean notify_timeout_cb(gpointer data)
+{
+ gdk_threads_enter();
+ trayicon_set_blinking(FALSE);
+ notify_tag = 0;
+ gdk_threads_leave();
+
+ return FALSE;
+}
+
+void trayicon_set_notify(gboolean enabled)
+{
+ if (enabled && !on_notify) {
Expand All @@ -213,6 +304,14 @@ index ef56dc1..d5e6ff7 100644
+ trayicon_set_stock_icon(TRAYICON_IMAGE);
+ on_notify = FALSE;
+ }
+
+ if (enabled && notify_tag == 0) {
+ trayicon_set_blinking(enabled);
+ notify_tag = g_timeout_add(TRAYICON_NOTIFY_PERIOD, notify_timeout_cb, NULL);
+ } else if (!enabled && notify_tag > 0) {
+ g_source_remove(notify_tag);
+ notify_timeout_cb(NULL);
+ }
+}
+
+void trayicon_set_stock_icon(StockPixmap icon)
Expand Down

0 comments on commit c4f3c35

Please sign in to comment.