[Pkg-mozext-commits] [firetray] 371/399: Merge branch 'cross-fade' into v0.4.6rc2

David Prévot taffit at alioth.debian.org
Tue Oct 29 18:24:16 UTC 2013


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch dfsg-clean
in repository firetray.

commit 9472fe22a2804631357e6752ce79c8b668c8019f
Merge: c439efb 08bd79a
Author: foudfou <foudil.newbie+git at gmail.com>
Date:   Thu May 30 22:22:08 2013 +0200

    Merge branch 'cross-fade' into v0.4.6rc2
    
    Conflicts:
    	src/modules/FiretrayChat.jsm
    	src/modules/linux/FiretrayChatStatusIcon.jsm

 src/chrome/content/options.js                |   45 ++++++++++++++++++++-
 src/chrome/content/options.xul               |   26 ++++++++++++-
 src/chrome/locale/en-US/options.dtd          |    8 ++++
 src/defaults/preferences/prefs.js            |    2 +
 src/modules/FiretrayChat.jsm                 |   54 ++++++++++++++++++--------
 src/modules/FiretrayHandler.jsm              |   32 ++++++++++++++-
 src/modules/commons.js                       |    5 +++
 src/modules/ctypes/linux/gdk.jsm             |    5 ++-
 src/modules/linux/FiretrayChatStatusIcon.jsm |   18 ++++++---
 src/modules/linux/FiretrayStatusIcon.jsm     |    2 +-
 src/modules/linux/FiretrayWindow.jsm         |    2 +-
 11 files changed, 169 insertions(+), 30 deletions(-)

diff --cc src/modules/FiretrayChat.jsm
index fe7cb43,19a96ea..eace0a7
--- a/src/modules/FiretrayChat.jsm
+++ b/src/modules/FiretrayChat.jsm
@@@ -129,15 -130,26 +130,26 @@@ firetray.Chat = 
      log.debug("convIsCurrentlyShown="+convIsCurrentlyShown);
      if (convIsCurrentlyShown) return; // don't blink when conv tab already on top
  
-     this.shouldAcknowledgeConvs.ids[conv.id] = conv;
-     log.debug(conv.id+' added to shouldAcknowledgeConvs');
-     log.debug('shouldAcknowledgeConvs.length='+this.shouldAcknowledgeConvs.length());
+     this.startGetAttention(conv);
  
-     if (this.shouldAcknowledgeConvs.length() > 1) return; // already calling attention
+     this.shouldAcknowledgeConvs.ids[conv.id] = conv;
+     log.debug(conv.id+' added to shouldAcknowledgeConvs, length='+this.shouldAcknowledgeConvs.length());
+   },
  
