From 68749a7ad54dd4b2cb528dd9f28bc98464878d77 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 14 Dec 2009 02:15:08 +0000 Subject: [PATCH] Fix #594 tray password dialog freeze in Windows Made the password dialog prettier --- deluge/data/pixmaps/lock48.png | Bin 0 -> 2978 bytes deluge/ui/gtkui/systemtray.py | 83 ++++++++++++++++++++------------- 2 files changed, 51 insertions(+), 32 deletions(-) create mode 100644 deluge/data/pixmaps/lock48.png diff --git a/deluge/data/pixmaps/lock48.png b/deluge/data/pixmaps/lock48.png new file mode 100644 index 0000000000000000000000000000000000000000..f24ae3a60a17564088ac4aebbf1b40b0bb3cdb23 GIT binary patch literal 2978 zcmV;T3tjYyP)LZbix0K#-d zSad^gZEa<4bO0!0DIhX1FfbrWVQY0_ASX&`ZEay=Cm>UFWod3@ataDmXlZjGX>DO= zWgvH9b0A}KWnpw>WFU2OX>MmAM`>+vE+9u~ZEzrIb0B7NWo009Z)S9NVRB_43Sn~~ zWMyV)Ze?U3VtF8RXk{Qqa%E*8Q*UN;cVTj6AVzO>Ze(F}X>V>IVQyp~X>%Z9c4293 zVPb4$3TAI|AY^ZMZftL1WFTR5AZT=Sa5^t9cXxL#XK8J4E^l&YMp_mN000VMNkl=?~57l8(eD6GbW=uLua_9o7CFu9O{#0w#;-Uy6` z%9+cr-r&$T?tq&zx&i(G_+8*Tz)|PiteLgI7r;+}p8)>=bmfdw&e%5%KVOVK2>bxJ z>YTHeUw+xnoH=6`FJ82zr6v39v(N0~k3Y5(Cr+4i&VXg$1h5F)1sp2x@p}!byG6*< zz{9`^=iGPRd+$B&zyE$lqY>VFRF#}FB0|oYoHOI`n2$dCh^L-<3N!mp;Lm`60ycm# zkoE$p@HHLq#rVg8A0Iz{{OFr+zRBX^BHnv)&a`by-}j`H$T_2`08~}Q-FM&3v17-$ zeEIT`&p-eC81Ub~#VL;H?Q~!|@;`p*rI%)3c;N*O9z00fwv5MP*4NirSy^FeX^GX< zRbq^&D$Y5)_uJW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7a%`iG}5a%2s z88rbX1P6o)?-XAJ43C*%sz@3*l)9F_-$ME!0}{t*=jq$6p}ZE-@2dlr5@v~8p&U>mV;DX07z)e+oG~ zj|t5XHRD6IzYgI2z<~gDHNu(^vE4#MNRp5^CbnDjT~F+L`gV*KvJdm1fUg2oUE>0H z)uBIF22Hq>t}i9Z;XCdw`fVQ}B+_HCC#H_B9pmeOcaE9bkmew>hvtTzOjY3n_$pjq z#uUjia3E%+-9mCVRHC*;tBO1xBVO>KBFxR>_p=INL-zy*xlBa2GUkTPnQ|t_ekhlz z+m_4DIlQZ|$`x`}g96nwbYqEF?#bO4(S#G*7IU%-4DH?l=eLbASAM-=YDE*3#d031 zju}`+U5${Y6nqaFhX$4e%RQ!P*h`opmQl$ZxZ{_;q+)Mb3wiI!-ec7WPlK658>MlP zE-kl#9BKZF2bW+=UWpGmB$kjuU|C&Xt=b(?f%gKP-CMr-#a z_)IWuW=QIX=Y5TYo*;pGcAjSb2yuOxDC6lWwBrZC-8f*=PGrrvB*T`_r0j?DP$D%$ z%;lZ|{a|#dLRDx8RZU&jz#Ohrnd-pdLh3~Djw@?dxcupv=|(0yeKV+bVZ3IwpS=I0 zKmP4If9)YegnoSmSzklRXl8(dWU|j_Qp{g3g#gtJ%Vx(Q;7mxRY?=y((Tg@Le!To*{+{54GSHzW0-uhxQpWICLY55FwwK%gqrTeNv z>&rA?9=NlNHx8F;{x*FupX4i-8PMv~H-?Qey41ZuD3yUN#rv5uCGfW~_>);^oSFx1 z-E3UBo5=a8x#v#fjoXm{E0~{*=JU-4yt`d^dc5v#!~a<9I6~Ut|0`}Oa*l8Q*iqH} YFWv5pgVkIMHvj+t07*qoM6N<$f;)M)NB{r; literal 0 HcmV?d00001 diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index 4c0be9564..ae0ac607d 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -278,9 +278,9 @@ class SystemTray(component.Component): self.window.hide() else: if self.config["lock_tray"]: - if not self.unlock_tray(): - return - self.window.present() + self.unlock_tray() + else: + self.window.present() def on_tray_popup(self, status_icon, button, activate_time): """Called when the tray icon is right clicked.""" @@ -301,9 +301,9 @@ class SystemTray(component.Component): log.debug("on_menuitem_show_deluge_activate") if menuitem.get_active() and not self.window.visible(): if self.config["lock_tray"]: - if not self.unlock_tray(): - return - self.window.present() + self.unlock_tray() + else: + self.window.present() elif not menuitem.get_active() and self.window.visible(): self.window.hide() @@ -322,8 +322,7 @@ class SystemTray(component.Component): def on_menuitem_quit_activate(self, menuitem): log.debug("on_menuitem_quit_activate") if self.config["lock_tray"] and not self.window.visible(): - if not self.unlock_tray(): - return + self.unlock_tray() if self.config["classic_mode"]: client.daemon.shutdown() @@ -333,8 +332,7 @@ class SystemTray(component.Component): def on_menuitem_quitdaemon_activate(self, menuitem): log.debug("on_menuitem_quitdaemon_activate") if self.config["lock_tray"] and not self.window.visible(): - if not self.unlock_tray(): - return + self.unlock_tray() client.daemon.shutdown() self.window.quit() @@ -370,7 +368,6 @@ class SystemTray(component.Component): from sha import new as sha_hash log.debug("Show tray lock dialog") - result = False if is_showing_dlg[0]: return @@ -380,25 +377,47 @@ class SystemTray(component.Component): entered_pass.set_activates_default(True) entered_pass.set_width_chars(25) entered_pass.set_visibility(False) - entered_pass.show() - tray_lock = gtk.Dialog(title=_("Deluge is locked"), parent=None, - buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, - gtk.RESPONSE_ACCEPT)) - label = gtk.Label(_("Deluge is password protected.\nTo show the Deluge \ -window, please enter your password")) - label.set_line_wrap(True) - label.set_justify(gtk.JUSTIFY_CENTER) - tray_lock.set_position(gtk.WIN_POS_CENTER_ALWAYS) - tray_lock.set_size_request(400, 200) - tray_lock.set_default_response(gtk.RESPONSE_ACCEPT) - tray_lock.vbox.pack_start(label) - tray_lock.vbox.pack_start(entered_pass) - tray_lock.show_all() - if tray_lock.run() == gtk.RESPONSE_ACCEPT: - if self.config["tray_password"] == sha_hash(\ - entered_pass.get_text()).hexdigest(): - result = True - tray_lock.destroy() - is_showing_dlg[0] = False - return result + tray_lock = gtk.Dialog(title="", parent=self.window.window, + buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OK, + gtk.RESPONSE_OK)) + tray_lock.set_default_response(gtk.RESPONSE_OK) + tray_lock.set_has_separator(False) + + tray_lock.set_border_width(5) + + hbox = gtk.HBox(spacing=5) + + image = gtk.image_new_from_file(deluge.common.get_pixmap("lock48.png")) + image.set_alignment(0.5, 0.0) + hbox.pack_start(image, False) + + vbox = gtk.VBox(spacing=5) + hbox.pack_start(vbox, False) + + label = gtk.Label(_("Deluge is password protected!")) + label.set_use_markup(True) + label.set_alignment(0.0, 0.5) + label.set_line_wrap(True) + vbox.pack_start(label, False) + + tlabel = gtk.Label(_("Enter your password to continue")) + tlabel.set_use_markup(True) + tlabel.set_alignment(0.0, 0.5) + tlabel.set_line_wrap(True) + vbox.pack_start(tlabel, False) + + vbox.pack_start(entered_pass) + + tray_lock.vbox.pack_start(hbox) + + def on_response(dialog, response_id): + if response_id == gtk.RESPONSE_OK: + if self.config["tray_password"] == sha_hash(entered_pass.get_text()).hexdigest(): + self.window.present() + + tray_lock.destroy() + is_showing_dlg[0] = False + + tray_lock.connect("response", on_response) + tray_lock.show_all()