📜 ⬆️ ⬇️

Meld in windows

Quick Reference: Meld is a utility for visually comparing files / folders.

Surely not everyone agrees that this instrument is worth those dances with a tambourine that must be performed around it for less comfortable work (Meld is slightly not designed for work in Windows, but since it is written in python using GTK, it can also function in it) . I, having poked the free alternatives with my wand, decided for myself that if it got started, then the efforts would not be in vain.

I suggest that interested to get to the point.
')
The process can be divided into two parts: installation and finishing.

Installation


The main manipulations are described here: Meld / Windows . Below is the same list with my comments.
  1. Python:
  2. GTK + All-in-one bundle:
  3. Python gnome bindings:
  4. libglade:
  5. gtksourceview:
  6. Cygwin:
    • Why I did not understand Cygwin. Works without it.
    • http://www.cygwin.com/setup.exe .
    • Install according to the situation (eg c: \ dev \ cygwin).
    • If it does not work, neither without Cygwin'a, nor with it, you need to install the patch package.
  7. Download meld source code:
  8. Add this to your Path:
    • Yes, yes, in the PATH variable, add paths to python (item 1, c: \ dev \ python), to libraries (items 2, 4 and 5, c: \ dev \ gtk \ bin, c: \ dev \ glade \ bin and c: \ dev \ gtksourceview \ bin) and to Cygwin if it is installed (point 6, c: \ dev \ cygwin \ bin). You can also add a path to Meld himself (point 7, c: \ dev \ meld \ meld-1.3.1)
Now, if you run python , specifying the path to Meld (c: \ dev \ meld \ meld-1.3.1 \ meld) as a parameter, the Meld window should open. Otherwise, either I was sealed, or you did something wrong.

