Advertisement
Guest User

Untitled

a guest
Nov 1st, 2012
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- applet.js.orig  2012-10-31 23:25:21.485032500 +0700
  2. +++ applet.js   2012-11-01 14:27:09.777544467 +0700
  3. @@ -1,20 +1,11 @@
  4.  const Applet = imports.ui.applet;
  5.  const Clutter = imports.gi.Clutter;
  6.  const GLib = imports.gi.GLib;
  7. -var Bluetooth;
  8. -try {
  9. -    Bluetooth = imports.gi.GnomeBluetooth;
  10. -    new Bluetooth.Applet(); // try the 3.6 ABI
  11. -    global.logError("Bluetooth Gnome 3.6 ABI");
  12. -}
  13. -catch(e) {
  14. -    // Fallback to the 3.4 ABI
  15. -    Bluetooth = imports.gi.GnomeBluetoothApplet;
  16. -    global.logError("Bluetooth Gnome 3.4 ABI");
  17. -}
  18. +const GnomeBluetoothApplet = imports.gi.GnomeBluetoothApplet;
  19. +const GnomeBluetooth = imports.gi.GnomeBluetooth;
  20.  const Lang = imports.lang;
  21.  const St = imports.gi.St;
  22. -
  23. +var ABI=6;
  24.  const Main = imports.ui.main;
  25.  const MessageTray = imports.ui.messageTray;
  26.  const PopupMenu = imports.ui.popupMenu;
  27. @@ -26,6 +17,10 @@
  28.      CONNECTING: 3
  29.  }
  30.  
  31. + if (!GnomeBluetooth.hasOwnProperty('KillswitchState')){
  32. +   ABI=4;
  33. +}
  34. +
  35.  function Source() {
  36.      this._init.apply(this, arguments);
  37.  }
  38. @@ -216,19 +211,29 @@
  39.              this.set_applet_tooltip(_("Bluetooth"));
  40.                          
  41.              GLib.spawn_command_line_sync ('pkill -f "^bluetooth-applet$"');
  42. -            this._applet = new Bluetooth.Applet();
  43. -
  44. +            this._applet = new GnomeBluetoothApplet.Applet();
  45.              this._killswitch = new PopupMenu.PopupSwitchMenuItem(_("Bluetooth"), false);
  46.              this._applet.connect('notify::killswitch-state', Lang.bind(this, this._updateKillswitch));
  47.              this._killswitch.connect('toggled', Lang.bind(this, function() {
  48.                  let current_state = this._applet.killswitch_state;
  49. -                if (current_state != Bluetooth.KillswitchState.HARD_BLOCKED &&
  50. -                    current_state != Bluetooth.KillswitchState.NO_ADAPTER) {
  51. -                    this._applet.killswitch_state = this._killswitch.state ?
  52. -                        Bluetooth.KillswitchState.UNBLOCKED:
  53. -                        Bluetooth.KillswitchState.SOFT_BLOCKED;
  54. -                } else
  55. -                    this._killswitch.setToggleState(false);
  56. +       if (ABI==6){
  57. +           if (current_state != GnomeBluetooth.KillswitchState.HARD_BLOCKED &&
  58. +               current_state != GnomeBluetooth.KillswitchState.NO_ADAPTER) {
  59. +               this._applet.killswitch_state = this._killswitch.state ?
  60. +               GnomeBluetooth.KillswitchState.UNBLOCKED:
  61. +                   GnomeBluetooth.KillswitchState.SOFT_BLOCKED;
  62. +           } else
  63. +               this._killswitch.setToggleState(false);
  64. +       } else {
  65. +           if (current_state != GnomeBluetoothApplet.KillswitchState.HARD_BLOCKED &&
  66. +               current_state != GnomeBluetoothApplet.KillswitchState.NO_ADAPTER) {
  67. +               this._applet.killswitch_state = this._killswitch.state ?
  68. +               GnomeBluetoothApplet.KillswitchState.UNBLOCKED:
  69. +                   GnomeBluetoothApplet.KillswitchState.SOFT_BLOCKED;
  70. +           } else
  71. +               this._killswitch.setToggleState(false);
  72. +       }
  73. +       global.logError(this._killswitch.state)
  74.              }));
  75.  
  76.              this._discoverable = new PopupMenu.PopupSwitchMenuItem(_("Visibility"), this._applet.discoverable);
  77. @@ -290,11 +295,20 @@
  78.    
  79.      _updateKillswitch: function() {
  80.          let current_state = this._applet.killswitch_state;
  81. -        let on = current_state == Bluetooth.KillswitchState.UNBLOCKED;
  82. -        let has_adapter = current_state != Bluetooth.KillswitchState.NO_ADAPTER;
  83. -        let can_toggle = current_state != Bluetooth.KillswitchState.NO_ADAPTER &&
  84. -                         current_state != Bluetooth.KillswitchState.HARD_BLOCKED;
  85. -
  86. +   let on;
  87. +   let has_adapter;
  88. +   let can_toggle;
  89. +   if (ABI==6){
  90. +       on = current_state == GnomeBluetooth.KillswitchState.UNBLOCKED;
  91. +       has_adapter = current_state != GnomeBluetooth.KillswitchState.NO_ADAPTER;
  92. +       can_toggle = current_state != GnomeBluetooth.KillswitchState.NO_ADAPTER &&
  93. +                    current_state != GnomeBluetooth.KillswitchState.HARD_BLOCKED;
  94. +   } else {
  95. +       on = current_state == GnomeBluetoothApplet.KillswitchState.UNBLOCKED;
  96. +       has_adapter = current_state != GnomeBluetoothApplet.KillswitchState.NO_ADAPTER;
  97. +       can_toggle = current_state != GnomeBluetoothApplet.KillswitchState.NO_ADAPTER &&
  98. +                    current_state != GnomeBluetoothApplet.KillswitchState.HARD_BLOCKED;
  99. +   }
  100.          this._killswitch.setToggleState(on);
  101.          if (can_toggle)
  102.              this._killswitch.setStatus(null);
  103. @@ -352,7 +366,7 @@
  104.      },
  105.  
  106.      _updateDeviceItem: function(item, device) {
  107. -        if (!device.can_connect && device.capabilities == Bluetooth.Capabilities.NONE) {
  108. +        if (!device.can_connect && device.capabilities == GnomeBluetoothApplet.Capabilities.NONE) {
  109.              item.destroy();
  110.              return;
  111.          }
  112. @@ -381,7 +395,7 @@
  113.      },
  114.  
  115.      _createDeviceItem: function(device) {
  116. -        if (!device.can_connect && device.capabilities == Bluetooth.Capabilities.NONE)
  117. +        if (!device.can_connect && device.capabilities == GnomeBluetoothApplet.Capabilities.NONE)
  118.              return null;
  119.          let item = new PopupMenu.PopupSubMenuMenuItem(device.alias);
  120.  
  121. @@ -436,12 +450,12 @@
  122.              item.menu.addMenuItem(item._connectedMenuitem);
  123.          }
  124.  
  125. -        if (device.capabilities & Bluetooth.Capabilities.OBEX_PUSH) {
  126. +        if (device.capabilities & GnomeBluetoothApplet.Capabilities.OBEX_PUSH) {
  127.              item.menu.addAction(_("Send Files..."), Lang.bind(this, function() {
  128.                  this._applet.send_to_address(device.bdaddr, device.alias);
  129.              }));
  130.          }
  131. -        if (device.capabilities & Bluetooth.Capabilities.OBEX_FILE_TRANSFER) {
  132. +        if (device.capabilities & GnomeBluetoothApplet.Capabilities.OBEX_FILE_TRANSFER) {
  133.              item.menu.addAction(_("Browse Files..."), Lang.bind(this, function(event) {
  134.                  this._applet.browse_address(device.bdaddr, event.get_time(),
  135.                      Lang.bind(this, function(applet, result) {
  136. @@ -459,15 +473,15 @@
  137.          }
  138.  
  139.          switch (device.type) {
  140. -        case Bluetooth.Type.KEYBOARD:
  141. +        case GnomeBluetoothApplet.Type.KEYBOARD:
  142.              item.menu.addSettingsAction(_("Keyboard Settings"), 'gnome-keyboard-panel.desktop');
  143.              break;
  144. -        case Bluetooth.Type.MOUSE:
  145. +        case GnomeBluetoothApplet.Type.MOUSE:
  146.              item.menu.addSettingsAction(_("Mouse Settings"), 'gnome-mouse-panel.desktop');
  147.              break;
  148. -        case Bluetooth.Type.HEADSET:
  149. -        case Bluetooth.Type.HEADPHONES:
  150. -        case Bluetooth.Type.OTHER_AUDIO:
  151. +        case GnomeBluetoothApplet.Type.HEADSET:
  152. +        case GnomeBluetoothApplet.Type.HEADPHONES:
  153. +        case GnomeBluetoothApplet.Type.OTHER_AUDIO:
  154.              item.menu.addSettingsAction(_("Sound Settings"), 'gnome-sound-panel.desktop');
  155.              break;
  156.          default:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement