Re: [Deskbar] Updater changes
- From: Sebastian Pölsterl <marduk k-d-w org>
- To: deskbar-applet-list gnome org
- Subject: Re: [Deskbar] Updater changes
- Date: Tue, 1 Aug 2006 12:22:03 +0200 (CEST)
Sebastian Pölsterl wrote:
> Hi!
>
> I'm back in bussiness and I'm brining some changes to the updater the next
> day.
>
> I start with a patch that solves the problem that you can't use the
> preferences dialog without a connection to the internet. I might add a
> dialog said says that a connection to the internet is missing.
This adds the dialog.
The previous patch is obsolete.
--
Greetings,
Sebastian Pölsterl
Index: data/prefs-dialog.glade
===================================================================
RCS file: /cvs/gnome/deskbar-applet/data/prefs-dialog.glade,v
retrieving revision 1.21
diff -u -r1.21 prefs-dialog.glade
--- data/prefs-dialog.glade 10 Jul 2006 14:07:28 -0000 1.21
+++ data/prefs-dialog.glade 1 Aug 2006 10:12:03 -0000
@@ -637,6 +637,84 @@
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
+
+ <child>
+ <widget class="GtkButton" id="check_new_extensions">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+
+ <child>
+ <widget class="GtkAlignment" id="alignment28">
+ <property name="visible">True</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xscale">0</property>
+ <property name="yscale">0</property>
+ <property name="top_padding">0</property>
+ <property name="bottom_padding">0</property>
+ <property name="left_padding">0</property>
+ <property name="right_padding">0</property>
+
+ <child>
+ <widget class="GtkHBox" id="hbox197">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">2</property>
+
+ <child>
+ <widget class="GtkImage" id="image7">
+ <property name="visible">True</property>
+ <property name="stock">gtk-network</property>
+ <property name="icon_size">4</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkLabel" id="label1329">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">_Check for new extensions</property>
+ <property name="use_underline">True</property>
+ <property name="use_markup">False</property>
+ <property name="justify">GTK_JUSTIFY_LEFT</property>
+ <property name="wrap">False</property>
+ <property name="selectable">False</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+ <property name="width_chars">-1</property>
+ <property name="single_line_mode">False</property>
+ <property name="angle">0</property>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="padding">0</property>
Index: deskbar/updater/NewStuffUpdater.py
===================================================================
RCS file: /cvs/gnome/deskbar-applet/deskbar/updater/NewStuffUpdater.py,v
retrieving revision 1.4
diff -u -r1.4 NewStuffUpdater.py
--- deskbar/updater/NewStuffUpdater.py 10 Jul 2006 13:43:18 -0000 1.4
+++ deskbar/updater/NewStuffUpdater.py 1 Aug 2006 10:12:04 -0000
@@ -24,8 +24,12 @@
class NewStuffUpdater(gobject.GObject):
__gsignals__ = {
"ready" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
+ "connection-failed" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [gobject.TYPE_PYOBJECT]),
}
def __init__(self, parent, module_loader, module_list, web_module_list):
+ """
+ Creates NewStuffManager and NewStuff object
+ """
gobject.GObject.__init__(self)
self.parent = parent
self.module_list = module_list
@@ -40,18 +44,27 @@
stuffmanager.GetNewStuff('deskbarapplet', reply_handler=self.on_newstuff_ready, error_handler=global_error_handler)
def on_newstuff_ready(self, newstuff_infos):
+ """
+ Sets up the NewStuff object
+
+ Called by L{self.__init__}
+ """
service, path = newstuff_infos
proxy_obj_stuff = self.bus.get_object(service, path)
self.newstuff = dbus.Interface(proxy_obj_stuff, 'org.gnome.NewStuffManager.NewStuff')
self.newstuff.connect_to_signal('Updated', self.on_newstuff_updated)
self.newstuff.connect_to_signal('DownloadStatus', self.on_newstuff_downloadstatus)
- self.newstuff.Refresh(reply_handler=self.check_new, error_handler=global_error_handler)
+ self.newstuff.Refresh(reply_handler=lambda: self.emit('ready'), error_handler=lambda e: self.emit('connection-failed', e))
def check_new(self):
+ """
+ Fetches all the available handlers in the repository
+
+ Called by L{self.on_newstuff_ready}
+ """
if self.check_for_newstuff:
self.check_for_newstuff = False
self.newstuff.GetAvailableNewStuff(reply_handler=self.on_available_newstuff, error_handler=global_error_handler)
- self.emit('ready')
def on_newstuff_downloadstatus(self, action, progress):
self.progressdialog.set_current_operation(action)
Index: deskbar/ui/DeskbarPreferencesUI.py
===================================================================
RCS file: /cvs/gnome/deskbar-applet/deskbar/ui/DeskbarPreferencesUI.py,v
retrieving revision 1.20
diff -u -r1.20 DeskbarPreferencesUI.py
--- deskbar/ui/DeskbarPreferencesUI.py 30 Jul 2006 19:39:06 -0000 1.20
+++ deskbar/ui/DeskbarPreferencesUI.py 1 Aug 2006 10:12:04 -0000
@@ -143,11 +143,6 @@
# Since newstuff is optional we have to check if self.newstuff is None each time we use it
self.newstuff = None
- try:
- self.newstuff = NewStuffUpdater(self.dialog, module_loader, module_list, self.web_module_list)
- self.newstuff.connect('ready', self.on_newstuff_ready)
- except Exception, e:
- print '** Warning: Couldn\'t start newstuff updater:', e
# Retreive current values
self.width = deskbar.GCONF_CLIENT.get_int(applet.prefs.GCONF_WIDTH)
@@ -214,18 +209,43 @@
container.add(self.webmoduleview)
self.install = self.glade.get_widget("install")
+ self.check_new_extensions = self.glade.get_widget("check_new_extensions")
self.check = self.glade.get_widget("check")
self.update = self.glade.get_widget("update")
self.check.connect('clicked', self.on_check_handlers)
- self.check.set_sensitive(False)
self.update.connect('clicked', self.on_update_handler)
self.update.set_sensitive(False)
+ self.check_new_extensions.connect('clicked', self.on_check_new_extensions)
self.install.connect('clicked', self.on_install_handler)
self.install.set_sensitive(False)
self.sync_ui()
+ def __invoke_newstuff(self, func):
+ if self.newstuff == None:
+ self.newstuff = NewStuffUpdater(self.dialog, self.module_loader, self.module_list, self.web_module_list)
+ self.newstuff.connect('ready', self.on_newstuff_ready, getattr(self.newstuff, func))
+ self.newstuff.connect('connection-failed', self.on_connection_failed)
+ else:
+ getattr(self.newstuff, func)()
+
+ def on_connection_failed(self, newstuff, error):
+ """
+ Called if a connection to the repository failed
+
+ An error message will be displayed in a MessageDialog
+ and C{self.newstuff} is reset
+
+ @type error: dbus_bindings.DBusException instance
+ """
+ dialog = gtk.MessageDialog(parent=self.dialog, type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_OK)
+ dialog.set_markup('<span weight="bold" size="larger">Connection to repository failed</span>\n\nPlease check your internet connection')
+ dialog.run()
+ dialog.destroy()
+ self.newstuff.close()
+ self.newstuff = None
+
def show_run_hide(self):
self.dialog.show_all()
self.moduleview.grab_focus()
@@ -400,14 +420,15 @@
else:
loader.initialize_module_async (context)
- def on_newstuff_ready(self, newstuff):
- self.check.set_sensitive(True)
- self.install.set_sensitive(True)
+ def on_newstuff_ready(self, newstuff, func):
+ func()
def on_check_handlers(self, button):
#Update all handlers
- if self.newstuff != None:
- self.newstuff.check_all()
+ self.__invoke_newstuff('check_all')
+
+ def on_check_new_extensions(self, button):
+ self.__invoke_newstuff('check_new')
def on_update_handler(self, button):
module_context = self.moduleview.get_selected_module_context()
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]