meld r1084 - in trunk: . glade2
- From: stevek svn gnome org
- To: svn-commits-list gnome org
- Subject: meld r1084 - in trunk: . glade2
- Date: Sun, 23 Nov 2008 15:30:02 +0000 (UTC)
Author: stevek
Date: Sun Nov 23 15:30:01 2008
New Revision: 1084
URL: http://svn.gnome.org/viewvc/meld?rev=1084&view=rev
Log:
Bug 556404 - remove libgnomeui dependency (Kai Willadsen)
Added:
trunk/historyentry.py
Modified:
trunk/filediff.py
trunk/glade2/dirdiff.glade
trunk/glade2/filediff.glade
trunk/glade2/meldapp.glade
trunk/glade2/vcview.glade
trunk/gnomeglade.py
trunk/meldapp.py
trunk/vcview.py
Modified: trunk/filediff.py
==============================================================================
--- trunk/filediff.py (original)
+++ trunk/filediff.py Sun Nov 23 15:30:01 2008
@@ -431,12 +431,15 @@
gladefile = paths.share_dir("glade2/filediff.glade")
gnomeglade.Component.__init__(self, gladefile, "finddialog")
self.widget.set_transient_for(app.widget.get_toplevel())
+ self.gnome_entry_search_for.child.connect("activate", self.on_entry_search_for_activate)
self.widget.show_all()
def on_destroy(self, *args):
self.parent.find_dialog = None
self.widget.destroy()
def on_entry_search_for_activate(self, *args):
- self.parent._find_text( self.entry_search_for.get_chars(0,-1),
+ search_text = self.gnome_entry_search_for.get_active_text()
+ self.gnome_entry_search_for.prepend_text(search_text)
+ self.parent._find_text(search_text,
self.check_case.get_active(),
self.check_word.get_active(),
self.check_wrap.get_active(),
Modified: trunk/glade2/dirdiff.glade
==============================================================================
--- trunk/glade2/dirdiff.glade (original)
+++ trunk/glade2/dirdiff.glade Sun Nov 23 15:30:01 2008
@@ -2,8 +2,6 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
-<requires lib="gnome"/>
-
<widget class="GtkWindow" id="container">
<property name="visible">True</property>
<property name="title" translatable="yes">window1</property>
@@ -111,30 +109,13 @@
</child>
<child>
- <widget class="GnomeFileEntry" id="fileentry0">
- <property name="visible">True</property>
- <property name="history_id">direntry</property>
- <property name="max_saved">10</property>
- <property name="directory_entry">True</property>
- <property name="modal">False</property>
- <property name="use_filechooser">True</property>
- <property name="filechooser_action">GTK_FILE_CHOOSER_ACTION_OPEN</property>
- <signal name="activate" handler="on_fileentry_activate" last_modification_time="Tue, 30 Jul 2002 21:08:21 GMT"/>
-
- <child internal-child="entry">
- <widget class="GtkEntry" id="comboentry0">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- </widget>
- </child>
- </widget>
+ <widget class="Custom" id="fileentry0">
+ <property name="visible">True</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">direntry</property>
+ <property name="int1">1</property>
+ <signal name="activate" handler="on_fileentry_activate"/>
+ </widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
@@ -145,30 +126,13 @@
</child>
<child>
- <widget class="GnomeFileEntry" id="fileentry1">
- <property name="visible">True</property>
- <property name="history_id">direntry</property>
- <property name="max_saved">10</property>
- <property name="directory_entry">True</property>
- <property name="modal">False</property>
- <property name="use_filechooser">True</property>
- <property name="filechooser_action">GTK_FILE_CHOOSER_ACTION_OPEN</property>
- <signal name="activate" handler="on_fileentry_activate" last_modification_time="Thu, 18 Jul 2002 10:45:51 GMT"/>
-
- <child internal-child="entry">
- <widget class="GtkEntry" id="comboentry1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- </widget>
- </child>
- </widget>
+ <widget class="Custom" id="fileentry1">
+ <property name="visible">True</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">direntry</property>
+ <property name="int1">1</property>
+ <signal name="activate" handler="on_fileentry_activate"/>
+ </widget>
<packing>
<property name="left_attach">3</property>
<property name="right_attach">4</property>
@@ -179,31 +143,13 @@
</child>
<child>
- <widget class="GnomeFileEntry" id="fileentry2">
- <property name="visible">True</property>
- <property name="history_id">direntry</property>
- <property name="max_saved">10</property>
- <property name="browse_dialog_title" translatable="yes"></property>
- <property name="directory_entry">True</property>
- <property name="modal">False</property>
- <property name="use_filechooser">True</property>
- <property name="filechooser_action">GTK_FILE_CHOOSER_ACTION_OPEN</property>
- <signal name="activate" handler="on_fileentry_activate" last_modification_time="Thu, 18 Jul 2002 10:46:00 GMT"/>
-
- <child internal-child="entry">
- <widget class="GtkEntry" id="comboentry2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- </widget>
- </child>
- </widget>
+ <widget class="Custom" id="fileentry2">
+ <property name="visible">True</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">direntry</property>
+ <property name="int1">1</property>
+ <signal name="activate" handler="on_fileentry_activate"/>
+ </widget>
<packing>
<property name="left_attach">5</property>
<property name="right_attach">6</property>
Modified: trunk/glade2/filediff.glade
==============================================================================
--- trunk/glade2/filediff.glade (original)
+++ trunk/glade2/filediff.glade Sun Nov 23 15:30:01 2008
@@ -2,7 +2,6 @@
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<glade-interface>
- <requires lib="gnome"/>
<widget class="GtkWindow" id="container">
<property name="visible">True</property>
<property name="title" translatable="yes">window1</property>
@@ -16,19 +15,11 @@
<placeholder/>
</child>
<child>
- <widget class="GnomeFileEntry" id="fileentry2">
+ <widget class="Custom" id="fileentry2">
<property name="visible">True</property>
- <property name="history_id">fileentry</property>
- <property name="use_filechooser">True</property>
- <property name="max_saved">10</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">fileentry</property>
<signal name="activate" handler="on_fileentry_activate"/>
- <child internal-child="entry">
- <widget class="GtkEntry" id="comboentry0">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- </widget>
- </child>
</widget>
<packing>
<property name="left_attach">5</property>
@@ -38,19 +29,11 @@
</packing>
</child>
<child>
- <widget class="GnomeFileEntry" id="fileentry1">
+ <widget class="Custom" id="fileentry1">
<property name="visible">True</property>
- <property name="history_id">fileentry</property>
- <property name="use_filechooser">True</property>
- <property name="max_saved">10</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">fileentry</property>
<signal name="activate" handler="on_fileentry_activate"/>
- <child internal-child="entry">
- <widget class="GtkEntry" id="comboentry1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- </widget>
- </child>
</widget>
<packing>
<property name="left_attach">3</property>
@@ -60,19 +43,11 @@
</packing>
</child>
<child>
- <widget class="GnomeFileEntry" id="fileentry0">
+ <widget class="Custom" id="fileentry0">
<property name="visible">True</property>
- <property name="history_id">fileentry</property>
- <property name="use_filechooser">True</property>
- <property name="max_saved">10</property>
+ <property name="string1">fileentry</property>
+ <property name="creation_function">create_fileentry</property>
<signal name="activate" handler="on_fileentry_activate"/>
- <child internal-child="entry">
- <widget class="GtkEntry" id="comboentry0">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- </widget>
- </child>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -467,18 +442,10 @@
<placeholder/>
</child>
<child>
- <widget class="GnomeEntry" id="gnome_entry_search_for">
+ <widget class="Custom" id="gnome_entry_search_for">
<property name="visible">True</property>
- <property name="history_id">search_for</property>
- <property name="max_saved">10</property>
- <child internal-child="entry">
- <widget class="GtkEntry" id="entry_search_for">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- <signal name="activate" handler="on_entry_search_for_activate"/>
- </widget>
- </child>
+ <property name="string1">search_for</property>
+ <property name="creation_function">create_entry</property>
</widget>
<packing>
<property name="left_attach">1</property>
Modified: trunk/glade2/meldapp.glade
==============================================================================
--- trunk/glade2/meldapp.glade (original)
+++ trunk/glade2/meldapp.glade Sun Nov 23 15:30:01 2008
@@ -2,7 +2,6 @@
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<glade-interface>
- <requires lib="gnome"/>
<widget class="GtkWindow" id="meldapp">
<property name="height_request">480</property>
<property name="title" translatable="yes">Meld</property>
@@ -70,27 +69,21 @@
</widget>
</child>
</widget>
- <widget class="GnomeAbout" id="about">
+ <widget class="GtkAboutDialog" id="about">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="destroy_with_parent">True</property>
<property name="icon">pixmaps/icon.png</property>
+ <property name="program-name">Meld</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
- <property name="copyright" translatable="yes">Copyright (C) 2002-2006 Stephen Kennedy</property>
- <property name="comments">http://meld.sourceforge.net</property>
+ <property name="copyright" translatable="yes">Copyright  2002-2008 Stephen Kennedy</property>
+ <property name="website">http://meld.sourceforge.net/</property>
<property name="authors">Stephen Kennedy <stevek gnome org>
With help from:
-
-Ross Burton (debian packaging, patches)
-Dag Wieers (rpm packaging)
-Martin Pool (localtime cvs patch)
-Adam Muegge (patched cvsview to support svn)
-Aaron Bentley (bzr vc plugin)
-Daniel Thompson (monotone vc plugin)
-
+See changelog for individual credits.
</property>
- <property name="translator_credits">BenoÃt Dejean (fr)
+ <property name="translator-credits">BenoÃt Dejean (fr)
Takeshi Aihana (ja)
Dongsu Jang (ko)
Danilo Åegan (sr)
@@ -148,20 +141,12 @@
</packing>
</child>
<child>
- <widget class="GnomeFileEntry" id="fileentry2">
+ <widget class="Custom" id="fileentry2">
<property name="visible">True</property>
- <property name="history_id">file_comparison</property>
- <property name="browse_dialog_title">My File</property>
- <property name="use_filechooser">True</property>
- <property name="max_saved">10</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">file_comparison</property>
+ <property name="string2">My File</property>
<signal name="activate" handler="on_entry_activate"/>
- <child internal-child="entry">
- <widget class="GtkEntry" id="combo-entry6">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- </widget>
- </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -172,20 +157,12 @@
</packing>
</child>
<child>
- <widget class="GnomeFileEntry" id="fileentry1">
+ <widget class="Custom" id="fileentry1">
<property name="visible">True</property>
- <property name="history_id">file_comparison</property>
- <property name="browse_dialog_title">Original File</property>
- <property name="use_filechooser">True</property>
- <property name="max_saved">10</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">file_comparison</property>
+ <property name="string2">Original File</property>
<signal name="activate" handler="on_entry_activate"/>
- <child internal-child="entry">
- <widget class="GtkEntry" id="combo-entry5">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- </widget>
- </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -196,22 +173,13 @@
</packing>
</child>
<child>
- <widget class="GnomeFileEntry" id="fileentry0">
+ <widget class="Custom" id="fileentry0">
<property name="visible">True</property>
<property name="sensitive">False</property>
- <property name="can_default">True</property>
- <property name="history_id">file_comparison</property>
- <property name="browse_dialog_title">Other File</property>
- <property name="use_filechooser">True</property>
- <property name="max_saved">10</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">file_comparison</property>
+ <property name="string2">Other File</property>
<signal name="activate" handler="on_entry_activate"/>
- <child internal-child="entry">
- <widget class="GtkEntry" id="combo-entry4">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- </widget>
- </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -311,21 +279,13 @@
</packing>
</child>
<child>
- <widget class="GnomeFileEntry" id="direntry2">
+ <widget class="Custom" id="direntry2">
<property name="visible">True</property>
- <property name="history_id">dir_comparison</property>
- <property name="browse_dialog_title">My Directory</property>
- <property name="directory_entry">True</property>
- <property name="use_filechooser">True</property>
- <property name="max_saved">10</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">dir_comparison</property>
+ <property name="string2">My Directory</property>
+ <property name="int1">1</property>
<signal name="activate" handler="on_entry_activate"/>
- <child internal-child="entry">
- <widget class="GtkEntry" id="entry3">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- </widget>
- </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -336,21 +296,13 @@
</packing>
</child>
<child>
- <widget class="GnomeFileEntry" id="direntry1">
+ <widget class="Custom" id="direntry1">
<property name="visible">True</property>
- <property name="history_id">dir_comparison</property>
- <property name="browse_dialog_title">Original Directory</property>
- <property name="directory_entry">True</property>
- <property name="use_filechooser">True</property>
- <property name="max_saved">10</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">dir_comparison</property>
+ <property name="string2">Original Directory</property>
+ <property name="int1">1</property>
<signal name="activate" handler="on_entry_activate"/>
- <child internal-child="entry">
- <widget class="GtkEntry" id="entry2">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- </widget>
- </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -361,24 +313,14 @@
</packing>
</child>
<child>
- <widget class="GnomeFileEntry" id="direntry0">
+ <widget class="Custom" id="direntry0">
<property name="visible">True</property>
<property name="sensitive">False</property>
- <property name="can_default">True</property>
- <property name="has_default">True</property>
- <property name="history_id">dir_comparison</property>
- <property name="browse_dialog_title">Other Directory</property>
- <property name="directory_entry">True</property>
- <property name="use_filechooser">True</property>
- <property name="max_saved">10</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">dir_comparison</property>
+ <property name="string2">Other Directory</property>
+ <property name="int1">1</property>
<signal name="activate" handler="on_entry_activate"/>
- <child internal-child="entry">
- <widget class="GtkEntry" id="entry1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- </widget>
- </child>
</widget>
<packing>
<property name="left_attach">2</property>
@@ -461,21 +403,13 @@
<property name="column_spacing">10</property>
<property name="row_spacing">10</property>
<child>
- <widget class="GnomeFileEntry" id="vcentry0">
+ <widget class="Custom" id="vcentry0">
<property name="visible">True</property>
- <property name="history_id">vc_directory</property>
- <property name="browse_dialog_title">CVS Directory</property>
- <property name="directory_entry">True</property>
- <property name="use_filechooser">True</property>
- <property name="max_saved">10</property>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">vc_directory</property>
+ <property name="string2">VC Directory</property>
+ <property name="int1">1</property>
<signal name="activate" handler="on_entry_activate"/>
- <child internal-child="entry">
- <widget class="GtkEntry" id="entry4">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">*</property>
- </widget>
- </child>
</widget>
<packing>
<property name="left_attach">1</property>
@@ -783,14 +717,12 @@
</packing>
</child>
<child>
- <widget class="GnomeFontPicker" id="fontpicker">
+ <widget class="GtkFontButton" id="fontpicker">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="response_id">0</property>
- <property name="mode">GNOME_FONT_PICKER_MODE_FONT_INFO</property>
- <property name="use_font_in_label">True</property>
- <property name="label_font_size">10</property>
- <signal name="font_set" handler="on_fontpicker_font_set"/>
+ <property name="use-font">True</property>
+ <signal name="font-set" handler="on_fontpicker_font_set"/>
</widget>
<packing>
<property name="expand">False</property>
Modified: trunk/glade2/vcview.glade
==============================================================================
--- trunk/glade2/vcview.glade (original)
+++ trunk/glade2/vcview.glade Sun Nov 23 15:30:01 2008
@@ -2,8 +2,6 @@
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
-<requires lib="gnome"/>
-
<widget class="GtkWindow" id="container">
<property name="visible">True</property>
<property name="title" translatable="yes">window1</property>
@@ -33,29 +31,12 @@
<property name="spacing">0</property>
<child>
- <widget class="GnomeFileEntry" id="fileentry">
+ <widget class="Custom" id="fileentry">
<property name="visible">True</property>
- <property name="history_id">vcroot</property>
- <property name="max_saved">10</property>
- <property name="directory_entry">True</property>
- <property name="modal">False</property>
- <property name="use_filechooser">True</property>
- <property name="filechooser_action">GTK_FILE_CHOOSER_ACTION_OPEN</property>
- <signal name="activate" handler="on_fileentry_activate" last_modification_time="Sun, 28 Jul 2002 10:50:58 GMT"/>
-
- <child internal-child="entry">
- <widget class="GtkEntry" id="comboentry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">True</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- </widget>
- </child>
+ <property name="creation_function">create_fileentry</property>
+ <property name="string1">direntry</property>
+ <property name="int1">1</property>
+ <signal name="activate" handler="on_fileentry_activate"/>
</widget>
<packing>
<property name="padding">0</property>
@@ -494,27 +475,13 @@
</child>
<child>
- <widget class="GnomeEntry" id="previousentry">
+ <widget class="Custom" id="previousentry">
<property name="border_width">5</property>
- <property name="visible">True</property>
- <property name="history_id">previousentry</property>
- <property name="max_saved">15</property>
- <signal name="changed" handler="on_previousentry_activate" last_modification_time="Sun, 14 Sep 2003 14:08:20 GMT"/>
-
- <child internal-child="entry">
- <widget class="GtkEntry" id="comboentry1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="editable">False</property>
- <property name="visibility">True</property>
- <property name="max_length">0</property>
- <property name="text" translatable="yes"></property>
- <property name="has_frame">True</property>
- <property name="invisible_char">*</property>
- <property name="activates_default">False</property>
- </widget>
- </child>
- </widget>
+ <property name="visible">True</property>
+ <property name="string1">previousentry</property>
+ <property name="creation_function">create_entry</property>
+ <signal name="changed" handler="on_previousentry_activate"/>
+ </widget>
<packing>
<property name="padding">5</property>
<property name="expand">True</property>
Modified: trunk/gnomeglade.py
==============================================================================
--- trunk/gnomeglade.py (original)
+++ trunk/gnomeglade.py Sun Nov 23 15:30:01 2008
@@ -19,8 +19,7 @@
import gtk
import gtk.glade
-# FIXME: remove once there are no GnomeUI-based widgets in the glade file
-import gnome.ui
+import historyentry
class Component(object):
"""Base class for all glade objects.
@@ -39,6 +38,7 @@
def __init__(self, filename, root, override={}):
"""Load the widgets from the node 'root' in file 'filename'.
"""
+ gtk.glade.set_custom_handler(self.get_custom_handler)
self.xml = gtk.glade.XML(filename, root, typedict=override)
self.xml.signal_autoconnect(self)
self.widget = getattr(self, root)
@@ -73,6 +73,39 @@
lst.append(val)
i += 1
+ # Taken from the pygtk FAQ
+ def get_custom_handler(self, glade, function_name, widget_name,
+ str1, str2, int1, int2):
+ """
+ Generic handler for creating custom widgets, used to
+ enable custom widgets.
+
+ The custom widgets have a creation function specified in design time.
+ Those creation functions are always called with str1,str2,int1,int2 as
+ arguments, that are values specified in design time.
+
+ This handler assumes that we have a method for every custom widget
+ creation function specified in glade.
+
+ If a custom widget has create_foo as creation function, then the
+ method named create_foo is called with str1,str2,int1,int2 as arguments.
+ """
+ if hasattr(self, function_name):
+ handler = getattr(self, function_name)
+ return handler(str1, str2, int1, int2)
+ else:
+ return None
+
+ def create_fileentry(self, history_id, dialog_title, is_directory_entry, int2):
+ w = historyentry.HistoryFileEntry(history_id, dialog_title)
+ w.directory_entry = is_directory_entry
+ return w
+
+ def create_entry(self, history_id, str2, int1, int2):
+ w = historyentry.HistoryEntry(history_id)
+ return w
+
+
def load_pixbuf(fname, size=0):
"""Load an image from a file as a pixbuf, with optional resizing.
"""
Added: trunk/historyentry.py
==============================================================================
--- (empty file)
+++ trunk/historyentry.py Sun Nov 23 15:30:01 2008
@@ -0,0 +1,479 @@
+# Copyright (C) 2008 Kai Willadsen <kai willadsen gmail com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+import os
+
+import gtk, gobject, atk
+# gconf is also imported; see end of HistoryEntry class for details
+# gnomevfs is also imported; see end of HistoryFileEntry class for details
+from gettext import gettext as _
+
+# This file is a Python translation of:
+# * gedit/gedit/gedit-history-entry.c
+# * libgnomeui/libgnomeui/gnome-file-entry.c
+# roughly based on Colin Walters' Python translation of msgarea.py from Hotwire
+
+MIN_ITEM_LEN = 3
+HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT = 10
+
+def _remove_item(store, text):
+ if text is None:
+ return False
+
+ for row in store:
+ if row[0] == text:
+ store.remove(row.iter)
+ return True
+ return False
+
+def _clamp_list_store(liststore, max_items):
+ try:
+ it = liststore.get_iter(max_items - 1) # -1 because TreePath counts from 0
+ except ValueError:
+ return
+ valid = True
+ while valid:
+ valid = liststore.remove(it)
+
+def _escape_cell_data_func(col, renderer, model, iter, escape_func):
+ string = model.get(iter, 0)
+ escaped = escape_func(string)
+ renderer.set("text", escaped)
+
+
+class HistoryEntry(gtk.ComboBoxEntry):
+
+ def __init__(self, history_id=None, enable_completion=False, **kwargs):
+ super(HistoryEntry, self).__init__(**kwargs)
+
+ self.__history_id = history_id
+ self.__history_length = HISTORY_ENTRY_HISTORY_LENGTH_DEFAULT
+ self.__completion = None
+ self._get_gconf_client()
+
+ self.set_model(gtk.ListStore(str))
+ self.props.text_column = 0
+
+ self._load_history()
+ self.set_enable_completion(enable_completion)
+
+ def _get_gconf_client(self):
+ self.__gconf_client = gconf.client_get_default()
+
+ def __get_history_store(self):
+ return self.get_model()
+
+ def __get_history_key(self):
+ # We store data under /apps/gnome-settings/ like GnomeEntry did.
+ if not self.__history_id:
+ return None
+ key = ''.join(["/apps/gnome-settings/","meld","/history-",
+ gconf.escape_key(self.__history_id, -1)])
+ return key
+
+ def __get_history_list(self):
+ store = self.__get_history_store()
+ if len(store):
+ hist_list = [row[0] for row in store]
+ return hist_list
+ else:
+ return []
+
+ def _save_history(self):
+ key = self.__get_history_key()
+ if key is None:
+ return
+ gconf_items = self.__get_history_list()
+ self.__gconf_client.set_list(key, gconf.VALUE_STRING, gconf_items)
+
+ def __insert_history_item(self, text, prepend):
+ if len(text) <= MIN_ITEM_LEN:
+ return
+
+ store = self.__get_history_store()
+ if not _remove_item(store, text):
+ _clamp_list_store(store, self.__history_length - 1)
+
+ if (prepend):
+ store.insert(0, (text,))
+ else:
+ store.append((text,))
+ self._save_history()
+
+ def prepend_text(self, text):
+ if not text:
+ return
+ self.__insert_history_item(text, True)
+
+ def append_text(self, text):
+ if not text:
+ return
+ self.__insert_history_item(text, False)
+
+ def _load_history(self):
+ key = self.__get_history_key()
+ if key is None:
+ return
+ gconf_items = self.__gconf_client.get_list(key, gconf.VALUE_STRING)
+
+ store = self.__get_history_store()
+ store.clear()
+
+ for item in gconf_items[:self.__history_length - 1]:
+ store.append((item,))
+
+ def clear(self):
+ store = self.__get_history_store()
+ store.clear()
+ self.save_history(entry);
+
+ def set_history_length(self, max_saved):
+ if max_saved <= 0:
+ return
+ self.__history_length = max_saved
+ if len(self.__get_history_store()) > max_saved:
+ self._load_history()
+
+ def get_history_length(self):
+ return self.__history_length
+
+ def get_history_id(self):
+ return self.__history_id
+
+ def __set_history_id(self, history_id):
+ self.__history_id = history_id
+ self._load_history()
+
+ def set_enable_completion(self, enable):
+ if enable:
+ if self.__completion is not None:
+ return
+ self.__completion = gtk.EntryCompletion()
+ self.__completion.set_model(self.__get_history_store())
+ self.__completion.set_text_column(0)
+ self.__completion.set_minimum_key_length(MIN_ITEM_LEN)
+ self.__completion.set_popup_completion(False)
+ self.__completion.set_inline_completion(True)
+ self.child.set_completion(self.__completion)
+ else:
+ if self.__completion is None:
+ return
+ self.get_entry().set_completion(None)
+ self.__completion = None
+
+ def get_enable_completion(self):
+ return self.__completion is not None
+
+ def get_entry(self):
+ return self.child
+
+ def set_escape_func(self, escape_func):
+ cells = entry.get_cells()
+ # We only have one cell renderer
+ if len(cells) == 0 or len(cells) > 1:
+ return
+
+ if escape_func is not None:
+ self.set_cell_data_func(cells[0], _escape_cell_data_func, escape_func)
+ else:
+ self.set_cell_data_func(cells[0], None, None)
+
+ history_id = gobject.property(get_history_id, __set_history_id, type=str)
+ max_saved = gobject.property(get_history_length, set_history_length, type=int)
+
+try:
+ import gconf
+except ImportError:
+ def do_nothing(self):
+ return
+
+ for m in ('_save_history', '_load_history', '_get_gconf_client'):
+ setattr(HistoryEntry, m, do_nothing)
+
+
+
+def _expand_filename(input, default_dir):
+ if not input:
+ return ""
+ if os.path.isabs(input):
+ return input
+ expanded = os.path.expanduser(input)
+ if expanded != input:
+ return expanded
+ elif default_dir:
+ return os.path.expanduser(os.path.join([default_dir, input]))
+ else:
+ return os.path.join([os.getcwd(), input])
+
+
+class HistoryFileEntry(gtk.VBox, gtk.Editable):
+ __gsignals__ = {
+ "browse_clicked" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
+ "activate" : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
+ }
+
+ def __init__(self, history_id=None, browse_dialog_title=None, **kwargs):
+ super(HistoryFileEntry, self).__init__(**kwargs)
+
+ self.fsw = None
+ self.__default_path = "~"
+ # TODO: completion would be nice, but some quirks make it currently too irritating to turn on by default
+ self.__gentry = HistoryEntry(history_id, False)
+ self.browse_dialog_title = browse_dialog_title
+ self.__filechooser_action = gtk.FILE_CHOOSER_ACTION_OPEN
+ self.__is_modal = False
+ self.directory_entry = False
+
+ self.set_spacing(4)
+
+ # Allow for a preview thingie to be smacked on top of the file entry
+ hbox = gtk.HBox(False, 4)
+ hbox.show()
+ self.pack_end(hbox, False, False, 0)
+
+ self.gtk_entry.connect("changed", self.__entry_changed_signal)
+ self.gtk_entry.connect("activate", self.__entry_activate_signal)
+
+ self._setup_dnd()
+
+ hbox.pack_start(self.__gentry, True, True, 0)
+ self.__gentry.show()
+
+ button = gtk.Button(_("_Browse..."))
+ button.connect("clicked", self.__browse_clicked)
+ hbox.pack_start(button, False, False, 0)
+ button.show()
+
+ access_entry = self.__gentry.get_accessible()
+ access_button = button.get_accessible()
+ if access_entry and access_button:
+ access_entry.set_name(_("Path"))
+ access_entry.set_description(_("Path to file"))
+ access_button.set_description(_("Pop up a file selector to choose a file"))
+ access_button.add_relationship(atk.RELATION_CONTROLLER_FOR, access_entry)
+ access_entry.add_relationship(atk.RELATION_CONTROLLED_BY, access_button)
+
+ def _setup_dnd(self):
+ # we must get rid of gtk's drop site on the entry else weird stuff can happen
+ self.gtk_entry.drag_dest_unset()
+ self.drag_dest_set(gtk.DEST_DEFAULT_MOTION |
+ gtk.DEST_DEFAULT_HIGHLIGHT |
+ gtk.DEST_DEFAULT_DROP,
+ [], gtk.gdk.ACTION_COPY)
+ self.drag_dest_add_uri_targets()
+ self.connect("drag_data_received", self.history_entry_drag_data_received)
+
+ def gnome_entry(self):
+ return self.__gentry
+
+ def gtk_entry(self):
+ return self.__gentry.child
+
+ def set_title(self, browse_dialog_title):
+ self.browse_dialog_title = browse_dialog_title
+
+ def set_default_path(self, path):
+ if path:
+ self.__default_path = os.path.abspath(path)
+ else:
+ self.__default_path = None
+
+ def set_directory_entry(self, is_directory_entry):
+ self.directory_entry = is_directory_entry
+
+ def get_directory_entry(self):
+ return self.directory_entry
+
+ def get_full_path(self, file_must_exist=False):
+ text = self.__gentry.child.get_text()
+ if not text:
+ return None
+
+ sys_text = gobject.filename_from_utf8(text)
+ filename = _expand_filename(sys_text, self.__default_path)
+ if not filename:
+ return None
+
+ if file_must_exist:
+ if self.directory_entry:
+ if os.path.isdir(filename):
+ return filename
+
+ d = os.path.dirname(filename)
+ if os.path.isdir(d):
+ return d
+
+ return None
+ elif os.path.isfile(filename):
+ return filename
+ return None
+ else:
+ return filename
+
+ def set_filename(self, filename):
+ self.__gentry.child.set_text(filename)
+
+ def set_modal(self, is_modal):
+ self.__is_model = is_modal
+
+ def get_modal(self):
+ return self.__is_modal
+
+ def __browse_dialog_ok(self, filewidget):
+ locale_filename = filewidget.get_filename()
+ if not locale_filename:
+ return
+
+ encoding = os.getenv("G_FILENAME_ENCODING")
+ if encoding:
+ # FIXME: This isn't tested.
+ locale_filename = unicode(locale_filename, encoding)
+ self.gtk_entry.set_text(locale_filename)
+ self.gtk_entry.emit("changed")
+ self.gtk_entry.activate()
+ filewidget.destroy()
+
+ def __browse_dialog_response(self, widget, response):
+ if response == gtk.RESPONSE_ACCEPT:
+ self.__browse_dialog_ok(widget)
+ else:
+ widget.destroy()
+
+ def __setup_filter(self, filechooser, *args):
+ filefilter = gtk.FileFilter()
+ filefilter.add_mime_type("x-directory/normal")
+ filechooser.set_filter(filefilter)
+
+ def __build_filename(self):
+ text = self.gtk_entry.get_text()
+
+ if text is None or len(text) == 0:
+ return self.__default_path + os.sep
+
+ locale_text = gobject.filename_from_utf8(text)
+ if locale_text is None:
+ return self.__default_path + os.sep
+
+ filename = _expand_filename(locale_text, self.__default_path);
+ if not filename:
+ return self.__default_path + os.sep
+
+ if len(filename) != 0 and not filename.endswith(os.sep) and (self.directory_entry or os.path.isdir(filename)):
+ return filename + os.sep
+
+ return filename
+
+ def __browse_clicked(self, *args):
+ if self.fsw:
+ self.fsw.show()
+ if self.fsw.window:
+ self.fsw.window.raise_()
+
+ if self.directory_entry:
+ self.fsw.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
+ else:
+ self.fsw.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
+
+ p = self.__build_filename()
+ if p:
+ self.fsw.set_filename(p)
+
+ return
+
+ if self.directory_entry:
+ action = gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER
+ else:
+ action = self.__filechooser_action
+
+ title = self.browse_dialog_title if self.browse_dialog_title else _("Select file")
+ self.fsw = gtk.FileChooserDialog(title, None, action,
+ (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL), None)
+
+ if action == gtk.FILE_CHOOSER_ACTION_SAVE:
+ self.fsw.add_button(gtk.STOCK_SAVE, gtk.RESPONSE_ACCEPT)
+ else:
+ self.fsw.add_button(gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT)
+
+ if self.directory_entry:
+ self.fsw.connect("size-request", self.__setup_filter, self)
+
+ self.fsw.set_default_response(gtk.RESPONSE_ACCEPT)
+
+ p = self.__build_filename()
+ if p:
+ self.fsw.set_filename(p)
+ self.fsw.connect("response", self.__browse_dialog_response)
+
+ toplevel = self.get_toplevel()
+ modal_fentry = False
+ if toplevel.flags() & gtk.TOPLEVEL:
+ self.fsw.set_transient_for(toplevel)
+ modal_fentry = toplevel.get_modal()
+
+ if self.__is_modal or modal_fentry:
+ self.fsw.set_modal(True)
+
+ self.fsw.show()
+
+ def __entry_changed_signal(self, widget, *data):
+ self.emit("changed")
+
+ def __entry_activate_signal(self, widget, *data):
+ self.emit("activate")
+
+ def __get_history_id(self):
+ self.__gentry.get_history_id()
+
+ def __set_history_id(self, newid):
+ self.__gentry.props.history_id = newid
+
+ def history_entry_drag_data_received(self, widget, context, x, y, selection_data, info, time):
+ uris = selection_data.data.split()
+ if not uris:
+ context.finish(False, False, time);
+ return
+
+ for uri in uris:
+ file = gnomevfs.get_local_path_from_uri(uri)
+ if file:
+ break
+ else:
+ context.finish(False, False, time);
+ return
+
+ widget.gtk_entry.set_text(file)
+ widget.gtk_entry.emit("changed")
+ widget.gtk_entry.activate()
+
+ browse_dialog_title = gobject.property(type=str)
+ default_path = gobject.property(lambda self: self.__default_path, set_default_path, type=str)
+ directory_entry = gobject.property(type=bool, default=False)
+ filechooser_action = gobject.property(type=gobject.GObject) # FIXME: gtk.FileChooserAction with newer pygobject
+ filename = gobject.property(get_full_path, set_filename, type=str)
+ gnome_entry = gobject.property(gnome_entry, None, type=gobject.GObject) # FIXME: historyentry.Historyentry with newer pygobject
+ gtk_entry = gobject.property(gtk_entry, None, type=gobject.GObject) # FIXME: gtk.Entry with newer pygobject
+ history_id = gobject.property(__get_history_id, __set_history_id, type=str)
+ modal = gobject.property(set_modal, get_modal, type=bool, default=False)
+ use_filechooser = gobject.property(type=bool, default=True)
+
+try:
+ import gnomevfs
+except ImportError:
+ def do_nothing(self):
+ return
+
+ setattr(HistoryFileEntry, '_setup_dnd', do_nothing)
+
Modified: trunk/meldapp.py
==============================================================================
--- trunk/meldapp.py (original)
+++ trunk/meldapp.py Sun Nov 23 15:30:01 2008
@@ -70,6 +70,8 @@
self.widget.set_transient_for(parentapp.widget)
cur_page = type // 2
self.notebook.set_current_page( cur_page )
+ self.fileentry[0].set_sensitive(self.three_way_compare[0].get_active())
+ self.direntry[0].set_sensitive(self.three_way_compare[1].get_active())
self.widget.show_all()
def on_entry_activate(self, entry):
@@ -79,12 +81,12 @@
if i == len(el) - 1:
self.button_ok.grab_focus()
else:
- el[i+1].gtk_entry().grab_focus()
+ el[i+1].gtk_entry.grab_focus()
def on_three_way_toggled(self, button):
page = self.three_way_compare.index(button)
self.entrylists[page][0].set_sensitive( button.get_active() )
- self.entrylists[page][ not button.get_active() ].gtk_entry().grab_focus()
+ self.entrylists[page][ not button.get_active() ].gtk_entry.grab_focus()
def on_response(self, dialog, arg):
if arg != gtk.RESPONSE_CANCEL:
@@ -93,7 +95,7 @@
if page < 2 and not self.three_way_compare[page].get_active():
paths.pop(0)
for path in paths:
- self.entrylists[page][0].gnome_entry().append_history(True, path)
+ self.entrylists[page][0].gnome_entry.append_text(path)
methods = (self.parentapp.append_filediff,
self.parentapp.append_dirdiff,
self.parentapp.append_vcview )
@@ -278,8 +280,8 @@
#
# editor
#
- def on_fontpicker_font_set(self, picker, font):
- self.prefs.custom_font = font
+ def on_fontpicker_font_set(self, picker):
+ self.prefs.custom_font = picker.get_font_name()
def on_radiobutton_font_toggled(self, radio):
if radio.get_active():
custom = radio == self.radiobutton_custom_font
@@ -770,9 +772,9 @@
def on_menu_about_activate(self, *extra):
about = gtk.glade.XML(paths.share_dir("glade2/meldapp.glade"),"about").get_widget("about")
- about.props.name = "Meld"
about.props.version = version
- about.show()
+ about.run()
+ about.hide()
#
# Toolbar and menu items (misc)
Modified: trunk/vcview.py
==============================================================================
--- trunk/vcview.py (original)
+++ trunk/vcview.py Sun Nov 23 15:30:01 2008
@@ -68,7 +68,8 @@
self.widget.show_all()
def run(self):
- self.previousentry.list.select_item(0)
+ self.previousentry.child.set_editable(False)
+ self.previousentry.set_active(0)
self.textview.grab_focus()
buf = self.textview.get_buffer()
buf.place_cursor( buf.get_start_iter() )
@@ -78,11 +79,11 @@
if response == gtk.RESPONSE_OK:
self.parent._command_on_selected( self.parent.vc.commit_command(msg) )
if len(msg.strip()):
- self.previousentry.prepend_history(1, msg)
+ self.previousentry.prepend_text(msg)
self.widget.destroy()
def on_previousentry_activate(self, gentry):
buf = self.textview.get_buffer()
- buf.set_text( gentry.gtk_entry().get_text() )
+ buf.set_text( gentry.child.get_text() )
COL_LOCATION, COL_STATUS, COL_REVISION, COL_TAG, COL_OPTIONS, COL_END = range(tree.COL_END, tree.COL_END+6)
@@ -196,6 +197,7 @@
self.consolestream = ConsoleStream(self.consoleview)
self.location = None
self.treeview_column_location.set_visible(self.actiongroup.get_action("VcFlatten").get_active())
+ self.fileentry.show() #TODO: remove
size = self.fileentry.size_request()[1]
self.button_jump.set_size_request(size, size)
self.button_jump.hide()
@@ -205,7 +207,7 @@
def set_location(self, location):
self.model.clear()
self.location = location = os.path.abspath(location or ".")
- self.fileentry.gtk_entry().set_text(location)
+ self.fileentry.gtk_entry.set_text(location)
self.vc = vc.Vc(location)
it = self.model.add_entries( None, [location] )
self.treeview.grab_focus()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]