diff --git a/src/chrome/content/options.js b/src/chrome/content/options.js index 735ee24..612db61 100644 --- a/src/chrome/content/options.js +++ b/src/chrome/content/options.js @@ -20,6 +20,7 @@ var firetrayUIOptions = { this.strings = document.getElementById("firetray-options-strings"); this.updateWindowAndIconOptions(); + this.updateScrollOptions(); if(firetray.Handler.inMailApp) { Cu.import("resource://firetray/FiretrayMessaging.jsm"); @@ -70,6 +71,11 @@ var firetrayUIOptions = { !(hides_on_close || hides_on_minimize); }, + updateScrollOptions: function() { + let scroll_to_hide = document.getElementById("ui_scroll_to_hide").checked; + this.disableGroup(document.getElementById("ui_radiogroup_scroll"), !scroll_to_hide); + }, + initMailControls: function() { this.populateExcludedFoldersList(); this.populateTreeAccountsOrServerTypes(); diff --git a/src/chrome/content/options.xul b/src/chrome/content/options.xul index f3e9b69..cfa95fa 100644 --- a/src/chrome/content/options.xul +++ b/src/chrome/content/options.xul @@ -24,6 +24,8 @@ + + @@ -32,7 +34,6 @@ - @@ -64,13 +65,19 @@ + + + + + - - diff --git a/src/chrome/locale/en-US/options.dtd b/src/chrome/locale/en-US/options.dtd index 52894f0..f3aa08e 100644 --- a/src/chrome/locale/en-US/options.dtd +++ b/src/chrome/locale/en-US/options.dtd @@ -10,17 +10,24 @@ - - + + - + + + + + + + + diff --git a/src/defaults/preferences/prefs.js b/src/defaults/preferences/prefs.js index 935907e..495476b 100644 --- a/src/defaults/preferences/prefs.js +++ b/src/defaults/preferences/prefs.js @@ -11,6 +11,8 @@ pref("extensions.firetray.hides_on_minimize", true); pref("extensions.firetray.hides_single_window", false); pref("extensions.firetray.start_hidden", false); pref("extensions.firetray.show_icon_on_hide", false); +pref("extensions.firetray.scroll_to_hide", true); +pref("extensions.firetray.scroll_mode", "down_hides"); pref("extensions.firetray.mail_notification", 1); pref("extensions.firetray.icon_text_color", "#000000"); diff --git a/src/modules/ctypes/gdk.jsm b/src/modules/ctypes/gdk.jsm index 940d9ba..84df88e 100644 --- a/src/modules/ctypes/gdk.jsm +++ b/src/modules/ctypes/gdk.jsm @@ -112,6 +112,11 @@ function gdk_defines(lib) { this.GDK_PROP_MODE_REPLACE = 0; this.GDK_PROP_MODE_PREPEN = 1; this.GDK_PROP_MODE_APPEND = 2; + this.GdkScrollDirection = ctypes.int; // enum + this.GDK_SCROLL_UP = 0; + this.GDK_SCROLL_DOWN = 1; + this.GDK_SCROLL_LEFT = 2; + this.GDK_SCROLL_RIGHT = 3; this.GdkWindow = ctypes.StructType("GdkWindow"); this.GdkByteOrder = ctypes.int; // enum @@ -180,6 +185,19 @@ function gdk_defines(lib) { { "changed_mask": this.GdkWindowState }, { "new_window_state": this.GdkWindowState }, ]); + this.GdkDevice = ctypes.StructType("GdkDevice"); + this.GdkEventScroll = ctypes.StructType("GdkEventScroll", [ + { "type": this.GdkEventType }, + { "window": this.GdkWindow.ptr }, + { "send_event": gobject.gint8 }, + { "time": gobject.guint32 }, + { "x": gobject.gdouble }, + { "y": gobject.gdouble }, + { "state": gobject.guint }, + { "direction": this.GdkScrollDirection }, + { "device": this.GdkDevice.ptr }, + { "x_root": gobject.gdouble }, { "y_root": gobject.gdouble } + ]); this.GdkAtom = ctypes.StructType("GdkAtom"); this.GdkFilterFunc_t = ctypes.FunctionType( diff --git a/src/modules/ctypes/gobject.jsm b/src/modules/ctypes/gobject.jsm index 8d56d58..542e6ba 100644 --- a/src/modules/ctypes/gobject.jsm +++ b/src/modules/ctypes/gobject.jsm @@ -93,6 +93,7 @@ function gobject_defines(lib) { this.guchar = ctypes.unsigned_char; this.gboolean = this.gint; this.gfloat = ctypes.float; + this.gdouble = ctypes.double; this.gsize = ctypes.unsigned_long; this.GCallback = ctypes.voidptr_t; this.GClosureNotify = this.gpointer; diff --git a/src/modules/gtk2/FiretrayStatusIcon.jsm b/src/modules/gtk2/FiretrayStatusIcon.jsm index 4e59bd5..e1406b2 100644 --- a/src/modules/gtk2/FiretrayStatusIcon.jsm +++ b/src/modules/gtk2/FiretrayStatusIcon.jsm @@ -149,8 +149,29 @@ firetray.StatusIcon = { }, onScroll: function(icon, event, data) { - LOG("scroll-event"); - // TODO: + let iconGpointer = ctypes.cast(icon, gobject.gpointer); + let gdkEventScroll = ctypes.cast(event, gdk.GdkEventScroll.ptr); + let scroll_mode = firetray.Utils.prefService.getCharPref("scroll_mode"); + + let direction = gdkEventScroll.contents.direction; + switch(direction) { + case gdk.GDK_SCROLL_UP: + LOG("SCROLL UP"); + if (scroll_mode === "down_hides") + firetray.Handler.showAllWindows(); + else if (scroll_mode === "up_hides") + firetray.Handler.hideAllWindows(); + break; + case gdk.GDK_SCROLL_DOWN: + LOG("SCROLL DOWN"); + if (scroll_mode === "down_hides") + firetray.Handler.hideAllWindows(); + else if (scroll_mode === "up_hides") + firetray.Handler.showAllWindows(); + break; + default: + ERROR("SCROLL UNKNOWN"); + } } }; // firetray.StatusIcon