Skip to content
This repository has been archived by the owner on Aug 22, 2023. It is now read-only.

v2.0 #32

Closed
wants to merge 3 commits into from
Closed

v2.0 #32

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ po/*.po~
po/*.pot
data/ui/*.ui~
builddir/
.idea/
*.iml
build.sh
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,20 @@ Nautilus/Nemo extension to add important information about the current git direc

<div align="center"><img src="screenshots/screenshot2.png" alt="Preview" /></div>



## Requirements:
## Requirements

### Running dependencies

- `python2`
- `git`
- `python-pygit`

#### For Nautilus :
#### For Nautilus

- `nautilus-python`:
- Archlinux : `python2-nautilus`

#### For Nemo:
#### For Nemo

- `nemo-python`
- Archlinux : `nemo-python`
Expand All @@ -37,6 +36,7 @@ Nautilus/Nemo extension to add important information about the current git direc
### Fedora 24/25/26

#### Nautilus

```bash
sudo dnf copr enable heikoada/nautilus-git
sudo dnf install nautilus-git
Expand All @@ -60,6 +60,7 @@ sudo apt-get install nautilus-git
### Archlinux

#### Nautilus

```bash
yaourt -S nautilus-ext-git
```
Expand All @@ -85,7 +86,6 @@ meson builddir --prefix=/usr -Dfile_manager=[nautilus|nemo]
sudo ninja -C builddir install
```


4- Restart Nautilus

```bash
Expand Down
67 changes: 63 additions & 4 deletions data/ui/branch.ui
Original file line number Diff line number Diff line change
@@ -1,26 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<object class="GtkWindow" id="window">
<property name="can_focus">False</property>
<property name="border_width">18</property>
<property name="type">popup</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="default_width">350</property>
<property name="default_height">100</property>
<property name="default_width">400</property>
<property name="default_height">150</property>
<property name="destroy_with_parent">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkRevealer" id="revealer">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkInfoBar" id="infobar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="message_type">error</property>
<property name="show_close_button">True</property>
<signal name="response" handler="on_infobar_response" object="revealer" swapped="no"/>
<child internal-child="action_area">
<object class="GtkButtonBox" id="action_area">
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child internal-child="content_area">
<object class="GtkBox" id="content_area">
<property name="can_focus">False</property>
<property name="spacing">16</property>
<child>
<object class="GtkLabel" id="msg_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBoxText" id="branch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="border_width">18</property>
<property name="has_entry">True</property>
<signal name="changed" handler="branch_changed" swapped="no"/>
<child internal-child="entry">
Expand All @@ -32,7 +91,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="position">1</property>
</packing>
</child>
</object>
Expand Down
31 changes: 21 additions & 10 deletions data/ui/compare.ui
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.0 -->
<interface>
<requires lib="gtk+" version="3.14"/>
<requires lib="gtksourceview" version="3.0"/>
Expand All @@ -24,20 +25,29 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="stats">
<property name="name">stats</property>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_left">6</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkSourceView" id="origin">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
<property name="monospace">True</property>
<property name="show_line_numbers">True</property>
<property name="show_line_marks">True</property>
<property name="auto_indent">True</property>
<property name="highlight_current_line">True</property>
<property name="background_pattern">grid</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
Expand All @@ -48,7 +58,7 @@
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkSourceView" id="source">
<object class="GtkSourceView" id="head">
<property name="name">source</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
Expand All @@ -63,6 +73,7 @@
<property name="show_line_marks">True</property>
<property name="auto_indent">True</property>
<property name="highlight_current_line">True</property>
<property name="background_pattern">grid</property>
</object>
</child>
</object>
Expand Down
6 changes: 3 additions & 3 deletions data/ui/location.ui
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<object class="GtkImage" id="removed_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Removed Files</property>
<property name="tooltip_text" translatable="yes">Removed Files</property>
<property name="icon_name">list-remove-symbolic</property>
</object>
<object class="GtkInfoBar" id="main">
Expand Down Expand Up @@ -211,7 +211,7 @@
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
Expand All @@ -229,7 +229,7 @@
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
Expand Down
11 changes: 4 additions & 7 deletions nautilus-git/nautilus-git.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,15 @@ from gi.repository import Gtk, Nautilus, GObject, Gio


environ["DATA_DIR"] = "@DATADIR@"
environ["SRC_DIR"] = path.join("@DATADIR@", "src")
environ["WIDGETS_DIR"] = path.join("@DATADIR@", "src", "widgets")
environ["MODELS_DIR"] = path.join("@DATADIR@", "src", "models")

sys_path.insert(0, environ["SRC_DIR"])
sys_path.insert(0, environ["WIDGETS_DIR"])
sys_path.insert(0, path.join("@DATADIR@", "src"))
sys_path.insert(0, path.join("@DATADIR@", "src", "widgets"))
sys_path.insert(0, path.join("@DATADIR@", "src", "models"))

from utils import is_git
from git_utils import is_git
from location import NautilusLocation
from page import NautilusPropertyPage


resource = Gio.resource_load(path.join(environ["DATA_DIR"],
'nautilus-git.gresource'))
Gio.Resource._register(resource)
Expand Down
2 changes: 1 addition & 1 deletion nemo-git/nemo-git.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ environ["MODELS_DIR"] = path.join("@DATADIR@", "src", "models")
sys_path.insert(0, environ["SRC_DIR"])
sys_path.insert(0, environ["WIDGETS_DIR"])

from utils import is_git
from git_utils import is_git
from location import NautilusLocation
from page import NautilusPropertyPage

Expand Down
47 changes: 32 additions & 15 deletions src/utils.py → src/git_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,14 @@
You should have received a copy of the GNU General Public License
along with nautilus-git. If not, see <http://www.gnu.org/licenses/>.
"""
import difflib
from os import path
from subprocess import PIPE, Popen
from urlparse import urlsplit
from urllib2 import unquote

def get_file_path(uri):

def uriparse(uri):
"""Return file path from an uri."""
url = urlsplit(uri)
if url.scheme.lower() == "file":
Expand All @@ -32,26 +34,13 @@ def get_file_path(uri):

def is_git(folder_path):
"""Verify if the current folder_path is a git directory."""
folder_path = get_file_path(folder_path)
folder_path = uriparse(folder_path)
if folder_path:
output = execute('git rev-parse --is-inside-work-tree',
folder_path).lower()
return output == "true"
return None


def get_real_git_dir(directory):
"""Return the absolute path of the .git folder."""
dirs = directory.split("/")
current_path = ""
for i in range(len(dirs) - 1, 0, -1):
current_path = "/".join(dirs[0:i])
git_folder = path.join(current_path, ".git")
if path.exists(git_folder):
return current_path
return None


def execute(cmd, working_dir=None):
"""Execute a shell command."""
if working_dir:
Expand All @@ -61,3 +50,31 @@ def execute(cmd, working_dir=None):
command = Popen(cmd, stdout=PIPE, stderr=PIPE)
output = command.communicate()[0]
return output.decode("utf-8").strip()


def get_diff(content1, content2):
differ = difflib.Differ()
diff = list(differ.compare(content1, content2))
resultat = []
line_no1 = 0
line_no2 = 0

for line in diff:
code = line[:2]
line_code = line[2:]
if code == " ":
line_no1 += 1
line_no2 += 1
elif code == "- ":
if line != "\n":
line_no1 += 1
resultat.append([line_no1, None, code, line_code])
else:
line_no1 -= 1
elif code == "+ ":
if line != "\n":
line_no2 += 1
resultat.append([None, line_no2, code, line_code])
else:
line_no2 -= 1
return resultat
Loading