[meld] Emit filter-changed signals from MeldApp and respond in DirDiff
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Emit filter-changed signals from MeldApp and respond in DirDiff
- Date: Tue, 15 Feb 2011 09:09:40 +0000 (UTC)
commit ba7d91d075fcb0d8030af1ef7de8735c26b9ae4f
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sat Feb 12 07:30:24 2011 +1000
Emit filter-changed signals from MeldApp and respond in DirDiff
This commit also splits DirDiff filter menu creation so that we can
recreate menus when filters change.
meld/dirdiff.py | 28 +++++++++++++++++++++++-----
meld/meldapp.py | 14 +++++++++-----
2 files changed, 32 insertions(+), 10 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index e22a756..a2c4967 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -235,6 +235,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self.actiongroup.add_actions(actions)
self.actiongroup.add_toggle_actions(toggleactions)
self.create_name_filters()
+ # FIXME: also handle text-filters-changed
+ app.connect("file-filters-changed", self.on_file_filters_changed)
for button in ("DirCompare", "DirCopyLeft", "DirCopyRight",
"DirDelete", "Hide", "IgnoreCase", "ShowSame",
"ShowNew", "ShowModified", "CustomFilterMenu"):
@@ -285,8 +287,15 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self.custom_popup.popup(None, None, misc.position_menu_under_widget,
1, gtk.get_current_event_time(), self.filter_menu_button)
- def on_container_switch_in_event(self, ui):
- melddoc.MeldDoc.on_container_switch_in_event(self, ui)
+ def _cleanup_filter_menu_button(self, ui):
+ if self.popup_deactivate_id:
+ self.popup_menu.disconnect(self.popup_deactivate_id)
+ if self.custom_merge_id:
+ ui.remove_ui(self.custom_merge_id)
+ if self.filter_actiongroup in ui.get_action_groups():
+ ui.remove_action_group(self.filter_actiongroup)
+
+ def _create_filter_menu_button(self, ui):
ui.insert_action_group(self.filter_actiongroup, -1)
self.custom_merge_id = ui.new_merge_id()
for x in self.filter_ui:
@@ -297,6 +306,11 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
label = misc.make_tool_button_widget(self.filter_menu_button.props.label)
self.filter_menu_button.set_label_widget(label)
+ def on_container_switch_in_event(self, ui):
+ melddoc.MeldDoc.on_container_switch_in_event(self, ui)
+ self._create_filter_menu_button(ui)
+ self.ui_manager = ui
+
# FIXME: Add real sensitivity handling
self.emit("next-diff-changed", True, True)
if self.treeview_focussed:
@@ -304,11 +318,15 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
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)
+ self._cleanup_filter_menu_button(ui)
melddoc.MeldDoc.on_container_switch_out_event(self, ui)
+ def on_file_filters_changed(self, app):
+ self._cleanup_filter_menu_button(self.ui_manager)
+ self.create_name_filters()
+ self._create_filter_menu_button(self.ui_manager)
+ self.refresh()
+
def create_name_filters(self):
self.name_filters = [copy.copy(f) for f in app.file_filters]
actions = []
diff --git a/meld/meldapp.py b/meld/meldapp.py
index 91df41d..f0b2dda 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -96,9 +96,15 @@ class FilterEntry(object):
return new
-class MeldApp(object):
+class MeldApp(gobject.GObject):
+
+ __gsignals__ = {
+ 'file-filters-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()),
+ 'text-filters-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ()),
+ }
def __init__(self):
+ gobject.GObject.__init__(self)
gobject.set_application_name("Meld")
gtk.window_set_default_icon_name("meld")
self.version = version
@@ -116,12 +122,10 @@ class MeldApp(object):
def on_preference_changed(self, key, val):
if key == "filters":
self.file_filters = self._parse_filters(val, FilterEntry.SHELL)
- # FIXME: should emit a file-filters-changed signal here for
- # DirDiff to respond to
+ self.emit('file-filters-changed')
elif key == "regexes":
self.text_filters = self._parse_filters(val, FilterEntry.REGEX)
- # FIXME: should emit a text-filters-changed signal here for
- # FileDiff and DirDiff to respond to
+ self.emit('text-filters-changed')
def _parse_filters(self, string, filt_type):
return [FilterEntry.parse(l, filt_type) for l in string.split("\n")]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]