[jokosher-devel] [PATCH] Fixed: Ticket #169 (No way to delete projects from welcome dialog) [second try]
- From: Niels Kjøller Hansen <niels k h gmail com>
- To: jokosher-devel-list gnome org
- Subject: [jokosher-devel] [PATCH] Fixed: Ticket #169 (No way to delete projects from welcome dialog) [second try]
- Date: Tue, 24 Oct 2006 22:18:49 +0200
Hello all,
Second try on this thing
Removal is now done by right-clicking the project in the welcome screen.
Hopefully I should be able to reuse some of the code for a 'clear list' option from
the recent projects menu.
Any comments on anything remotely related to the patch are still very welcome.
/Niels
PS: To the administrator: I accidentally posted the same message from my other e-mail address. Delete it please.
Index: Jokosher/Jokosher.glade
===================================================================
--- Jokosher/Jokosher.glade (revision 847)
+++ Jokosher/Jokosher.glade (working copy)
@@ -2520,6 +2520,7 @@
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
+ <signal name="button_press_event" handler="on_recentprojectslist_button_press_event" last_modification_time="Tue, 24 Oct 2006 20:00:30 GMT"/>
</widget>
</child>
</widget>
@@ -4306,4 +4307,28 @@
</child>
</widget>
+<widget class="GtkMenu" id="RecentListMenu">
+
+ <child>
+ <widget class="GtkImageMenuItem" id="removefromrecent">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Remove from list</property>
+ <property name="use_underline">True</property>
+ <signal name="activate" handler="on_removefromrecent_activate" last_modification_time="Tue, 24 Oct 2006 20:01:30 GMT"/>
+
+ <child internal-child="image">
+ <widget class="GtkImage" id="image173">
+ <property name="visible">True</property>
+ <property name="stock">gtk-delete</property>
+ <property name="icon_size">1</property>
+ <property name="xalign">0.5</property>
+ <property name="yalign">0.5</property>
+ <property name="xpad">0</property>
+ <property name="ypad">0</property>
+ </widget>
+ </child>
+ </widget>
+ </child>
+</widget>
+
</glade-interface>
Index: Jokosher/WelcomeDialog.py
===================================================================
--- Jokosher/WelcomeDialog.py (revision 847)
+++ Jokosher/WelcomeDialog.py (working copy)
@@ -35,6 +35,7 @@
"on_openrecentprojectbutton_clicked" : self.OnOpenRecentProjectButton,
"on_quit_clicked" : self.OnQuit,
"on_startupcb_toggled" : self.OnStartupToggled,
+ "on_recentprojectslist_button_press_event": self.OnRecentProjectListButtonPress,
}
self.res.signal_autoconnect(self.signals)
@@ -44,6 +45,11 @@
self.window.set_transient_for(self.mainwindow.window)
self.tree = self.res.get_widget("recentprojectslist")
+ # get the right-click menu for the recent projects list
+ self.menu = gtk.glade.XML(Globals.GLADE_PATH,"RecentListMenu")
+ self.recentlistmenu = self.menu.get_widget("RecentListMenu")
+ self.menu.signal_autoconnect({"on_removefromrecent_activate": self.OnRemoveFromRecent})
+
self.headerimage = self.res.get_widget("headerimage")
self.headerimage.set_from_file(os.path.join(Globals.IMAGE_PATH, "welcomeheader.png"))
@@ -120,6 +126,7 @@
def PopulateRecentProjects(self):
'''Populate the Recent Projects menu with items from global settings'''
+ self.model.clear()
for path, name in self.mainwindow.recentprojectitems:
self.model.append([gtk.STOCK_NEW, name, path])
@@ -150,7 +157,28 @@
self.window.destroy()
#_____________________________________________________________________
+
+ def OnRecentProjectListButtonPress(self, treeview, event):
+ if event.button == 3: #If the click is a right-click
+ x = int(event.x)
+ y = int(event.y)
+ time = event.time
+ pthinfo = treeview.get_path_at_pos(x, y)
+ if pthinfo is not None:
+ path, col, cellx, celly = pthinfo
+ treeview.grab_focus()
+ treeview.set_cursor(path, col, 0)
+ self.recentlistmenu.popup(None, None, None, event.button, time)
+
+ #_____________________________________________________________________
+ def OnRemoveFromRecent(self, widget):
+ """Remove the selected recent project from the list of recent projects."""
+ item = self.model[self.tree.get_cursor()[0]]
+ self.mainwindow.RemoveRecentProject(item[2], item[1])
+ self.PopulateRecentProjects()
+ #_____________________________________________________________________
+
def OnStartupToggled(self, widget):
"""When the startup toggle box is toggled, this method is run to update
the setting in Globals."""
Index: Jokosher/JokosherApp.py
===================================================================
--- Jokosher/JokosherApp.py (revision 847)
+++ Jokosher/JokosherApp.py (working copy)
@@ -693,6 +693,17 @@
#_____________________________________________________________________
+ def RemoveRecentProject(self, path, name):
+ for item in self.recentprojectitems:
+ if path == item[0]:
+ self.recentprojectitems.remove(item)
+ break
+
+ self.SaveRecentProjects()
+ self.PopulateRecentProjects()
+
+ #_____________________________________________________________________
+
def PopulateRecentProjects(self):
'''Populate the Recent Projects menu with items from self.recentprojectitems'''
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]