[Deskbar] Updater changes



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 patch also includes Nigel's reasonable suggestion that deskbar should
not connect to the repository each time the preferences dialog is opened.
You have to ivoke that yourself now.
Finally, I addes some minor documentation.

Next will be some work on the ProgressbarDialog and a function to search
new extensions.

-- 
Gruß,
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	31 Jul 2006 21:42:50 -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	31 Jul 2006 21:39:38 -0000
@@ -26,6 +26,9 @@
 		"ready" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
 	}
 	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 +43,32 @@
 		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: None, error_handler=self.on_load_repository_failed)
+		self.emit('ready')
+		
+	def on_load_repository_failed(self, e):
+		if isinstance(e, Exception):
+			raise IOError, "Connection to repository failed"
 	
 	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	31 Jul 2006 21:39:38 -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,30 @@
 		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.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:
+			try:
+				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))
+			except Exception, e:
+				print '** Warning: Couldn\'t start newstuff updater:', e
+		else:
+			getattr(self.newstuff, func)()
+		
 	def show_run_hide(self):
 		self.dialog.show_all()
 		self.moduleview.grab_focus()
@@ -400,14 +407,22 @@
 		else:
 			loader.initialize_module_async (context)
 	
-	def on_newstuff_ready(self, newstuff):
+	def on_newstuff_ready(self, newstuff, func):
+		print 'READY'
 		self.check.set_sensitive(True)
 		self.install.set_sensitive(True)
+		func()
 		
 	def on_check_handlers(self, button):
 		#Update all handlers
-		if self.newstuff != None:
-			self.newstuff.check_all()
+		self.__invoke_newstuff('check_all')
+		#if self.newstuff != None:
+		#	self.newstuff.check_all()
+			
+	def on_check_new_extensions(self, button):
+		self.__invoke_newstuff('check_new')
+		#if self.newstuff != None:
+		#	self.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]