[meld] Remove option to edit files in Meld and simplify preference interface
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Remove option to edit files in Meld and simplify preference interface
- Date: Sun, 13 Jun 2010 01:09:21 +0000 (UTC)
commit 64288832db803fb75e397f400c7a1eaf0f4fc1f7
Author: Kai Willadsen <kai willadsen gmail com>
Date: Fri Apr 30 17:07:25 2010 +1000
Remove option to edit files in Meld and simplify preference interface
We currently provide options to edit files in Meld, the system editor,
or an external editor. However, Meld is not designed as a stand-alone
editor; the system editor is almost certain to be a superior editing
tool. This commit removes the option to edit files in Meld, leaving
the system editor and custom editor options.
This only changes the behaviour of selecting "Open" from the context
menu in various views. Starting a 'comparison', even if on a single
file, will always open in Meld.
data/ui/preferences.glade | 81 ++++++--------------------------------------
meld/melddoc.py | 11 ++----
meld/preferences.py | 29 ++++++++--------
3 files changed, 30 insertions(+), 91 deletions(-)
---
diff --git a/data/ui/preferences.glade b/data/ui/preferences.glade
index eaa353c..a92f3f5 100644
--- a/data/ui/preferences.glade
+++ b/data/ui/preferences.glade
@@ -324,7 +324,7 @@
<widget class="GtkLabel" id="label69">
<property name="visible">True</property>
<property name="xalign">0</property>
- <property name="label" translatable="yes"><b>Edit Menu</b></property>
+ <property name="label" translatable="yes"><b>External editor</b></property>
<property name="use_markup">True</property>
</widget>
<packing>
@@ -350,92 +350,34 @@
<child>
<widget class="GtkVBox" id="vbox43">
<property name="visible">True</property>
+ <property name="spacing">6</property>
<child>
- <widget class="GtkLabel" id="label71">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="xpad">4</property>
- <property name="ypad">4</property>
- <property name="label" translatable="yes">Edit files with:</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkRadioButton" id="editor_command0">
- <property name="label" translatable="yes">Internal editor</property>
+ <widget class="GtkCheckButton" id="system_editor_checkbutton">
+ <property name="label" translatable="yes">Use _default system editor</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
- <signal name="toggled" handler="on_editor_command_toggled"/>
+ <signal name="toggled" handler="on_system_editor_checkbutton_toggled"/>
</widget>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox35">
<property name="visible">True</property>
+ <property name="spacing">6</property>
<child>
- <widget class="GtkRadioButton" id="editor_command1">
- <property name="label" translatable="yes">Gnome default editor</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">editor_command0</property>
- <signal name="toggled" handler="on_editor_command_toggled"/>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <widget class="GtkLabel" id="gnome_default_editor_label">
- <property name="visible">True</property>
- <property name="label">(gnome-default-editor)</property>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">5</property>
- <property name="position">1</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <widget class="GtkHBox" id="hbox36">
- <property name="visible">True</property>
- <child>
- <widget class="GtkRadioButton" id="editor_command2">
- <property name="label" translatable="yes">Custom command</property>
+ <widget class="GtkLabel" id="label2">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
+ <property name="label" translatable="yes">Edito_r command:</property>
<property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- <property name="group">editor_command0</property>
- <signal name="toggled" handler="on_editor_command_toggled"/>
+ <property name="mnemonic_widget">custom_edit_command_entry</property>
</widget>
<packing>
<property name="expand">False</property>
- <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
@@ -454,12 +396,11 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">3</property>
+ <property name="position">1</property>
</packing>
</child>
</widget>
<packing>
- <property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
diff --git a/meld/melddoc.py b/meld/melddoc.py
index 4124f2d..a711fca 100644
--- a/meld/melddoc.py
+++ b/meld/melddoc.py
@@ -61,15 +61,12 @@ class MeldDoc(gobject.GObject):
files = [f for f in selected if os.path.isfile(f)]
dirs = [d for d in selected if os.path.isdir(d)]
if len(files):
- if self.prefs.edit_command_type == "internal":
- for f in files:
- self.emit("create-diff", (f,))
- elif self.prefs.edit_command_type == "gnome":
- cmd = self.prefs.get_gnome_editor_command(files)
- os.spawnvp(os.P_NOWAIT, cmd[0], cmd)
- elif self.prefs.edit_command_type == "custom":
+ if self.prefs.edit_command_type == "custom":
cmd = self.prefs.get_custom_editor_command(files)
os.spawnvp(os.P_NOWAIT, cmd[0], cmd)
+ else: # self.prefs.edit_command_type == "gnome" or "internal"
+ cmd = self.prefs.get_gnome_editor_command(files)
+ os.spawnvp(os.P_NOWAIT, cmd[0], cmd)
for d in dirs:
cmd = ["xdg-open", d]
os.spawnvp(os.P_NOWAIT, cmd[0], cmd)
diff --git a/meld/preferences.py b/meld/preferences.py
index e790b50..5a16bc2 100644
--- a/meld/preferences.py
+++ b/meld/preferences.py
@@ -118,14 +118,10 @@ class ListWidget(gnomeglade.Component):
class PreferencesDialog(gnomeglade.Component):
- editor_radio_values = {"internal":0, "gnome":1, "custom":2}
-
def __init__(self, parentapp):
gnomeglade.Component.__init__(self, paths.ui_dir("preferences.glade"), "preferencesdialog")
self.widget.set_transient_for(parentapp.widget)
self.prefs = parentapp.prefs
- # editor
- self.map_widgets_into_lists( ["editor_command"] )
if not self.prefs.use_custom_font:
self.checkbutton_default_font.set_active(True)
self.fontpicker.set_sensitive(False)
@@ -155,9 +151,12 @@ class PreferencesDialog(gnomeglade.Component):
self.checkbutton_split_words.set_active(False)
self.checkbutton_wrap_text.set_active(True)
self.checkbutton_supply_newline.set_active( self.prefs.supply_newline )
- self.editor_command[ self.editor_radio_values.get(self.prefs.edit_command_type, "internal") ].set_active(1)
- self.gnome_default_editor_label.set_text( "(%s)" % " ".join(self.prefs.get_gnome_editor_command([])) )
+ use_default = self.prefs.edit_command_type == "internal" or \
+ self.prefs.edit_command_type == "gnome"
+ self.system_editor_checkbutton.set_active(use_default)
+ self.custom_edit_command_entry.set_sensitive(not use_default)
self.custom_edit_command_entry.set_text( " ".join(self.prefs.get_custom_editor_command([])) )
+
# file filters
cols = [ (_("Name"), type("")), (_("Active"), type(0)), (_("Pattern"), type("")) ]
self.filefilter = ListWidget( cols, self.prefs, "filters")
@@ -203,13 +202,15 @@ class PreferencesDialog(gnomeglade.Component):
self.prefs.show_line_numbers = check.get_active()
def on_checkbutton_use_syntax_highlighting_toggled(self, check):
self.prefs.use_syntax_highlighting = check.get_active()
- def on_editor_command_toggled(self, radio):
- if radio.get_active():
- idx = self.editor_command.index(radio)
- for k,v in self.editor_radio_values.items():
- if v == idx:
- self.prefs.edit_command_type = k
- break
+
+ def on_system_editor_checkbutton_toggled(self, check):
+ use_default = check.get_active()
+ self.custom_edit_command_entry.set_sensitive(not use_default)
+ if use_default:
+ self.prefs.edit_command_type = "gnome"
+ else:
+ self.prefs.edit_command_type = "custom"
+
#
# filters
#
@@ -239,7 +240,7 @@ class MeldPreferences(prefs.Preferences):
"show_line_numbers": prefs.Value(prefs.BOOL, 0),
"use_syntax_highlighting": prefs.Value(prefs.BOOL, 0),
"edit_wrap_lines" : prefs.Value(prefs.INT, 0),
- "edit_command_type" : prefs.Value(prefs.STRING, "internal"), #internal, gnome, custom
+ "edit_command_type" : prefs.Value(prefs.STRING, "gnome"), #gnome, custom
"edit_command_custom" : prefs.Value(prefs.STRING, "gedit"),
"supply_newline": prefs.Value(prefs.BOOL, False),
"text_codecs": prefs.Value(prefs.STRING, "utf8 latin1"),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]