Ticket #1581: enable_appindicator_patch.patch

File enable_appindicator_patch.patch, 8.9 KB (added by nick, 13 years ago)

Add 'enable application indicator' option to gtkui. Defaults to false.

  • deluge/ui/gtkui/glade/preferences_dialog.glade

    diff --git a/deluge/ui/gtkui/glade/preferences_dialog.glade b/deluge/ui/gtkui/glade/preferences_dialog.glade
    index d4cdc61..76c71ce 100644
    a b Disabled</property> 
    20692069                                          </packing> 
    20702070                                        </child> 
    20712071                                        <child> 
     2072                                          <widget class="GtkAlignment" id="alignment32"> 
     2073                                            <property name="visible">True</property> 
     2074                                            <property name="left_padding">10</property> 
     2075                                            <child> 
     2076                                              <widget class="GtkCheckButton" id="chk_enable_appindicator"> 
     2077                                                <property name="label" translatable="yes">Enable Application Indicator</property> 
     2078                                                <property name="visible">True</property> 
     2079                                                <property name="sensitive">False</property> 
     2080                                                <property name="can_focus">False</property> 
     2081                                                <property name="receives_default">False</property> 
     2082                                                <property name="use_underline">True</property> 
     2083                                                <property name="draw_indicator">True</property> 
     2084                                              </widget> 
     2085                                            </child> 
     2086                                          </widget> 
     2087                                          <packing> 
     2088                                            <property name="position">3</property> 
     2089                                          </packing> 
     2090                                        </child> 
     2091                                        <child> 
    20722092                                          <widget class="GtkAlignment" id="alignment17"> 
    20732093                                            <property name="visible">True</property> 
    20742094                                            <property name="bottom_padding">3</property> 
    Disabled</property> 
    20882108                                          </widget> 
    20892109                                          <packing> 
    20902110                                            <property name="expand">False</property> 
    2091                                             <property name="position">3</property> 
     2111                                            <property name="position">4</property> 
    20922112                                          </packing> 
    20932113                                        </child> 
    20942114                                        <child> 
    Disabled</property> 
    21312151                                            </child> 
    21322152                                          </widget> 
    21332153                                          <packing> 
    2134                                             <property name="position">4</property> 
     2154                                            <property name="position">5</property> 
    21352155                                          </packing> 
    21362156                                        </child> 
    21372157                                      </widget> 
  • deluge/ui/gtkui/gtkui.py

    diff --git a/deluge/ui/gtkui/gtkui.py b/deluge/ui/gtkui/gtkui.py
    index 1609a28..1efbda3 100644
    a b def start(): 
    116116    "enable_system_tray": True, 
    117117    "close_to_tray": True, 
    118118    "start_in_tray": False, 
     119    "enable_appindicator": False, 
    119120    "lock_tray": False, 
    120121    "tray_password": "", 
    121122    "check_new_releases": True, 
  • deluge/ui/gtkui/preferences.py

    diff --git a/deluge/ui/gtkui/preferences.py b/deluge/ui/gtkui/preferences.py
    index edc253e..a13937a 100644
    a b def _show(self): 
    471471            self.gtkui_config["close_to_tray"]) 
    472472        self.glade.get_widget("chk_start_in_tray").set_active( 
    473473            self.gtkui_config["start_in_tray"]) 
     474        self.glade.get_widget("chk_enable_appindicator").set_active( 
     475            self.gtkui_config["enable_appindicator"]) 
    474476        self.glade.get_widget("chk_lock_tray").set_active( 
    475477            self.gtkui_config["lock_tray"]) 
    476478        self.glade.get_widget("chk_classic_mode").set_active( 
    def set_config(self, hide=False): 
    637639            self.glade.get_widget("chk_min_on_close").get_active() 
    638640        new_gtkui_config["start_in_tray"] = \ 
    639641            self.glade.get_widget("chk_start_in_tray").get_active() 
     642        new_gtkui_config["enable_appindicator"] = \ 
     643            self.glade.get_widget("chk_enable_appindicator").get_active() 
    640644        new_gtkui_config["lock_tray"] = \ 
    641645            self.glade.get_widget("chk_lock_tray").get_active() 
    642646        passhex = sha_hash(\ 
    def on_toggle(self, widget): 
    782786                                              "spin_outgoing_port_max": False}, 
    783787                "chk_use_tray": {"chk_min_on_close": True, 
    784788                                 "chk_start_in_tray": True, 
     789                                 "chk_enable_appindicator": True, 
    785790                                 "chk_lock_tray": True}, 
    786791                "chk_lock_tray": {"txt_tray_password": True, 
    787792                                  "password_label": True}, 
  • deluge/ui/gtkui/systemtray.py

    diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py
    index c4bce49..b465c54 100644
    a b def __init__(self): 
    7070        ] 
    7171        self.config.register_set_function("enable_system_tray", 
    7272                                          self.on_enable_system_tray_set) 
     73        # bit of a hack to prevent function from doing something on startup 
     74        self.__enabled_set_once = False 
     75        self.config.register_set_function("enable_appindicator", 
     76                                          self.on_enable_appindicator_set) 
    7377 
    7478        self.max_download_speed = -1.0 
    7579        self.download_rate = 0.0 
    def enable(self): 
    103107 
    104108        self.tray_menu = self.tray_glade.get_widget("tray_menu") 
    105109 
    106         if appindicator: 
     110        if appindicator and self.config["enable_appindicator"]: 
    107111            log.debug("Enabling the Application Indicator..") 
    108112            self.indicator = appindicator.Indicator ( 
    109113                "deluge", "deluge", appindicator.CATEGORY_APPLICATION_STATUS) 
    def __start(self): 
    162166 
    163167            # These do not work with appindicator currently and can crash Deluge. 
    164168            # Related to Launchpad bug #608219 
    165             if appindicator: 
     169            if appindicator and self.config["enable_appindicator"]: 
    166170                self.hide_widget_list.remove("menuitem_download_limit") 
    167171                self.hide_widget_list.remove("menuitem_upload_limit") 
    168172                self.hide_widget_list.remove("separatormenuitem3") 
    def stop(self): 
    200204 
    201205    def shutdown(self): 
    202206        if self.config["enable_system_tray"]: 
    203             if appindicator: 
     207            if appindicator and self.config["enable_appindicator"]: 
    204208                self.indicator.set_status(appindicator.STATUS_PASSIVE) 
    205209            else: 
    206210                self.tray.set_visible(False) 
    def update(self): 
    236240            return 
    237241 
    238242        # Tool tip text not available for appindicator 
    239         if appindicator: 
     243        if appindicator and self.config["enable_appindicator"]: 
    240244            return 
    241245 
    242246        # Set the tool tip text 
    def build_tray_bwsetsubmenu(self): 
    285289        submenu_bwupset.show_all() 
    286290 
    287291        # Re-set the menu to partly work around Launchpad bug #608219 
    288         if appindicator: 
     292        if appindicator and self.config["enable_appindicator"]: 
    289293            self.indicator.set_menu(self.tray_menu) 
    290294 
    291     def disable(self): 
     295    def disable(self,invert_app_ind_conf=False): 
    292296        """Disables the system tray icon or appindicator.""" 
    293297        try: 
    294             if appindicator: 
     298            if invert_app_ind_conf: 
     299                app_ind_conf = not self.config["enable_appindicator"] 
     300            else: 
     301                app_ind_conf = self.config["enable_appindicator"] 
     302            if appindicator and app_ind_conf: 
    295303                if hasattr(self, "_sig_win_hide"): 
    296304                    self.window.window.disconnect(self._sig_win_hide) 
    297305                    self.window.window.disconnect(self._sig_win_show) 
    def on_enable_system_tray_set(self, key, value): 
    323331        else: 
    324332            self.disable() 
    325333 
     334    def on_enable_appindicator_set(self, key, value): 
     335        """Called whenever the 'enable_appindicator' config key is modified""" 
     336        if self.__enabled_set_once: 
     337            self.disable(True) 
     338            self.enable() 
     339        self.__enabled_set_once = True 
     340 
    326341    def on_tray_clicked(self, icon): 
    327342        """Called when the tray icon is left clicked.""" 
    328343        self.blink(False)