[Xfce4-commits] r26441 - in mousepad/branches/nick_0_3: . mousepad po
Nick Schermer
nick at xfce.org
Thu Dec 6 21:11:21 CET 2007
Author: nick
Date: 2007-12-06 20:11:21 +0000 (Thu, 06 Dec 2007)
New Revision: 26441
Modified:
mousepad/branches/nick_0_3/ChangeLog
mousepad/branches/nick_0_3/mousepad/main.c
mousepad/branches/nick_0_3/mousepad/mousepad-application.c
mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c
mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.h
mousepad/branches/nick_0_3/mousepad/mousepad-document.c
mousepad/branches/nick_0_3/mousepad/mousepad-document.h
mousepad/branches/nick_0_3/mousepad/mousepad-encoding-dialog.c
mousepad/branches/nick_0_3/mousepad/mousepad-file.c
mousepad/branches/nick_0_3/mousepad/mousepad-file.h
mousepad/branches/nick_0_3/mousepad/mousepad-private.h
mousepad/branches/nick_0_3/mousepad/mousepad-search-bar.c
mousepad/branches/nick_0_3/mousepad/mousepad-util.c
mousepad/branches/nick_0_3/mousepad/mousepad-util.h
mousepad/branches/nick_0_3/mousepad/mousepad-view.c
mousepad/branches/nick_0_3/mousepad/mousepad-view.h
mousepad/branches/nick_0_3/mousepad/mousepad-window-ui.xml
mousepad/branches/nick_0_3/mousepad/mousepad-window.c
mousepad/branches/nick_0_3/po/mousepad.pot
Log:
* mousepad/mousepad-document.c: Fix column number in statusbar.
First column is 0 and not 1.
* mousepad/mousepad-dialogs.c: Improve the go to dialog. You can now
set the column number too.
* mousepad/mousepad-window{.c,-ui.xml}: Improve the menu layout big
time. Make mnemonics consistent right now. A couple of name,
tooltip and keybindings changes. Internal names make more sense
now.
* mousepad/mousepad-{window,view}.c Add option to paste from
history. The history holds the last 9 history cut/copied items
from Mousepad.
* mousepad/mousepad-window.c: New from template menu. Works the
same as the implementation in Thunar. Menu is generated the first
time the file menu is shown. Same for the recent menu.
* mousepad/mousepad-{window,view}.c: Add option to toggle between
column and normal selections. Put it in View -> Change to Column
Selection. To make this work properly I've removed multi
selection. Code got much easier and a couple of complex functions
were dropped.
* mousepad/mousepad-window{.c,-ui.xml}: Put search menu items in
the edit menu, since you will most likely access them from
keybindings most of the time.
* mousepad/mousepad-window.c: Cleanuped up a lot of functions.
* mousepad/mousepad-window.c: Check if files exists when generating
the recent menu, remove it when it was not found. Also unref the
action after adding it to the action group, fixes an ugly memory
leak, since the recent info isn't released eighter.
* mousepad/mousepad-util.c: Add faster function to escape
underscores in the recent menu. Drop the previous function used
for this.
* mousepad/mousepad-private.h: Add macros around g_object_(get/set)
_qdata and use them instead of the existing g_object_(get/set)
_data functions.
* mousepad/mousepad-view.c: Fix indent with (shift) tab.
* mousepad/mousepad-view.c: Improve line number drawing. Only
redraw the line numbers in the expose area and some other changes
to reduce the amount of redraws and iter calls.
* mousepad/mousepad-view.c: Use the IM to type in multi selections,
the previous way was deprecated and this fixes a couple of weird
issues.
* mousepad/mousepad-view.c: Show realtime selection size in column
selections.
* mousepad/mousepad-{document,view,window}.c: Put selection change
in a separate signal to avoid multiple update the the action
group.
* mousepad/mousepad-view.c: Avoid a lot of statusbar updates and
column selection redraws during dragging by comparing the old and
new cursor position. On the other hand, the 'only draw the visible
area during drag' trick has been partly removed to properly
display the selection length during a column draw that covers
more then the window height.
* mousepad/mousepad-{util,view}.c: Add functions to change the case
of a selection.
* mousepad/mousepad-view.c: Add function to replace tabs with spaces
and vice versa. The replacements are inlined, so you don't see
visual changes in the document. Actions are not usable during
column selections.
* mousepad/mousepad-window.c: Make the arrow buttons in the notebook
work.
* mousepad/mousepad-window.c: Close document on middle click on the
tab, this is a stupid feature, but since everyone requests it on
apps with tabs: add it to save a bugzilla report.
* mousepad/mousepad-{window,view}.c: Add actions to increase or
decrease the indentation of line(s) using the menu or keybindings.
* mousepad/mousepad-{window,view}.c: Add an action to duplicate a
line or selection. Only work for normal selections or no
selection.
* mousepad/mousepad-{window,view}.c: Add an action to move the
selected lines up and down. Not implemented for column selections
(yet). Menu actions are insensitive when there is no regual
selection.
* mousepad/mousepad-{window,view}.c: Add option to strip trailing
spaces and tabs.
* mousepad/mousepad-window.c: Add a file to the recent history
after saving it under another name.
* mousepad/mousepad-window{.c,-ui.xml}: Add line ending type in the
document menu.
* mousepad/mousepad-window.c: Avoid one menu update when adding or
removing a new document to the window.
* mousepad/mousepad-document.c: Change tab label color when the
document is modified or readonly.
* ChangeLog: Properly break lines.
Modified: mousepad/branches/nick_0_3/ChangeLog
===================================================================
--- mousepad/branches/nick_0_3/ChangeLog 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/ChangeLog 2007-12-06 20:11:21 UTC (rev 26441)
@@ -1,113 +1,222 @@
+2007-xx-xx Nick Schermer <nick at xfce.org>
+
+ * mousepad/mousepad-document.c: Fix column number in statusbar.
+ First column is 0 and not 1.
+ * mousepad/mousepad-dialogs.c: Improve the go to dialog. You can now
+ set the column number too.
+ * mousepad/mousepad-window{.c,-ui.xml}: Improve the menu layout big
+ time. Make mnemonics consistent right now. A couple of name,
+ tooltip and keybindings changes. Internal names make more sense
+ now.
+ * mousepad/mousepad-{window,view}.c Add option to paste from
+ history. The history holds the last 9 history cut/copied items
+ from Mousepad.
+ * mousepad/mousepad-window.c: New from template menu. Works the
+ same as the implementation in Thunar. Menu is generated the first
+ time the file menu is shown. Same for the recent menu.
+ * mousepad/mousepad-{window,view}.c: Add option to toggle between
+ column and normal selections. Put it in View -> Change to Column
+ Selection. To make this work properly I've removed multi
+ selection. Code got much easier and a couple of complex functions
+ were dropped.
+ * mousepad/mousepad-window{.c,-ui.xml}: Put search menu items in
+ the edit menu, since you will most likely access them from
+ keybindings most of the time.
+ * mousepad/mousepad-window.c: Cleanuped up a lot of functions.
+ * mousepad/mousepad-window.c: Check if files exists when generating
+ the recent menu, remove it when it was not found. Also unref the
+ action after adding it to the action group, fixes an ugly memory
+ leak, since the recent info isn't released eighter.
+ * mousepad/mousepad-util.c: Add faster function to escape
+ underscores in the recent menu. Drop the previous function used
+ for this.
+ * mousepad/mousepad-private.h: Add macros around g_object_(get/set)
+ _qdata and use them instead of the existing g_object_(get/set)
+ _data functions.
+ * mousepad/mousepad-view.c: Fix indent with (shift) tab.
+ * mousepad/mousepad-view.c: Improve line number drawing. Only
+ redraw the line numbers in the expose area and some other changes
+ to reduce the amount of redraws and iter calls.
+ * mousepad/mousepad-view.c: Use the IM to type in multi selections,
+ the previous way was deprecated and this fixes a couple of weird
+ issues.
+ * mousepad/mousepad-view.c: Show realtime selection size in column
+ selections.
+ * mousepad/mousepad-{document,view,window}.c: Put selection change
+ in a separate signal to avoid multiple update the the action
+ group.
+ * mousepad/mousepad-view.c: Avoid a lot of statusbar updates and
+ column selection redraws during dragging by comparing the old and
+ new cursor position. On the other hand, the 'only draw the visible
+ area during drag' trick has been partly removed to properly
+ display the selection length during a column draw that covers
+ more then the window height.
+ * mousepad/mousepad-{util,view}.c: Add functions to change the case
+ of a selection.
+ * mousepad/mousepad-view.c: Add function to replace tabs with spaces
+ and vice versa. The replacements are inlined, so you don't see
+ visual changes in the document. Actions are not usable during
+ column selections.
+ * mousepad/mousepad-window.c: Make the arrow buttons in the notebook
+ work.
+ * mousepad/mousepad-window.c: Close document on middle click on the
+ tab, this is a stupid feature, but since everyone requests it on
+ apps with tabs: add it to save a bugzilla report.
+ * mousepad/mousepad-{window,view}.c: Add actions to increase or
+ decrease the indentation of line(s) using the menu or keybindings.
+ * mousepad/mousepad-{window,view}.c: Add an action to duplicate a
+ line or selection. Only work for normal selections or no
+ selection.
+ * mousepad/mousepad-{window,view}.c: Add an action to move the
+ selected lines up and down. Not implemented for column selections
+ (yet). Menu actions are insensitive when there is no regual
+ selection.
+ * mousepad/mousepad-{window,view}.c: Add option to strip trailing
+ spaces and tabs.
+ * mousepad/mousepad-window.c: Add a file to the recent history
+ after saving it under another name.
+ * mousepad/mousepad-window{.c,-ui.xml}: Add line ending type in the
+ document menu.
+ * mousepad/mousepad-window.c: Avoid one menu update when adding or
+ removing a new document to the window.
+ * mousepad/mousepad-document.c: Change tab label color when the
+ document is modified or readonly.
+ * ChangeLog: Properly break lines.
+
+
2007-11-29 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-document.c: Make tab close button a bit smaller.
2007-11-29 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-window.c: Use a box for packing the window elements.
- A table was not really needed, and boxes are a bit faster in calculating
- child sizes.
+
+ * mousepad/mousepad-window.c: Use a box for packing the window
+ elements. A table was not really needed, and boxes are a bit
+ faster in calculating child sizes.
* mousepad/mousepad-window.c: Remove unused variable.
2007-11-29 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-print.c: Use bold attribute for labels, so there
- is no html in the strings.
+ * mousepad/mousepad-print.c: Use bold attribute for labels, so
+ there is no html in the strings.
+
2007-11-29 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-utils.c: Add functions that extent the default
Gtk word start/end function. Use them in the search functions,
transpose and double click selection.
- * mousepad/mousepad-view.c: Implement transpose for multi selections.
+ * mousepad/mousepad-view.c: Implement transpose for multi
+ selections.
* mousepad/mousepad-view.c: Improve word swap function.
- * docs/manual/C/Mousepad.xml.in: Other layout of the help file. Content
- will follow.
- * mousepad/mousepad-{document,window,view}.c: Show the selection length
- in the statusbar. Also merged two signals and a couple of functions.
- * mousepad/mousepad-window.c: Change default keybinding of new document
- (Ctrl+N) and new window (Shift+Ctrl+N). Assign Ctrl+T to transpose.
- * mousepad/mousepad-window.c: Update the window title after saving a
- file with a new name.
- * mousepad/mousepad-file.c: Set readonly to FALSE when starting with
- a non-existing filename in the argument.
+ * docs/manual/C/Mousepad.xml.in: Other layout of the help file.
+ Content will follow.
+ * mousepad/mousepad-{document,window,view}.c: Show the selection
+ length in the statusbar. Also merged two signals and a couple of
+ functions.
+ * mousepad/mousepad-window.c: Change default keybinding of new
+ document (Ctrl+N) and new window (Shift+Ctrl+N). Assign Ctrl+T to
+ transpose.
+ * mousepad/mousepad-window.c: Update the window title after saving
+ a file with a new name.
+ * mousepad/mousepad-file.c: Set readonly to FALSE when starting
+ with a non-existing filename in the argument.
* mousepad/mousepad-print.c: Improve the print backend. Settings are
now saved. You can set the paper type, toggle options for line
numbers, wrap and page heading and use a custom font.
2007-10-26 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-view.c: Implement transpose:
- - Selection on one line: Inverse selected text.
- - Multiple lines selected: Invert seleted lines.
- - Cursor is inside a word: Swap chars on each side of the cursor.
- - Cursor is outside a word: Swap word left and right of the cursor.
- - Cursor at the start of a line: Swap line with the line above.
- - Cursor at the end of a line: Swap line with the line below.
- Will add support for multi- and column-selections later. Thanks to
- Textmate for this great idea.
+ * mousepad/mousepad-view.c: Implement transpose: - Selection on one
+ line: Inverse selected text.
+ - Multiple lines selected: Invert seleted lines.
+ - Cursor is inside a word: Swap chars on each side of the cursor.
+ - Cursor is outside a word: Swap word left and right of the
+ cursor.
+ - Cursor at the start of a line: Swap line with the line above.
+ - Cursor at the end of a line: Swap line with the line below.
+ Will add support for multi- and column-selections later. Thanks to
+ Textmate for this great idea.
+
2007-10-26 Nick Schermer <nick at xfce.org>
- * MousepadHelp.in, mousepad/mousepad-{dialogs,window}.{c,h}:
- Add support for the help file.
+
+ * MousepadHelp.in, mousepad/mousepad-{dialogs,window}.{c,h}: Add
+ support for the help file.
* Mousepad.spec.in: Add spec file.
2007-10-25 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-view.c: Redraw selection on theme change.
2007-10-25 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-view.c: Reimplemented multi-selection. It is also
- possible to do multi editing (typing in all the selections), select
- random words in the document (they will be copied to the clipboard as
- a list of words) and multi insert (create a drag without content or
- drag at the end of lines). Multiple selection will also be merged
- when possible. This proably has some rough edges, but it works pretty
- good. Keyboard multi drags will be added later.
- * docs/manual/C/Mousepad.xml.in: Add a bit of info about multiple- and
- column-selections, but I'm not very good at this.
- * mousepad/mousepad-{window.c,window-ui.xml}: Use our edit menu on right
- click, so copy/paste/delete works with multi selections. Also saves a
- bit of code since it integrates with the ui-manager.
+ * mousepad/mousepad-view.c: Reimplemented multi-selection. It is
+ also possible to do multi editing (typing in all the selections),
+ select random words in the document (they will be copied to the
+ clipboard as a list of words) and multi insert (create a drag
+ without content or drag at the end of lines). Multiple selection
+ will also be merged when possible. This proably has some rough
+ edges, but it works pretty good. Keyboard multi drags will be
+ added later.
+ * docs/manual/C/Mousepad.xml.in: Add a bit of info about multiple-
+ and column-selections, but I'm not very good at this.
+ * mousepad/mousepad-{window.c,window-ui.xml}: Use our edit menu on
+ right click, so copy/paste/delete works with multi selections.
+ Also saves a bit of code since it integrates with the ui-manager.
+
2007-10-23 Nick Schermer <nick at xfce.org>
+
* configure.in.in, po/POTFILES.in: Fix dist-check. Thank to Brian
for the hint.
- * mousepad/mousepad-{dialogs,window}.c: Implement tab size menu. You
- can set the default tab sizes in the rc file (MiscDefaultTabSizes).
- * mousepad/mousepad-window{-ui.xml,.c}: Reorder menus a bit. Go menu
- is now called 'Navigation' and the 'go to line' item is added to this
- menu. The document menu contains the tab size menu from now on.
+ * mousepad/mousepad-{dialogs,window}.c: Implement tab size menu.
+ You can set the default tab sizes in the rc file
+ (MiscDefaultTabSizes).
+ * mousepad/mousepad-window{-ui.xml,.c}: Reorder menus a bit. Go
+ menu is now called 'Navigation' and the 'go to line' item is
+ added to this menu. The document menu contains the tab size menu
+ from now on.
* Rename some functions and vars to more suitable names.
2007-10-22 Nick Schermer <nick at xfce.org>
- * configure.in.in: Make sure __OPTIMIZE__ is enabled in normal builds.
- * mousepad/mousepad-private.h: Tune G_LIKELY macros for pure booleans.
+ * configure.in.in: Make sure __OPTIMIZE__ is enabled in normal
+ builds.
+ * mousepad/mousepad-private.h: Tune G_LIKELY macros for pure
+ booleans.
+
2007-10-22 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-window.c: Idea of the previous commit was good,
but the implementation wasn't. Fix that.
2007-10-21 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-window.c: Make the recent manager a singleton
in the application, this is also done in gtk 2.12. We also
initialize the recent manager when needed, since it's quite
- expensive to create one. This should improve the startup speed
- a bit.
+ expensive to create one. This should improve the startup speed a
+ bit.
2007-10-21 Nick Schermer <nick at xfce.org>
+
* docs/: Import basic manual files.
* configure.in.in, mousepad/Makefile.am: Don't search for startup-
notification and gtk-unix-print. We don't use this in the code.
2007-10-18 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-view.c: Respect input methods and don't insert
text when the textview is not editable.
* mousepad/mousepad-{file,document,window}.c: Properly handle
@@ -116,6 +225,7 @@
2007-10-18 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-utils.{c,h}: Add iter function to move the iter
in front of text. Code used from one of the indentation functions.
* mousepad/mousepad-view.c: Add code for a smart home button: when
@@ -126,31 +236,34 @@
2007-10-17 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-window.c: Cleanup some code and get rid of the
multiple action groups.
2007-10-17 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-window.c: Decrease the menu lock when a window
- is closed and disconnect the recent manager handler (this is a
- bug since 2.12 because the manager is a floating object).
+ is closed and disconnect the recent manager handler (this is a bug
+ since 2.12 because the manager is a floating object).
2007-10-17 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-{window,util}.c: Fix compiler warnings.
2007-10-16 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-dialogs.c: Set the correct default return
- in the jump dialog.
+
+ * mousepad/mousepad-dialogs.c: Set the correct default return in
+ the jump dialog.
* mousepad/mousepad-replace-{dialog,window,preferences}.{c,h}:
Implement the new replace dialog.
- * Remove options from the type-ahead bar, it was too bloated
- and those options are now available in the replace dialog.
- * mousepad/mousepad-document.c: The MousepadDocument now holds
- utf-8 valid names, the MousepadFile the real filename.
- * mousepad/mousepad-window.c: Full tab dnd (detach) with
- Gtk+ 2.12.
+ * Remove options from the type-ahead bar, it was too bloated and
+ those options are now available in the replace dialog.
+ * mousepad/mousepad-document.c: The MousepadDocument now holds utf-8
+ valid names, the MousepadFile the real filename.
+ * mousepad/mousepad-window.c: Full tab dnd (detach) with Gtk+ 2.12.
* mousepad/mousepad-encoding-dialog.{c,h}: Add a encoding dialog.
This dialog should help users to find the right encoding for a
document.
@@ -177,288 +290,299 @@
remember after 5 months ;).
-2007-05-22 Nick Schermer <nick at xfce.org
+2007-05-22 Nick Schermer <nick at xfce.org>
+
* *.*: Remove copyright lines.
2007-05-20 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-{preferences,search-bar,document}.c,
- mousepad/mousepad-types.h: Add match whole word option.
+ * mousepad/mousepad-{preferences,search-bar,document}.c, mousepad/
+ mousepad-types.h: Add match whole word option.
+
2007-05-20 Nick Schermer <nick at xfce.org>
- * mousepad/Makefile.am: Use the new exo-csource
- --strip-comments and --strip-content arguments.
+ * mousepad/Makefile.am: Use the new exo-csource --strip-comments
+ and --strip-content arguments.
+
2007-05-20 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-view.c: Initialize variables, so gcc is
- happy.
+
+ * mousepad/mousepad-view.c: Initialize variables, so gcc is happy.
* README: Add some lines.
- * mousepad/mousepad-window.c: Ctrl + Shift + v is the shortcut
- to paste in a column.
+ * mousepad/mousepad-window.c: Ctrl + Shift + v is the shortcut to
+ paste in a column.
2007-05-17 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-view.c: Cleanup the line number code.
- This version is a bit faster and removed a bunch of code.
- * mousepad/mousepad-view.c: Cleanup the indentation code. You
- can also increase the (vertical) selected text with Shift +
- Space and decrease with Shift + Backspace. I though this
- might be useful for developers.
- * mousepad/mousepad-view.c: Vertical selection using the mouse
- and Ctrl + Shift. Keyboard vertical selection is not possible
- because that adds too much code for (hardly) nothing. You can
- (un-)indent the block with Tab, Shift + Tab and the 2 new
- space (in/de)crease commands above.
- * mousepad/mousepad-view.c: Draw a vertical line to separate
- the line numbers from the text, this looks beter with light
- themes (IMHO).
- * mousepad/mousepad-window.c: Add 'paste column' option to
- paste the clipboard text in a column under the cursor.
- * mousepad/mousepad-window.c: Set stock menu names to NULL so
- Gtk fills the default (translated) name, makes your binary
- smaller and translators happy.
- * mousepad/mousepad-{search-bar,document}.c: Fix segfault with
- empty string in the search bar and highlighting enabled.
+
+ * mousepad/mousepad-view.c: Cleanup the line number code. This
+ version is a bit faster and removed a bunch of code.
+ * mousepad/mousepad-view.c: Cleanup the indentation code. You can
+ also increase the (vertical) selected text with Shift + Space and
+ decrease with Shift + Backspace. I though this might be useful for
+ developers.
+ * mousepad/mousepad-view.c: Vertical selection using the mouse and
+ Ctrl + Shift. Keyboard vertical selection is not possible because
+ that adds too much code for (hardly) nothing. You can (un-)indent
+ the block with Tab, Shift + Tab and the 2 new space (in/de)crease
+ commands above.
+ * mousepad/mousepad-view.c: Draw a vertical line to separate the
+ line numbers from the text, this looks beter with light themes.
+ * mousepad/mousepad-window.c: Add 'paste column' option to paste
+ the clipboard text in a column under the cursor.
+ * mousepad/mousepad-window.c: Set stock menu names to NULL so Gtk
+ fills the default (translated) name, makes your binary smaller
+ and translators happy.
+ * mousepad/mousepad-{search-bar,document}.c: Fix segfault with empty
+ string in the search bar and highlighting enabled.
* TODO: Add items.
2007-05-12 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-window.c: Add extra tests if the file
- really exists, because Gtk file dialogs hang if the
- file does not exists.
+ * mousepad/mousepad-window.c: Add extra tests if the file really
+ exists, because Gtk file dialogs hang if the file does not exists.
+
2007-05-12 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-window.c: Jump to active file when
- opening a new document.
+ * mousepad/mousepad-window.c: Jump to active file when opening a new
+ document.
+
2007-05-10 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-undo.c: Don't store a string (or even
- prepend it in a GString) when the user is inserting text.
- This saves a whole bunch of relocations (Bug #2737). We also
- flush the insert buffer after a redo and don't copy strings
- when inverting a delete step. This should bring the memory
- usage of the undo manager to a minimum.
+
+ * mousepad/mousepad-undo.c: Don't store a string (or even prepend it
+ in a GString) when the user is inserting text. This saves a whole
+ bunch of relocations (Bug #2737). We also flush the insert buffer
+ after a redo and don't copy strings when inverting a delete step.
+ This should bring the memory usage of the undo manager to a
+ minimum.
* TODO: Add some undo manager reminders.
- * mousepad/mousepad-window.c: Fix compiler warning when
- debugging is enabled.
- * mousepad/mousepad-application.c: Change from append to
- prepend.
+ * mousepad/mousepad-window.c: Fix compiler warning when debugging is
+ enabled.
+ * mousepad/mousepad-application.c: Change from append to prepend.
2007-05-08 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-window.c: Rename function so it matches
- the standard mousepad_window_* names.
+ * mousepad/mousepad-window.c: Rename function so it matches the
+ standard mousepad_window_* names.
+
2007-05-08 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-window.c: Open a new tab when the notebook
- is double clicked. Also fix some indentation.
+ * mousepad/mousepad-window.c: Open a new tab when the notebook is
+ double clicked. Also fix some indentation.
+
2007-05-01 Nick Schermer <nick at xfce.org>
+
* configure.in.in: Don't break on a broken glibc.
2007-05-01 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-dbus-infos.xml, mousepad/mousepad-undo.c,
mousepad/mousepad-view.c: Fix some typos and replace tabs.
2007-05-01 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-{document,window}.c: Allow uri and tab
- drops inside the textview widget.
- * mousepad/mousepad-window.c: Hide the searchbar when all the
- tabs are closed and make sure nothing segfaults when no
- active document is found.
- * mousepad/mousepad-window.c: Make sure the textview is
- focused when a new document has been added.
+ * mousepad/mousepad-{document,window}.c: Allow uri and tab drops
+ inside the textview widget.
+ * mousepad/mousepad-window.c: Hide the searchbar when all the tabs
+ are closed and make sure nothing segfaults when no active document
+ is found.
+ * mousepad/mousepad-window.c: Make sure the textview is focused when
+ a new document has been added.
+
2007-04-28 Nick Schermer <nick at xfce.org>
+
* TODO: Removed the items I've fixed.
* Changelog: Break after 70 characters.
- * mousepad/mousepad-{document,statusbar}.c: Hide the visible
- event box window.
- * mousepad/mousepad-statusbar: The statusbar is now on top of
- the Gtk statusbar.
- * mousepad/mousepad-window.c: Add support for dropping uris
- in the main window. Droping in the textview doesn't work
- yet.
+ * mousepad/mousepad-{document,statusbar}.c: Hide the visible event
+ box window.
+ * mousepad/mousepad-statusbar: The statusbar is now on top of the
+ Gtk statusbar.
+ * mousepad/mousepad-window.c: Add support for dropping uris in the
+ main window. Droping in the textview doesn't work yet.
* mousepad/mousepad-window.c: Add tab dnd. This required some
- function reordering, but in the end it was quite easy and
- made the code more logical. I've also changed the window
- behaviour: when you close all the tabs in a window, an empty
- window is left. This is easier for tab dnd.
+ function reordering, but in the end it was quite easy and made the
+ code more logical. I've also changed the window behaviour: when
+ you close all the tabs in a window, an empty window is left. This
+ is easier for tab dnd.
* mousepad/mousepad-{application,window}.c: Beter handing of
application windows. Also added detachable tabs.
- * mousepad/mousepad-{properties,window}.c: The last settings
- of line numbers and auto indent are now stored.
- * mousepad/mousepad-window.c: Beter locking of menu updates,
- this avoids some unneeded menu updates and also made the
- start time of Mousepad equal to Leafpad (and probably also
- Mosuepad 0.2.x), which is quite nice since it supports a
- whole bunch of extra features.
- * mousepad/mousepad-window.c: Removed the 'close all windows'
- option from the menu and the code. Not need for a text
- editor IMHO.
+ * mousepad/mousepad-{properties,window}.c: The last settings of line
+ numbers and auto indent are now stored.
+ * mousepad/mousepad-window.c: Beter locking of menu updates, this
+ avoids some unneeded menu updates and also made the start time of
+ Mousepad equal to Leafpad (and probably also Mosuepad 0.2.x),
+ which is quite nice since it supports a whole bunch of extra
+ features.
+ * mousepad/mousepad-window.c: Removed the 'close all windows' option
+ from the menu and the code. Not need for a text editor IMHO.
2007-04-21 Nick Schermer <nick at xfce.org>
+
* TODO: Fix some typos and add some new ideas and reminders.
2007-04-20 Nick Schermer <nick at xfce.org>
+
* TODO: Add some stuff.
2007-04-20 Nick Schermer <nick at xfce.org>
+
* TODO, NEWS: Update and expand both documents.
2007-04-19 Erik Harrison <erikharrison at xfce.org>
+
* mousepad/mousepad-search-bar.c, mousepad-window.c: Fix some
compiler warnings.
2007-04-12 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-undo.c: Improve the behavior of the undo
- manager. It now merges multiple spaces, new lines are a
- separate undo action and when you redo some steps and then
- start editing again we append the redo-ed steps in reversed
- order with an inverted action, so you can undo every thing
- afterwards. This consumes a bit more memory compared to the
- old behavior (which simply removed every redo-ed step), but
- it's much more consistent.
+ manager. It now merges multiple spaces, new lines are a separate
+ undo action and when you redo some steps and then start editing
+ again we append the redo-ed steps in reversed order with an
+ inverted action, so you can undo every thing afterwards. This
+ consumes a bit more memory compared to the old behavior (which
+ simply removed every redo-ed step), but it's much more consistent.
2007-04-11 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-{window,view}.c: Fix some potential leaks,
- I'm not really sure, but it doesn't hurt...
+ * mousepad/mousepad-{window,view}.c: Fix some potential leaks, I'm
+ not really sure, but it doesn't hurt...
+
2007-04-11 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-statusbar.c: Destroy the tool items
- together with the searchbar (memory leak from valgrind).
+ * mousepad/mousepad-statusbar.c: Destroy the tool items together
+ with the searchbar (memory leak from valgrind).
+
2007-04-11 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-{document,window,statusbar}: You can now
- click the OVR text in the statusbar to toggle the overwrite
- mode.
- * mousepad/mousepad-{document,window,undo}: Initial version
- of an undo manager. Not finished yet.
- * mousepad/Makefile.am, mousepad/mousepad-csource.pl: Remove
- my perl script because it has some problems.
+
+ * mousepad/mousepad-{document,window,statusbar}: You can now click
+ the OVR text in the statusbar to toggle the overwrite mode.
+ * mousepad/mousepad-{document,window,undo}: Initial version of an
+ undo manager. Not finished yet.
+ * mousepad/Makefile.am, mousepad/mousepad-csource.pl: Remove my perl
+ script because it has some problems.
* Remove some empty object functions.
2007-04-06 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-document.c: Fix segfault from previous
- commit.
- * mousepad/mousepad-document.c: Fix bug in searching
- backwards, we have to jump one iter backwards before
- searching, because we start with the character right from
- the first iter. Also removed the equal check because it's
- not needed and only causing problems with backwards
- searching on the first character in the buffer.
+ * mousepad/mousepad-document.c: Fix segfault from previous commit.
+ * mousepad/mousepad-document.c: Fix bug in searching backwards, we
+ have to jump one iter backwards before searching, because we start
+ with the character right from the first iter. Also removed the
+ equal check because it's not needed and only causing problems with
+ backwards searching on the first character in the buffer.
+
2007-04-06 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-window.c: Fix opening recent files that
- do not exist.
- * mousepad/mousepad-window.c, mousepad/mousepad-document.c:
- Update the window title correctly and remove the unused
- notify::title signals.
+ * mousepad/mousepad-window.c: Fix opening recent files that do not
+ exist.
+ * mousepad/mousepad-window.c, mousepad/mousepad-document.c: Update
+ the window title correctly and remove the unused notify::title
+ signals.
+
2007-04-06 Nick Schermer <nick at xfce.org>
+
* mousepad/mousepad-document.c: Because we don't use invisible
- characters in the text buffer, I was able to write a custom
- iter search function that can search in both directions, can
- be case insensitive, no string duplications and above all:
- is't over 10x faster then the gtk version. This gives a nice
- performance boost to the highlight function.
- * mousepad/mousepad-search-bar.c: Connected the last signals
- and added a wrap around option to the search bar.
+ characters in the text buffer, I was able to write a custom iter
+ search function that can search in both directions, can be case
+ insensitive, no string duplications and above all: is't over 10x
+ faster then the gtk version. This gives a nice performance boost
+ to the highlight function.
+ * mousepad/mousepad-search-bar.c: Connected the last signals and
+ added a wrap around option to the search bar.
2007-04-05 Nick Schermer <nick at xfce.org>
* mousepad/mousepad-document.c: Remove unused properties.
- * mousepad/mousepad-{exo,window,preoperties,search-bar}:
- Remove the exo bindings, mousepad only depends on Gtk and
- libxfce4util.
- * mousepad/mousepad-csource.pl: Perl script to generate the
- menu code. This script also strips the code between the xml
- blocks, so a minimal amount of text is added to the binary
- (ie. it produces better code then exo-csource).
+ * mousepad/mousepad-{exo,window,preoperties,search-bar}: Remove the
+ exo bindings, mousepad only depends on Gtk and libxfce4util.
+ * mousepad/mousepad-csource.pl: Perl script to generate the menu
+ code. This script also strips the code between the xml blocks, so
+ a minimal amount of text is added to the binary (ie. it produces
+ better code then exo-csource).
2007-04-04 Nick Schermer <nick at xfce.org>
- * po/: Update the POTFILES.in file and regenerate the pot
- file.
- * mousepad/mousepad-document.c: Make the scroll offset
- smaller, so the textview doesn't jump around while searching.
- * mousepad/mousepad-search-bar.c: Make sure the search signal
- is send when the search field is empty after a backspace,
- so no text is selected in the buffer.
+ * po/: Update the POTFILES.in file and regenerate the pot file.
+ * mousepad/mousepad-document.c: Make the scroll offset smaller, so
+ the textview doesn't jump around while searching.
+ * mousepad/mousepad-search-bar.c: Make sure the search signal is
+ send when the search field is empty after a backspace, so no text
+ is selected in the buffer.
* Remove some leftover tabs.
2007-04-04 Nick Schermer <nick at xfce.org>
- * configure.in.in: Mousepad does not depend on exo anymore.
- Only when you run in maintainer-mode, exo-csource is required.
+ * configure.in.in: Mousepad does not depend on exo anymore. Only
+ when you run in maintainer-mode, exo-csource is required.
* mousepad/mousepad-document.*: Renamed mousepad-screen to
mousepad-document.
- * mousepad/mousepad-{search-bar,document,window).*: Added
- function for searching, including the type-ahead search bar.
- * mousepad/mousepad-statusbar.*: A custom statusbar suitable
- for displaying the tooltips, overwrite/insert and the line-
- and column-number.
- * mousepad/mousepad-exo.*: The exo-bindings so we don't depend
- on exo anymore, although I want to get rid of all of them.
- * mousepad/mousepad-marshal.list: Custom marshal for sending
- search signals.
- * mousepad/mousepad-types.h: Search types
- (a mousepad-enum-types.{c,h} is generated during build).
+ * mousepad/mousepad-{search-bar,document,window).*: Added function
+ for searching, including the type-ahead search bar.
+ * mousepad/mousepad-statusbar.*: A custom statusbar suitable for
+ displaying the tooltips, overwrite/insert and the line- and
+ column-number.
+ * mousepad/mousepad-exo.*: The exo-bindings so we don't depend on
+ exo anymore, although I want to get rid of all of them.
+ * mousepad/mousepad-marshal.list: Custom marshal for sending search
+ signals.
+ * mousepad/mousepad-types.h: Search types (a
+ mousepad-enum-types.{c,h} is generated during build).
* Various performance improvements and code cleanups.
2007-03-03 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-dialogs.{c,h}: Add response actions for
- Mousepad so it's easier to understand what happens.
+ * mousepad/mousepad-dialogs.{c,h}: Add response actions for Mousepad
+ so it's easier to understand what happens.
* mousepad/mousepad-window.c, * mousepad/mousepad-screen.{c,h}:
Basic support for document reloading.
2007-03-03 Nick Schermer <nick at xfce.org>
- * configure.in.in, mousepad/Makefile.am: Remove the PCRE
- dependency. I should have removed this earier after some
- testing.
+ * configure.in.in, mousepad/Makefile.am: Remove the PCRE dependency.
+ I should have removed this earier after some testing.
2007-03-03 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-dialogs.{c,h}: New file for the dialogs
- so the mousepad-window file becomes more readable.
- * mousepad/mousepad-window.c: Split some function and reorder
- them a bit.
- * mousepad/mousepad-window.c: The items in the go menu now
- have the filename as statusbar tooltip.
+ * mousepad/mousepad-dialogs.{c,h}: New file for the dialogs so the
+ mousepad-window file becomes more readable.
+ * mousepad/mousepad-window.c: Split some function and reorder them
+ a bit.
+ * mousepad/mousepad-window.c: The items in the go menu now have the
+ filename as statusbar tooltip.
* mousepad/mousepad-window.c: Check if the file is externally
modified before writing. If it is, ask the user what to do.
- * mousepad/main.c, mousepad/mousepad-dbus.{c,h},
- mousepad/mousepad-dbus-infos.xml: Support for terminating a
- running mousepad instance (that is connected to dbus), using
- mousepad -q.
+ * mousepad/main.c, mousepad/mousepad-dbus.{c,h}, mousepad/mousepad-
+ dbus-infos.xml: Support for terminating a running mousepad
+ instance (that is connected to dbus), using mousepad -q.
* mousepad/*: Add function destriptions for Erik (and others).
@@ -469,38 +593,37 @@
2007-02-18 Nick Schermer <nick at xfce.org>
- * mousepad/mousepad-window.c: Prevent multiple recent- and
- go-menu updates when multiple items are opened or the recent
- history is cleared.
+ * mousepad/mousepad-window.c: Prevent multiple recent- and go-menu
+ updates when multiple items are opened or the recent history is
+ cleared.
2007-02-18 Nick Schermer <nick at xfce.org>
- * TODO, mousepad/mousepad-window.c: Add option to the recent
- menu to clear the history.
+ * TODO, mousepad/mousepad-window.c: Add option to the recent menu
+ to clear the history.
* mousepad/mousepad-window.c: The recent items are now in the
- Mousepad group so it's easier to filter them when removing.
- The list is also sorted by the most recently used item.
- * mousepad/mousepad-window.c: Fix problem in checking if the
- file was already openened.
+ Mousepad group so it's easier to filter them when removing. The
+ list is also sorted by the most recently used item.
+ * mousepad/mousepad-window.c: Fix problem in checking if the file
+ was already openened.
* mousepad/mousepad-window.c: You can now reorder tabs.
- * mousepad/mousepad-window.c: A tab is now inserted right from
- the current active tab.
- * mousepad/mousepad-screen.c: Untitled documents now have a
- number like "Untitled #". The number is increased as long
- as the application is running.
+ * mousepad/mousepad-window.c: A tab is now inserted right from the
+ current active tab.
+ * mousepad/mousepad-screen.c: Untitled documents now have a number
+ like "Untitled #". The number is increased as long as the
+ application is running.
* mousepad/mousepad-window.c: Added first parts of code for a
statusbar.
2007-02-17 Nick Schermer <nick at xfce.org>
* TODO: Remind myself to fix problems with UTF-8 filenames.
- * mousepad/mousepad-window.c: Fix crash when opening files
- with the command line.
+ * mousepad/mousepad-window.c: Fix crash when opening files with the
+ command line.
* Mousepad.desktop.in.in, Mousepad.desktop.in.in: Mousepad
executable is now lowercase again.
- * mousepad/mousepad-screen.c: Remove unused signals from the
- Class.
+ * mousepad/mousepad-screen.c: Remove unused signals from the Class.
2007-02-17 Nick Schermer <nick at xfce.org>
Modified: mousepad/branches/nick_0_3/mousepad/main.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/main.c 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/main.c 2007-12-06 20:11:21 UTC (rev 26441)
@@ -45,15 +45,15 @@
/* command line options */
-static GOptionEntry option_entries[] =
+static const GOptionEntry option_entries[] =
{
#ifdef HAVE_DBUS
- { "disable-server", '\0', 0, G_OPTION_ARG_NONE, &opt_disable_server, N_("Do not register with the D-BUS session message bus"), NULL, },
- { "quit", 'q', 0, G_OPTION_ARG_NONE, &opt_quit, N_("Quit a running Mousepad instance"), NULL, },
+ { "disable-server", '\0', 0, G_OPTION_ARG_NONE, &opt_disable_server, N_("Do not register with the D-BUS session message bus"), NULL },
+ { "quit", 'q', 0, G_OPTION_ARG_NONE, &opt_quit, N_("Quit a running Mousepad instance"), NULL },
#endif
- { "version", 'v', 0, G_OPTION_ARG_NONE, &opt_version, N_("Print version information and exit"), NULL, },
+ { "version", 'v', 0, G_OPTION_ARG_NONE, &opt_version, N_("Print version information and exit"), NULL },
{ G_OPTION_REMAINING, '\0', 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL, NULL },
- { NULL, },
+ { NULL },
};
@@ -84,7 +84,7 @@
g_thread_init (NULL);
/* initialize gtk+ */
- if (!gtk_init_with_args (&argc, &argv, _("[FILES...]"), option_entries, GETTEXT_PACKAGE, &error))
+ if (!gtk_init_with_args (&argc, &argv, _("[FILES...]"), (GOptionEntry *) option_entries, GETTEXT_PACKAGE, &error))
{
/* check if we have an error message */
if (G_LIKELY (error == NULL))
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-application.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-application.c 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-application.c 2007-12-06 20:11:21 UTC (rev 26441)
@@ -64,25 +64,6 @@
-MousepadApplication*
-mousepad_application_get (void)
-{
- static MousepadApplication *application = NULL;
-
- if (G_LIKELY (application))
- {
- g_object_ref (G_OBJECT (application));
- }
- else
- {
- application = g_object_new (MOUSEPAD_TYPE_APPLICATION, NULL);
- }
-
- return application;
-}
-
-
-
GType
mousepad_application_get_type (void)
{
@@ -174,6 +155,26 @@
+MousepadApplication*
+mousepad_application_get (void)
+{
+ static MousepadApplication *application = NULL;
+
+ if (G_UNLIKELY (application == NULL))
+ {
+ application = g_object_new (MOUSEPAD_TYPE_APPLICATION, NULL);
+ g_object_add_weak_pointer (G_OBJECT (application), (gpointer) &application);
+ }
+ else
+ {
+ g_object_ref (G_OBJECT (application));
+ }
+
+ return application;
+}
+
+
+
gboolean
mousepad_application_has_windows (MousepadApplication *application)
{
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.c 2007-12-06 20:11:21 UTC (rev 26441)
@@ -42,7 +42,11 @@
"destroy-with-parent", TRUE,
"license", XFCE_LICENSE_GPL,
"logo-icon-name", PACKAGE_NAME,
+#if GTK_CHECK_VERSION (2,12,0)
+ "program-name", PACKAGE_NAME,
+#else
"name", PACKAGE_NAME,
+#endif
"version", PACKAGE_VERSION,
"translator-credits", _("translator-credits"),
"website", "http://www.xfce.org/",
@@ -166,20 +170,59 @@
-gint
-mousepad_dialogs_go_to_line (GtkWindow *parent,
- gint current_line,
- gint last_line)
+static void
+mousepad_dialogs_go_to_line_changed (GtkSpinButton *line_spin,
+ GtkSpinButton *col_spin)
{
- GtkWidget *dialog;
- GtkWidget *hbox;
- GtkWidget *label;
- GtkWidget *button;
- GtkAdjustment *adjustment;
- gint line_number = 0;
+ GtkTextBuffer *buffer;
+ GtkTextIter iter;
+ _mousepad_return_if_fail (GTK_IS_SPIN_BUTTON (line_spin));
+ _mousepad_return_if_fail (GTK_IS_SPIN_BUTTON (col_spin));
+
+ /* get the text buffer */
+ buffer = mousepad_object_get_data (G_OBJECT (col_spin), "buffer");
+
+ /* debug check */
+ _mousepad_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+
+ /* get iter at line */
+ gtk_text_buffer_get_iter_at_line (buffer, &iter, gtk_spin_button_get_value_as_int (line_spin) - 1);
+
+ /* move the iter to the end of the line if needed */
+ if (!gtk_text_iter_ends_line (&iter))
+ gtk_text_iter_forward_to_line_end (&iter);
+
+ /* update column spin button range */
+ gtk_spin_button_set_range (col_spin, 0, gtk_text_iter_get_line_offset (&iter));
+}
+
+
+
+gboolean
+mousepad_dialogs_go_to (GtkWindow *parent,
+ GtkTextBuffer *buffer)
+{
+ GtkWidget *dialog;
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *label;
+ GtkWidget *line_spin;
+ GtkWidget *col_spin;
+ GtkSizeGroup *size_group;
+ GtkTextIter iter;
+ gint line, column, lines;
+ gint response;
+
+ /* get cursor iter */
+ gtk_text_buffer_get_iter_at_mark (buffer, &iter, gtk_text_buffer_get_insert (buffer));
+ line = gtk_text_iter_get_line (&iter) + 1;
+
+ /* get number of lines */
+ lines = gtk_text_buffer_get_line_count (buffer);
+
/* build the dialog */
- dialog = gtk_dialog_new_with_buttons (_("Go To Line"),
+ dialog = gtk_dialog_new_with_buttons (_("Go To"),
parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_CANCEL, MOUSEPAD_RESPONSE_CANCEL,
@@ -188,36 +231,82 @@
gtk_dialog_set_default_response (GTK_DIALOG (dialog), MOUSEPAD_RESPONSE_JUMP_TO);
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
- hbox = gtk_hbox_new (FALSE, 8);
- gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE, 0);
- gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), vbox, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 6);
+ gtk_widget_show (vbox);
+
+ /* create size group */
+ size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+
+ /* line number box */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
gtk_widget_show (hbox);
label = gtk_label_new_with_mnemonic (_("_Line number:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+ gtk_size_group_add_widget (size_group, label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
gtk_widget_show (label);
- /* the spin button adjustment */
- adjustment = (GtkAdjustment *) gtk_adjustment_new (current_line, 1, last_line, 1, 10, 0);
+ line_spin = gtk_spin_button_new_with_range (1, lines, 1);
+ gtk_entry_set_activates_default (GTK_ENTRY (line_spin), TRUE);
+ gtk_box_pack_start (GTK_BOX (hbox), line_spin, FALSE, FALSE, 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), line_spin);
+ gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (line_spin), TRUE);
+ gtk_entry_set_width_chars (GTK_ENTRY (line_spin), 8);
+ gtk_widget_show (line_spin);
- /* the spin button */
- button = gtk_spin_button_new (adjustment, 1, 0);
- gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (button), TRUE);
- gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (button), TRUE);
- gtk_entry_set_width_chars (GTK_ENTRY (button), 8);
- gtk_entry_set_activates_default (GTK_ENTRY (button), TRUE);
- gtk_label_set_mnemonic_widget (GTK_LABEL(label), button);
- gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
+ /* column box */
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+ gtk_widget_show (hbox);
+ label = gtk_label_new_with_mnemonic (_("C_olumn number:"));
+ gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0);
+ gtk_size_group_add_widget (size_group, label);
+ gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5);
+ gtk_widget_show (label);
+
+ col_spin = gtk_spin_button_new_with_range (0, 0, 1);
+ gtk_entry_set_activates_default (GTK_ENTRY (col_spin), TRUE);
+ mousepad_object_set_data (G_OBJECT (col_spin), "buffer", buffer);
+ gtk_box_pack_start (GTK_BOX (hbox), col_spin, FALSE, FALSE, 0);
+ gtk_label_set_mnemonic_widget (GTK_LABEL (label), col_spin);
+ gtk_spin_button_set_snap_to_ticks (GTK_SPIN_BUTTON (col_spin), TRUE);
+ gtk_entry_set_width_chars (GTK_ENTRY (col_spin), 8);
+ gtk_widget_show (col_spin);
+
+ /* signal to monitor column number */
+ g_signal_connect (G_OBJECT (line_spin), "value-changed", G_CALLBACK (mousepad_dialogs_go_to_line_changed), col_spin);
+ gtk_spin_button_set_value (GTK_SPIN_BUTTON (line_spin), line);
+
/* run the dialog */
- if (gtk_dialog_run (GTK_DIALOG (dialog)) == MOUSEPAD_RESPONSE_JUMP_TO)
- line_number = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (button));
+ response = gtk_dialog_run (GTK_DIALOG (dialog));
+ if (response == MOUSEPAD_RESPONSE_JUMP_TO)
+ {
+ /* hide the dialog */
+ gtk_widget_hide (dialog);
+ /* get new position */
+ line = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (line_spin)) - 1;
+ column = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (col_spin));
+
+ /* get iter */
+ gtk_text_buffer_get_iter_at_line_offset (buffer, &iter, line, column);
+
+ /* get cursor position */
+ gtk_text_buffer_place_cursor (buffer, &iter);
+ }
+
+ /* release size group */
+ g_object_unref (G_OBJECT (size_group));
+
/* destroy the dialog */
gtk_widget_destroy (dialog);
- return line_number;
+ return (response == MOUSEPAD_RESPONSE_JUMP_TO);
}
@@ -304,65 +393,23 @@
gint
-mousepad_dialogs_ask_overwrite (GtkWindow *parent,
- const gchar *filename)
+mousepad_dialogs_revert (GtkWindow *parent)
{
GtkWidget *dialog;
gint response;
+ /* setup the question dialog */
dialog = gtk_message_dialog_new (parent,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
- _("The file has been externally modified. Are you sure "
- "you want to save the file?"));
-
- gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("If you save the file, the external changes "
- "to \"%s\" will be lost."), filename);
-
- gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, MOUSEPAD_RESPONSE_CANCEL);
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
- mousepad_util_image_button (GTK_STOCK_SAVE, _("_Overwrite")),
- MOUSEPAD_RESPONSE_OVERWRITE);
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
- mousepad_util_image_button (GTK_STOCK_REFRESH, _("_Reload")),
- MOUSEPAD_RESPONSE_RELOAD);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), MOUSEPAD_RESPONSE_CANCEL);
-
- /* run the dialog */
- response = gtk_dialog_run (GTK_DIALOG (dialog));
-
- /* destroy the dialog */
- gtk_widget_destroy (dialog);
-
- return response;
-}
-
-
-
-gint
-mousepad_dialogs_ask_reload (GtkWindow *parent)
-{
- GtkWidget *dialog;
- gint response;
-
- dialog = gtk_message_dialog_new (parent,
- GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE,
+ GTK_MESSAGE_QUESTION, GTK_BUTTONS_NONE,
_("Do you want to save your changes before reloading?"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
- _("If you reload the file, you changes will be lost."));
-
+ _("If you revert the file, all unsaved changes will be lost."));
gtk_dialog_add_buttons (GTK_DIALOG (dialog),
GTK_STOCK_CANCEL, MOUSEPAD_RESPONSE_CANCEL,
GTK_STOCK_SAVE_AS, MOUSEPAD_RESPONSE_SAVE_AS,
+ GTK_STOCK_REVERT_TO_SAVED, MOUSEPAD_RESPONSE_REVERT,
NULL);
- gtk_dialog_add_action_widget (GTK_DIALOG (dialog),
- mousepad_util_image_button (GTK_STOCK_REFRESH, _("_Reload")),
- MOUSEPAD_RESPONSE_RELOAD);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog), MOUSEPAD_RESPONSE_CANCEL);
/* run the dialog */
response = gtk_dialog_run (GTK_DIALOG (dialog));
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.h 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-dialogs.h 2007-12-06 20:11:21 UTC (rev 26441)
@@ -30,42 +30,38 @@
MOUSEPAD_RESPONSE_JUMP_TO,
MOUSEPAD_RESPONSE_OK,
MOUSEPAD_RESPONSE_OVERWRITE,
- MOUSEPAD_RESPONSE_RELOAD,
MOUSEPAD_RESPONSE_REPLACE,
+ MOUSEPAD_RESPONSE_REVERT,
MOUSEPAD_RESPONSE_SAVE,
MOUSEPAD_RESPONSE_SAVE_AS,
MOUSEPAD_RESPONSE_CHECK_ENTRY
};
-GtkWidget *mousepad_dialogs_image_button (const gchar *stock_id,
- const gchar *label);
+GtkWidget *mousepad_dialogs_image_button (const gchar *stock_id,
+ const gchar *label);
-void mousepad_dialogs_show_about (GtkWindow *parent);
+void mousepad_dialogs_show_about (GtkWindow *parent);
-void mousepad_dialogs_show_error (GtkWindow *parent,
- const GError *error,
- const gchar *message);
+void mousepad_dialogs_show_error (GtkWindow *parent,
+ const GError *error,
+ const gchar *message);
-void mousepad_dialogs_show_help (GtkWindow *parent,
- const gchar *page,
- const gchar *offset);
+void mousepad_dialogs_show_help (GtkWindow *parent,
+ const gchar *page,
+ const gchar *offset);
-gint mousepad_dialogs_other_tab_size (GtkWindow *parent,
- gint active_size);
+gint mousepad_dialogs_other_tab_size (GtkWindow *parent,
+ gint active_size);
-gint mousepad_dialogs_go_to_line (GtkWindow *parent,
- gint current_line,
- gint last_line);
+gboolean mousepad_dialogs_go_to (GtkWindow *parent,
+ GtkTextBuffer *buffer;);
-gboolean mousepad_dialogs_clear_recent (GtkWindow *parent);
+gboolean mousepad_dialogs_clear_recent (GtkWindow *parent);
-gint mousepad_dialogs_save_changes (GtkWindow *parent);
+gint mousepad_dialogs_save_changes (GtkWindow *parent);
-gint mousepad_dialogs_ask_overwrite (GtkWindow *parent,
- const gchar *filename);
+gint mousepad_dialogs_revert (GtkWindow *parent);
-gint mousepad_dialogs_ask_reload (GtkWindow *parent);
-
G_END_DECLS
#endif /* !__MOUSEPAD_DIALOGS_H__ */
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-document.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-document.c 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-document.c 2007-12-06 20:11:21 UTC (rev 26441)
@@ -50,9 +50,12 @@
static void mousepad_document_notify_cursor_position (GtkTextBuffer *buffer,
GParamSpec *pspec,
MousepadDocument *document);
-static void mousepad_document_toggle_overwrite (GtkTextView *textview,
+static void mousepad_document_notify_has_selection (GtkTextBuffer *buffer,
GParamSpec *pspec,
MousepadDocument *document);
+static void mousepad_document_notify_overwrite (GtkTextView *textview,
+ GParamSpec *pspec,
+ MousepadDocument *document);
static void mousepad_document_drag_data_received (GtkWidget *widget,
GdkDragContext *context,
gint x,
@@ -63,6 +66,7 @@
MousepadDocument *document);
static void mousepad_document_filename_changed (MousepadDocument *document,
const gchar *filename);
+static void mousepad_document_label_color (MousepadDocument *document);
static void mousepad_document_tab_button_clicked (GtkWidget *widget,
MousepadDocument *document);
@@ -71,8 +75,9 @@
{
CLOSE_TAB,
CURSOR_CHANGED,
+ SELECTION_CHANGED,
OVERWRITE_CHANGED,
- LAST_SIGNAL,
+ LAST_SIGNAL
};
struct _MousepadDocumentClass
@@ -160,6 +165,14 @@
_mousepad_marshal_VOID__INT_INT_INT,
G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
+ document_signals[SELECTION_CHANGED] =
+ g_signal_new (I_("selection-changed"),
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_NO_HOOKS,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__INT,
+ G_TYPE_NONE, 1, G_TYPE_INT);
+
document_signals[OVERWRITE_CHANGED] =
g_signal_new (I_("overwrite-changed"),
G_TYPE_FROM_CLASS (gobject_class),
@@ -186,6 +199,7 @@
/* initialize the variables */
document->priv->utf8_filename = NULL;
document->priv->utf8_basename = NULL;
+ document->priv->label = NULL;
/* setup the scolled window */
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (document), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
@@ -246,7 +260,9 @@
/* attach signals to the text view and buffer */
g_signal_connect (G_OBJECT (document->buffer), "notify::cursor-position", G_CALLBACK (mousepad_document_notify_cursor_position), document);
- g_signal_connect (G_OBJECT (document->textview), "notify::overwrite", G_CALLBACK (mousepad_document_toggle_overwrite), document);
+ g_signal_connect (G_OBJECT (document->buffer), "notify::has-selection", G_CALLBACK (mousepad_document_notify_has_selection), document);
+ g_signal_connect_swapped (G_OBJECT (document->buffer), "modified-changed", G_CALLBACK (mousepad_document_label_color), document);
+ g_signal_connect (G_OBJECT (document->textview), "notify::overwrite", G_CALLBACK (mousepad_document_notify_overwrite), document);
g_signal_connect (G_OBJECT (document->textview), "drag-data-received", G_CALLBACK (mousepad_document_drag_data_received), document);
}
@@ -281,7 +297,7 @@
MousepadDocument *document)
{
GtkTextIter iter;
- guint line, column, selection;
+ gint line, column, selection;
gint tab_size;
_mousepad_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
@@ -297,10 +313,10 @@
tab_size = mousepad_view_get_tab_size (document->textview);
/* get the column */
- column = mousepad_util_get_real_line_offset (&iter, tab_size) + 1;
+ column = mousepad_util_get_real_line_offset (&iter, tab_size);
/* get length of the selection */
- selection = mousepad_view_get_selection_length (document->textview);
+ selection = mousepad_view_get_selection_length (document->textview, NULL);
/* emit the signal */
g_signal_emit (G_OBJECT (document), document_signals[CURSOR_CHANGED], 0, line, column, selection);
@@ -309,7 +325,35 @@
static void
-mousepad_document_toggle_overwrite (GtkTextView *textview,
+mousepad_document_notify_has_selection (GtkTextBuffer *buffer,
+ GParamSpec *pspec,
+ MousepadDocument *document)
+{
+ gint selection;
+ gboolean is_column_selection;
+
+ _mousepad_return_if_fail (GTK_IS_TEXT_BUFFER (buffer));
+ _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (document));
+
+ /* get length of the selection */
+ selection = mousepad_view_get_selection_length (document->textview, &is_column_selection);
+
+ /* don't send large numbers */
+ if (selection > 1)
+ selection = 1;
+
+ /* if it's a column selection with content */
+ if (selection == 1 && is_column_selection)
+ selection = 2;
+
+ /* emit the signal */
+ g_signal_emit (G_OBJECT (document), document_signals[SELECTION_CHANGED], 0, selection);
+}
+
+
+
+static void
+mousepad_document_notify_overwrite (GtkTextView *textview,
GParamSpec *pspec,
MousepadDocument *document)
{
@@ -379,12 +423,40 @@
/* set the tab tooltip */
mousepad_util_set_tooltip (document->priv->ebox, utf8_filename);
+
+ /* update label color */
+ mousepad_document_label_color (document);
}
}
}
+static void
+mousepad_document_label_color (MousepadDocument *document)
+{
+ const GdkColor green = {0, 0x0000, 0x9999, 0x0000};
+ const GdkColor red = {0, 0xffff, 0x0000, 0x0000};
+ gboolean readonly, modified;
+
+ _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (document));
+ _mousepad_return_if_fail (GTK_IS_TEXT_BUFFER (document->buffer));
+ _mousepad_return_if_fail (MOUSEPAD_IS_FILE (document->file));
+
+ if (document->priv->label)
+ {
+ /* get states */
+ readonly = mousepad_file_get_read_only (document->file);
+ modified = gtk_text_buffer_get_modified (document->buffer);
+
+ /* update colors */
+ gtk_widget_modify_fg (document->priv->label, GTK_STATE_NORMAL, modified ? &red : (readonly ? &green : NULL));
+ gtk_widget_modify_fg (document->priv->label, GTK_STATE_ACTIVE, modified ? &red : (readonly ? &green : NULL));
+ }
+}
+
+
+
void
mousepad_document_set_overwrite (MousepadDocument *document,
gboolean overwrite)
@@ -443,55 +515,18 @@
void
-mousepad_document_go_to_line (MousepadDocument *document,
- gint line_number)
+mousepad_document_send_signals (MousepadDocument *document)
{
- GtkTextIter iter;
-
_mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (document));
- _mousepad_return_if_fail (GTK_IS_TEXT_BUFFER (document->buffer));
- /* move the cursor */
- gtk_text_buffer_get_iter_at_line (document->buffer, &iter, line_number - 1);
- gtk_text_buffer_place_cursor (document->buffer, &iter);
-
- /* make sure the cursor is in the visible area */
- mousepad_view_put_cursor_on_screen (document->textview);
-}
-
-
-
-void
-mousepad_document_send_statusbar_signals (MousepadDocument *document)
-{
- _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (document));
-
/* re-send the cursor changed signal */
mousepad_document_notify_cursor_position (document->buffer, NULL, document);
/* re-send the overwrite signal */
- mousepad_document_toggle_overwrite (GTK_TEXT_VIEW (document->textview), NULL, document);
-}
+ mousepad_document_notify_overwrite (GTK_TEXT_VIEW (document->textview), NULL, document);
-
-
-void
-mousepad_document_line_numbers (MousepadDocument *document,
- gint *current_line,
- gint *last_line)
-{
- GtkTextIter iter;
-
- _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (document));
- _mousepad_return_if_fail (GTK_IS_TEXT_BUFFER (document->buffer));
-
- /* get the current line number */
- gtk_text_buffer_get_iter_at_mark (document->buffer, &iter, gtk_text_buffer_get_insert (document->buffer));
- *current_line = gtk_text_iter_get_line (&iter) + 1;
-
- /* get the last line number */
- gtk_text_buffer_get_end_iter (document->buffer, &iter);
- *last_line = gtk_text_iter_get_line (&iter) + 1;
+ /* re-send the selection status */
+ mousepad_document_notify_has_selection (document->buffer, NULL, document);
}
@@ -518,6 +553,9 @@
gtk_container_add (GTK_CONTAINER (document->priv->ebox), document->priv->label);
gtk_widget_show (document->priv->label);
+ /* set label color */
+ mousepad_document_label_color (document);
+
/* create the button */
button = gtk_button_new ();
gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-document.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-document.h 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-document.h 2007-12-06 20:11:21 UTC (rev 26441)
@@ -61,38 +61,31 @@
GtkTextTag *tag;
};
-GType mousepad_document_get_type (void) G_GNUC_CONST;
+GType mousepad_document_get_type (void) G_GNUC_CONST;
-MousepadDocument *mousepad_document_new (void);
+MousepadDocument *mousepad_document_new (void);
-void mousepad_document_set_font (MousepadDocument *document,
- const gchar *font_name);
+void mousepad_document_set_font (MousepadDocument *document,
+ const gchar *font_name);
-void mousepad_document_set_overwrite (MousepadDocument *document,
- gboolean overwrite);
+void mousepad_document_set_overwrite (MousepadDocument *document,
+ gboolean overwrite);
-void mousepad_document_set_word_wrap (MousepadDocument *document,
- gboolean word_wrap);
+void mousepad_document_set_word_wrap (MousepadDocument *document,
+ gboolean word_wrap);
-void mousepad_document_focus_textview (MousepadDocument *document);
+void mousepad_document_focus_textview (MousepadDocument *document);
-void mousepad_document_go_to_line (MousepadDocument *document,
- gint line_number);
+void mousepad_document_send_signals (MousepadDocument *document);
-void mousepad_document_send_statusbar_signals (MousepadDocument *document);
+GtkWidget *mousepad_document_get_tab_label (MousepadDocument *document);
-void mousepad_document_line_numbers (MousepadDocument *document,
- gint *current_line,
- gint *last_line);
+const gchar *mousepad_document_get_basename (MousepadDocument *document);
-GtkWidget *mousepad_document_get_tab_label (MousepadDocument *document);
+const gchar *mousepad_document_get_filename (MousepadDocument *document);
-const gchar *mousepad_document_get_basename (MousepadDocument *document);
+gboolean mousepad_document_get_word_wrap (MousepadDocument *document);
-const gchar *mousepad_document_get_filename (MousepadDocument *document);
-
-gboolean mousepad_document_get_word_wrap (MousepadDocument *document);
-
G_END_DECLS
#endif /* !__MOUSEPAD_DOCUMENT_H__ */
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-encoding-dialog.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-encoding-dialog.c 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-encoding-dialog.c 2007-12-06 20:11:21 UTC (rev 26441)
@@ -354,7 +354,7 @@
/* get the first model iter, if there is one */
if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (dialog->store), &needle))
{
- while (TRUE)
+ for (;;)
{
/* get the column value */
gtk_tree_model_get (GTK_TREE_MODEL (dialog->store), &needle, COLUMN_UNPRINTABLE, &value, -1);
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-file.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-file.c 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-file.c 2007-12-06 20:11:21 UTC (rev 26441)
@@ -34,7 +34,7 @@
#define MAX_ENCODING_CHECK_CHARS (10000)
-#define MOUSEPAD_GET_LINE_END_CHARS(a) ((a) == MOUSEPAD_LINE_END_WIN32 ? "\r\n\0" : ((a) == MOUSEPAD_LINE_END_MAC ? "\r\0" : "\n\0"))
+#define MOUSEPAD_GET_LINE_END_CHARS(a) ((a) == MOUSEPAD_LINE_END_DOS ? "\r\n\0" : ((a) == MOUSEPAD_LINE_END_MAC ? "\r\0" : "\n\0"))
enum
@@ -298,7 +298,7 @@
if (g_file_test (file->filename, G_FILE_TEST_EXISTS) == FALSE)
{
file->readonly = FALSE;
-
+
return TRUE;
}
@@ -324,7 +324,7 @@
gtk_text_buffer_get_start_iter (file->buffer, &end);
/* read the content of the file */
- while (TRUE)
+ for (;;)
{
/* read the line */
status = g_io_channel_read_line (channel, &string, &length, &terminator_pos, error);
@@ -347,7 +347,7 @@
else if (strcmp (line_term, "\r") == 0)
file->line_ending = MOUSEPAD_LINE_END_MAC;
else if (strcmp (line_term, "\r\n") == 0)
- file->line_ending = MOUSEPAD_LINE_END_WIN32;
+ file->line_ending = MOUSEPAD_LINE_END_DOS;
else
g_warning (_("Unknown line ending detected (%s)"), line_term);
}
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-file.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-file.h 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-file.h 2007-12-06 20:11:21 UTC (rev 26441)
@@ -35,8 +35,8 @@
{
MOUSEPAD_LINE_END_NONE,
MOUSEPAD_LINE_END_UNIX,
- MOUSEPAD_LINE_END_WIN32,
- MOUSEPAD_LINE_END_MAC
+ MOUSEPAD_LINE_END_MAC,
+ MOUSEPAD_LINE_END_DOS
};
GType mousepad_file_get_type (void) G_GNUC_CONST;
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-private.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-private.h 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-private.h 2007-12-06 20:11:21 UTC (rev 26441)
@@ -34,14 +34,20 @@
#define TIMER_START GTimer *__FUNCTION__timer = g_timer_new();
#define TIMER_SPLIT g_print ("%s (%s:%d): %.2f ms\n", __FUNCTION__, __FILE__, __LINE__, g_timer_elapsed (__FUNCTION__timer, NULL) * 1000);
#define TIMER_STOP TIMER_SPLIT g_timer_destroy (__FUNCTION__timer);
-#define PRINT_LINE g_print ("%d\n", __LINE__);
+#define PRINT_LINE g_print ("%d (%s)\n", __LINE__, __FUNCTION__);
/* optimize the properties */
#define MOUSEPAD_PARAM_READWRITE (G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
-/* support for canonical strings */
-#define I_(string) (g_intern_static_string ((string)))
+/* support for canonical strings and quarks */
+#define I_(string) (g_intern_static_string (string))
+#define QU_(string) (g_quark_from_static_string (string))
+/* convienient function for setting object data */
+#define mousepad_object_set_data(object,key,data) (g_object_set_qdata ((object), QU_(key), (data)))
+#define mousepad_object_set_data_full(object,key,data,destroy) (g_object_set_qdata_full ((object), QU_(key), (data), (GDestroyNotify) (destroy)))
+#define mousepad_object_get_data(object,key) (g_object_get_qdata ((object), QU_(key)))
+
/* support macros for debugging */
#ifndef NDEBUG
#define _mousepad_assert(expr) g_assert (expr)
@@ -82,8 +88,8 @@
#undef G_UNLIKELY
#if defined(NDEBUG) && defined(__GNUC__) && (__GNUC__ > 2)
-#define G_LIKELY(expr) (__builtin_expect (!!(expr), 1))
-#define G_UNLIKELY(expr) (__builtin_expect (!!(expr), 0))
+#define G_LIKELY(expr) (__builtin_expect (!!(expr), TRUE))
+#define G_UNLIKELY(expr) (__builtin_expect (!!(expr), FALSE))
#else
#define G_LIKELY(expr) (expr)
#define G_UNLIKELY(expr) (expr)
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-search-bar.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-search-bar.c 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-search-bar.c 2007-12-06 20:11:21 UTC (rev 26441)
@@ -165,16 +165,16 @@
/* hide the shadow around the toolbar */
gtk_rc_parse_string ("style \"mousepad-search-bar-style\"\n"
- " {\n"
- " GtkToolbar::shadow-type = GTK_SHADOW_NONE\n"
- " }\n"
+ "{\n"
+ "GtkToolbar::shadow-type = GTK_SHADOW_NONE\n"
+ "}\n"
"class \"MousepadSearchBar\" style \"mousepad-search-bar-style\"\n"
/* add 2px space between the toolbar buttons */
"style \"mousepad-button-style\"\n"
- " {\n"
- " GtkToolButton::icon-spacing = 2\n"
- " }\n"
+ "{\n"
+ "GtkToolButton::icon-spacing = 2\n"
+ "}\n"
"widget \"MousepadWindow.*.Gtk*ToolButton\" style \"mousepad-button-style\"\n");
}
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-util.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-util.c 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-util.c 2007-12-06 20:11:21 UTC (rev 26441)
@@ -244,6 +244,130 @@
+gchar *
+mousepad_util_utf8_strcapital (const gchar *str)
+{
+ gunichar c;
+ const gchar *p;
+ gchar *buf;
+ GString *result;
+ gboolean upper = TRUE;
+
+ _mousepad_return_val_if_fail (g_utf8_validate (str, -1, NULL), NULL);
+
+ /* create a new string */
+ result = g_string_sized_new (strlen (str));
+
+ /* walk though the string */
+ for (p = str; *p != '\0'; p = g_utf8_next_char (p))
+ {
+ /* get the unicode char */
+ c = g_utf8_get_char (p);
+
+ /* only change the case of alpha chars */
+ if (g_unichar_isalpha (c))
+ {
+ /* check case */
+ if (upper ? g_unichar_isupper (c) : g_unichar_islower (c))
+ {
+ /* currect case is already correct */
+ g_string_append_unichar (result, c);
+ }
+ else
+ {
+ /* convert the case of the char and append it */
+ buf = upper ? g_utf8_strup (p, 1) : g_utf8_strdown (p, 1);
+ g_string_append (result, buf);
+ g_free (buf);
+ }
+
+ /* next char must be lowercase */
+ upper = FALSE;
+ }
+ else
+ {
+ /* append the char */
+ g_string_append_unichar (result, c);
+
+ /* next alpha char uppercase after a space */
+ upper = g_unichar_isspace (c);
+ }
+ }
+
+ /* return the result */
+ return g_string_free (result, FALSE);
+}
+
+
+
+gchar *
+mousepad_util_utf8_stropposite (const gchar *str)
+{
+ gunichar c;
+ const gchar *p;
+ gchar *buf;
+ GString *result;
+
+ _mousepad_return_val_if_fail (g_utf8_validate (str, -1, NULL), NULL);
+
+ /* create a new string */
+ result = g_string_sized_new (strlen (str));
+
+ /* walk though the string */
+ for (p = str; *p != '\0'; p = g_utf8_next_char (p))
+ {
+ /* get the unicode char */
+ c = g_utf8_get_char (p);
+
+ /* only change the case of alpha chars */
+ if (g_unichar_isalpha (c))
+ {
+ /* get the opposite case of the char */
+ if (g_unichar_isupper (c))
+ buf = g_utf8_strdown (p, 1);
+ else
+ buf = g_utf8_strup (p, 1);
+
+ /* append to the buffer */
+ g_string_append (result, buf);
+ g_free (buf);
+ }
+ else
+ {
+ /* append the char */
+ g_string_append_unichar (result, c);
+ }
+ }
+
+ /* return the result */
+ return g_string_free (result, FALSE);
+}
+
+
+
+gchar *
+mousepad_util_escape_underscores (const gchar *str)
+{
+ GString *result;
+ const gchar *s;
+
+ /* allocate a new string */
+ result = g_string_sized_new (strlen (str));
+
+ /* escape all underscores */
+ for (s = str; *s != '\0'; ++s)
+ {
+ if (G_UNLIKELY (*s == '_'))
+ g_string_append (result, "__");
+ else
+ g_string_append_c (result, *s);
+ }
+
+ return g_string_free (result, FALSE);
+}
+
+
+
GtkWidget *
mousepad_util_image_button (const gchar *stock_id,
const gchar *label)
@@ -273,7 +397,7 @@
_mousepad_return_if_fail (GTK_IS_WIDGET (widget));
/* get the current error state */
- pointer = g_object_get_data (G_OBJECT (widget), I_("error-state"));
+ pointer = mousepad_object_get_data (G_OBJECT (widget), "error-state");
/* only change the state when really needed to avoid multiple widget calls */
if (GPOINTER_TO_INT (pointer) != error)
@@ -283,7 +407,7 @@
gtk_widget_modify_text (widget, GTK_STATE_NORMAL, error ? &white : NULL);
/* set the new state */
- g_object_set_data (G_OBJECT (widget), I_("error-state"), GINT_TO_POINTER (error));
+ mousepad_object_set_data (G_OBJECT (widget), "error-state", GINT_TO_POINTER (error));
}
}
@@ -376,15 +500,19 @@
gint offset = 0;
GtkTextIter needle = *iter;
+ /* move the needle to the start of the line */
gtk_text_iter_set_line_offset (&needle, 0);
+ /* forward the needle until we hit the iter */
while (!gtk_text_iter_equal (&needle, iter))
{
+ /* append the real tab offset or 1 */
if (gtk_text_iter_get_char (&needle) == '\t')
offset += (tab_size - (offset % tab_size));
else
offset++;
+ /* next char */
gtk_text_iter_forward_char (&needle);
}
@@ -469,7 +597,7 @@
iter = *start;
/* walk from the start to the end iter */
- do
+ for (;;)
{
/* break when we reach the limit iter */
if (G_UNLIKELY (gtk_text_iter_equal (&iter, limit)))
@@ -555,7 +683,6 @@
|| (search_backwards && !gtk_text_iter_backward_char (&iter)))
break;
}
- while (TRUE);
return succeed;
}
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-util.h
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-util.h 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-util.h 2007-12-06 20:11:21 UTC (rev 26441)
@@ -74,6 +74,12 @@
gchar *mousepad_util_key_name (const gchar *name);
+gchar *mousepad_util_utf8_strcapital (const gchar *str);
+
+gchar *mousepad_util_utf8_stropposite (const gchar *str);
+
+gchar *mousepad_util_escape_underscores (const gchar *str);
+
GtkWidget *mousepad_util_image_button (const gchar *stock_id,
const gchar *label);
Modified: mousepad/branches/nick_0_3/mousepad/mousepad-view.c
===================================================================
--- mousepad/branches/nick_0_3/mousepad/mousepad-view.c 2007-12-06 19:19:59 UTC (rev 26440)
+++ mousepad/branches/nick_0_3/mousepad/mousepad-view.c 2007-12-06 20:11:21 UTC (rev 26441)
@@ -31,6 +31,8 @@
+#define LINE_NUMBER_MARGIN (10)
+#define LINE_NUMBER_OFFSET (4)
#define mousepad_view_get_buffer(view) (GTK_TEXT_VIEW (view)->buffer)
@@ -52,25 +54,26 @@
GtkTextIter *range_start,
GtkTextIter *range_end);
static void mousepad_view_selection_key_press_event (MousepadView *view,
- GdkEventKey *event,
+ const gchar *text,
+ guint keyval,
guint modifiers);
+static void mousepad_view_commit_handler (GtkIMContext *context,
+ const gchar *str,
+ MousepadView *view);
static void mousepad_view_selection_delete_content (MousepadView *view);
static void mousepad_view_selection_destroy (MousepadView *view);
-static void mousepad_view_selection_cleanup_equal_marks (MousepadView *view);
-static void mousepad_view_selection_add_marks (MousepadView *view,
- GtkTextIter *start_iter,
- GtkTextIter *end_iter);
static void mousepad_view_selection_draw (MousepadView *view,
- gboolean draw_cursors,
- gboolean add_marks);
+ gboolean append);
static gboolean mousepad_view_selection_timeout (gpointer user_data);
static void mousepad_view_selection_timeout_destroy (gpointer user_data);
+static gchar *mousepad_view_selection_string (MousepadView *view);
static void mousepad_view_indent_increase (MousepadView *view,
GtkTextIter *iter);
static void mousepad_view_indent_decrease (MousepadView *view,
GtkTextIter *iter);
static void mousepad_view_indent_selection (MousepadView *view,
- gboolean increase);
+ gboolean increase,
+ gboolean force);
static gchar *mousepad_view_indent_string (GtkTextBuffer *buffer,
const GtkTextIter *iter);
static gint mousepad_view_calculate_layout_width (GtkWidget *widget,
@@ -89,15 +92,6 @@
-enum _MousepadViewFlags
-{
- HAS_SELECTION = 1 << 0, /* if there are marks in the selection list */
- EDITING_MODE = 1 << 1, /* users can type in the selection */
- HAS_CONTENT = 1 << 2, /* selection contains content */
- DRAGGING = 1 << 3, /* still dragging */
- MULTIPLE = 1 << 4 /* whether this is an multiple selection */
-};
-
struct _MousepadViewClass
{
GtkTextViewClass __parent__;
@@ -107,14 +101,11 @@
{
GtkTextView __parent__;
- /* current status */
- MousepadViewFlags flags;
-
/* the selection style tag */
GtkTextTag *selection_tag;
/* list with all the selection marks */
- GSList *marks;
+ GSList *selection_marks;
/* selection timeout id */
guint selection_timeout_id;
@@ -125,9 +116,12 @@
gint selection_end_x;
gint selection_end_y;
- /* length of the selection */
+ /* length of the selection (-1 = zerro width selection, 0 = no selection) */
gint selection_length;
+ /* if the selection is in editing mode */
+ guint selection_editing : 1;
+
/* settings */
guint auto_indent : 1;
guint line_numbers : 1;
@@ -194,10 +188,17 @@
/* initialize selection variables */
view->selection_timeout_id = 0;
- view->flags = 0;
view->selection_tag = NULL;
- view->marks = NULL;
+ view->selection_marks = NULL;
view->selection_length = 0;
+ view->selection_editing = FALSE;
+
+ /* reset drag coordinates */
+ view->selection_start_x = view->selection_end_x = -1;
+ view->selection_start_y = view->selection_end_y = -1;
+
+ g_signal_connect (GTK_TEXT_VIEW (view)->im_context, "commit",
+ G_CALLBACK (mousepad_view_commit_handler), view);
}
@@ -211,9 +212,9 @@
if (G_UNLIKELY (view->selection_timeout_id != 0))
g_source_remove (view->selection_timeout_id);
- /* free the selection marks list */
- if (G_UNLIKELY (view->marks != NULL))
- g_slist_free (view->marks);
+ /* free the selection marks list (marks are owned by the buffer) */
+ if (G_UNLIKELY (view->selection_marks != NULL))
+ g_slist_free (view->selection_marks);
(*G_OBJECT_CLASS (mousepad_view_parent_class)->finalize) (object);
}
@@ -226,36 +227,37 @@
{
GtkTextView *textview = GTK_TEXT_VIEW (widget);
MousepadView *view = MOUSEPAD_VIEW (widget);
- gint y_top, y_offset, y_bottom;
- gint y, height;
- gint line_number = 0, line_count;
+ gint y_start, y_offset, y_finish;
+ gint y_iter, height;
+ gint line_number, line_count;
GtkTextIter iter;
- gint width;
+ gint width, border_width;
PangoLayout *layout;
gchar str[8]; /* maximum of 10e6 lines */
- if (view->flags != 0
- && MOUSEPAD_HAS_FLAG (view->flags, HAS_CONTENT) == FALSE
- && event->window == gtk_text_view_get_window (textview, GTK_TEXT_WINDOW_TEXT))
+ if (G_UNLIKELY (view->selection_length == -1
+ && (view->selection_marks != NULL || view->selection_end_x != -1)
+ && event->window == gtk_text_view_get_window (textview, GTK_TEXT_WINDOW_TEXT)))
{
- /* redraw the retangles for the vertical selection */
- mousepad_view_selection_draw (view, TRUE, FALSE);
+ /* redraw the cursor lines for the vertical selection */
+ mousepad_view_selection_draw (view, FALSE);
}
else if (event->window == gtk_text_view_get_window (textview, GTK_TEXT_WINDOW_LEFT))
{
/* get the real start position */
gtk_text_view_window_to_buffer_coords (textview, GTK_TEXT_WINDOW_LEFT,
- 0, event->area.y, NULL, &y_top);
+ 0, event->area.y, NULL, &y_start);
+ /* get the left window y offset (this is *NOT* the textview offset!) */
+ y_offset = event->area.y - y_start;
+
/* get the bottom position */
- y_bottom = y_top + event->area.height;
+ y_finish = y_start + event->area.height;
- /* get the buffer offset (negative value or 0) */
- y_offset = event->area.y - y_top;
+ /* get the start iter and its line number */
+ gtk_text_view_get_line_at_y (textview, &iter, y_start, NULL);
+ line_number = gtk_text_iter_get_line (&iter);
- /* get the start iter */
- gtk_text_view_get_line_at_y (textview, &iter, y_top, NULL);
-
/* get the number of lines in the buffer */
line_count = gtk_text_buffer_get_line_count (textview->buffer);
@@ -265,57 +267,67 @@
/* create the pango layout */
layout = gtk_widget_create_pango_layout (widget, str);
pango_layout_get_pixel_size (layout, &width, NULL);
+
+ /* border width */
+ border_width = width + LINE_NUMBER_MARGIN;
+
+ /* check if we need to set the border size again */
+ if (G_UNLIKELY (gtk_text_view_get_border_window_size (textview, GTK_TEXT_WINDOW_LEFT) != border_width))
+ {
+ /* set the new border size */
+ gtk_text_view_set_border_window_size (textview, GTK_TEXT_WINDOW_LEFT, border_width);
+
+ /* leave, we'll redraw on the next expose event */
+ goto bail_out;
+ }
+
+ /* finish the pango layout */
pango_layout_set_width (layout, width);
pango_layout_set_alignment (layout, PANGO_ALIGN_RIGHT);
- /* set the width of the left window border */
- gtk_text_view_set_border_window_size (textview, GTK_TEXT_WINDOW_LEFT, width + 8);
-
/* draw a vertical line to separate the numbers and text */
gtk_paint_vline (widget->style, event->window,
GTK_WIDGET_STATE (widget),
NULL, widget, NULL,
event->area.y,
event->area.y + event->area.height,
- width + 6);
+ border_width - 2);
/* walk through the lines until we hit the last line */
- while (line_number < line_count)
+ for (; line_number < line_count; line_number++)
{
/* get the y position and the height of the iter */
- gtk_text_view_get_line_yrange (textview, &iter, &y, &height);
+ gtk_text_view_get_line_yrange (textview, &iter, &y_iter, &height);
- /* include the buffer offset */
- y += y_offset;
-
- /* get the number of the line */
- line_number = gtk_text_iter_get_line (&iter) + 1;
-
/* create the number */
- g_snprintf (str, sizeof (str), "%d", line_number);
+ g_snprintf (str, sizeof (str), "%d", line_number + 1);
/* create the pange layout */
- pango_layout_set_text (layout, str, strlen (str));
+ pango_layout_set_text (layout, str, -1);
/* draw the layout on the left window */
gtk_paint_layout (widget->style, event->window,
GTK_WIDGET_STATE (widget),
FALSE, NULL, widget, NULL,
- width + 2, y, layout);
+ width + LINE_NUMBER_OFFSET,
+ y_iter + y_offset, layout);
/* stop when we reached the end of the expose area */
- if ((y + height) >= y_bottom)
+ if (y_iter + height >= y_finish)
break;
/* jump to the next line */
gtk_text_iter_forward_line (&iter);
}
+ /* label for leaving after setting the left border size */
+ bail_out:
+
/* release the pango layout */
g_object_unref (G_OBJECT (layout));
}
- /* Gtk can draw the text now */
+ /* gtk can draw the text now */
return (*GTK_WIDGET_CLASS (mousepad_view_parent_class)->expose_event) (widget, event);
}
@@ -359,8 +371,8 @@
mousepad_view_set_tab_size (view, view->tab_size);
/* redraw selection */
- if (view->flags != 0)
- mousepad_view_selection_draw (view, !MOUSEPAD_HAS_FLAG (view->flags, HAS_CONTENT), FALSE);
+ if (view->selection_marks != NULL)
+ mousepad_view_selection_draw (view, FALSE);
}
}
@@ -421,7 +433,7 @@
gtk_text_buffer_end_user_action (buffer);
/* make sure the new string is visible for the user */
- mousepad_view_put_cursor_on_screen (view);
+ mousepad_view_scroll_to_cursor (view);
}
/* cleanup */
@@ -478,7 +490,7 @@
gtk_text_buffer_place_cursor (buffer, &iter);
/* make sure the cursor is visible for the user */
- mousepad_view_put_cursor_on_screen (view);
+ mousepad_view_scroll_to_cursor (view);
return TRUE;
}
@@ -486,10 +498,25 @@
case GDK_Delete:
case GDK_KP_Delete:
+ if (view->selection_marks != NULL && is_editable)
+ {
+ /* delete or destroy the selection */
+ if (view->selection_length > 0)
+ mousepad_view_delete_selection (view);
+ else
+ mousepad_view_selection_destroy (view);
+
+ return TRUE;
+ }
+ break;
+
case GDK_BackSpace:
- if (view->flags != 0)
+ if (view->selection_marks != NULL && is_editable)
{
- goto selection_key_press;
+ /* backspace in the selection */
+ mousepad_view_selection_key_press_event (view, NULL, GDK_BackSpace, modifiers);
+
+ return TRUE;
}
break;
@@ -498,14 +525,17 @@
case GDK_ISO_Left_Tab:
if (G_LIKELY (is_editable))
{
- if (view->flags != 0)
+ if (view->selection_marks != NULL)
{
- goto selection_key_press;
+ /* insert a tab in the selection */
+ mousepad_view_selection_key_press_event (view, NULL, GDK_Tab, modifiers);
+
+ return TRUE;
}
else if (gtk_text_buffer_get_selection_bounds (buffer, NULL, NULL))
{
/* indent the selection */
- mousepad_view_indent_selection (view, (modifiers & GDK_SHIFT_MASK));
+ mousepad_view_indent_selection (view, !(modifiers & GDK_SHIFT_MASK), FALSE);
return TRUE;
}
@@ -530,21 +560,25 @@
break;
default:
- if (view->flags != 0 && event->length > 0)
+ if (G_UNLIKELY (view->selection_marks != NULL && is_editable))
{
- /* label for tab and backspace */
- selection_key_press:
+ /* block textview updates (from gtk) */
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), FALSE);
- /* handle a key press event for a selection */
- mousepad_view_selection_key_press_event (view, event, modifiers);
+ /* handle the im context */
+ im_handled = gtk_im_context_filter_keypress (GTK_TEXT_VIEW (view)->im_context, event);
- return TRUE;
+ /* allow textview updates again */
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view), TRUE);
+
+ /* only leave when the im handle the event */
+ if (im_handled)
+ return TRUE;
}
- break;
}
/* remove the selection when no valid key combination has been pressed */
- if (G_UNLIKELY (view->flags != 0 && event->is_modifier == FALSE))
+ if (G_UNLIKELY (view->selection_marks != NULL && event->is_modifier == FALSE))
mousepad_view_selection_destroy (view);
return (*GTK_WIDGET_CLASS (mousepad_view_parent_class)->key_press_event) (widget, event);
@@ -552,6 +586,27 @@
+static void
+mousepad_view_commit_handler (GtkIMContext *context,
+ const gchar *str,
+ MousepadView *view)
+{
+ _mousepad_return_if_fail (MOUSEPAD_IS_VIEW (view));
+ _mousepad_return_if_fail (GTK_IS_IM_CONTEXT (context));
+
+ /* if there is a selection, insert this string there too */
+ if (G_UNLIKELY (view->selection_marks != NULL))
+ {
+ /* debug check */
+ _mousepad_return_if_fail (gtk_text_view_get_editable (GTK_TEXT_VIEW (view)) == FALSE);
+
+ /* handle the text input for the multi selection */
+ mousepad_view_selection_key_press_event (view, str, 0, 0);
+ }
+}
+
+
+
static gboolean
mousepad_view_button_press_event (GtkWidget *widget,
GdkEventButton *event)
@@ -561,6 +616,10 @@
GtkTextIter iter, start_iter, end_iter;
GtkTextBuffer *buffer;
+ /* destroy old selection */
+ if (view->selection_marks != NULL && event->button != 3)
+ mousepad_view_selection_destroy (view);
+
/* work with vertical selection while ctrl is pressed */
if (event->state & GDK_CONTROL_MASK
&& event->x >= 0
@@ -568,65 +627,38 @@
&& event->button == 1
&& event->type == GDK_BUTTON_PRESS)
{
- /* set the vertical selection start position, inclusing textview offset */
+ /* set the vertical selection start position, including textview offset */
view->selection_start_x = event->x + textview->xoffset;
view->selection_start_y = event->y + textview->yoffset;
- /* whether this is going to be a multiple selection */
- if (view->flags != 0)
- MOUSEPAD_SET_FLAG (view->flags, MULTIPLE);
+ /* hide cursor */
+ gtk_text_view_set_cursor_visible (textview, FALSE);
- /* enable dragging */
- MOUSEPAD_SET_FLAG (view->flags, DRAGGING);
-
/* start a vertical selection timeout */
view->selection_timeout_id = g_timeout_add_full (G_PRIORITY_LOW, 50, mousepad_view_selection_timeout,
view, mousepad_view_selection_timeout_destroy);
return TRUE;
}
- else if (event->type == GDK_2BUTTON_PRESS) /* todo, button 1 en pos x coords */
+ else if (event->type == GDK_2BUTTON_PRESS && event->button == 1)
{
/* get the iter under the cursor */
gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (view), &iter,
- event->x + textview->xoffset, event->y + textview->yoffset);
+ event->x + textview->xoffset,
+ event->y + textview->yoffset);
/* try to select a whole word or space */
if (mousepad_view_selection_word_range (&iter, &start_iter, &end_iter))
{
- /* get buffer */
+ /* get the buffer */
buffer = mousepad_view_get_buffer (view);
- /* add to normal selection or multiple selection */
- if (event->state & GDK_CONTROL_MASK)
- {
- /* make it a multiple selection when there is already something selected */
- if (view->flags != 0)
- MOUSEPAD_SET_FLAG (view->flags, MULTIPLE);
+ /* select range */
+ gtk_text_buffer_select_range (buffer, &end_iter, &start_iter);
- /* add to the list */
- mousepad_view_selection_add_marks (view, &start_iter, &end_iter);
-
- /* redraw */
- mousepad_view_selection_draw (view, FALSE, FALSE);
-
- /* set the cursor at the end of the word */
- gtk_text_buffer_place_cursor (buffer, &end_iter);
- }
- else
- {
- /* select range */
- gtk_text_buffer_select_range (buffer, &start_iter, &end_iter);
- }
+ return TRUE;
}
-
- return TRUE;
}
- else if (view->flags != 0 && event->button != 3)
- {
- /* no drag started or continued */
- mousepad_view_selection_destroy (view);
- }
return (*GTK_WIDGET_CLASS (mousepad_view_parent_class)->button_press_event) (widget, event);
}
@@ -638,7 +670,6 @@
GdkEventButton *event)
{
MousepadView *view = MOUSEPAD_VIEW (widget);
- gboolean has_content;
/* end of a vertical selection */
if (G_UNLIKELY (view->selection_timeout_id != 0))
@@ -646,14 +677,12 @@
/* stop the timeout */
g_source_remove (view->selection_timeout_id);
- /* check if the selection has any content */
- has_content = MOUSEPAD_HAS_FLAG (view->flags, HAS_CONTENT);
+ /* append the selected marks */
+ mousepad_view_selection_draw (view, TRUE);
- /* prepend the selected marks */
- mousepad_view_selection_draw (view, !has_content, TRUE);
-
- /* remove the dragging flag */
- MOUSEPAD_UNSET_FLAG (view->flags, DRAGGING);
+ /* reset the drag coordinates */
+ view->selection_start_x = view->selection_end_x = -1;
+ view->selection_start_y = view->selection_end_y = -1;
}
return (*GTK_WIDGET_CLASS (mousepad_view_parent_class)->button_release_event) (widget, event);
@@ -706,85 +735,65 @@
static void
mousepad_view_selection_key_press_event (MousepadView *view,
- GdkEventKey *event,
+ const gchar *text,
+ guint keyval,
guint modifiers)
{
- GtkTextIter start, end;
+ GtkTextIter start_iter, end_iter;
GSList *li;
GtkTextBuffer *buffer;
- gboolean has_content = FALSE;
- _mousepad_return_if_fail (view->marks != NULL);
+ _mousepad_return_if_fail (view->selection_marks != NULL);
+ _mousepad_return_if_fail (view->selection_start_x == -1);
+ _mousepad_return_if_fail (view->selection_end_x == -1);
+ _mousepad_return_if_fail ((keyval == 0 && text != NULL) || keyval != 0);
+ _mousepad_return_if_fail (g_slist_length (view->selection_marks) % 2 == 0);
- /* get buffer */
+ /* get the buffer */
buffer = mousepad_view_get_buffer (view);
/* begin user action */
gtk_text_buffer_begin_user_action (buffer);
- /* delete the content when the selection has content, we're not
- * in editing more or the delete key is pressed */
- if (MOUSEPAD_HAS_FLAG (view->flags, HAS_CONTENT))
- {
- if (!MOUSEPAD_HAS_FLAG (view->flags, EDITING_MODE)
- || (event->keyval == GDK_Delete || event->keyval == GDK_KP_Delete))
- {
- mousepad_view_selection_delete_content (view);
- }
- }
+ /* delete the content of the selection when we're not in editing mode yet */
+ if (view->selection_editing == FALSE && view->selection_length > 0)
+ mousepad_view_selection_delete_content (view);
/* enter editing mode */
- MOUSEPAD_SET_FLAG (view->flags, EDITING_MODE);
+ view->selection_editing = TRUE;
- for (li = view->marks; li != NULL; li = li->next)
+ for (li = view->selection_marks; li != NULL; li = li->next)
{
/* get end iter */
- gtk_text_buffer_get_iter_at_mark (buffer, &end, li->next->data);
+ gtk_text_buffer_get_iter_at_mark (buffer, &end_iter, li->next->data);
- /* handle the events */
- switch (event->keyval)
+ /* handle the event */
+ if (keyval == GDK_Tab)
{
- case GDK_Tab:
- case GDK_KP_Tab:
- case GDK_ISO_Left_Tab:
- /* insert a (soft) tab */
- mousepad_view_indent_increase (view, &end);
- break;
-
- case GDK_BackSpace:
- /* get start iter */
- gtk_text_buffer_get_iter_at_mark (buffer, &start, li->data);
-
- /* only backspace when there is text inside the selection or ctrl is pressed */
- if (!gtk_text_iter_equal (&start, &end) || modifiers == GDK_CONTROL_MASK)
- {
- gtk_text_buffer_backspace (buffer, &end, FALSE, TRUE);
- }
- break;
-
- default:
- /* insert the typed string */
- gtk_text_buffer_insert (buffer, &end, event->string, event->length);
- break;
+ /* insert a (soft) tab */
+ mousepad_view_indent_increase (view, &end_iter);
}
-
- /* get the start iter */
- gtk_text_buffer_get_iter_at_mark (buffer, &start, li->data);
-
- if (!gtk_text_iter_equal (&start, &end))
+ else if (keyval == GDK_BackSpace)
{
- /* select the text */
- gtk_text_buffer_apply_tag (buffer, view->selection_tag, &start, &end);
+ /* get start iter */
+ gtk_text_buffer_get_iter_at_mark (buffer, &start_iter, li->data);
- /* we have some selected text */
- has_content = TRUE;
+ /* only backspace when there is text inside the selection or ctrl is pressed */
+ if (!gtk_text_iter_equal (&start_iter, &end_iter) || modifiers == GDK_CONTROL_MASK)
+ gtk_text_buffer_backspace (buffer, &end_iter, FALSE, TRUE);
}
+ else if (text != NULL)
+ {
+ /* insert the text */
+ gtk_text_buffer_insert (buffer, &end_iter, text, -1);
+ }
/* go to next element in the list */
li = li->next;
}
- /* TODO content */
+ /* redraw the content */
+ mousepad_view_selection_draw (view, FALSE);
/* end user action */
gtk_text_buffer_end_user_action (buffer);
@@ -799,9 +808,9 @@
GtkTextIter start_iter, end_iter;
GSList *li;
- _mousepad_return_if_fail (view->marks != NULL);
- _mousepad_return_if_fail (MOUSEPAD_HAS_FLAG (view->flags, HAS_CONTENT));
- _mousepad_return_if_fail (view->marks == NULL || g_slist_length (view->marks) % 2 == 0);
+ _mousepad_return_if_fail (view->selection_marks != NULL);
+ _mousepad_return_if_fail (view->selection_length > 0);
+ _mousepad_return_if_fail (g_slist_length (view->selection_marks) % 2 == 0);
/* get the buffer */
buffer = mousepad_view_get_buffer (view);
@@ -810,23 +819,23 @@
gtk_text_buffer_begin_user_action (buffer);
/* remove everything between the marks */
- for (li = view->marks; li != NULL; li = li->next)
+ for (li = view->selection_marks; li != NULL; li = li->next)
{
- /* get end iter */
+ /* get start iter */
gtk_text_buffer_get_iter_at_mark (buffer, &start_iter, li->data);
/* next element */
li = li->next;
- /* get start iter */
+ /* get end iter */
gtk_text_buffer_get_iter_at_mark (buffer, &end_iter, li->data);
- /* delete */
+ /* delete content between the iters */
gtk_text_buffer_delete (buffer, &start_iter, &end_iter);
}
- /* set the selection length to zerro */
- view->selection_length = 0;
+ /* set the selection length to -1 */
+ view->selection_length = -1;
/* end user action */
gtk_text_buffer_end_user_action (buffer);
@@ -841,264 +850,94 @@
GSList *li;
GtkTextIter start_iter, end_iter;
- _mousepad_return_if_fail (view->marks != NULL);
- _mousepad_return_if_fail (view->flags != 0);
+ _mousepad_return_if_fail (view->selection_marks != NULL);
/* get the buffer */
buffer = mousepad_view_get_buffer (view);
+ /* freeze notifications */
+ g_object_freeze_notify (G_OBJECT (buffer));
+
/* remove the selection tags */
gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter);
gtk_text_buffer_remove_tag (buffer, view->selection_tag, &start_iter, &end_iter);
/* remove all the selection marks */
- if (G_LIKELY (view->marks))
+ if (G_LIKELY (view->selection_marks))
{
/* delete marks from the buffer */
- for (li = view->marks; li != NULL; li = li->next)
+ for (li = view->selection_marks; li != NULL; li = li->next)
gtk_text_buffer_delete_mark (buffer, li->data);
/* free the list */
- g_slist_free (view->marks);
+ g_slist_free (view->selection_marks);
/* null */
- view->marks = NULL;
+ view->selection_marks = NULL;
}
- /* reset status */
- view->flags = 0;
-
/* set selection length to zerro */
view->selection_length = 0;
-}
+ /* unset editing mode */
+ view->selection_editing = FALSE;
+ /* show cursor again */
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), TRUE);
-static void
-mousepad_view_selection_cleanup_equal_marks (MousepadView *view)
-{
- GtkTextBuffer *buffer;
- GtkTextIter start_iter, end_iter;
- GSList *li, *lnext;
+ /* update buffer status */
+ g_object_notify (G_OBJECT (buffer), "has-selection");
- _mousepad_return_if_fail (view->marks == NULL || g_slist_length (view->marks) % 2 == 0);
-
- /* get buffer */
- buffer = mousepad_view_get_buffer (view);
-
- for (li = view->marks; li != NULL; li = lnext)
- {
- /* get iters */
- gtk_text_buffer_get_iter_at_mark (buffer, &start_iter, li->data);
- gtk_text_buffer_get_iter_at_mark (buffer, &end_iter, li->next->data);
-
- /* get next element */
- lnext = li->next->next;
-
- if (gtk_text_iter_equal (&start_iter, &end_iter))
- {
- gtk_text_buffer_delete_mark (buffer, li->next->data);
- view->marks = g_slist_delete_link (view->marks, li->next);
-
- gtk_text_buffer_delete_mark (buffer, li->data);
- view->marks = g_slist_delete_link (view->marks, li);
- }
- }
+ /* allow notifications again */
+ g_object_thaw_notify (G_OBJECT (buffer));
}
static void
-mousepad_view_selection_add_marks (MousepadView *view,
- GtkTextIter *start_iter,
- GtkTextIter *end_iter)
-{
- GtkTextBuffer *buffer;
- GtkTextIter iter;
- GtkTextMark *start_mark, *end_mark;
- GSList *li, *lnext;
- gboolean is_start = FALSE;
- gboolean handled_start = FALSE;
- gint compare, length;
-
- _mousepad_return_if_fail (view->marks == NULL || g_slist_length (view->marks) % 2 == 0);
-
- /* make sure the iters are correctly sorted */
- gtk_text_iter_order (start_iter, end_iter);
-
- /* get buffer */
- buffer = mousepad_view_get_buffer (view);
-
- /* calculate length of selection */
- length = gtk_text_iter_get_line_offset (end_iter) - gtk_text_iter_get_line_offset (start_iter);
-
- /* add to selection length */
- view->selection_length += length;
-
- /* create marks */
- start_mark = gtk_text_buffer_create_mark (buffer, NULL, start_iter, TRUE);
- end_mark = gtk_text_buffer_create_mark (buffer, NULL, end_iter, FALSE);
-
- for (li = view->marks; li != NULL; li = lnext)
- {
- /* type of mark */
- is_start = !is_start;
-
- /* determine next element in the list */
- lnext = li->next;
-
- /* get the iter of a mark in the list */
- gtk_text_buffer_get_iter_at_mark (buffer, &iter, li->data);
-
- /* search the insert position of the start mark */
- if (!handled_start)
- {
- /* compare iters */
- compare = gtk_text_iter_compare (&iter, start_iter);
-
- if (compare >= 0)
- {
- if (compare == 0 && gtk_text_iter_equal (start_iter, end_iter))
- {
- /* zerro width insert on top of an existing mark, skip those */
- gtk_text_buffer_delete_mark (buffer, start_mark);
- gtk_text_buffer_delete_mark (buffer, end_mark);
-
- break;
- }
- else if (is_start)
- {
- /* inserted before a start mark */
- view->marks = g_slist_insert_before (view->marks, li, start_mark);
- }
- else
- {
- /* inserted after a start mark, remove the new one */
- gtk_text_buffer_delete_mark (buffer, start_mark);
- }
-
- /* we've handled the start mark */
- handled_start = TRUE;
- }
- }
-
- /* handle the end mark */
- if (handled_start)
- {
- /* check if the iter can be merged inside our selection */
- if (gtk_text_iter_compare (&iter, end_iter) < 0)
- {
- /* delete the existing mark from the buffer */
- gtk_text_buffer_delete_mark (buffer, li->data);
-
- /* delete item from the list */
- view->marks = g_slist_delete_link (view->marks, li);
- }
- else
- {
- /* handle the end mark */
- if (is_start)
- view->marks = g_slist_insert_before (view->marks, li, end_mark);
- else
- gtk_text_buffer_delete_mark (buffer, end_mark);
-
- break;
- }
- }
- }
-
- /* reached end of list */
- if (li == NULL)
- {
- /* still not start mark added, append it to the list */
- if (!handled_start)
- view->marks = g_slist_append (view->marks, start_mark);
-
- /* append end mark */
- view->marks = g_slist_append (view->marks, end_mark);
- }
-}
-
-
-
-static void
mousepad_view_selection_draw (MousepadView *view,
- gboolean draw_cursors,
- gboolean add_marks)
+ gboolean append)
{
GtkTextBuffer *buffer;
GtkTextView *textview = GTK_TEXT_VIEW (view);
GtkTextIter start_iter, end_iter;
+ GdkWindow *window;
+ gint y, y_begin, y_height, y_end;
gint line_x, line_y;
- gint y, y_begin, y_height, y_end;
- gboolean has_content = FALSE;
GdkRectangle rect;
- GdkWindow *window;
+ gint length = 0;
+ gint visible_start_y = 0;
+ GtkTextMark *start_mark, *end_mark;
GSList *li;
- _mousepad_return_if_fail (view->marks == NULL || g_slist_length (view->marks) % 2 == 0);
+ _mousepad_return_if_fail (MOUSEPAD_IS_VIEW (view));
+ _mousepad_return_if_fail (view->selection_marks == NULL || g_slist_length (view->selection_marks) % 2 == 0);
/* get the buffer */
buffer = mousepad_view_get_buffer (view);
+ /* freeze buffer notifications */
+ g_object_freeze_notify (G_OBJECT (buffer));
+
/* get the drawable window */
window = gtk_text_view_get_window (textview, GTK_TEXT_WINDOW_TEXT);
- if (MOUSEPAD_HAS_FLAG (view->flags, HAS_CONTENT))
+ /* cleanup the old selection */
+ if (view->selection_length > 0)
{
/* remove the old tags */
gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter);
gtk_text_buffer_remove_tag (buffer, view->selection_tag, &start_iter, &end_iter);
}
- else
+ else if (view->selection_length == -1)
{
/* invalidate the window so no retangles are left */
gtk_widget_queue_draw (GTK_WIDGET (view));
}
- /* if the selection already contains marks, show them first */
- for (li = view->marks; li != NULL; li = li->next)
+ /* draw the dragging selection or the marks in the list */
+ if (view->selection_start_y != -1 && view->selection_end_y != -1)
{
- /* get the end iter */
- gtk_text_buffer_get_iter_at_mark (buffer, &start_iter, li->data);
-
- /* next element in the list */
- li = li->next;
-
- if (draw_cursors)
- {
- /* get the iter location and size */
- gtk_text_view_get_iter_location (textview, &start_iter, &rect);
-
- /* calculate line coordinates */
- line_x = rect.x - textview->xoffset;
- line_y = rect.y - textview->yoffset;
-
- /* draw a line in front of the iter */
- gdk_draw_line (GDK_DRAWABLE (window),
- GTK_WIDGET (view)->style->text_gc[GTK_STATE_NORMAL],
- line_x, line_y, line_x, line_y + rect.height - 1);
- }
- else
- {
- /* get the start iter */
- gtk_text_buffer_get_iter_at_mark (buffer, &end_iter, li->data);
-
- /* check if the iters are not equal */
- if (!gtk_text_iter_equal (&start_iter, &end_iter))
- {
- /* apply tag */
- gtk_text_buffer_apply_tag (buffer, view->selection_tag, &start_iter, &end_iter);
-
- /* this selection has atleast some content */
- has_content = TRUE;
- }
- }
- }
-
- /* when we're still dragging, show the selection in the area */
- if (MOUSEPAD_HAS_FLAG (view->flags, DRAGGING))
- {
/* get the start and end iter */
gtk_text_view_get_iter_at_location (textview, &start_iter, 0, view->selection_start_y);
gtk_text_view_get_iter_at_location (textview, &end_iter, 0, view->selection_end_y);
@@ -1113,6 +952,13 @@
/* make sure atleast one line is selected */
y_end += y_height;
+ /* get the visible area */
+ if (G_LIKELY (append == FALSE))
+ {
+ visible_start_y = MIN (y_begin, y_end);
+ visible_start_y = MAX (visible_start_y, textview->yoffset);
+ }
+
/* walk the lines inside the selection area */
for (y = y_begin; y < y_end; y += y_height)
{
@@ -1120,7 +966,17 @@
gtk_text_view_get_iter_at_location (textview, &start_iter, view->selection_start_x, y);
gtk_text_view_get_iter_at_location (textview, &end_iter, view->selection_end_x, y);
- if (draw_cursors)
+ /* make sure the iters are correctly sorted */
+ gtk_text_iter_order (&start_iter, &end_iter);
+
+ /* calculate length of selection */
+ length += gtk_text_iter_get_line_offset (&end_iter) - gtk_text_iter_get_line_offset (&start_iter);
+
+ /* continue if this iter is outside the visible area */
+ if (y < visible_start_y)
+ continue;
+
+ if (length == 0)
{
/* get the iter location and size */
gtk_text_view_get_iter_location (textview, &end_iter, &rect);
@@ -1131,50 +987,82 @@
/* draw a line in front of the iter */
gdk_draw_line (GDK_DRAWABLE (window),
- GTK_WIDGET (view)->style->text_gc[GTK_STATE_NORMAL],
+ GTK_WIDGET (view)->style->base_gc[GTK_STATE_SELECTED],
line_x, line_y, line_x, line_y + rect.height - 1);
}
else if (!gtk_text_iter_equal (&start_iter, &end_iter))
{
/* apply tag */
gtk_text_buffer_apply_tag (buffer, view->selection_tag, &start_iter, &end_iter);
-
- /* this selection has atlea