+   startGetAttention: function(conv) {
+     log.debug("startGetAttention");
      this.setUrgencyMaybe(conv);
-     // firetray.ChatStatusIcon.startIconBlinking();
-     firetray.ChatStatusIcon.startCrossFade();
+ 
 -    log.info("this.isBlinking="+this.isBlinking);
++    log.debug("this.isBlinking="+this.isBlinking);
+     if (this.isBlinking) return;
+     let blinkStyle = firetray.Utils.prefService.getIntPref("chat_icon_blink_style");
+     log.debug("chat_icon_blink_style="+blinkStyle);
+     if (blinkStyle === FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL)
+       firetray.ChatStatusIcon.startIconBlinking();
+     else if (blinkStyle === FIRETRAY_CHAT_ICON_BLINK_STYLE_CROSS_FADE)
+       firetray.ChatStatusIcon.startCrossFading();
+     else
+       throw new Error("Undefined chat icon blink style.");
    },
  
    /**
@@@ -160,12 -171,21 +171,21 @@@
        }
      }
  
-     if(this.shouldAcknowledgeConvs.length() === 0) {
-       log.debug("do stop icon blinking !!!");
-       firetray.ChatStatusIcon.setUrgency(xid, false);
-       // firetray.ChatStatusIcon.stopIconBlinking();
-       firetray.ChatStatusIcon.stopCrossFade();
-     }
+     if (this.shouldAcknowledgeConvs.length() === 0)
+       this.stopGetAttention(xid);
+   },
+ 
+   stopGetAttention: function(xid) {
 -    log.debug("do stop icon blinking !!!");
++    log.debug("do stop get attention !!!");
+     firetray.ChatStatusIcon.setUrgency(xid, false);
+ 
+     let blinkStyle = firetray.Utils.prefService.getIntPref("chat_icon_blink_style");
+     if (blinkStyle === FIRETRAY_CHAT_ICON_BLINK_STYLE_NORMAL)
+       firetray.ChatStatusIcon.stopIconBlinking();
+     else if (blinkStyle === FIRETRAY_CHAT_ICON_BLINK_STYLE_CROSS_FADE)
+       firetray.ChatStatusIcon.stopCrossFading();
+     else
+       throw new Error("Undefined chat icon blink style.");
    },
  
    onSelect: function(event) {
diff --cc src/modules/linux/FiretrayChatStatusIcon.jsm
index a8e51d0,a8fd670..9115778
--- a/src/modules/linux/FiretrayChatStatusIcon.jsm
+++ b/src/modules/linux/FiretrayChatStatusIcon.jsm
@@@ -93,125 -87,100 +93,133 @@@ firetray.ChatStatusIcon = 
      gtk.gtk_status_icon_set_from_pixbuf(this.trayIcon, null);
    },
  
 -  /**
 -   * EXPERIMENTAL fancy blinking.
 -   * TODO: how to wait for last fade in to restore themedIconNameCurrent
 -   */
 -  startCrossFading: function() {
 -
 -    /* borrowed from mozmill utils.js*/
 -    function sleep(milliseconds) {
 -      var timeup = false;
 -      function wait() { timeup = true; }
 -      let timer = Components.classes["@mozilla.org/timer;1"]
 -            .createInstance(Components.interfaces.nsITimer);
 -      timer.initWithCallback(wait, milliseconds, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
 -
 -      var thread = Components.classes["@mozilla.org/thread-manager;1"].
 -        getService().currentThread;
 -      while(!timeup) {
 -        thread.processNextEvent(true);
 +  buildPixBuf: function() {
 +    let icon_theme = gtk.gtk_icon_theme_get_for_screen(gdk.gdk_screen_get_default());
 +
 +    // get pixbuf
 +    let arry = gobject.gchar.ptr.array()(2);
 +    arry[0] = gobject.gchar.array()(firetray.ChatStatusIcon.themedIconNameCurrent);
 +    arry[1] = null;
 +    log.debug("icon name="+firetray.ChatStatusIcon.themedIconNameCurrent+", theme="+icon_theme+", arry="+arry);
 +    let icon_info = gtk.gtk_icon_theme_choose_icon(icon_theme, arry, 22, gtk.GTK_ICON_LOOKUP_FORCE_SIZE);
 +
 +    // create pixbuf
 +    let pixbuf = gdk.gdk_pixbuf_copy(gtk.gtk_icon_info_load_icon(icon_info, null));
 +    gtk.gtk_icon_info_free(icon_info);   // gobject.g_object_unref(icon_info) in 3.8
 +
 +    // checks
 +    if (gdk.gdk_pixbuf_get_colorspace(pixbuf) != gdk.GDK_COLORSPACE_RGB)
 +      log.error("wrong colorspace for pixbuf");
 +    if (gdk.gdk_pixbuf_get_bits_per_sample(pixbuf) != 8)
 +      log.error("wrong bits_per_sample for pixbuf");
 +    if (!gdk.gdk_pixbuf_get_has_alpha(pixbuf))
 +      log.error("pixbuf doesn't have alpha");
 +    let n_channels = gdk.gdk_pixbuf_get_n_channels(pixbuf);
 +    if (n_channels != 4)
 +      log.error("wrong nb of channels for pixbuf");
 +
 +    // init transform
 +    let width = gdk.gdk_pixbuf_get_width(pixbuf);
 +    let height = gdk.gdk_pixbuf_get_height(pixbuf);
 +    log.debug("width="+width+", height="+height);
 +    let length = width*height*n_channels;
 +    let pixels = ctypes.cast(gdk.gdk_pixbuf_get_pixels(pixbuf),
 +                             gobject.guchar.array(length).ptr);
 +    log.debug("pixels="+pixels);
 +
 +    // backup alpha for later fade-in
 +    let buffer = new ArrayBuffer(width*height);
 +    let alpha_bak = new Uint8Array(buffer);
 +    for (let i=3; i<length; i+=n_channels)
 +      alpha_bak[(i-3)/n_channels] = pixels.contents[i];
 +
++    log.debug("pixbuf created");
++
 +    let ret = {
 +      pixbuf: pixbuf,           // TO BE UNREFED WITH to g_object_unref() !!
 +      width: width,
 +      height: height,
 +      length: length,
 +      n_channels: n_channels,
 +      pixels: pixels,
 +      buffer: buffer,
 +      alpha_bak: alpha_bak
 +    };
- 
 +    return ret;
 +  },
 +  dropPixBuf: function(p) {
 +    gobject.g_object_unref(p.pixbuf); // FIXME: not sure if this shouldn't be done at 'stop-cross-fade'
-     log.info("pixbuf unref'd");
++    log.debug("pixbuf unref'd");
 +  },
 +
-   startCrossFade: function() {  // TODO: Foudil: rename to startFading
++  startCrossFading: function() {  // TODO: Foudil: rename to startFading
++    log.debug("startCrossFading");
 +    const ALPHA_STEP                    = 5;
 +    const ALPHA_STEP_SLEEP_MILLISECONDS = 10;
 +    const FADE_OVER_SLEEP_MILLISECONDS  = 500;
 +
 +    function fadeGen(p) {
 +      for (let a=255; a>0; a-=ALPHA_STEP) {
 +        for(let i=3; i<p.length; i+=p.n_channels)
 +          if (p.pixels.contents[i]-ALPHA_STEP>0)
 +            p.pixels.contents[i] -= ALPHA_STEP;
 +        gtk.gtk_status_icon_set_from_pixbuf(firetray.ChatStatusIcon.trayIcon, p.pixbuf);
 +        yield true;
 +      }
 +
 +      for (let a=255; a>0; a-=ALPHA_STEP) {
 +        for(let i=3; i<p.length; i+=p.n_channels)
 +          if (p.pixels.contents[i]+ALPHA_STEP<=p.alpha_bak[(i-3)/p.n_channels]) {
 +            p.pixels.contents[i] += ALPHA_STEP;
 +          }
 +        gtk.gtk_status_icon_set_from_pixbuf(firetray.ChatStatusIcon.trayIcon, p.pixbuf);
 +        yield true;
        }
      }
  
 -    let icon_theme = gtk.gtk_icon_theme_get_for_screen(gdk.gdk_screen_get_default());
 -    firetray.ChatStatusIcon.timers['cross-fade'] = firetray.Utils.timer(
 -      500, Ci.nsITimer.TYPE_REPEATING_SLACK, function() {
 +    function fadeLoop(p) {
 +
 +      let fadeOutfadeIn = fadeGen(p);
 +      (function step() {
 +        try {
 +          if (fadeOutfadeIn.next())
 +            firetray.Utils.timer(ALPHA_STEP_SLEEP_MILLISECONDS,
 +                                 Ci.nsITimer.TYPE_ONE_SHOT, step);
 +        } catch (e if e instanceof StopIteration) {
 +
 +          if (firetray.ChatStatusIcon.events['stop-cross-fade']) {
 +            delete firetray.ChatStatusIcon.events['stop-cross-fade'];
 +            firetray.ChatStatusIcon.setIconImage(firetray.ChatStatusIcon.themedIconNameCurrent);
 +            return;
 +          }
 +
 +          if (firetray.ChatStatusIcon.events['icon-changed']) {
 +            delete firetray.ChatStatusIcon.events['icon-changed'];
 +            firetray.ChatStatusIcon.dropPixBuf(p);
 +            let newPixbufObj = firetray.ChatStatusIcon.buildPixBuf();
 +            firetray.Utils.timer(FADE_OVER_SLEEP_MILLISECONDS,
 +                                 Ci.nsITimer.TYPE_ONE_SHOT, function(){fadeLoop(newPixbufObj);});
 +
 +          } else {
 +            firetray.Utils.timer(FADE_OVER_SLEEP_MILLISECONDS,
 +                                 Ci.nsITimer.TYPE_ONE_SHOT, function(){fadeLoop(p);});
 +          }
 +        };
 +      })();
  
 -        // get pixbuf
 -        let arry = gobject.gchar.ptr.array()(2);
 -        arry[0] = gobject.gchar.array()(firetray.ChatStatusIcon.themedIconNameCurrent);
 -        arry[1] = null;
 -        log.debug("theme="+icon_theme+", arry="+arry);
 -        let icon_info = gtk.gtk_icon_theme_choose_icon(icon_theme, arry, 22, gtk.GTK_ICON_LOOKUP_FORCE_SIZE);
 -
 -        // create pixbuf
 -        let pixbuf = gdk.gdk_pixbuf_copy(gtk.gtk_icon_info_load_icon(icon_info, null));
 -        gtk.gtk_icon_info_free(icon_info);   // gobject.g_object_unref(icon_info) in 3.8
 -
 -        // checks
 -        if (gdk.gdk_pixbuf_get_colorspace(pixbuf) != gdk.GDK_COLORSPACE_RGB)
 -          log.error("wrong colorspace for pixbuf");
 -        if (gdk.gdk_pixbuf_get_bits_per_sample(pixbuf) != 8)
 -          log.error("wrong bits_per_sample for pixbuf");
 -        if (!gdk.gdk_pixbuf_get_has_alpha(pixbuf))
 -          log.error("pixbuf doesn't have alpha");
 -        let n_channels = gdk.gdk_pixbuf_get_n_channels(pixbuf);
 -        if (n_channels != 4)
 -          log.error("wrong nb of channels for pixbuf");
 -
 -        // init transform
 -        let width = gdk.gdk_pixbuf_get_width(pixbuf);
 -        let height = gdk.gdk_pixbuf_get_height(pixbuf);
 -        log.warn("width="+width+", height="+height);
 -        let rowstride = gdk.gdk_pixbuf_get_rowstride(pixbuf);
 -        log.warn("rowstride="+rowstride);
 -        let length = width*height*n_channels;
 -        let pixels = ctypes.cast(gdk.gdk_pixbuf_get_pixels(pixbuf),
 -                                 gobject.guchar.array(length).ptr);
 -        log.warn("pixels="+pixels);
 -
 -        // backup alpha for later fade-in
 -        let buffer = new ArrayBuffer(width*height);
 -        let alpha_bak = new Uint8Array(buffer);
 -        for (let i=3; i<length; i+=n_channels)
 -          alpha_bak[(i-3)/n_channels] = pixels.contents[i];
 -
 -        const ALPHA_STEP = 5;
 -
 -        // fade out
 -        for (let a=255; a>0; a-=ALPHA_STEP) {
 -          for(let i=3; i<length; i+=n_channels)
 -            if (pixels.contents[i]-ALPHA_STEP>0)
 -              pixels.contents[i] -= ALPHA_STEP;
 -          gtk.gtk_status_icon_set_from_pixbuf(firetray.ChatStatusIcon.trayIcon, pixbuf);
 -          sleep(10);
 -        }
 -
 -        // fade in
 -        for (let a=255; a>0; a-=ALPHA_STEP) {
 -          for(let i=3; i<length; i+=n_channels)
 -            if (pixels.contents[i]+ALPHA_STEP<=alpha_bak[(i-3)/n_channels]) {
 -              pixels.contents[i] += ALPHA_STEP;
 -            }
 -          gtk.gtk_status_icon_set_from_pixbuf(firetray.ChatStatusIcon.trayIcon, pixbuf);
 -          sleep(10);
 -        }
 -
 -        gobject.g_object_unref(pixbuf);
 -      });
 +    }
 +    let pixbufObj = this.buildPixBuf();
 +    fadeLoop(pixbufObj);
 +
 +    firetray.ChatStatusIcon.dropPixBuf(pixbufObj);
    },
  
+   stopCrossFading: function() {
++    log.debug("stopCrossFading");
+     this.timers['cross-fade'].cancel();
+     this.setIconImage(firetray.ChatStatusIcon.themedIconNameCurrent);
+   },
+ 
    startIconBlinking: function() { // gtk_status_icon_set_blinking() deprecated
      this.on = true;
      firetray.ChatStatusIcon.timers['blink'] = firetray.Utils.timer(
@@@ -230,10 -199,6 +238,10 @@@
      this.on = false;
    },
  
-   stopCrossFade: function() {
++  stopCrossFading: function() {
 +    this.events['stop-cross-fade'] = true;
 +  },
 +
    setUrgency: function(xid, urgent) {
      gtk.gtk_window_set_urgency_hint(firetray.Handler.gtkWindows.get(xid), urgent);
    },
diff --cc src/modules/linux/FiretrayStatusIcon.jsm
index d3ee240,faa3ba7..5c13c97
--- a/src/modules/linux/FiretrayStatusIcon.jsm
+++ b/src/modules/linux/FiretrayStatusIcon.jsm
@@@ -328,10 -328,9 +328,10 @@@ firetray.Handler.setIconText = function
      gobject.g_object_unref(buf);
  
      // merge the rendered text on top
-     gdk.gdk_pixbuf_composite(bufAlpha,dest,0,0,w,h,0,0,1,1,gdk.GDK_INTERP_NEAREST,255);
+     gdk.gdk_pixbuf_composite(bufAlpha,dest,0,0,w,h,0,0,1,1,gdk.GDK_INTERP_BILINEAR,255);
      gobject.g_object_unref(bufAlpha);
  
 +    log.info("gtk_status_icon_set_from_pixbuf="+dest);
      gtk.gtk_status_icon_set_from_pixbuf(firetray.StatusIcon.trayIcon, dest);
    } catch (x) {
      log.error(x);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/firetray.git



More information about the Pkg-mozext-commits mailing list