GNOME Bugzilla – Bug 356008
a 'reload all scripts' button on the deskbar applet
Last modified: 2008-01-09 21:04:26 UTC
It would make development of deskbar handlers much quicker if one could refresh all handler code with one mouseclick. A developer mode of the desklet a button providing this functionality would be great. Other information:
Ideally it should notice change and reload a module..
Marking as gnome-love
I'm willing to give it a shot. I'll post a patch when I've got it.
Created attachment 102306 [details] [review] Patch to add reload all button Applies to svn r1820
I've posted a patch to add the reload all button. Apply it in the desktop-applet directory. Applicable to latest revision at time of writing, 1820. The actual button is in the preferences window. Feedback is greatly appreciated. This is my first ever patch to anything, so let me know if I've posted it correctly, etc.
Very good work for your first patch. But there are still some issues: 1) The button should display 'Reload' rather than 'Restart' 2) You have to clear DisabledModuleList as well. In CoreImpl.reload_all_modules you have access both to ModuleList and DisabledModuleList. That way ModuleList.modules_reloading_cb is obsolete.
Created attachment 102483 [details] [review] patch for reloading deskbar modules I'd like you to check out this patch, mm im sorry if its not a good one, its my first patch i hope it will be useful..
Comment on attachment 102483 [details] [review] patch for reloading deskbar modules Index: data/prefs-dialog.glade =================================================================== --- data/prefs-dialog.glade (revision 1823) +++ data/prefs-dialog.glade (working copy) @@ -224,6 +224,84 @@ <property name="spacing">6</property> <child> + <widget class="GtkButton" id="reload"> + <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="alignment30"> + <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="hbox199"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">2</property> + + <child> + <widget class="GtkImage" id="image8"> + <property name="visible">True</property> + <property name="stock">gtk-clear</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="label1332"> + <property name="visible">True</property> + <property name="label" translatable="yes">_Reload</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">False</property> + </packing> + </child> + + <child> <widget class="GtkButton" id="more"> <property name="visible">True</property> <property name="can_focus">True</property> Index: deskbar/core/CoreImpl.py =================================================================== --- deskbar/core/CoreImpl.py (revision 1823) +++ deskbar/core/CoreImpl.py (working copy) @@ -237,6 +237,13 @@ else: self._module_loader.initialize_module(module) self._module_list.increase_bottom_enabled_path() + + def reload_all_modules(self): + self._module_list.clear() + self._disabled_module_list.clear() + logging.info("Reloading all modules") + self._module_loader.emit("modules-reloading") + self._module_loader.load_all() def stop_queries(self): self._stop_queries = True @@ -337,4 +344,4 @@ def forward_query_ready(self, handler, query, matches): if query == self._last_query and matches != None and len(matches) > 0 and not self._stop_queries: self._emit_query_ready(matches) - \ No newline at end of file + Index: deskbar/core/ModuleLoader.py =================================================================== --- deskbar/core/ModuleLoader.py (revision 1823) +++ deskbar/core/ModuleLoader.py (working copy) @@ -34,6 +34,8 @@ "module-not-initialized" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [gobject.TYPE_PYOBJECT]), # Fired when the passed module module has run the stop() method successfully. The module is not usable anymore "module-stopped" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [gobject.TYPE_PYOBJECT]), + #Fired when reload_all gets called, but before any reloading actually gets done + "modules-reloading" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []), } def __init__ (self, dirs, extension=".py"): Index: deskbar/ui/preferences/DeskbarPreferences.py =================================================================== --- deskbar/ui/preferences/DeskbarPreferences.py (revision 1823) +++ deskbar/ui/preferences/DeskbarPreferences.py (working copy) @@ -74,6 +74,8 @@ self.more_button.set_sensitive(False) self.more_button.connect("clicked", self.on_more_button_clicked) self.more_button_callback = None + self.reload_button = self.glade.get_widget("reload") + self.reload_button.connect("clicked", self.on_reload_button_clicked) # Info are at the bottom self.info_area = self.glade.get_widget("info_area") @@ -220,6 +222,9 @@ def on_more_button_clicked(self, button): if self.more_button_callback != None: self.more_button_callback(self.dialog) + + def on_reload_button_clicked(self, button): + self._model.reload_all_modules() def on_module_selected(self, selection): module_context = self.moduleview.get_selected_module()
Created attachment 102484 [details] [review] sorry it this one the patch i wanted to send, this works for me This is the patch i wanted to send, does the same as the other i sent but the glade modification is less and works
Thanks a lot for this patch. It's perfectly. I just changed the icon of the button and added a tooltip and committed it to svn trunk. It will be part of 2.21.5.