foiegras r61 - in trunk: . data src/foiegras src/foiegras/buffer src/foiegras/windows
- From: denisw svn gnome org
- To: svn-commits-list gnome org
- Subject: foiegras r61 - in trunk: . data src/foiegras src/foiegras/buffer src/foiegras/windows
- Date: Sun, 9 Mar 2008 19:09:19 +0000 (GMT)
Author: denisw
Date: Sun Mar 9 19:09:19 2008
New Revision: 61
URL: http://svn.gnome.org/viewvc/foiegras?rev=61&view=rev
Log:
2008-03-09 Denis Washington <denisw svn gnome org>
* data/main.glade:
* data/menubar.ui:
* data/toolbar.ui:
Restructure menus, add new toolbar to set the paragraph style
(represents the non-container block tags) and bullets (corresponds
to list block tag; not implemented yet). The block toolbar was removed;
there is only an "Annotations" bar left which is for inline tags.
* src/foiegras/buffer/main.py:
* src/foiegras/buffer/document.py:
Changed to match the UI changes.
* src/foiegras/buffer/block_handler.py:
Accept a "new_block" boolean argument in block_handler() to control
if the tag should be applied to an exisiting block or if a new block
with the tag should be created.
* src/foiegras/buffer/tags.py:
New module that contains lists of all types of tags and the matching
GtkTextTags.
Added:
trunk/src/foiegras/buffer/tags.py
Modified:
trunk/ChangeLog
trunk/data/main.glade
trunk/data/menubar.ui
trunk/data/toolbar.ui
trunk/src/foiegras/buffer/block_handler.py
trunk/src/foiegras/buffer/docbuffer.py
trunk/src/foiegras/document.py
trunk/src/foiegras/windows/main.py
Modified: trunk/data/main.glade
==============================================================================
--- trunk/data/main.glade (original)
+++ trunk/data/main.glade Sun Mar 9 19:09:19 2008
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.0 on Tue Feb 19 11:46:40 2008 -->
+<!--Generated with glade3 3.4.1 on Sat Mar 8 19:42:57 2008 -->
<glade-interface>
<widget class="GtkWindow" id="window_main">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -20,371 +20,22 @@
<placeholder/>
</child>
<child>
- <placeholder/>
- </child>
- <child>
- <widget class="GtkVPaned" id="vpaned1">
- <property name="height_request">0</property>
+ <widget class="GtkHPaned" id="hpaned_document">
<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>
<child>
- <widget class="GtkHPaned" id="hpaned_document">
- <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>
- <child>
- <placeholder/>
- </child>
- </widget>
- <packing>
- <property name="resize">True</property>
- <property name="shrink">True</property>
- </packing>
- </child>
- <child>
- <widget class="GtkFrame" id="frame1">
- <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="label_xalign">0</property>
- <property name="shadow_type">GTK_SHADOW_NONE</property>
- <child>
- <widget class="GtkAlignment" id="alignment1">
- <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="left_padding">12</property>
- <child>
- <widget class="GtkTable" id="table1">
- <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="border_width">3</property>
- <property name="n_rows">3</property>
- <property name="n_columns">20</property>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <placeholder/>
- </child>
- <child>
- <widget class="GtkLinkButton" id="linkbutton2">
- <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="label" translatable="yes">> List </property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <property name="uri">http://glade.gnome.org</property>
- </widget>
- <packing>
- <property name="left_attach">6</property>
- <property name="right_attach">7</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLinkButton" id="linkbutton5">
- <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="label" translatable="yes"> > Link</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <property name="uri">http://glade.gnome.org</property>
- </widget>
- <packing>
- <property name="left_attach">7</property>
- <property name="right_attach">8</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLinkButton" id="linkbutton5">
- <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="label" translatable="yes">> List </property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <property name="uri">http://glade.gnome.org</property>
- </widget>
- <packing>
- <property name="left_attach">5</property>
- <property name="right_attach">6</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLinkButton" id="linkbutton5">
- <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="label" translatable="yes">> Media </property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <property name="uri">http://glade.gnome.org</property>
- </widget>
- <packing>
- <property name="left_attach">3</property>
- <property name="right_attach">4</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLinkButton" id="linkbutton5">
- <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="label" translatable="yes">> Synopsis </property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <property name="uri">http://glade.gnome.org</property>
- </widget>
- <packing>
- <property name="left_attach">4</property>
- <property name="right_attach">5</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLinkButton" id="linkbutton5">
- <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="label" translatable="yes"> > List</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <property name="uri">http://glade.gnome.org</property>
- </widget>
- <packing>
- <property name="left_attach">2</property>
- <property name="right_attach">3</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLinkButton" id="linkbutton5">
- <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="label" translatable="yes"> > List</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <property name="uri">http://glade.gnome.org</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <widget class="GtkLinkButton" id="linkbutton5">
- <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="label" translatable="yes"> >Figure</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="response_id">0</property>
- <property name="uri">http://glade.gnome.org</property>
- </widget>
- <packing>
- <property name="x_options"></property>
- <property name="y_options"></property>
- </packing>
- </child>
- </widget>
- </child>
- </widget>
- </child>
- <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="label" translatable="yes">Tag Hierarchy</property>
- <property name="use_markup">True</property>
- </widget>
- <packing>
- <property name="type">label_item</property>
- </packing>
- </child>
- </widget>
- <packing>
- <property name="resize">False</property>
- <property name="shrink">False</property>
- </packing>
+ <placeholder/>
</child>
</widget>
<packing>
- <property name="position">4</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
+ <placeholder/>
+ </child>
+ <child>
<widget class="GtkStatusbar" id="statusbar_main">
<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>
Modified: trunk/data/menubar.ui
==============================================================================
--- trunk/data/menubar.ui (original)
+++ trunk/data/menubar.ui Sun Mar 9 19:09:19 2008
@@ -8,6 +8,8 @@
<menuitem name="Save" action="SaveAction" />
<menuitem name="SaveAs" action="SaveAsAction" />
<separator />
+ <menuitem name="DocumentProperties" action="DocumentPropertiesAction" />
+ <separator />
<menuitem name="Quit" action="QuitAction" />
</menu>
<menu name="EditMenu" action="EditMenuAction">
@@ -20,27 +22,23 @@
<separator />
<menuitem name="Preferences" action="PreferencesAction" />
</menu>
- <menu name="DocumentMenu" action="DocumentMenuAction">
- <menuitem name="Informations" action="InformationsAction" />
- <menuitem name="Sections" action="SectionsAction" />
+ <menu name="ViewMenu" action="ViewMenuAction">
+ <menuitem name="SidePane" action="SidePaneAction" />
</menu>
- <menu name="BlockMenu" action="BlockMenuAction">
- <menuitem name="Caption" action="CaptionAction" />
+ <menu name="InsertMenu" action="InsertMenuAction">
<menuitem name="Citation" action="CitationAction" />
- <menuitem name="MultimediaObject" action="MultimediaObjectAction" />
- <menuitem name="CodeSnippet" action="CodeSnippetAction" />
- <menuitem name="Paragraph" action="ParagraphAction" />
- <menuitem name="Screen" action="ScreenAction" />
<menuitem name="EditorialComment" action="EditorialCommentAction" />
- <menuitem name="Figure" action="FigureAction" />
- <menuitem name="List" action="ListAction" />
<menuitem name="Note" action="NoteAction" />
<menuitem name="Synopse" action="SynopseAction" />
- <menuitem name="Table" action="TableAction" />
+ <separator />
+ <menuitem name="Table" action="TableAction" />
+ <separator />
+ <menuitem name="Figure" action="FigureAction" />
+ <menuitem name="MultimediaObject" action="MultimediaObjectAction" />
</menu>
- <menu name="InlineMenu" action="InlineMenuAction">
+ <menu name="AnnotateMenu" action="AnnotateMenuAction">
<menuitem name="ApplicationName" action="ApplicationNameAction" />
- <menuitem name="CodeSnippet" action="CodeSnippetAction" />
+ <menuitem name="InlineCode" action="InlineCodeAction" />
<menuitem name="Command" action="CommandAction" />
<menuitem name="ComputerOutput" action="ComputerOutputAction" />
<menuitem name="Date" action="DateAction" />
@@ -49,7 +47,6 @@
<menuitem name="GUILabel" action="GUILabelAction" />
<menuitem name="Hyperlink" action="HyperlinkAction" />
<menuitem name="KeyStroke" action="KeyStrokeAction" />
- <menuitem name="MultimediaObject" action="MultimediaObjectAction" />
<menuitem name="Quote" action="QuoteAction" />
<menuitem name="SystemItem" action="SystemItemAction" />
<menuitem name="UserInput" action="UserInputAction" />
Modified: trunk/data/toolbar.ui
==============================================================================
--- trunk/data/toolbar.ui (original)
+++ trunk/data/toolbar.ui Sun Mar 9 19:09:19 2008
@@ -4,26 +4,23 @@
<toolitem name="Open" action="OpenToolAction" />
<toolitem name="Save" action="SaveAction" />
<separator />
+ <toolitem name="Undo" action="UndoAction" />
+ <toolitem name="Redo" action="RedoAction" />
+ <separator />
<toolitem name="Cut" action="CutAction" />
<toolitem name="Copy" action="CopyAction" />
<toolitem name="Paste" action="PasteAction" />
<separator />
- <toolitem name="Preferences" action="PreferencesAction" />
+ <toolitem name="Insert" action="InsertAction" />
<separator />
<toolitem name="CreatePatch" action="CreatePatchAction" />
<toolitem name="Commit" action="CommitAction" />
<toolitem name="Review" action="ReviewAction" />
</toolbar>
- <toolbar name="BlockToolbar">
- <toolitem name="Caption" action="CaptionAction" />
- <toolitem name="Citation" action="CitationAction" />
- <toolitem name="CodeSnippet" action="CodeSnippetAction" />
- <toolitem name="Paragraph" action="ParagraphAction" />
- <toolitem name="Screen" action="ScreenAction" />
- <toolitem name="EditorialComment" action="EditorialCommentAction" />
- <toolitem name="List" action="ListAction" />
- <toolitem name="Note" action="NoteAction" />
- <toolitem name="Synopse" action="SynopseAction" />
+ <toolbar name="ParagraphToolbar">
+ <toolitem name="ToggleList" action="ToggleListAction" />
+ <toolitem name="ListIndent" action="ListIndentAction" />
+ <toolitem name="ListUnindent" action="ListUnindentAction" />
</toolbar>
<toolbar name="InlineToolbar">
<toolitem name="ApplicationName" action="ApplicationNameAction" />
@@ -35,7 +32,6 @@
<toolitem name="GUILabel" action="GUILabelAction" />
<toolitem name="InlineCode" action="InlineCodeAction" />
<toolitem name="KeyStroke" action="KeyStrokeAction" />
- <toolitem name="MultimediaObject" action="MultimediaObjectAction" />
<toolitem name="Quote" action="QuoteAction" />
<toolitem name="SystemItem" action="SystemItemAction" />
<toolitem name="UserInput" action="UserInputAction" />
Modified: trunk/src/foiegras/buffer/block_handler.py
==============================================================================
--- trunk/src/foiegras/buffer/block_handler.py (original)
+++ trunk/src/foiegras/buffer/block_handler.py Sun Mar 9 19:09:19 2008
@@ -12,13 +12,16 @@
#
# 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
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
import pygtk
pygtk.require('2.0')
import gtk
import docbuffer
+
+from tags import SIMPLE_BLOCK_TAGS
-def block_handler(buffer, tag_name, block_iter = None):
+def block_handler(buffer, tag_name, block_iter = None, new_block = True):
"""
Hanlder for block tags.
Maintains the working of nested block tags
@@ -27,17 +30,19 @@
text. If not, the text starting from current cursor point will
turn to a block.
"""
-
if not block_iter:
block_mark = buffer.get_insert()
block_iter = buffer.get_iter_at_mark(block_mark)
- if not block_iter.starts_line():
- buffer.insert(block_iter,"\n")
- block_iter = buffer.get_iter_at_mark(buffer.get_insert())
-
+ if not block_iter.starts_line():
+ if new_block:
+ buffer.insert(block_iter,"\n")
+ block_iter = buffer.get_iter_at_mark(buffer.get_insert())
+ else:
+ block_iter.set_line_offset(0)
+
start_offset = block_iter.get_offset()
-
+
end_iter = buffer.get_iter_at_mark(buffer.get_selection_bound())
end_offset = end_iter.get_offset()
@@ -51,7 +56,11 @@
start_iter = buffer.get_iter_at_offset(start_offset)
end_iter = buffer.get_iter_at_offset(end_offset)
-
+
+ if tag_name in SIMPLE_BLOCK_TAGS:
+ for t in SIMPLE_BLOCK_TAGS:
+ buffer.remove_tag_by_name(t, start_iter, end_iter)
+
buffer.apply_tag_by_name(tag_name, start_iter, end_iter)
Modified: trunk/src/foiegras/buffer/docbuffer.py
==============================================================================
--- trunk/src/foiegras/buffer/docbuffer.py (original)
+++ trunk/src/foiegras/buffer/docbuffer.py Sun Mar 9 19:09:19 2008
@@ -17,150 +17,14 @@
import pygtk
pygtk.require('2.0')
import gtk
-import pango
import gobject
from block_handler import block_handler
+from tags import INLINE_TAGS, BLOCK_TAGS, SIMPLE_BLOCK_TAGS, TAG_TABLE
def _(string):
return string
-
-INLINE_TAGS = []
-BLOCK_TAGS = []
-ATTRIBUTES = []
-
-TAG_TABLE = gtk.TextTagTable()
-
-def setup_tags():
-
- def block_tag(name):
- BLOCK_TAGS.append(name)
- return gtk.TextTag(name)
-
- def inline_tag(name):
- INLINE_TAGS.append(name)
- return gtk.TextTag(name)
-
- # read-only areas
- tag = gtk.TextTag("_readonly")
- tag.set_property("editable", False)
- TAG_TABLE.add(tag)
-
- # <app>
- tag = inline_tag("app")
- TAG_TABLE.add(tag)
-
- # <caption>
- tag = block_tag("caption")
- TAG_TABLE.add(tag)
-
- # <cmd>
- tag = inline_tag("cmd")
- tag.set_property("family", "monospace")
- TAG_TABLE.add(tag)
-
- # <code>
- tag = inline_tag("code")
- tag.set_property("family", "monospace")
- TAG_TABLE.add(tag)
-
- # <code-inline>
- tag = inline_tag("code-inline")
- tag.set_property("family", "monospace")
- TAG_TABLE.add(tag)
-
- # <cite>
- tag = block_tag("cite")
- tag.set_property("style", pango.STYLE_ITALIC)
- TAG_TABLE.add(tag)
-
- # <date>
- tag = inline_tag("date")
- tag.set_property("style", pango.STYLE_ITALIC)
- TAG_TABLE.add(tag)
-
- # <em>
- tag = inline_tag("em")
- tag.set_property("weight", pango.WEIGHT_BOLD)
- TAG_TABLE.add(tag)
-
- # <figure>
- tag = block_tag("figure")
- TAG_TABLE.add(tag)
-
- # <file>
- tag = inline_tag("file")
- tag.set_property("style", pango.STYLE_ITALIC)
- TAG_TABLE.add(tag)
-
- # <gui>
- tag = inline_tag("gui")
- tag.set_property("style", pango.STYLE_ITALIC)
- TAG_TABLE.add(tag)
-
- # <input>
- tag = inline_tag("input")
- tag.set_property("family", "monospace")
- TAG_TABLE.add(tag)
-
- # <key>
- tag = inline_tag("key")
- tag.set_property("style", pango.STYLE_ITALIC)
- TAG_TABLE.add(tag)
-
- # <link>
- tag = inline_tag("link")
- tag.set_property("foreground", "#0000ff")
- tag.set_property("underline", True)
- TAG_TABLE.add(tag)
-
- # <list>
- tag = block_tag("list")
- TAG_TABLE.add(tag)
-
- # <note>
- tag = block_tag("note")
- tag.set_property("paragraph-background", "#f0f0f0")
- tag.set_property("foreground", "#0000ee")
- TAG_TABLE.add(tag)
-
- # <output>
- tag = inline_tag("output")
- tag.set_property("family", "monospace")
- TAG_TABLE.add(tag)
-
- # <p>
- tag = block_tag("p")
- TAG_TABLE.add(tag)
-
- # <screen>
- tag = block_tag("screen")
- TAG_TABLE.add(tag)
-
- # <synopsis>
- tag = block_tag("synopsis")
- TAG_TABLE.add(tag)
-
- # <sys>
- tag = inline_tag("sys")
- tag.set_property("family", "monospace")
- TAG_TABLE.add(tag)
-
- # <title>
- tag = block_tag("title")
- tag.set_property("scale", pango.SCALE_XX_LARGE)
- tag.set_property("underline", True)
- TAG_TABLE.add(tag)
-
- # <var>
- tag = inline_tag("var")
- tag.set_property("style", pango.STYLE_ITALIC)
- TAG_TABLE.add(tag)
-
-setup_tags()
-
-
class DocumentBuffer (gtk.TextBuffer):
"""
Represents a Mallard document.
@@ -230,7 +94,15 @@
is located. If no iterator is given, the tag is applied to the block
at the current cursor position.
"""
- block_handler(self, tag_name, block_iter)
+ block_handler(self, tag_name, block_iter, False)
+
+
+ def insert_block_tag(self, tag_name, start_iter = None):
+ """
+ Inserts a new a block tag at the passed position. If no iterator is
+ given, the block is inserted at the current cursor position.
+ """
+ block_handler(self, tag_name, start_iter, True)
def apply_inline_tag(self, tag_name, start_iter = None, end_iter = None):
@@ -298,11 +170,10 @@
if len(bounds) == 0:
start = end = self.get_iter_at_mark(self.get_insert())
+ start.backward_char()
else:
start = bounds[0]
end = bounds[1]
-
- start.backward_char()
tags = set()
Added: trunk/src/foiegras/buffer/tags.py
==============================================================================
--- (empty file)
+++ trunk/src/foiegras/buffer/tags.py Sun Mar 9 19:09:19 2008
@@ -0,0 +1,159 @@
+# Copyright (C) 2008 by Denis Washington <denisw svn gnome org>
+#
+# 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
+import pango
+
+INLINE_TAGS = []
+BLOCK_TAGS = []
+SIMPLE_BLOCK_TAGS = []
+ATTRIBUTES = []
+
+TAG_TABLE = gtk.TextTagTable()
+
+def setup_tags():
+
+ def block_tag(name):
+ BLOCK_TAGS.append(name)
+ return gtk.TextTag(name)
+
+ def simple_block_tag(name):
+ SIMPLE_BLOCK_TAGS.append(name)
+ return block_tag(name)
+
+ def inline_tag(name):
+ INLINE_TAGS.append(name)
+ return gtk.TextTag(name)
+
+ # read-only areas
+ tag = gtk.TextTag("_readonly")
+ tag.set_property("editable", False)
+ TAG_TABLE.add(tag)
+
+ # <app>
+ tag = inline_tag("app")
+ TAG_TABLE.add(tag)
+
+ # <caption>
+ tag = block_tag("caption")
+ TAG_TABLE.add(tag)
+
+ # <cmd>
+ tag = inline_tag("cmd")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <code>
+ tag = simple_block_tag("code")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <code-inline>
+ tag = inline_tag("code-inline")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <cite>
+ tag = block_tag("cite")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+ # <date>
+ tag = inline_tag("date")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+ # <em>
+ tag = inline_tag("em")
+ tag.set_property("weight", pango.WEIGHT_BOLD)
+ TAG_TABLE.add(tag)
+
+ # <figure>
+ tag = block_tag("figure")
+ TAG_TABLE.add(tag)
+
+ # <file>
+ tag = inline_tag("file")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+ # <gui>
+ tag = inline_tag("gui")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+ # <input>
+ tag = inline_tag("input")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <key>
+ tag = inline_tag("key")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+ # <link>
+ tag = inline_tag("link")
+ tag.set_property("foreground", "#0000ff")
+ tag.set_property("underline", True)
+ TAG_TABLE.add(tag)
+
+ # <list>
+ tag = block_tag("list")
+ TAG_TABLE.add(tag)
+
+ # <note>
+ tag = block_tag("note")
+ tag.set_property("paragraph-background", "#f0f0f0")
+ tag.set_property("foreground", "#0000ee")
+ TAG_TABLE.add(tag)
+
+ # <output>
+ tag = inline_tag("output")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <p>
+ tag = simple_block_tag("p")
+ TAG_TABLE.add(tag)
+
+ # <screen>
+ tag = simple_block_tag("screen")
+ TAG_TABLE.add(tag)
+
+ # <synopsis>
+ tag = block_tag("synopsis")
+ TAG_TABLE.add(tag)
+
+ # <sys>
+ tag = inline_tag("sys")
+ tag.set_property("family", "monospace")
+ TAG_TABLE.add(tag)
+
+ # <title>
+ tag = simple_block_tag("title")
+ tag.set_property("scale", pango.SCALE_XX_LARGE)
+ tag.set_property("underline", True)
+ TAG_TABLE.add(tag)
+
+ # <var>
+ tag = inline_tag("var")
+ tag.set_property("style", pango.STYLE_ITALIC)
+ TAG_TABLE.add(tag)
+
+setup_tags()
Modified: trunk/src/foiegras/document.py
==============================================================================
--- trunk/src/foiegras/document.py (original)
+++ trunk/src/foiegras/document.py Sun Mar 9 19:09:19 2008
@@ -45,6 +45,7 @@
# Create the ScrolledWindow
self._scrolledwindow = gtk.ScrolledWindow()
+ self._scrolledwindow.set_shadow_type(gtk.SHADOW_IN)
self._scrolledwindow.add(self._view)
self._scrolledwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
Modified: trunk/src/foiegras/windows/main.py
==============================================================================
--- trunk/src/foiegras/windows/main.py (original)
+++ trunk/src/foiegras/windows/main.py Sun Mar 9 19:09:19 2008
@@ -112,66 +112,68 @@
# Set up actions
actions = [
- ('FileMenuAction', None, _("File"), None, _(""), self.dummy_action),
- ('EditMenuAction', None, _("Edit"), None, _(""), self.dummy_action),
- ('DocumentMenuAction', None, _("Document"), None, _(""), self.dummy_action),
- ('BlockMenuAction', None, _("Block"), None, _(""), self.dummy_action),
- ('InlineMenuAction', None, _("Inline"), None, _(""), self.dummy_action),
- ('ContributeMenuAction', None, _("Contribute"), None, _(""), self.dummy_action),
- ('HelpMenuAction', None, _("Help"), None, _(""), self.dummy_action),
- ('NewAction', gtk.STOCK_NEW, _("New"), None, _(""), self.new_document),
- ('OpenAction', gtk.STOCK_OPEN, _("Open"), None, _(""), self.open_document),
- ('RecentlyUsedAction', None, _("Recently Used"), None, _(""), self.dummy_action),
- ('SaveAction', gtk.STOCK_SAVE, _("Save"), None, _(""), self.save_document),
- ('SaveAsAction', gtk.STOCK_SAVE_AS, _("Save As"), None, _(""), self.save_document_as),
- ('QuitAction', gtk.STOCK_QUIT, _("Quit"), None, _(""), self.quit),
- ('UndoAction', gtk.STOCK_UNDO, _("Undo"), None, _(""), self.dummy_action),
- ('RedoAction', gtk.STOCK_REDO, _("Redo"), None, _(""), self.dummy_action),
- ('CutAction', gtk.STOCK_CUT, _("Cut"), None, _(""), self.dummy_action),
- ('CopyAction', gtk.STOCK_COPY, _("Copy"), None, _(""), self.dummy_action),
- ('PasteAction', gtk.STOCK_PASTE, _("Paste"), None, _(""), self.dummy_action),
- ('PreferencesAction', gtk.STOCK_PREFERENCES, _("Preferences"), None, _(""), self.show_preferences),
- ('InformationsAction', gtk.STOCK_INFO, _("Informations"), None, _(""), self.dummy_action),
- ('SectionsAction', None, _("Sections"), None, _(""), self.dummy_action),
- ('CreatePatchAction', None, _("Create Patch"), None, _(""), self.create_patch),
- ('CommitAction', None, _("Commit"), None, _(""), self.commit),
- ('ReviewAction', None, _("Review"), None, _(""), self.dummy_action),
- ('ContentsAction', None, _("Contents"), None, _(""), self.dummy_action),
- ('AboutAction', gtk.STOCK_ABOUT, _("About"), None, _(""), self.about)
+ ('FileMenuAction', None, _("_File"), None, _(""), self.dummy_action),
+ ('EditMenuAction', None, _("_Edit"), None, _(""), self.dummy_action),
+ ('ViewMenuAction', None, _("_View"), None, _(""), self.dummy_action),
+ ('InsertMenuAction', None, _("_Insert"), None, _(""), self.dummy_action),
+ ('AnnotateMenuAction', None, _("_Annotate"), None, _(""), self.dummy_action),
+ ('ContributeMenuAction', None, _("_Contribute"), None, _(""), self.dummy_action),
+ ('HelpMenuAction', None, _("_Help"), None, _(""), self.dummy_action),
+ ('NewAction', gtk.STOCK_NEW, _("_New"), None, _("Create a new document"), self.new_document),
+ ('OpenAction', gtk.STOCK_OPEN, _("_Open"), None, _("Open a document"), self.open_document),
+ ('RecentlyUsedAction', None, _("Open _Recent"), None, _(""), self.dummy_action),
+ ('SaveAction', gtk.STOCK_SAVE, _("_Save"), None, _("Save the current document"), self.save_document),
+ ('SaveAsAction', gtk.STOCK_SAVE_AS, _("Save _As..."), "<Ctrl><Shift>S", _(""), self.save_document_as),
+ ('DocumentPropertiesAction', gtk.STOCK_PROPERTIES, _("Document Properties"), None, _(""), self.dummy_action),
+ ('QuitAction', gtk.STOCK_QUIT, _("_Quit"), None, _(""), self.quit),
+ ('UndoAction', gtk.STOCK_UNDO, _("_Undo"), "<Ctrl>Z", _("Undo the last action"), self.dummy_action),
+ ('RedoAction', gtk.STOCK_REDO, _("_Redo"), "<Ctrl>Y", _("Redo the last undone action"), self.dummy_action),
+ ('CutAction', gtk.STOCK_CUT, _("Cu_t"), None, _("Cut the selection"), self.dummy_action),
+ ('CopyAction', gtk.STOCK_COPY, _("_Copy"), None, _("Copy the selection"), self.dummy_action),
+ ('PasteAction', gtk.STOCK_PASTE, _("_Paste"), None, _("Paste the clipboard"), self.dummy_action),
+ ('PreferencesAction', gtk.STOCK_PREFERENCES, _("_Preferences"), None, _(""), self.show_preferences),
+ ('InsertAction', gtk.STOCK_ADD, _("Insert"), None, _(""), self.dummy_action),
+ ('CitationAction', None, _("_Citation"), None, _(""), self.apply_block_tag),
+ ('MultimediaObjectAction', None, _("_Multimedia Object..."), None, _(""), self.apply_block_tag),
+ ('EditorialCommentAction', None, _("_Editorial Comment"), None, _(""), self.apply_block_tag),
+ ('FigureAction', None, _("_Figure..."), None, _(""), self.apply_block_tag),
+ ('NoteAction', None, _("_Note"), None, _(""), self.apply_block_tag),
+ ('SynopseAction', None, _("_Synopse"), None, _(""), self.apply_block_tag),
+ ('TableAction', None, _("_Table..."), None, _(""), self.apply_block_tag),
+ ('CreatePatchAction', gtk.STOCK_MISSING_IMAGE, _("Create _Patch"), None, _("Create a patch"), self.create_patch),
+ ('CommitAction', gtk.STOCK_MISSING_IMAGE, _("_Commit"), None, _("Commit document changes"), self.commit),
+ ('ReviewAction', gtk.STOCK_MISSING_IMAGE, _("_Review"), None, _("Review the current document"), self.dummy_action),
+ ('ContentsAction', gtk.STOCK_HELP, _("_Contents"), "F1", _(""), self.dummy_action),
+ ('AboutAction', gtk.STOCK_ABOUT, _("_About"), None, _(""), self.about),
+ ('ToggleListAction', gtk.STOCK_MISSING_IMAGE, _("Bullets"), None, _("Toggle bullets on/off"), self.dummy_action),
+ ('ListIndentAction', gtk.STOCK_INDENT, _("Indent"), None, _("Indent list item"), self.dummy_action),
+ ('ListUnindentAction', gtk.STOCK_UNINDENT, _("Unindent"), None, _("Unindent list item"), self.dummy_action)
]
self._annotation_actions = [
- ('CaptionAction', None, _("Caption"), None, _(""), self.apply_block_tag),
- ('CitationAction', None, _("Citation"), None, _(""), self.apply_block_tag),
- ('MultimediaObjectAction', None, _("Multimedia Object"), None, _(""), self.apply_block_tag),
- ('CodeSnippetAction', None, _("Code Snippet"), None, _(""), self.apply_block_tag),
- ('ParagraphAction', None, _("Paragraph"), None, _(""), self.apply_block_tag),
- ('ScreenAction', None, _("Screen"), None, _(""), self.apply_block_tag),
- ('EditorialCommentAction', None, _("Editorial Comment"), None, _(""), self.apply_block_tag),
- ('FigureAction', None, _("Figure"), None, _(""), self.apply_block_tag),
- ('ListAction', None, _("List"), None, _(""), self.apply_block_tag),
- ('NoteAction', None, _("Note"), None, _(""), self.apply_block_tag),
- ('SynopseAction', None, _("Synopse"), None, _(""), self.apply_block_tag),
- ('TableAction', None, _("Table"), None, _(""), self.apply_block_tag),
- ('ApplicationNameAction', gtk.STOCK_EXECUTE, _("Application Name"), None, _(""), self.apply_inline_tag),
- ('CommandAction', None, _("Command"), None, _(""), self.apply_inline_tag),
- ('ComputerOutputAction', None, _("Computer Output"), None, _(""), self.apply_inline_tag),
- ('DateAction', None, _("Date"), None, _(""), self.apply_inline_tag),
- ('EmphasisAction', None, _("_Emphasis"), None, _(""), self.apply_inline_tag),
- ('FileNameAction', None, _("File Name"), None, _(""), self.apply_inline_tag),
- ('GUILabelAction', None, _("GUI Label"), None, _(""), self.apply_inline_tag),
- ('HyperlinkAction', None, _("Hyperlink"), None, _(""), self.apply_inline_tag),
- ('InlineCodeAction', None, _("Inline Code"), None, _(""), self.apply_inline_tag),
- ('KeyStrokeAction', None, _("Key Stroke"), None, _(""), self.apply_inline_tag),
- ('QuoteAction', None, _("Quote"), None, _(""), self.apply_inline_tag),
- ('SystemItemAction', None, _("System Item"), None, _(""), self.apply_inline_tag),
- ('UserInputAction', None, _("User Input"), None, _(""), self.apply_inline_tag),
- ('VariableTextAction', None, _("Variable Text"), None, _(""), self.apply_inline_tag),
+ ('ApplicationNameAction', None, _("A_pplication Name"), None, _(""), self.apply_inline_tag),
+ ('CommandAction', None, _("_Command"), None, _(""), self.apply_inline_tag),
+ ('ComputerOutputAction', None, _("C_omputer Output"), None, _(""), self.apply_inline_tag),
+ ('DateAction', None, _("_Date"), None, _(""), self.apply_inline_tag),
+ ('EmphasisAction', None, _("E_mphasis"), None, _(""), self.apply_inline_tag),
+ ('FileNameAction', None, _("F_ile Name"), None, _(""), self.apply_inline_tag),
+ ('GUILabelAction', None, _("_GUI Label"), None, _(""), self.apply_inline_tag),
+ ('HyperlinkAction', None, _("H_yperlink"), None, _(""), self.apply_inline_tag),
+ ('InlineCodeAction', None, _("I_nline Code"), None, _(""), self.apply_inline_tag),
+ ('KeyStrokeAction', None, _("_Key Stroke"), None, _(""), self.apply_inline_tag),
+ ('QuoteAction', None, _("_Quote"), None, _(""), self.apply_inline_tag),
+ ('SystemItemAction', None, _("_System Item"), None, _(""), self.apply_inline_tag),
+ ('UserInputAction', None, _("_User Input"), None, _(""), self.apply_inline_tag),
+ ('VariableTextAction', None, _("Va_riable Text"), None, _(""), self.apply_inline_tag),
]
+ self._toggle_actions = self._annotation_actions + [
+ ('SidePaneAction', None, _("_Side Pane"), "F9", _(""), self.dummy_action),
+ ]
+
self._actiongroup = gtk.ActionGroup('menubar')
self._actiongroup.add_actions(actions)
- self._actiongroup.add_actions(self._annotation_actions)
+ self._actiongroup.add_toggle_actions(self._toggle_actions)
self._actiongroup.add_action(OpenRecentToolAction("OpenToolAction", _("Open"), _(""), gtk.STOCK_OPEN))
self.uimanager.insert_action_group(self._actiongroup, 0)
@@ -184,7 +186,7 @@
self._menu_recent = self.uimanager.get_widget('/MainMenu/FileMenu/RecentlyUsed')
self._toolbar_main = self.uimanager.get_widget('/MainToolbar')
self._tool_open = self.uimanager.get_widget('/MainToolbar/Open')
- self._toolbar_block = self.uimanager.get_widget('/BlockToolbar')
+ self._toolbar_paragraph = self.uimanager.get_widget('/ParagraphToolbar')
self._toolbar_inline = self.uimanager.get_widget('/InlineToolbar')
# Initialize Recently Used submenus
@@ -202,28 +204,59 @@
self._tool_open.connect('clicked', self._open_toolbar)
# Toolbar properties
- self._toolbar_block.set_orientation(gtk.ORIENTATION_VERTICAL)
- self._toolbar_block.set_style(gtk.TOOLBAR_BOTH_HORIZ)
- self._toolbar_block.set_border_width(3)
+ self._toolbar_paragraph.set_style(gtk.TOOLBAR_ICONS)
+ self._toolbar_paragraph.set_property("icon-size", gtk.ICON_SIZE_SMALL_TOOLBAR)
self._toolbar_inline.set_orientation(gtk.ORIENTATION_VERTICAL)
self._toolbar_inline.set_style(gtk.TOOLBAR_BOTH_HORIZ)
self._toolbar_inline.set_border_width(3)
- # Iterate through the ToolItems and set the label alignment accordingly
- num = self._toolbar_block.get_n_items()
- for i in range(num):
- item = self._toolbar_block.get_nth_item(i)
- item.set_use_underline(True)
- try:
- l = gtk.Label(item.get_label())
- l.set_alignment(0.0, 0.5)
- l.set_padding(3, 0)
- l.set_use_underline(True)
- l.show()
- item.set_label_widget(l)
- except AttributeError:
- pass
+ # Set up paragraph style combo
+ self._paragraph_style_combo = gtk.ComboBox()
+ parastyle_renderer = gtk.CellRendererText()
+ self._paragraph_style_combo.pack_start(parastyle_renderer)
+ self._paragraph_style_combo.add_attribute(parastyle_renderer, "text", 0)
+ parastyle_model = gtk.ListStore(str, str)
+ it = parastyle_model.append()
+ parastyle_model.set(it, 0, _("Normal"), 1, "p")
+ it = parastyle_model.append()
+ parastyle_model.set(it, 0, _("Code Snippet"), 1, "code")
+ it = parastyle_model.append()
+ parastyle_model.set(it, 0, _("Screen Output"), 1, "screen")
+ self._paragraph_style_combo.set_model(parastyle_model)
+ self._paragraph_style_combo.connect("changed", self._paragraph_style_changed)
+ parastyle_hbox = gtk.HBox(spacing=9)
+ parastyle_hbox.set_border_width(3)
+ parastyle_label = gtk.Label(_("Paragraph style:"))
+ parastyle_label.set_mnemonic_widget(self._paragraph_style_combo)
+ parastyle_hbox.pack_start(parastyle_label)
+ parastyle_hbox.pack_start(self._paragraph_style_combo)
+ parastyle_item = gtk.ToolItem()
+ parastyle_item.add(parastyle_hbox)
+ self._toolbar_paragraph.insert(parastyle_item, 0)
+ self._toolbar_paragraph.insert(gtk.SeparatorToolItem(), 1)
+
+ # Set up hierarchy toolbar
+ self._toolbar_hierarchy = gtk.Toolbar()
+ hierarchy_label = gtk.Label(_("Hierarchy:"))
+ hierarchy_label_item = gtk.ToolItem()
+ hierarchy_label_item.set_border_width(3)
+ hierarchy_label_item.add(hierarchy_label)
+ self._toolbar_hierarchy.add(hierarchy_label_item)
+ self._document_button = gtk.RadioButton(label="Document")
+ self._document_button.set_mode(False)
+ document_button_item = gtk.ToolItem()
+ document_button_item.set_border_width(3)
+ document_button_item.set_border_width(3)
+ document_button_item.add(self._document_button)
+ self._toolbar_hierarchy.add(document_button_item)
+
+ # Set up title for annotations toolbar
+ inline_label = gtk.Label(_("Annotations"))
+ inline_label.set_alignment(0.0, 0.5)
+ inline_label.set_padding(3, 6)
+ inline_label.set_use_markup(True)
+ # Iterate through the ToolItems and set the label alignment accordingly
num = self._toolbar_inline.get_n_items()
for i in range(num):
item = self._toolbar_inline.get_nth_item(i)
@@ -240,8 +273,12 @@
# Pack menus and toolbars into the appropriate places
self._vbox.pack_start(self._menubar, False, False)
self._vbox.pack_start(self._toolbar_main, False, False)
+ self._vbox.pack_start(self._toolbar_paragraph, False, False)
+ self._vbox.pack_start(self._toolbar_hierarchy, False, False)
self._vbox.reorder_child(self._menubar, 0)
self._vbox.reorder_child(self._toolbar_main, 1)
+ self._vbox.reorder_child(self._toolbar_paragraph, 2)
+ self._vbox.reorder_child(self._toolbar_hierarchy, 4)
# Try to open default document (if n/a, just load a blank one)
if filename is not None and os.path.exists(filename):
@@ -251,14 +288,22 @@
self._app.set_document(self._document)
self._document.get_buffer().connect("notify::cursor-position", self._cursor_position_changed)
- # Set up a notebook
- self._notebook_toolbox = gtk.Notebook()
- self._notebook_toolbox.append_page(self._toolbar_block, gtk.Label(_("Block")))
- self._notebook_toolbox.append_page(self._toolbar_inline, gtk.Label(_("Inline")))
+ hhbox = gtk.HBox()
+ hhbox.pack_start(inline_label, True, True)
+ close_button = gtk.Button("")
+ close_button.set_image(gtk.image_new_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_MENU))
+ close_button.set_relief(gtk.RELIEF_NONE)
+ hhbox.pack_start(close_button, False, False)
+ vvbox = gtk.VBox()
+ vvbox.pack_start(hhbox, False, False)
+ vport = gtk.Viewport()
+ vport.set_shadow_type(gtk.SHADOW_IN)
+ vport.add(self._toolbar_inline)
+ vvbox.pack_start(vport, True, True)
# Add the document and the notebook to the window
- self._hpaned.add1(self._document)
- self._hpaned.add2(self._notebook_toolbox)
+ self._hpaned.pack1(self._document, True, True)
+ self._hpaned.pack2(vvbox, False, False)
# To be able to show the star on changes
self._document.get_buffer().connect('changed', self._buffer_changed)
@@ -294,15 +339,30 @@
"""
tags = buf.get_tags_at_selected_range()
- #self._auto_toggled = True
+ self._auto_toggled = True
for action_tuple in self._annotation_actions:
name = action_tuple[0]
tag = ACTION_TO_TAG[name]
- #self._actiongroup.get_action(name).set_active(tag in tags)
+ self._actiongroup.get_action(name).set_active(tag in tags)
+
+ parastyle_dict = {
+ "title": -1,
+ "p": 0,
+ "code": 1,
+ "screen": 2
+ }
+
+ for t in tags:
+ active = parastyle_dict.get(t, -2)
+
+ if active != -2:
+ self._paragraph_style_combo.set_active(active)
+
+ self._toolbar_paragraph.set_sensitive(self._paragraph_style_combo.get_active() != -1)
- #self._auto_toggled = False
+ self._auto_toggled = False
def _open_toolbar(self, widget):
@@ -341,6 +401,15 @@
self._app.recent_manager.add_full(uri, self._app.recent_data)
+ def _paragraph_style_changed(self, widget):
+ """
+ Apply block tag according to the chosen paragraph style.
+ """
+ if not self._auto_toggled:
+ tag = widget.get_model().get(widget.get_active_iter(), 1)[0]
+ self._document._buffer.apply_block_tag(tag)
+
+
def about(self, action):
"""
About action handler.
@@ -677,7 +746,6 @@
tag = ACTION_TO_TAG[action.get_name()]
self._document._buffer.apply_block_tag(tag)
-
def apply_inline_tag(self, action):
@@ -687,9 +755,9 @@
if not self._auto_toggled:
tag = ACTION_TO_TAG[action.get_name()]
- #if action.get_active():
- self._document._buffer.apply_inline_tag(tag)
- #else:
- #self._document._buffer.remove_inline_tag(tag)
+ if action.get_active():
+ self._document._buffer.apply_inline_tag(tag)
+ else:
+ self._document._buffer.remove_inline_tag(tag)
self._document.get_view().grab_focus()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]