Skip to content

Commit

Permalink
Import advanced-bookmarks-gedit-plugin-0.6.3.tar.gz
Browse files Browse the repository at this point in the history
  • Loading branch information
FooBarWidget committed Aug 30, 2008
0 parents commit 071106d
Show file tree
Hide file tree
Showing 8 changed files with 1,173 additions and 0 deletions.
10 changes: 10 additions & 0 deletions advanced-bookmarks.gedit-plugin
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Gedit Plugin]
Loader=python
Module=advanced-bookmarks
IAge=2
Name=Advanced Bookmarks
Description=Advanced bookmarking tool
Icon=stock_help-add-bookmark
Authors=Eugene Khorev <eugene.khorev@gmail.com>
Copyright=Copyright © 2008 Eugene Khorev
Website=http://www.gedit.org
22 changes: 22 additions & 0 deletions advanced-bookmarks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-

# Copyright (C) 2008 - Eugene Khorev
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307, USA.

import plugin
from plugin import AdvancedBookmarksPlugin

176 changes: 176 additions & 0 deletions advanced-bookmarks/bookmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# -*- coding: utf-8 -*-

# Copyright (C) 2008 - Eugene Khorev
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330,
# Boston, MA 02111-1307, USA.

import pygtk
pygtk.require("2.0")
import gtk

class bookmark_list(object):

def __init__(self, config):
self._list = {}

self._config = config

# Load bookmarks from configuration
sections = config.sections()

if config.has_section("common"):
index = sections.index("common")
del sections[index]

# Create an empty store for the documents that have no bookmarks yet
self._empty_store = gtk.ListStore(int, str)

for sec in sections:
store = gtk.ListStore(int, str)

self._list[sec] = {"store": store, "iters": {}}

for line in config.options(sec):
comment = config.get(sec, line)
self._list[sec]["iters"][int(line)] = store.append([int(line), comment])

# Setup sorting
store.set_sort_func(0, self._line_sort)
store.set_sort_column_id(0, gtk.SORT_ASCENDING)

def get_store(self, uri): # Gets tree store for an uri
try:
return self._list[uri]["store"]
except:
return self._empty_store

def get_iters(self, uri):
try:
return self._list[uri]["iters"]
except:
return {}

def add(self, uri, line, source, comment = ""): # Adds a line for an uri (returns True on success)
exists = self.exists(uri, line)

if comment == "":
content = source
else:
content = comment

if not exists:
if self._list.has_key(uri):
self._list[uri]["iters"][line] = self._list[uri]["store"].append([line, content])
else:
store = gtk.ListStore(int, str)
self._list[uri] = {"store": store, "iters": {line: store.append([line, content])}}

# Setup sorting
store.set_sort_func(0, self._line_sort)
store.set_sort_column_id(0, gtk.SORT_ASCENDING)

# Create uri section in configuration
self._config.add_section(uri)

# Upadate configuration
self._config.set(uri, str(line), comment)

return not exists

def delete(self, uri, line = None): # Deletes a line or an entire uri (returns True on success)
if line:
exists = self.exists(uri, line)

if exists:
self._list[uri]["store"].remove(self._list[uri]["iters"][line])
del self._list[uri]["iters"][line]

# Upadate configuration
self._config.remove_option(uri, str(line))

return exists
else:
try:
del self._list[uri]

# Upadate configuration
self._config.remove_section(uri)

return True
except:
return False

def exists(self, uri, line): # Returns True if there is a line exists in an uri
try:
return self._list[uri]["iters"][line]
except:
return False

def toggle(self, uri, line, source, comment = ""): # Adds or removes a line for an uri
if self.exists(uri, line):
self.delete(uri, line)
return False
else:
self.add(uri, line, source, comment)
return True

def update(self, uri, offset, cur_line, end_line):
if self._list.has_key(uri):
iters = {}

keys = self._list[uri]["iters"].keys()

for line in keys:
row = self._list[uri]["iters"][line]

comment = self._config.get(uri, str(line))
self._config.remove_option(uri, str(line))

if line < cur_line:
self._list[uri]["store"].set_value(row, 0, line)
iters[line] = row

# Upadate configuration
self._config.set(uri, str(line), comment)

elif (end_line < 0 and line >= cur_line) or (end_line >= 0 and line > end_line):
line = line-offset
self._list[uri]["store"].set_value(row, 0, line)
iters[line] = row

# Upadate configuration
self._config.set(uri, str(line), comment)

else:
self._list[uri]["store"].remove(row)

self._list[uri]["iters"] = iters

return True
else:
return False

def _line_sort(self, model, line1, line2):
val1 = model.get_value(line1, 0)
val2 = model.get_value(line2, 0)

if val1 < val2:
return -1
if val1 == val2:
return 0
return 1

# ex:ts=4:et:
107 changes: 107 additions & 0 deletions advanced-bookmarks/config_dlg.glade
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.0 on Sun Jan 20 10:34:53 2008 -->
<glade-interface>
<widget class="GtkDialog" id="config_dialog">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Advanced Bookmarks settings</property>
<property name="modal">True</property>
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="skip_taskbar_hint">True</property>
<property name="has_separator">False</property>
<signal name="response" handler="on_config_dialog_response"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="vbox">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">2</property>
<child>
<widget class="GtkCheckButton" id="chk_highlight">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Highlight bookmarks</property>
<property name="response_id">0</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Highlight color</property>
</widget>
</child>
<child>
<widget class="GtkColorButton" id="btn_color">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="response_id">0</property>
<property name="color">#000000000000</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
</packing>
</child>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="action_area">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="btn_cancel">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_btn_cancel_clicked"/>
</widget>
</child>
<child>
<widget class="GtkButton" id="btn_ok">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-ok</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_btn_ok_clicked"/>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>
26 changes: 26 additions & 0 deletions advanced-bookmarks/menu.ui.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<ui>
<menubar name="MenuBar">
<menu name="EditMenu" action="Edit">
<placeholder name="EditOps_6">
<menu name="AdvancedBookmarks" action="AdvancedBookmarks">
<menu name="NumberedBookmarks" action="NumberedBookmarks">
<menuitem name="ToggleBookmark0" action="ToggleBookmark0"/>
<menuitem name="ToggleBookmark1" action="ToggleBookmark1"/>
<menuitem name="ToggleBookmark2" action="ToggleBookmark2"/>
<menuitem name="ToggleBookmark3" action="ToggleBookmark3"/>
<menuitem name="ToggleBookmark4" action="ToggleBookmark4"/>
<menuitem name="ToggleBookmark5" action="ToggleBookmark5"/>
<menuitem name="ToggleBookmark6" action="ToggleBookmark6"/>
<menuitem name="ToggleBookmark7" action="ToggleBookmark7"/>
<menuitem name="ToggleBookmark8" action="ToggleBookmark8"/>
<menuitem name="ToggleBookmark9" action="ToggleBookmark9"/>
</menu>

<menuitem name="ToggleBookmark" action="ToggleBookmark"/>
<menuitem name="ToggleBookmarkAdvanced" action="ToggleBookmarkAdvanced"/>
<menuitem name="EditBookmark" action="EditBookmark"/>
</menu>
</placeholder>
</menu>
</menubar>
</ui>
Loading

0 comments on commit 071106d

Please sign in to comment.