meld r1137 - in trunk: . glade2
- From: kaiw svn gnome org
- To: svn-commits-list gnome org
- Subject: meld r1137 - in trunk: . glade2
- Date: Sat, 31 Jan 2009 07:21:26 +0000 (UTC)
Author: kaiw
Date: Sat Jan 31 07:21:26 2009
New Revision: 1137
URL: http://svn.gnome.org/viewvc/meld?rev=1137&view=rev
Log:
Use gtk.UIManager merging for all views, removing the current double toolbar
MeldApp: Add container switching calls
MeldDoc: Add ui-switching merge callbacks; change save_file to save_as for more consistent focus handling
DirDiff: Remove toolbar handling, and add merging of custom filters on switch
FileDiff: Remove toolbar handling and duplicated cut/copy/paste actions
VcView: Remove toolbar handling
glade2/*-ui.xml: Adapt to use single toolbar and placeholders
Some of this code was taken from the old 0.9 branch of Meld.
Modified:
trunk/dirdiff.py
trunk/filediff.py
trunk/glade2/dirdiff-ui.xml
trunk/glade2/filediff-ui.xml
trunk/glade2/meldapp-ui.xml
trunk/glade2/vcview-ui.xml
trunk/meldapp.py
trunk/melddoc.py
trunk/vcview.py
Modified: trunk/dirdiff.py
==============================================================================
--- trunk/dirdiff.py (original)
+++ trunk/dirdiff.py Sat Jan 31 07:21:26 2009
@@ -187,12 +187,10 @@
actions = (
("DirCompare", gtk.STOCK_DIALOG_INFO, _("_Compare"), None, _("Compare selected"), self.on_button_diff_clicked),
- # FIXME: the glade files were inconsistent: GO_BACK vs GOTO_FIRST, "Left" vs "Copy To Left"
("DirCopyLeft", gtk.STOCK_GO_BACK, _("Left"), None, _("Copy To Left"), self.on_button_copy_left_clicked),
- # FIXME: the glade files were inconsistent: GO_FORWARD vs GOTO_LAST, "Right" vs "Copy To Right"
("DirCopyRight", gtk.STOCK_GO_FORWARD, _("Right"), None, _("Copy To Right"), self.on_button_copy_right_clicked),
("DirDelete", gtk.STOCK_DELETE, None, None, _("Delete selected"), self.on_button_delete_clicked),
- ("Hide", gtk.STOCK_NO, _("Hide..."), None, _("Hide selected"), self.on_filter_hide_current_clicked),
+ ("Hide", gtk.STOCK_NO, _("Hide"), None, _("Hide selected"), self.on_filter_hide_current_clicked),
("DirOpen", gtk.STOCK_OPEN, None, None, _("Open selected"), self.on_button_open_clicked),
)
@@ -203,25 +201,17 @@
("ShowNew", gtk.STOCK_ADD, _("New"), None, _("Show new"), self.on_filter_state_new_toggled, True),
("ShowModified", gtk.STOCK_REMOVE, _("Modified"), None, _("Show modified"), self.on_filter_state_modified_toggled, True),
)
- ui_file = paths.share_dir("glade2/dirdiff-ui.xml")
- self.ui = gtk.UIManager()
+ self.ui_file = paths.share_dir("glade2/dirdiff-ui.xml")
self.actiongroup = gtk.ActionGroup('DirdiffToolbarActions')
self.actiongroup.set_translation_domain("meld")
self.actiongroup.add_actions(actions)
self.actiongroup.add_toggle_actions(toggleactions)
- self.ui.insert_action_group(self.actiongroup, 0)
- self.ui.add_ui_from_file(ui_file)
self.create_name_filters()
for button in ("DirCompare", "DirCopyLeft", "DirCopyRight",
"DirDelete", "Hide", "IgnoreCase", "ShowSame",
"ShowNew", "ShowModified"):
self.actiongroup.get_action(button).props.is_important = True
- self.toolbar = self.ui.get_widget('/DirdiffToolbar')
- self.dirdiff.pack_start(self.toolbar, False, True, 0)
- self.toolbar.set_style( self.prefs.get_toolbar_style() )
self.map_widgets_into_lists( ["treeview", "fileentry", "diffmap", "scrolledwindow", "linkmap"] )
- self.popup_menu = self.ui.get_widget('/DirdiffPopup')
- self.popup_menu.connect("deactivate", self.on_popup_deactivate_event)
self.set_num_panes(num_panes)
self.focus_in_events = []
self.focus_out_events = []
@@ -264,6 +254,23 @@
misc.run_dialog(
text=_("Error converting pattern '%s' to regular expression") % r.value )
+ def on_container_switch_in_event(self, ui):
+ melddoc.MeldDoc.on_container_switch_in_event(self, ui)
+ ui.insert_action_group(self.filter_actiongroup)
+ self.custom_merge_id = ui.new_merge_id()
+ for x in self.filter_ui:
+ ui.add_ui(self.custom_merge_id, *x)
+ self.popup_deactivate_id = self.popup_menu.connect("deactivate", self.on_popup_deactivate_event)
+ if self.treeview_focussed:
+ self.scheduler.add_task(self.treeview_focussed.grab_focus)
+ self.scheduler.add_task(self.on_treeview_cursor_changed)
+
+ def on_container_switch_out_event(self, ui):
+ self.popup_menu.disconnect(self.popup_deactivate_id)
+ ui.remove_ui(self.custom_merge_id)
+ ui.remove_action_group(self.filter_actiongroup)
+ melddoc.MeldDoc.on_container_switch_out_event(self, ui)
+
def create_name_filters(self):
self.name_filters_available = []
for f in [misc.ListItem(s) for s in self.prefs.filters.split("\n") ]:
@@ -281,20 +288,21 @@
else:
func = lambda x, r=cregex : r.match(x) == None
self.name_filters_available.append( TypeFilter(f.name, f.active, func) )
- self.name_filters = []
- merge_id = self.ui.new_merge_id()
+ self.name_filters = [f for f in self.name_filters_available if f.active]
+
+ actions = []
+ self.filter_ui = []
for i,f in enumerate(self.name_filters_available):
name = "Hide%d" % i
- entry = (name, gtk.STOCK_FIND, f.label, None, _("Hide %s") % f.label, lambda b,i=i : self._update_name_filter(b,i), f.active)
- self.actiongroup.add_toggle_actions([entry])
- if f.active:
- self.name_filters.append(self.name_filters_available[i])
- self.ui.add_ui(merge_id, "/DirdiffToolbar/FilterButtons", name, name, gtk.UI_MANAGER_TOOLITEM, False)
+ callback = lambda b, i=i: self._update_name_filter(b, i)
+ actions.append((name, gtk.STOCK_FIND, f.label, None, _("Hide %s") % f.label, callback, f.active))
+ self.filter_ui.append(["/Toolbar/FilterActions/FilterButtons" , name, name, gtk.UI_MANAGER_TOOLITEM, False])
+
+ self.filter_actiongroup = gtk.ActionGroup("DirdiffFilterActions")
+ self.filter_actiongroup.add_toggle_actions(actions)
def on_preference_changed(self, key, value):
- if key == "toolbar_style":
- self.toolbar.set_style( self.prefs.get_toolbar_style() )
- elif key == "regexes":
+ if key == "regexes":
self.update_regexes()
def _do_to_others(self, master, objects, methodname, args):
@@ -601,11 +609,6 @@
else:
self.emit("status-changed", "%s : %s" % (rwx(stat.st_mode), nice(time.time() - stat.st_mtime) ) )
- def on_switch_event(self):
- if self.treeview_focussed:
- self.scheduler.add_task( self.treeview_focussed.grab_focus )
- self.scheduler.add_task( self.on_treeview_cursor_changed )
-
def on_treeview_key_press_event(self, view, event):
pane = self.treeview.index(view)
tree = None
Modified: trunk/filediff.py
==============================================================================
--- trunk/filediff.py (original)
+++ trunk/filediff.py Sat Jan 31 07:21:26 2009
@@ -141,30 +141,26 @@
"replace" : darken(self.fill_colors["replace"])}
actions = (
- ("FilePopupSave", gtk.STOCK_SAVE, None, None, _("Save the current file"), self.save),
- ("FilePopupSaveAs", gtk.STOCK_SAVE_AS, None, "<control><shift>S", _("Save the current file with a different name"), self.save_as),
- ("FilePopupCut", gtk.STOCK_CUT, None, None, _("Cut the selection"), self.on_cut_activate),
- ("FilePopupCopy", gtk.STOCK_COPY, None, None, _("Copy the selection"), self.on_copy_activate),
- ("FilePopupPaste", gtk.STOCK_PASTE, None, None, _("Paste the clipboard"), self.on_paste_activate),
("FileOpen", gtk.STOCK_OPEN, None, None, _("Open selected"), self.on_open_activate),
("CreatePatch", None, _("Create Patch"), None, _("Create a patch"), self.make_patch),
("CopyAllLeft", gtk.STOCK_GOTO_FIRST, _("Copy To Left"), None, _("Copy all changes from right pane to left pane"), lambda x: self.copy_selected(-1)),
("CopyAllRight", gtk.STOCK_GOTO_LAST, _("Copy To Right"), None, _("Copy all changes from left pane to right pane"), lambda x: self.copy_selected(1)),
)
- ui_file = paths.share_dir("glade2/filediff-ui.xml")
+ self.ui_file = paths.share_dir("glade2/filediff-ui.xml")
self.actiongroup = gtk.ActionGroup('FilediffPopupActions')
self.actiongroup.set_translation_domain("meld")
self.actiongroup.add_actions(actions)
- self.ui = gtk.UIManager()
- self.ui.insert_action_group(self.actiongroup, 0)
- self.ui.add_ui_from_file(ui_file)
- self.popup_menu = self.ui.get_widget('/FilediffPopup')
self.find_dialog = None
self.last_search = None
self.set_num_panes(num_panes)
gobject.idle_add( lambda *args: self.load_font()) # hack around Bug 316730
+ def on_container_switch_in_event(self, ui):
+ melddoc.MeldDoc.on_container_switch_in_event(self, ui)
+ if self.textview_focussed:
+ self.scheduler.add_task(self.textview_focussed.grab_focus)
+
def _update_regexes(self):
self.regexes = []
for r in [ misc.ListItem(i) for i in self.prefs.regexes.split("\n") ]:
@@ -212,9 +208,6 @@
def on_textview_focus_in_event(self, view, event):
self.textview_focussed = view
self._update_cursor_status(view.get_buffer())
- def on_switch_event(self):
- if self.textview_focussed:
- self.scheduler.add_task( self.textview_focussed.grab_focus )
def _after_text_modified(self, buffer, startline, sizechange):
if self.num_panes > 1:
@@ -465,21 +458,6 @@
else:
self.on_find_activate()
- def on_copy_activate(self, *extra):
- t = self._get_focused_textview()
- if t:
- t.emit("copy-clipboard") #XXX .get_buffer().copy_clipboard()
-
- def on_cut_activate(self, *extra):
- t = self._get_focused_textview()
- if t:
- t.emit("cut-clipboard") #XXX get_buffer().cut_clipboard()
-
- def on_paste_activate(self, *extra):
- t = self._get_focused_textview()
- if t:
- t.emit("paste-clipboard") #XXX t.get_buffer().paste_clipboard(None, 1)
-
def popup_in_pane(self, pane):
self.actiongroup.get_action("CopyAllLeft").set_sensitive(pane > 0)
self.actiongroup.get_action("CopyAllRight").set_sensitive(pane+1 < self.num_panes)
Modified: trunk/glade2/dirdiff-ui.xml
==============================================================================
--- trunk/glade2/dirdiff-ui.xml (original)
+++ trunk/glade2/dirdiff-ui.xml Sat Jan 31 07:21:26 2009
@@ -1,22 +1,26 @@
<ui>
- <toolbar name="DirdiffToolbar">
- <toolitem action="DirCompare" />
- <separator/>
- <toolitem action="DirCopyLeft" />
- <toolitem action="DirCopyRight" />
- <toolitem action="DirDelete" />
- <separator/>
- <toolitem action="Hide" />
- <separator/>
- <toolitem action="IgnoreCase" />
- <separator/>
- <toolitem action="ShowSame" />
- <toolitem action="ShowNew" />
- <toolitem action="ShowModified" />
- <placeholder name="FilterButtons" />
+ <toolbar name="Toolbar">
+ <placeholder name="GeneralActions">
+ <toolitem action="DirCompare" />
+ </placeholder>
+ <placeholder name="SpecialActions">
+ <toolitem action="DirCopyLeft" />
+ <toolitem action="DirCopyRight" />
+ <toolitem action="DirDelete" />
+ <separator/>
+ <toolitem action="Hide" />
+ <toolitem action="IgnoreCase" />
+ </placeholder>
+ <placeholder name="FilterActions">
+ <toolitem action="ShowSame" />
+ <toolitem action="ShowNew" />
+ <toolitem action="ShowModified" />
+ <separator/>
+ <placeholder name="FilterButtons" />
+ </placeholder>
</toolbar>
- <popup name="DirdiffPopup">
+ <popup name="Popup">
<menuitem action="DirCompare" />
<separator/>
<menuitem action="DirCopyLeft" />
Modified: trunk/glade2/filediff-ui.xml
==============================================================================
--- trunk/glade2/filediff-ui.xml (original)
+++ trunk/glade2/filediff-ui.xml Sat Jan 31 07:21:26 2009
@@ -1,14 +1,21 @@
<ui>
+ <toolbar name="Toolbar">
+ <placeholder name="GeneralActions">
+ <toolitem action="Save"/>
+ <toolitem action="Undo"/>
+ <toolitem action="Redo"/>
+ </placeholder>
+ </toolbar>
- <popup name="FilediffPopup">
- <menuitem action="FilePopupSave" />
- <menuitem action="FilePopupSaveAs" />
+ <popup name="Popup">
+ <menuitem action="Save" />
+ <menuitem action="SaveAs" />
<separator/>
<menuitem action="CreatePatch" />
<separator/>
- <menuitem action="FilePopupCut" />
- <menuitem action="FilePopupCopy" />
- <menuitem action="FilePopupPaste" />
+ <menuitem action="Cut" />
+ <menuitem action="Copy" />
+ <menuitem action="Paste" />
<separator/>
<menuitem action="CopyAllLeft" />
<menuitem action="CopyAllRight" />
Modified: trunk/glade2/meldapp-ui.xml
==============================================================================
--- trunk/glade2/meldapp-ui.xml (original)
+++ trunk/glade2/meldapp-ui.xml Sat Jan 31 07:21:26 2009
@@ -39,15 +39,17 @@
<toolbar action="Toolbar">
<toolitem action="New"/>
<toolitem action="Magic"/>
- <toolitem action="Save"/>
- <toolitem action="Undo"/>
- <toolitem action="Redo"/>
- <separator/>
+ <placeholder name="GeneralActions" />
<toolitem action="Down"/>
<toolitem action="Up"/>
- <separator/>
<toolitem action="Stop"/>
+ <separator/>
+ <placeholder name="SpecialActions" />
+ <separator/>
+ <placeholder name="FilterActions" />
</toolbar>
+ <popup name="Popup">
+ </popup>
</ui>
Modified: trunk/glade2/vcview-ui.xml
==============================================================================
--- trunk/glade2/vcview-ui.xml (original)
+++ trunk/glade2/vcview-ui.xml Sat Jan 31 07:21:26 2009
@@ -1,23 +1,26 @@
<ui>
-
- <toolbar name="VcviewToolbar">
- <toolitem action="VcCompare" />
- <separator/>
- <toolitem action="VcFlatten" />
- <toolitem action="VcShowModified" />
- <toolitem action="VcShowNormal" />
- <toolitem action="VcShowNonVC" />
- <toolitem action="VcShowIgnored" />
- <separator/>
- <toolitem action="VcCommit" />
- <toolitem action="VcUpdate" />
- <toolitem action="VcAdd" />
- <toolitem action="VcRemove" />
- <toolitem action="VcRevert" />
- <toolitem action="VcDeleteLocally" />
+ <toolbar name="Toolbar">
+ <placeholder name="GeneralActions">
+ <toolitem action="VcCompare" />
+ </placeholder>
+ <placeholder name="SpecialActions">
+ <toolitem action="VcCommit" />
+ <toolitem action="VcUpdate" />
+ <toolitem action="VcAdd" />
+ <toolitem action="VcRemove" />
+ <toolitem action="VcRevert" />
+ <toolitem action="VcDeleteLocally" />
+ </placeholder>
+ <placeholder name="FilterActions">
+ <toolitem action="VcFlatten" />
+ <toolitem action="VcShowModified" />
+ <toolitem action="VcShowNormal" />
+ <toolitem action="VcShowNonVC" />
+ <toolitem action="VcShowIgnored" />
+ </placeholder>
</toolbar>
- <popup name="VcviewPopup">
+ <popup name="Popup">
<menuitem action="VcCompare" />
<menuitem action="VcUpdate" />
<menuitem action="VcCommit" />
Modified: trunk/meldapp.py
==============================================================================
--- trunk/meldapp.py (original)
+++ trunk/meldapp.py Sat Jan 31 07:21:26 2009
@@ -542,14 +542,13 @@
self.ui = gtk.UIManager()
self.ui.insert_action_group(self.actiongroup, 0)
self.ui.add_ui_from_file(ui_file)
- for menuitem in ("New", "Save", "Undo", "Redo"):
+ for menuitem in ("Save", "Undo"):
self.actiongroup.get_action(menuitem).props.is_important = True
self.widget.add_accel_group(self.ui.get_accel_group())
self.menubar = self.ui.get_widget('/Menubar')
self.toolbar = self.ui.get_widget('/Toolbar')
self.appvbox.pack_start(self.menubar, expand=False)
self.appvbox.pack_start(self.toolbar, expand=False)
- self.map_widgets_into_lists( "settings_drawstyle".split() )
self.statusbar = MeldStatusBar(self.task_progress, self.task_status, self.doc_status)
self.prefs = MeldPreferences()
if not developer:#hide magic testing button
@@ -604,12 +603,16 @@
def on_switch_page(self, notebook, page, which):
newdoc = notebook.get_nth_page(which).get_data("pyobject")
newseq = newdoc.undosequence
+ oldidx = notebook.get_current_page()
+ if oldidx >= 0:
+ olddoc = notebook.get_nth_page(oldidx).get_data("pyobject")
+ olddoc.on_container_switch_out_event(self.ui)
self.actiongroup.get_action("Undo").set_sensitive(newseq.can_undo())
self.actiongroup.get_action("Redo").set_sensitive(newseq.can_redo())
nbl = self.notebook.get_tab_label( newdoc.widget )
self.widget.set_title(nbl.get_label_text() + " - Meld")
self.statusbar.set_doc_status("")
- newdoc.on_switch_event()
+ newdoc.on_container_switch_in_event(self.ui)
self.scheduler.add_task( newdoc.scheduler )
def on_notebook_label_changed(self, component, text):
@@ -638,9 +641,7 @@
self.current_doc().save()
def on_menu_save_as_activate(self, menuitem):
- pane = self.current_doc()._get_focused_pane()
- if pane >= 0:
- self.current_doc().save_file(pane, 1)
+ self.current_doc().save_as()
def on_menu_refresh_activate(self, *args):
self.current_doc().refresh()
@@ -773,6 +774,9 @@
self.scheduler.remove_scheduler( page.scheduler )
i = self.notebook.page_num( page.widget )
assert(i>=0)
+ # If the page we're removing is the current page, we need to trigger a switch out
+ if self.notebook.get_current_page() == i:
+ page.on_container_switch_out_event(self.ui)
self.notebook.remove_page(i)
if self.notebook.get_n_pages() == 0:
self.widget.set_title("Meld")
Modified: trunk/melddoc.py
==============================================================================
--- trunk/melddoc.py (original)
+++ trunk/melddoc.py Sat Jan 31 07:21:26 2009
@@ -48,7 +48,7 @@
def save(self):
pass
- def save_file(self, pane, saveas=0):
+ def save_as(self):
pass
def stop(self):
@@ -112,8 +112,19 @@
def set_labels(self, lst):
pass
- def on_switch_event(self):
- pass
+ def on_container_switch_in_event(self, uimanager):
+ """Called when the container app switches to this tab.
+ """
+ self.ui_merge_id = uimanager.add_ui_from_file(self.ui_file)
+ uimanager.insert_action_group(self.actiongroup)
+ self.popup_menu = uimanager.get_widget("/Popup")
+ uimanager.ensure_update()
+
+ def on_container_switch_out_event(self, uimanager):
+ """Called when the container app switches away from this tab.
+ """
+ uimanager.remove_action_group(self.actiongroup)
+ uimanager.remove_ui(self.ui_merge_id)
def on_delete_event(self, appquit=0):
"""Called when the docs container is about to close.
Modified: trunk/vcview.py
==============================================================================
--- trunk/vcview.py (original)
+++ trunk/vcview.py Sat Jan 31 07:21:26 2009
@@ -135,14 +135,11 @@
("VcShowIgnored", "filter-ignored-24", _("Ignored"), None, _("Show ignored files"), self.on_button_filter_toggled, False),
)
- ui_file = paths.share_dir("glade2/vcview-ui.xml")
+ self.ui_file = paths.share_dir("glade2/vcview-ui.xml")
self.actiongroup = gtk.ActionGroup('VcviewActions')
self.actiongroup.set_translation_domain("meld")
self.actiongroup.add_actions(actions)
self.actiongroup.add_toggle_actions(toggleactions)
- self.ui = gtk.UIManager()
- self.ui.insert_action_group(self.actiongroup, 0)
- self.ui.add_ui_from_file(ui_file)
for action in ("VcCompare", "VcFlatten", "VcShowModified",
"VcShowNormal", "VcShowNonVC", "VcShowIgnored"):
self.actiongroup.get_action(action).props.is_important = True
@@ -151,11 +148,6 @@
"VcShowIgnored"):
button = self.actiongroup.get_action(action)
button.props.icon_name = button.props.stock_id
- self.toolbar = self.ui.get_widget('/VcviewToolbar')
- self.vcview.pack_start(self.toolbar, False, True, 0)
- self.vcview.reorder_child(self.toolbar, 0)
- self.toolbar.set_style( self.prefs.get_toolbar_style() )
- self.popup_menu = self.ui.get_widget('/VcviewPopup')
self.tempdirs = []
self.model = VcTreeStore()
self.treeview.set_model(self.model)
@@ -273,10 +265,6 @@
self.treeview.expand_row( (0,), 0)
self.vc.uncache_inventory()
- def on_preference_changed(self, key, value):
- if key == "toolbar_style":
- self.toolbar.set_style( self.prefs.get_toolbar_style() )
-
def on_fileentry_activate(self, fileentry):
path = fileentry.get_full_path(0)
self.set_location(path)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]