Dopilivanie

  1. The first question, after a successful launch: “what the hell is this black console window for me ?!”.

    The solution is simple: you do not need to run python , but pythonw .

  2. The next point: the utility window does not save its position and the state of deployment to the full screen (not that fullscreen, but that maximized). Perhaps this is a GTK problem, perhaps a windows window manager.
    I could not completely correct this behavior.

    Saving the position of the window can be realized by saving the coordinates manually, but since positioning the window before displaying it is impossible, and moving it after the display is ugly, I did not do that.

    I decided to limit WINDOW_STATE_MAXIMIZED to saving the WINDOW_STATE_MAXIMIZED flag. This is achieved by adding the window_maximized option to the application settings, and the window-state-event signal handler. First, you need to describe the handler: in the meldapp.glade file (c: \ dev \ meld \ meld-1.3.1 \ glade2 \ meldapp.glade) in the <widget class="GtkWindow" id="meldapp"> add the line <signal name="window_state_event" handler="on_window_state_event"/> :
      --- c: \ dev \ meld-base \ meld-1.3.1 \ glade2 \ meldapp.glade
     +++ c: \ dev \ meld \ meld-1.3.1 \ glade2 \ meldapp.glade
     @@ -7.6 +7.7 @@
          <property name = "title" translatable = "yes"> Meld </ property>
          <property name = "icon"> pixmaps / icon.png </ property>
          <signal name = "size_allocate" handler = "on_size_allocate" />
     + <signal name = "window_state_event" handler = "on_window_state_event" />
          <signal name = "delete_event" handler = "on_delete_event" />
              <child>
                <widget class = "GtkVBox" id = "appvbox">
    

    Then add a handler: in the meldapp.py file (c: \ dev \ meld \ meld-1.3.1 \ meldapp.py) add the on_window_state_event method:
      --- c: \ dev \ meld-base \ meld-1.3.1 \ meldapp.py
     +++ c: \ dev \ meld \ meld-1.3.1 \ meldapp.py
     @@ -615.6 +615.9 @@
              self.prefs.window_size_x = rect.width
              self.prefs.window_size_y = rect.height
    
     + def on_window_state_event (self, window, state):
     + self.prefs.window_maximized = bool (state.new_window_state & gtk.gdk.WINDOW_STATE_MAXIMIZED)
     +
          #
          # Toolbar and menu items (file)
          #
    

    Add default setting:
      --- c: \ dev \ meld-base \ meld-1.3.1 \ meldapp.py
     +++ c: \ dev \ meld \ meld-1.3.1 \ meldapp.py
     @@ -313.6 +313.7 @@
          defaults = {
              "window_size_x": prefs.Value (prefs.INT, 600),
              "window_size_y": prefs.Value (prefs.INT, 600),
     + "window_maximized": prefs.Value (prefs.BOOL, 1),
              "use_custom_font": prefs.Value (prefs.BOOL, 0),
              "custom_font": prefs.Value (prefs.STRING, "monospace, 14"),
              "tab_size": prefs.Value (prefs.INT, 4),
    

    And finally, apply the setting before displaying the window:
      --- c: \ dev \ meld-base \ meld-1.3.1 \ meldapp.py
     +++ c: \ dev \ meld \ meld-1.3.1 \ meldapp.py
     @@ -499.6 +500.8 @@
              self.scheduler.connect ("runnable", self.on_scheduler_runnable)
              self.widget.set_default_size (self.prefs.window_size_x, self.prefs.window_size_y)
              self.ui.ensure_update ()
     + if self.prefs.window_maximized:
     + self.widget.maximize ()
              self.widget.show ()
              self.widget.connect ('focus_in_event', self.on_focus_change)
              self.widget.connect ('focus_out_event', self.on_focus_change)
    

  3. Some settings, such as the toolbar display style, are taken from the GNOME desktop configuration files, and if they are not, the default setting is used. For the toolbar style, this is TOOLBAR_BOTH , i.e. display of icons and signatures.

    For myself, I just changed to TOOLBAR_ICONS :
      --- c: \ dev \ meld-base \ meld-1.3.1 \ meldapp.py
     +++ c: \ dev \ meld \ meld-1.3.1 \ meldapp.py
     @@ -375.7 +376.7 @@
    
          def get_toolbar_style (self):
              if not hasattr (self, "_gconf"):
     - return gtk.TOOLBAR_BOTH
     + return gtk.TOOLBAR_ICONS
              style = self._gconf.get_string ('/ desktop / gnome / interface / toolbar_style') or "both"
              style = {"both": gtk.TOOLBAR_BOTH, "text": gtk.TOOLBAR_TEXT,
                       "icon": gtk.TOOLBAR_ICONS, "icons": gtk.TOOLBAR_ICONS,
    

  4. Funny things happen when saving files with hyphens other than LF (\ n). In this case, all LFs are replaced by file transfers, so CRLF (\ r \ n) is converted to CRCRLF, and the next time it is saved again.

    Perhaps the problem lies in the incorrect parsing of the file (in Ubuntu Meld does not allow this), but so far I have solved it, simply commenting out a section of code that replaces some hyphens with others:
      --- c: \ dev \ meld-base \ meld-1.3.1 \ filediff.py
     +++ c: \ dev \ meld \ meld-1.3.1 \ filediff.py
     @@ -815.6 +815.7 @@
                  else:
                      return melddoc.RESULT_ERROR
              text = buf.get_text (buf.get_start_iter (), buf.get_end_iter (), 0)
     + "" "
              if bufdata.newlines:
                  if type (bufdata.newlines) == type (""):
                      if (bufdata.newlines)! = '\ n':
     @@ -832.6 +833.7 @@
                              if k! = '\ n':
                                  text = text.replace ('\ n', k)
                              break
     + "" "
              if bufdata.encoding:
                  try:
                      text = text.encode (bufdata.encoding)
    

    Moreover, the same code makes all transfers even with one comb.

  5. In Meld, which was installed according to the instructions on the GNOME website, the syntax highlighting functions, the display of line numbers and the display of spaces instead of tabs are not available.

    To fix this, I added the gtksourceview-2.2.2 library to the manual. It lacks the language.rng , language2.rng and styles.rng files , but they are in gtksourceview-2.9.3 in the share \ gtksourceview-2.0 \ language-specs folder. They just need to be copied to a similar one in gtksourceview-2.2.2.
Now Meld behaves quite adequately. You can use.

If someone practices the above, take a look from time to time, there may be updates.

PS I haven’t dealt with python, GTK and PyGTK before, so if you have written outright nonsense somewhere, please correct.

Source: https://habr.com/ru/post/87597/


All Articles