kassoulet / gedit-focus-autosave Goto Github PK
View Code? Open in Web Editor NEWA small plugin for gedit to autosave when the window goes out of focus. Use master branch for Gedit3, gedit2 branch for Gedit2.
A small plugin for gedit to autosave when the window goes out of focus. Use master branch for Gedit3, gedit2 branch for Gedit2.
Hi,
It seems the plugin doesn't work on gedit 2.30.4 with the following error ImportError: No module named gi.repository
.
Greetings
After losing a couple hours worth of unsaved tabs on a system crash, I searched for a solution. Found this plugin and after looking for a bit, I altered it to solve my personal issue. thought you might want to incorporate similar functionality. My patch does not address multiple user or security, so those are open issues.
essentially:
def on_focus_out_event(self, widget, focus):
for doc in self.window.get_unsaved_documents():
if doc.is_untouched():
continue
uri = doc.get_uri()
if uri is None:
now = datetime.datetime.now();
uri = now.strftime("file:///tmp/gedit.unsaved.%y%m%d-%H%M%S.txt");
doc.set_uri(uri)
doc.save(0)
cheers.
Whenever I open a new file, it doesn't save it automatically on losing focus and make the following error: (in fedora 31, python 3.7, gedit 3.34.1)
AttributeError: 'Document' object has no attribute 'set_location'
With gedit 3 that time ;)
When gedit loses its focus, here what happen:
Traceback (most recent call last):
File "/home/maya/.local/share/gedit/plugins/focus_autosave.py", line 33, in on_focus_out_event
tab.emit('save')
TypeError: <Tab object at 0x26da0a0 (GeditTab at 0x240c360)>: unknown signal name: save
Sorry, for all my bug reports ^^"
With the current design for plugins you can just move your code directly to the plugin object.
With gedit 2.30.4, again :p
When I want to enable the plugin, gedit freezes with the following trace:
/usr/lib64/python2.7/site-packages/gi/module.py:138: Warning: cannot register existing type `GtkWidget'
g_type = info.get_g_type()
/usr/lib64/python2.7/site-packages/gi/module.py:138: Warning: g_type_add_interface_static: assertion `G_TYPE_IS_INSTANTIATABLE (instance_type)' failed
g_type = info.get_g_type()
/usr/lib64/python2.7/site-packages/gi/module.py:138: Warning: cannot register existing type `GtkBuildable'
g_type = info.get_g_type()
/usr/lib64/python2.7/site-packages/gi/module.py:138: Warning: g_type_interface_add_prerequisite: assertion `G_TYPE_IS_INTERFACE (interface_type)' failed
g_type = info.get_g_type()
/usr/lib64/python2.7/site-packages/gi/module.py:138: Warning: g_once_init_leave: assertion `initialization_value != 0' failed
g_type = info.get_g_type()
/usr/lib64/python2.7/site-packages/gi/module.py:142: Warning: g_type_get_qdata: assertion `node != NULL' failed
type_ = g_type.pytype
While it seems to be the only plugin to save on lost focus, it would be great to be able to use it ;)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.