Skip to content

Commit

Permalink
[bug 706] 706-Favorites-Bookmarks-Plugin-next gnome-terminator#706
Browse files Browse the repository at this point in the history
- bookmark plugin, basic features, support in UI in prefs window (via plugin)
- tags feature, can be used to build xml later
-
- TODO:
-       display shortcuts in menu
-       selection of urls from keyboard
- Defaults:
- press <Alt>b (see below) to add current dir in bookmark <Alt>r to remove
- sub-menu via right click->bookmarks->urls->(act menu) and
- Prefs->Plugins->BookmarkPlugin
  • Loading branch information
vssdeo committed Sep 10, 2023
1 parent a6a0eca commit 17e343f
Show file tree
Hide file tree
Showing 7 changed files with 555 additions and 8 deletions.
4 changes: 2 additions & 2 deletions terminatorlib/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def get_children(self):
children.append(self.get_nth_page(page))
return(children)

def newtab(self, debugtab=False, widget=None, cwd=None, metadata=None, profile=None):
def newtab(self, debugtab=False, widget=None, cwd=None, metadata=None, profile=None, cmd=None):
"""Add a new tab, optionally supplying a child widget"""
dbg('making a new tab')
maker = Factory()
Expand All @@ -270,7 +270,7 @@ def newtab(self, debugtab=False, widget=None, cwd=None, metadata=None, profile=N
widget.set_cwd(cwd)
if profile and self.config['always_split_with_profile']:
widget.force_set_profile(None, profile)
widget.spawn_child(debugserver=debugtab)
widget.spawn_child(debugserver=debugtab, init_command=cmd)
elif profile and self.config['always_split_with_profile']:
widget.force_set_profile(None, profile)

Expand Down
40 changes: 40 additions & 0 deletions terminatorlib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
from .util import dbg, err, get_config_dir
from .terminator import Terminator

from .version import APP_NAME

class Plugin(object):
"""Definition of our base plugin class"""
capabilities = None
Expand Down Expand Up @@ -118,6 +120,11 @@ def load_plugins(self, force=False):

self.done = True

def get_plugin_instance(self, plugin):
instance = self.instances.get(plugin, None)
dbg('get plugin: %s instance: %s' % (plugin, instance))
return instance

def get_plugins_by_capability(self, capability):
"""Return a list of plugins with a particular capability"""
result = []
Expand Down Expand Up @@ -332,3 +339,36 @@ def get_act_to_keys_config(self, act):

keybindings = self.config["keybindings"]
return keybindings.get(act)


# glade file util
from . import config
def plugin_get_glade_data(plugin):
gladedata = ''
try:
# Figure out where our library is on-disk so we can open our
(head, _tail) = os.path.split(config.__file__)
if plugin:
filename = plugin + '.glade'
plugin_glade_file = os.path.join(head, 'plugins', filename)
gladefile = open(plugin_glade_file, 'r')
gladedata = gladefile.read()
gladefile.close()
except Exception as ex:
print("Failed to find: %s", plugin_glade_file)
print(ex)

return gladedata


def plugin_get_builder(plugin):

gladedata = plugin_get_glade_data(plugin)
if not gladedata:
return

plugin_builder = Gtk.Builder()
plugin_builder.set_translation_domain(APP_NAME)
plugin_builder.add_from_string(gladedata)

return plugin_builder
81 changes: 81 additions & 0 deletions terminatorlib/plugins/BookmarkPlugin.glade
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkWindow" id="BookmarkPlugin">
<property name="can-focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="vexpand">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTreeView" id="BookmarkPluginTreeView_1">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="enable-grid-lines">horizontal</property>
<child internal-child="selection">
<object class="GtkTreeSelection"/>
</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="GtkButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="layout-style">center</property>
<child>
<object class="GtkButton" id="BookmarkPluginButtonAdd">
<property name="label">gtk-add</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="use-stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="BookmarkPluginButtonRemove">
<property name="label">gtk-remove</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="use-stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
Loading

0 comments on commit 17e343f

Please sign in to comment.