Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add latin language in plugin description #16

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Installation
4. Restart Gedit.
5. Activate the plugin in the Gedit preferences dialog.

Or just run `install.sh` (`bash install.sh`) file.

### For Example...

git clone git://github.com/Quixotix/gedit-restore-tabs.git
Expand Down
16 changes: 16 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Install the Tabs Rertore GEdit plugin.
# Written by Hildo Guillardi Júnior.
# Distributed by GNU General Propose License 3.0.

#git clone git://github.com/hildogjr/gedit-restore-tabs.git

echo 'Creating the plugin folder...'
mkdir $HOME/.local/share/gedit/plugins/ -p # Create the directories recursively.

echo 'Installing the files...'
cp restoretabs.* $HOME/.local/share/gedit/plugins/ # Copy: py, icon and plugin configuration.
sudo cp org.gnome.gedit.plugins.restoretabs.gschema.xml /usr/share/glib-*/schemas/

echo 'Updating Linux register...'
#sudo glib-compile-schemas /usr/share/glib-2.0/schemas/
sudo glib-compile-schemas /usr/share/glib-*/schemas/
7 changes: 5 additions & 2 deletions restoretabs.plugin
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
[Plugin]
Loader=python
Loader=python3
Module=restoretabs
IAge=3
Name=Restore Tabs
Name[pt]=Recupera Abas
Name[it]=Recupera Tabs
Name[es]=Recupera las Fichas
Description=Restores document tabs on startup.
Authors=Micah Carrick <micah@quixotix.com>
Copyright=Copyright © 2011 Micah Carrick
Icon=restoretabs.png
Website=https://github.com/Quixotix/gedit-restore-tabs
Version=3.0.0

Binary file added restoretabs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 30 additions & 7 deletions restoretabs.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Written by Micah Carrick.
# Distribute under GNU GPL 3.0 License.

import os
from gi.repository import GObject, GLib, Gtk, Gio, Gedit

Expand All @@ -21,7 +24,10 @@ def do_activate(self):
self._handlers.append(handler_id)

# temporary handler to catch the first time a window is shown
self._temp_handler = self.window.connect("show", self.on_window_show)
self._temp_handler = self.window.connect("show", self.on_window_show)

# handler to catch the Untitled Document tab
self.tab_handler_id = self.window.connect("tab-added", self.on_tab_added)

def do_deactivate(self):
"""
Expand Down Expand Up @@ -58,16 +64,33 @@ def on_window_show(self, window, data=None):
"""
if self.is_first_window():
tab = self.window.get_active_tab()
if tab.get_state() == 0 and not tab.get_document().get_location():
if tab and tab.get_state() == 0 and not tab.get_document().get_location():
self.window.close_tab(tab)
settings = Gio.Settings.new(SETTINGS_SCHEMA)
uris = settings.get_value('uris')
if uris:
for uri in uris:
location = Gio.file_new_for_uri(uri)
tab = self.window.get_tab_from_location(location)
if not tab:
self.window.create_tab_from_location(location, None, 0,
0, False, True)
if os.path.isfile(uri if uri[:7]!='file://' else uri[7:]):
location = Gio.file_new_for_uri(uri)
tab = self.window.get_tab_from_location(location)
if not tab:
self.window.create_tab_from_location(location, None, 0,
0, False, True)
self.window.disconnect(self._temp_handler)

def on_tab_added(self, window, tab, data=None):
"""
Catch the default created Untitled Document and mark for deletion on idle.
Remove handler after first use.
"""
document = tab.get_document()
if document.is_untitled():
# crash with segfault
#self.window.close_tab(tab)
# workaround
source_id = GObject.idle_add(self.tabclose, tab)
self.window.disconnect(self.tab_handler_id)

def tabclose(self, tab):
self.window.close_tab(tab)
return False