[Xfce4-commits] <mousepad:master> * 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-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. * 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 un needed 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.

Nick Schermer noreply at xfce.org
Sat May 5 21:30:26 CEST 2012


Updating branch refs/heads/master
         to 2beb0bf4ad103e2bc112b516f6253157e821e2a7 (commit)
       from a20de9eada02c7cc07cda472ea4f197c3e3b97aa (commit)

commit 2beb0bf4ad103e2bc112b516f6253157e821e2a7
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Apr 28 18:59:18 2007 +0000

    * 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-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.
    * 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.
    
    
    (Old svn revision: 25654)

 ChangeLog                       |  220 +++++++++------
 TODO                            |   14 +-
 mousepad/main.c                 |    2 +-
 mousepad/mousepad-application.c |  247 ++++++++--------
 mousepad/mousepad-application.h |   17 +-
 mousepad/mousepad-dbus.c        |    6 +-
 mousepad/mousepad-document.c    |    2 +-
 mousepad/mousepad-document.h    |    2 +
 mousepad/mousepad-preferences.c |   56 +++-
 mousepad/mousepad-search-bar.c  |   17 +-
 mousepad/mousepad-statusbar.c   |   93 +++----
 mousepad/mousepad-statusbar.h   |    6 +-
 mousepad/mousepad-window-ui.xml |    4 +-
 mousepad/mousepad-window.c      |  627 ++++++++++++++++++++++++++++-----------
 mousepad/mousepad-window.h      |    5 +
 15 files changed, 846 insertions(+), 472 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4c0e334..dfa8d47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+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-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.
+	* 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.
+
+
 2007-04-21	Nick Schermer <nick at xfce.org>
 	* TODO: Fix some typos and add some new ideas and reminders.
 
@@ -16,109 +45,125 @@
 
 
 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.
+	* 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.
 
 
 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. This is not finished yet, but it's a start.
-	* mousepad/Makefile.am, mousepad/mousepad-csource.pl: Remove my perl script
-	  because it has some problems. Use exo-csource instead.
+	* 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 over 10x faster then the gtk version. This gives a nice
+	* 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.
+	* 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.
-	* 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).
+	* 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).
 	* 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-window.c, * mousepad/mousepad-screen.{c,h}: Basic
-	  support for document reloading.
+	* 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>
 
@@ -126,49 +171,56 @@
 	  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/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/*: Add function destriptions for Erik (and others) :-).
+	  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).
+
 
 2007-02-18	Nick Schermer <nick at xfce.org>
 
 	* mousepad/mousepad-window.c: Improve the menu tooltips.
 
+
 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.
-	* 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.
+	* 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/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: Added first parts of code for a statusbar.
+	* 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.desktop.in.in, Mousepad.desktop.in.in: Mousepad executable
-	  is now lowercase again.
-	* mousepad/mousepad-screen.c: Remove unused signals from the Class.
+	* Mousepad.desktop.in.in, Mousepad.desktop.in.in: Mousepad
+	  executable is now lowercase again.
+	* mousepad/mousepad-screen.c: Remove unused signals from the
+	   Class.
 
 2007-02-17	Nick Schermer <nick at xfce.org>
 
diff --git a/TODO b/TODO
index 0182096..21da6cc 100644
--- a/TODO
+++ b/TODO
@@ -13,24 +13,14 @@ Interface
 - Tab font color when the file is modified or read only.
 - Test the application with a screen reader and add Atk objects
   where needed.
-- Support for tab DND between windows.
-- Support for dropping uris inside the window and then open them
-  in a new tab.
+- Allow dropping of tabs and uri's inside the textview, menubar
+  and statusbar is already possible.
 - Cleanup the menus and make them consistent. For example: we're
   using both file and document atm. The name of the Go menu should
   also be changed to something more descriptive.
 - You can't use the Ctrl - v/c/x buttons in the type-ahead bar
   because they are 'registered' by the textview/ui.
-- Maybe add a document icon to the recent menu. In a perfect
-  situation we shoud detect the mime from the file and not by using
-  the mime info from GtkRecentInfo, but this is probably too much
-  work for Mousepad.
-- Set the mime type when saving the recent file, not for us, but for
-  applications that might use the entire recent history.
 - When hitting the enter button in the jump dialog, we should jump.
-- Remove the frame borders from the statusbar (we can entirely drop
-  the frames) and add a resize grip. This way it will look like a
-  real Gtk statusbar.
 
 
 Code
diff --git a/mousepad/main.c b/mousepad/main.c
index 22c188b..9f339de 100644
--- a/mousepad/main.c
+++ b/mousepad/main.c
@@ -170,7 +170,7 @@ main (gint argc, gchar **argv)
   application = mousepad_application_get ();
 
   /* open an empty window (with an empty document or the files) */
-  mousepad_application_open_window (application, NULL, working_directory, filenames);
+  mousepad_application_new_window_with_files (application, NULL, working_directory, filenames);
 
   /* cleanup */
   g_free (working_directory);
diff --git a/mousepad/mousepad-application.c b/mousepad/mousepad-application.c
index 9b3caa6..7054862 100644
--- a/mousepad/mousepad-application.c
+++ b/mousepad/mousepad-application.c
@@ -23,15 +23,25 @@
 
 #include <mousepad/mousepad-private.h>
 #include <mousepad/mousepad-application.h>
+#include <mousepad/mousepad-types.h>
+#include <mousepad/mousepad-document.h>
 #include <mousepad/mousepad-window.h>
 
 
 
-static void mousepad_application_class_init       (MousepadApplicationClass  *klass);
-static void mousepad_application_init             (MousepadApplication       *application);
-static void mousepad_application_window_destroyed (GtkWidget                 *window,
-                                                   MousepadApplication       *application);
-static void mousepad_application_finalize         (GObject                   *object);
+static void        mousepad_application_class_init                (MousepadApplicationClass  *klass);
+static void        mousepad_application_init                      (MousepadApplication       *application);
+static void        mousepad_application_finalize                  (GObject                   *object);
+static void        mousepad_application_window_destroyed          (GtkWidget                 *window,
+                                                                   MousepadApplication        *application);
+static GtkWidget  *mousepad_application_create_window             (MousepadApplication        *application);
+static void        mousepad_application_new_window_with_document  (MousepadWindow             *existing,
+                                                                   MousepadDocument           *document,
+                                                                   MousepadApplication        *application);
+static void        mousepad_application_new_window                (MousepadWindow             *existing,
+                                                                   MousepadApplication        *application);
+
+
 
 
 
@@ -45,7 +55,7 @@ struct _MousepadApplication
   GObject  __parent__;
 
   /* internal list of all the opened windows */
-  GList   *windows;
+  GSList  *windows;
 };
 
 
@@ -54,28 +64,18 @@ static GObjectClass *mousepad_application_parent_class;
 
 
 
-/**
- * mousepad_application_get:
- *
- * Returns the global shared #MousepadApplication instance.
- * This method takes a reference on the global instance
- * for the caller, so you must call g_object_unref()
- * on it when done.
- *
- * Return value: the shared #MousepadApplication instance.
- **/
 MousepadApplication*
 mousepad_application_get (void)
 {
   static MousepadApplication *application = NULL;
 
-  if (G_UNLIKELY (application == NULL))
+  if (G_LIKELY (application))
     {
-      application = g_object_new (MOUSEPAD_TYPE_APPLICATION, NULL);
+      g_object_ref (G_OBJECT (application));
     }
   else
     {
-      g_object_ref (G_OBJECT (application));
+      application = g_object_new (MOUSEPAD_TYPE_APPLICATION, NULL);
     }
 
   return application;
@@ -123,7 +123,7 @@ mousepad_application_init (MousepadApplication *application)
   gchar *path;
 
   /* check if we have a saved accel map */
-  path = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, PACKAGE_NAME "/accels.scm");
+  path = xfce_resource_lookup (XFCE_RESOURCE_CONFIG, PACKAGE_NAME G_DIR_SEPARATOR_S "accels.scm");
   if (G_LIKELY (path != NULL))
     {
       /* load the accel map */
@@ -138,11 +138,11 @@ static void
 mousepad_application_finalize (GObject *object)
 {
   MousepadApplication *application = MOUSEPAD_APPLICATION (object);
-  GList               *li;
+  GSList              *li;
   gchar               *path;
 
   /* save the current accel map */
-  path = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, PACKAGE_NAME "/accels.scm", TRUE);
+  path = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, PACKAGE_NAME G_DIR_SEPARATOR_S "accels.scm", TRUE);
   if (G_LIKELY (path != NULL))
     {
       /* save the accel map */
@@ -157,141 +157,154 @@ mousepad_application_finalize (GObject *object)
       gtk_widget_destroy (GTK_WIDGET (li->data));
     }
 
-  g_list_free (application->windows);
+  g_slist_free (application->windows);
 
   (*G_OBJECT_CLASS (mousepad_application_parent_class)->finalize) (object);
 }
 
 
 
-/**
- * mousepad_application_get_windows:
- * @application: A #MousepadApplication.
- *
- * Returns a list of #MousepadWindows currently registered by the
- * #MousepadApplication. The returned list is owned by the caller and
- * must be freed using g_list_free().
- *
- * Return value: the list of regular #MousepadWindows in @application.
- **/
-GList*
-mousepad_application_get_windows (MousepadApplication *application)
+gboolean
+mousepad_application_has_windows (MousepadApplication *application)
 {
-  GList *windows = NULL;
-  GList *li;
+  _mousepad_return_val_if_fail (MOUSEPAD_IS_APPLICATION (application), FALSE);
+
+  return (application->windows != NULL);
+}
 
-  _mousepad_return_val_if_fail (MOUSEPAD_IS_APPLICATION (application), NULL);
 
-  for (li = application->windows; li != NULL; li = li->next)
-    if (G_LIKELY (MOUSEPAD_IS_WINDOW (li->data)))
-      windows = g_list_prepend (windows, li->data);
 
-  return windows;
+static void
+mousepad_application_window_destroyed (GtkWidget           *window,
+                                       MousepadApplication *application)
+{
+  _mousepad_return_if_fail (GTK_IS_WINDOW (window));
+  _mousepad_return_if_fail (MOUSEPAD_IS_APPLICATION (application));
+  _mousepad_return_if_fail (g_slist_find (application->windows, window) != NULL);
+
+  /* remove the window from the list */
+  application->windows = g_slist_remove (application->windows, window);
+
+  /* quit if there are no windows opened */
+  if (application->windows == NULL)
+    gtk_main_quit ();
 }
 
 
 
-/**
- * mousepad_application_has_windows:
- * @application : a #MousepadApplication.
- *
- * Returns %TRUE if @application controls atleast one window.
- *
- * Return value: %TRUE if @application controls atleast one window.
- **/
-gboolean
-mousepad_application_has_windows (MousepadApplication *application)
+void
+mousepad_application_take_window (MousepadApplication *application,
+                                  GtkWindow           *window)
 {
-  _mousepad_return_val_if_fail (MOUSEPAD_IS_APPLICATION (application), FALSE);
+  _mousepad_return_if_fail (MOUSEPAD_IS_WINDOW (window));
+  _mousepad_return_if_fail (MOUSEPAD_IS_APPLICATION (application));
+  _mousepad_return_if_fail (g_slist_find (application->windows, window) == NULL);
 
-  return (application->windows != NULL);
+  /* connect to the "destroy" signal */
+  g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (mousepad_application_window_destroyed), application);
+
+  /* add the window to our internal list */
+  application->windows = g_slist_append (application->windows, window);
 }
 
 
 
-/**
- * mousepad_application_open_window:
- * @application       : A #MousepadApplication.
- * @screen            : The #GdkScreen on which to open the window or %NULL
- *                      to open on the default screen.
- * @working_directory : The default working directory for this window.
- * @filenames         : A list of filenames we try to open in tabs. The file names
- *                      can either be absolute paths, supported URIs or relative file
- *                      names to @working_directory or %NULL for an untitled document.
- *
- * Opens a new Mousepad window and tries to open all the file names in tabs. If
- * @filename is %NULL an empty Untiled documenten will be opened in the window.
- **/
-void
-mousepad_application_open_window (MousepadApplication  *application,
-                                  GdkScreen            *screen,
-                                  const gchar          *working_directory,
-                                  gchar               **filenames)
+static GtkWidget *
+mousepad_application_create_window (MousepadApplication *application)
 {
   GtkWidget *window;
-  gboolean   succeed;
-
-  _mousepad_return_if_fail (MOUSEPAD_IS_APPLICATION (application));
-  _mousepad_return_if_fail (screen == NULL || GDK_IS_SCREEN (screen));
 
   /* create a new window */
   window = mousepad_window_new ();
 
-  /* get the screen */
-  if (G_UNLIKELY (screen == NULL))
-    screen = gdk_screen_get_default ();
+  /* hook up the new window */
+  mousepad_application_take_window (application, GTK_WINDOW (window));
 
-  /* move to the correct screen */
-  gtk_window_set_screen (GTK_WINDOW (window), screen);
+  /* connect signals */
+  g_signal_connect (G_OBJECT (window), "new-window-with-document", G_CALLBACK (mousepad_application_new_window_with_document), application);
+  g_signal_connect (G_OBJECT (window), "new-window", G_CALLBACK (mousepad_application_new_window), application);
 
-  /* open the filenames or an empty tab */
-  if (filenames != NULL && *filenames != NULL)
-    {
-      /* try to open the files */
-      succeed = mousepad_window_open_files (MOUSEPAD_WINDOW (window), working_directory, filenames);
+  return window;
+}
 
-      /* if we failed, open an empty tab */
-      if (G_UNLIKELY (succeed == FALSE))
-        mousepad_window_open_tab (MOUSEPAD_WINDOW (window), NULL);
-    }
-  else
-    {
-      mousepad_window_open_tab (MOUSEPAD_WINDOW (window), NULL);
-    }
 
-  /* connect to the "destroy" signal */
-  g_signal_connect (G_OBJECT (window), "destroy",
-                    G_CALLBACK (mousepad_application_window_destroyed), application);
 
-  /* add the window to our internal list */
-  application->windows = g_list_prepend (application->windows, window);
+static void
+mousepad_application_new_window_with_document (MousepadWindow      *existing,
+                                               MousepadDocument    *document,
+                                               MousepadApplication *application)
+{
+  GtkWidget *window;
+  GdkScreen *screen;
+
+  _mousepad_return_if_fail (MOUSEPAD_IS_WINDOW (existing));
+  _mousepad_return_if_fail (document == NULL || MOUSEPAD_IS_DOCUMENT (document));
+  _mousepad_return_if_fail (MOUSEPAD_IS_APPLICATION (application));
+
+  /* create a new window (signals added and already hooked up) */
+  window = mousepad_application_create_window (application);
 
+  /* place the new window on the same screen as the existing window */
+  screen = gtk_window_get_screen (GTK_WINDOW (existing));
+  if (G_LIKELY (screen != NULL))
+    gtk_window_set_screen (GTK_WINDOW (window), screen);
+
+  /* create an empty document if no document was send */
+  if (document == NULL)
+    document = MOUSEPAD_DOCUMENT (mousepad_document_new ());
+
+  /* add the document to the new window */
+  mousepad_window_add (MOUSEPAD_WINDOW (window), document);
+
+  /* show the window */
   gtk_widget_show (window);
 }
 
 
 
-/**
- * mousepad_application_window_destroyed:
- * @window      : The window that has been destroyed.
- * @application : A #MousepadApplication.
- *
- * This function removes @window from the registed windows in @application.
- * When there are no more windows left in @application, the application is
- * terminated.
- **/
 static void
-mousepad_application_window_destroyed (GtkWidget           *window,
-                                       MousepadApplication *application)
+mousepad_application_new_window (MousepadWindow      *existing,
+                                 MousepadApplication *application)
 {
-  _mousepad_return_if_fail (GTK_IS_WINDOW (window));
+  /* trigger new document function */
+  mousepad_application_new_window_with_document (existing, NULL, application);
+}
+
+
+
+void
+mousepad_application_new_window_with_files (MousepadApplication  *application,
+                                            GdkScreen            *screen,
+                                            const gchar          *working_directory,
+                                            gchar               **filenames)
+{
+  GtkWidget        *window;
+  gboolean          succeed = FALSE;
+  MousepadDocument *document;
+
   _mousepad_return_if_fail (MOUSEPAD_IS_APPLICATION (application));
-  _mousepad_return_if_fail (g_list_find (application->windows, window) != NULL);
+  _mousepad_return_if_fail (screen == NULL || GDK_IS_SCREEN (screen));
 
-  /* remove the window from the list */
-  application->windows = g_list_remove (application->windows, window);
+  /* create a new window (signals added and already hooked up) */
+  window = mousepad_application_create_window (application);
 
-  /* quit if there are no windows opened */
-  if (application->windows == NULL)
-    gtk_main_quit ();
+  /* place the window on the right screen */
+  gtk_window_set_screen (GTK_WINDOW (window), screen ? screen : gdk_screen_get_default ());
+
+  /* try to open the files */
+  if (working_directory && filenames && g_strv_length (filenames))
+    succeed = mousepad_window_open_files (MOUSEPAD_WINDOW (window), working_directory, filenames);
+
+  /* open an empty document */
+  if (succeed == FALSE)
+    {
+      /* create a new document */
+      document = MOUSEPAD_DOCUMENT (mousepad_document_new ());
+
+      /* add the document to the new window */
+      mousepad_window_add (MOUSEPAD_WINDOW (window), document);
+    }
+
+  /* show the window */
+  gtk_widget_show (window);
 }
diff --git a/mousepad/mousepad-application.h b/mousepad/mousepad-application.h
index 4920b12..0b18964 100644
--- a/mousepad/mousepad-application.h
+++ b/mousepad/mousepad-application.h
@@ -32,18 +32,19 @@ typedef struct _MousepadApplication      MousepadApplication;
 #define MOUSEPAD_IS_APPLICATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MOUSEPAD_TYPE_APPLICATION))
 #define MOUSEPAD_APPLICATION_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), MOUSEPAD_TYPE_APPLICATION, MousepadApplicationClass))
 
-GType                mousepad_application_get_type    (void) G_GNUC_CONST;
+GType                mousepad_application_get_type               (void) G_GNUC_CONST;
 
-MousepadApplication *mousepad_application_get         (void);
+MousepadApplication *mousepad_application_get                    (void);
 
-GList               *mousepad_application_get_windows (MousepadApplication  *application);
+gboolean             mousepad_application_has_windows            (MousepadApplication  *application);
 
-gboolean             mousepad_application_has_windows (MousepadApplication  *application);
+void                 mousepad_application_take_window            (MousepadApplication  *application,
+                                                                  GtkWindow            *window);
 
-void                 mousepad_application_open_window (MousepadApplication  *application,
-                                                       GdkScreen            *screen,
-                                                       const gchar          *working_directory,
-                                                       gchar               **filenames);
+void                 mousepad_application_new_window_with_files  (MousepadApplication  *application,
+                                                                  GdkScreen            *screen,
+                                                                  const gchar          *working_directory,
+                                                                  gchar               **filenames);
 
 G_END_DECLS
 
diff --git a/mousepad/mousepad-dbus.c b/mousepad/mousepad-dbus.c
index ad2467e..12760f3 100644
--- a/mousepad/mousepad-dbus.c
+++ b/mousepad/mousepad-dbus.c
@@ -180,17 +180,13 @@ mousepad_dbus_service_launch_files (MousepadDBusService  *dbus_service,
                                     GError              **error)
 {
   MousepadApplication *application;
-   GdkScreen          *screen;
 
   _mousepad_return_val_if_fail (g_path_is_absolute (working_directory), FALSE);
   _mousepad_return_val_if_fail (error == NULL || *error == NULL, FALSE);
 
-  /* get the default screen */
-  screen = gdk_screen_get_default ();
-
   /* open a mousepad window */
   application = mousepad_application_get ();
-  mousepad_application_open_window (application, screen, working_directory, filenames);
+  mousepad_application_new_window_with_files (application, NULL, working_directory, filenames);
   g_object_unref (G_OBJECT (application));
 
   return TRUE;
diff --git a/mousepad/mousepad-document.c b/mousepad/mousepad-document.c
index 035db81..d7d7c1f 100644
--- a/mousepad/mousepad-document.c
+++ b/mousepad/mousepad-document.c
@@ -1130,7 +1130,7 @@ mousepad_document_get_tab_label (MousepadDocument *document)
   gtk_widget_show (hbox);
 
   /* the ebox */
-  document->ebox = g_object_new (GTK_TYPE_EVENT_BOX, "border-width", 2, NULL);
+  document->ebox = g_object_new (GTK_TYPE_EVENT_BOX, "border-width", 2, "visible-window", FALSE, NULL);
   gtk_box_pack_start (GTK_BOX (hbox), document->ebox, TRUE, TRUE, 0);
   gtk_widget_show (document->ebox);
 
diff --git a/mousepad/mousepad-document.h b/mousepad/mousepad-document.h
index fe4ba64..28e01fa 100644
--- a/mousepad/mousepad-document.h
+++ b/mousepad/mousepad-document.h
@@ -22,6 +22,8 @@
 
 G_BEGIN_DECLS
 
+#include <mousepad/mousepad-types.h>
+
 typedef struct _MousepadDocumentClass MousepadDocumentClass;
 typedef struct _MousepadDocument      MousepadDocument;
 
diff --git a/mousepad/mousepad-preferences.c b/mousepad/mousepad-preferences.c
index cb30743..a602057 100644
--- a/mousepad/mousepad-preferences.c
+++ b/mousepad/mousepad-preferences.c
@@ -49,12 +49,14 @@ enum
 {
   PROP_0,
   PROP_FONT_NAME,
+  PROP_LAST_AUTO_INDENT,
+  PROP_LAST_LINE_NUMBERS,
   PROP_LAST_MATCH_CASE,
   PROP_LAST_STATUSBAR_VISIBLE,
   PROP_LAST_WINDOW_HEIGHT,
   PROP_LAST_WINDOW_WIDTH,
+  PROP_LAST_WORD_WRAP,
   PROP_LAST_WRAP_AROUND,
-  PROP_WORD_WRAP,
   PROP_MISC_ALWAYS_SHOW_TABS,
   PROP_MISC_CYCLE_TABS,
   PROP_MISC_SHOW_FULL_PATH_IN_TITLE,
@@ -192,6 +194,32 @@ mousepad_preferences_class_init (MousepadPreferencesClass *klass)
                                                         MOUSEPAD_PARAM_READWRITE));
 
   /**
+   * MousepadPreferences:last-auto-indent
+   *
+   * Whether we auto indent lines
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_LAST_AUTO_INDENT,
+                                   g_param_spec_boolean ("last-auto-indent",
+                                                         "last-auto-indent",
+                                                         "last-auto-indent",
+                                                         FALSE,
+                                                         MOUSEPAD_PARAM_READWRITE));
+
+  /**
+   * MousepadPreferences:last-line-numbers
+   *
+   * Whether line numbers are visible
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_LAST_LINE_NUMBERS,
+                                   g_param_spec_boolean ("last-line-numbers",
+                                                         "last-line-numbers",
+                                                         "last-line-numbers",
+                                                         FALSE,
+                                                         MOUSEPAD_PARAM_READWRITE));
+
+  /**
    * MousepadPreferences:last-match-case
    *
    * Whether to enable match case in the search bar.
@@ -246,6 +274,19 @@ mousepad_preferences_class_init (MousepadPreferencesClass *klass)
                                                      MOUSEPAD_PARAM_READWRITE));
 
   /**
+   * MousepadPreferences:last-word-wrap
+   *
+   * Whether word wrapping is enabled.
+   **/
+  g_object_class_install_property (gobject_class,
+                                   PROP_LAST_WORD_WRAP,
+                                   g_param_spec_boolean ("last-word-wrap",
+                                                         "last-word-wrap",
+                                                         "last-word-wrap",
+                                                         FALSE,
+                                                         MOUSEPAD_PARAM_READWRITE));
+
+  /**
    * MousepadPreferences:last-wrap-around
    *
    * Whether to enable wrap around in the search bar.
@@ -259,19 +300,6 @@ mousepad_preferences_class_init (MousepadPreferencesClass *klass)
                                                          MOUSEPAD_PARAM_READWRITE));
 
   /**
-   * MousepadPreferences:word-wrap
-   *
-   * Whether word wrapping is enabled.
-   **/
-  g_object_class_install_property (gobject_class,
-                                   PROP_WORD_WRAP,
-                                   g_param_spec_boolean ("word-wrap",
-                                                         "word-wrap",
-                                                         "word-wrap",
-                                                         FALSE,
-                                                         MOUSEPAD_PARAM_READWRITE));
-
-  /**
    * MousepadPreferences:misc-always-show-tabs
    *
    * Whether tabs are always visible. By default the tabs are hidden
diff --git a/mousepad/mousepad-search-bar.c b/mousepad/mousepad-search-bar.c
index ed65616..f9c3e05 100644
--- a/mousepad/mousepad-search-bar.c
+++ b/mousepad/mousepad-search-bar.c
@@ -181,11 +181,18 @@ mousepad_search_bar_class_init (MousepadSearchBarClass *klass)
   binding_set = gtk_binding_set_by_class (klass);
   gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "hide-bar", 0);
 
-  /* style to hide the shadow around the toolbar and to add a 2px space between the label
-   * and the icon in a toolbar button */
-  gtk_rc_parse_string ("style \"mousepad-search-bar-style\"{GtkToolbar::shadow-type=GTK_SHADOW_NONE}\n"
-                       "class\"MousepadSearchBar\"style\"mousepad-search-bar-style\"\n"
-                       "style \"mousepad-button-style\"{GtkToolButton::icon-spacing=2}\n"
+  /* 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"
+                       "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"
                        "widget \"MousepadWindow.*.Gtk*ToolButton\" style \"mousepad-button-style\"\n");
 }
 
diff --git a/mousepad/mousepad-statusbar.c b/mousepad/mousepad-statusbar.c
index e75b0b1..cf2926d 100644
--- a/mousepad/mousepad-statusbar.c
+++ b/mousepad/mousepad-statusbar.c
@@ -23,6 +23,7 @@
 
 #include <mousepad/mousepad-private.h>
 #include <mousepad/mousepad-statusbar.h>
+#include <mousepad/mousepad-window.h>
 
 
 
@@ -42,18 +43,17 @@ enum
 
 struct _MousepadStatusbarClass
 {
-  GtkHBoxClass __parent__;
+  GtkStatusbarClass __parent__;
 };
 
 struct _MousepadStatusbar
 {
-  GtkHBox             __parent__;
+  GtkStatusbar        __parent__;
 
   /* whether overwrite is enabled */
   guint               overwrite_enabled : 1;
 
-  /* the three statusbar labels */
-  GtkWidget          *label;
+  /* extra labels in the statusbar */
   GtkWidget          *position;
   GtkWidget          *overwrite;
 };
@@ -79,7 +79,7 @@ mousepad_statusbar_get_type (void)
 
   if (G_UNLIKELY (type == G_TYPE_INVALID))
     {
-      type = g_type_register_static_simple (GTK_TYPE_HBOX,
+      type = g_type_register_static_simple (GTK_TYPE_STATUSBAR,
                                             I_("MousepadStatusbar"),
                                             sizeof (MousepadStatusbarClass),
                                             (GClassInitFunc) mousepad_statusbar_class_init,
@@ -96,7 +96,7 @@ mousepad_statusbar_get_type (void)
 static void
 mousepad_statusbar_class_init (MousepadStatusbarClass *klass)
 {
-  GObjectClass *gobject_class;
+  GObjectClass   *gobject_class;
 
   gobject_class = G_OBJECT_CLASS (klass);
 
@@ -107,6 +107,13 @@ mousepad_statusbar_class_init (MousepadStatusbarClass *klass)
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__BOOLEAN,
                   G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+
+  /* don't show the statusbar frame */
+  gtk_rc_parse_string ("style \"mousepad-statusbar-style\"\n"
+                       "  {\n"
+                       "    GtkStatusbar::shadow-type = GTK_SHADOW_NONE\n"
+                       "  }\n"
+                       "class \"MousepadStatusbar\" style \"mousepad-statusbar-style\"\n");
 }
 
 
@@ -114,52 +121,26 @@ mousepad_statusbar_class_init (MousepadStatusbarClass *klass)
 static void
 mousepad_statusbar_init (MousepadStatusbar *statusbar)
 {
-  GtkWidget *frame, *ebox;
-
-  /* spacing between the 3 frames */
-  gtk_box_set_spacing (GTK_BOX (statusbar), 3);
+  GtkWidget *ebox;
 
-  /* tooltip entry */
-  frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
-  gtk_box_pack_start (GTK_BOX (statusbar), frame, TRUE, TRUE, 0);
-  gtk_widget_show (frame);
-
-  statusbar->label = gtk_label_new (NULL);
-  gtk_label_set_single_line_mode (GTK_LABEL (statusbar->label), TRUE);
-  gtk_misc_set_alignment (GTK_MISC (statusbar->label), 0.0, 0.5);
-  gtk_misc_set_padding (GTK_MISC (statusbar->label), 4, 2);
-  gtk_label_set_ellipsize (GTK_LABEL (statusbar->label), PANGO_ELLIPSIZE_END);
-  gtk_container_add (GTK_CONTAINER (frame), statusbar->label);
-  gtk_widget_show (statusbar->label);
+  /* set statusbar spaceing */
+  gtk_box_set_spacing (GTK_BOX (statusbar), 8);
 
   /* line and column numbers */
-  frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
-  gtk_box_pack_start (GTK_BOX (statusbar), frame, FALSE, FALSE, 0);
-  gtk_widget_show (frame);
-
   statusbar->position = gtk_label_new (NULL);
-  gtk_container_add (GTK_CONTAINER (frame), statusbar->position);
-  gtk_misc_set_padding (GTK_MISC (statusbar->position), 4, 2);
-  gtk_widget_show (statusbar->position);
+  gtk_box_pack_start (GTK_BOX (statusbar), statusbar->position, FALSE, TRUE, 0);
 
   /* overwrite */
-  frame = gtk_frame_new (NULL);
-  gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
-  gtk_box_pack_start (GTK_BOX (statusbar), frame, FALSE, FALSE, 0);
-  gtk_widget_show (frame);
-
   ebox = gtk_event_box_new ();
-  gtk_container_add (GTK_CONTAINER (frame), ebox);
+  gtk_box_pack_start (GTK_BOX (statusbar), ebox, FALSE, TRUE, 0);
+  gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
   gtk_widget_show (ebox);
+  mousepad_gtk_set_tooltip (ebox, _("Toggle the overwrite mode"));
   g_signal_connect (G_OBJECT (ebox), "button-press-event",
                     G_CALLBACK (mousepad_statusbar_overwrite_clicked), statusbar);
 
   statusbar->overwrite = gtk_label_new (_("OVR"));
   gtk_container_add (GTK_CONTAINER (ebox), statusbar->overwrite);
-  gtk_misc_set_padding (GTK_MISC (statusbar->overwrite), 4, 2);
-  gtk_widget_show (statusbar->overwrite);
 }
 
 
@@ -175,7 +156,7 @@ mousepad_statusbar_overwrite_clicked (GtkWidget         *widget,
   if (event->type != GDK_BUTTON_PRESS || event->button != 1)
     return FALSE;
 
-  /* swap the startusbar state */
+  /* swap the overwrite mode */
   statusbar->overwrite_enabled = !statusbar->overwrite_enabled;
 
   /* send the signal */
@@ -187,18 +168,6 @@ mousepad_statusbar_overwrite_clicked (GtkWidget         *widget,
 
 
 void
-mousepad_statusbar_set_text (MousepadStatusbar *statusbar,
-                             const gchar       *text)
-{
-  _mousepad_return_if_fail (MOUSEPAD_IS_STATUSBAR (statusbar));
-
-  /* set the label text */
-  gtk_label_set_text (GTK_LABEL (statusbar->label), text);
-}
-
-
-
-void
 mousepad_statusbar_set_cursor_position (MousepadStatusbar *statusbar,
                                         gint               line,
                                         gint               column)
@@ -224,3 +193,23 @@ mousepad_statusbar_set_overwrite (MousepadStatusbar *statusbar,
 
   statusbar->overwrite_enabled = overwrite;
 }
+
+
+
+void
+mousepad_statusbar_visible (MousepadStatusbar *statusbar,
+                            gboolean           visible)
+{
+  _mousepad_return_if_fail (MOUSEPAD_IS_STATUSBAR (statusbar));
+
+  if (visible)
+    {
+      gtk_widget_show (statusbar->position);
+      gtk_widget_show (statusbar->overwrite);
+    }
+  else
+    {
+      gtk_widget_hide (statusbar->position);
+      gtk_widget_hide (statusbar->overwrite);
+    }
+}
diff --git a/mousepad/mousepad-statusbar.h b/mousepad/mousepad-statusbar.h
index f83b47f..2a40f09 100644
--- a/mousepad/mousepad-statusbar.h
+++ b/mousepad/mousepad-statusbar.h
@@ -36,9 +36,6 @@ GType       mousepad_statusbar_get_type             (void) G_GNUC_CONST;
 
 GtkWidget  *mousepad_statusbar_new                  (void);
 
-void        mousepad_statusbar_set_text             (MousepadStatusbar *statusbar,
-                                                     const gchar       *text);
-
 void        mousepad_statusbar_set_cursor_position  (MousepadStatusbar *statusbar,
                                                      gint               line,
                                                      gint               column);
@@ -46,6 +43,9 @@ void        mousepad_statusbar_set_cursor_position  (MousepadStatusbar *statusba
 void        mousepad_statusbar_set_overwrite        (MousepadStatusbar *statusbar,
                                                      gboolean           overwrite);
 
+void        mousepad_statusbar_visible              (MousepadStatusbar *statusbar,
+                                                     gboolean           visible);
+
 G_END_DECLS
 
 #endif /* !__MOUSEPAD_STATUSBAR_H__ */
diff --git a/mousepad/mousepad-window-ui.xml b/mousepad/mousepad-window-ui.xml
index 1477e41..e69829f 100644
--- a/mousepad/mousepad-window-ui.xml
+++ b/mousepad/mousepad-window-ui.xml
@@ -27,9 +27,10 @@
       <separator />
       <menuitem action="print-document" />
       <separator />
+      <menuitem action="detach-tab" />
       <menuitem action="close-tab" />
+      <separator />
       <menuitem action="close-window" />
-      <menuitem action="close-all-windows" />
     </menu>
 
     <menu action="edit-menu">
@@ -83,6 +84,7 @@
     <separator />
     <menuitem action="reload" />
     <separator />
+    <menuitem action="detach-tab" />
     <menuitem action="close-tab" />
   </popup>
 </ui>
diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index 8b3d605..89f02b4 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -49,6 +49,21 @@
 
 
 
+enum
+{
+  TARGET_TEXT_URI_LIST,
+  TARGET_GTK_NOTEBOOK_TAB,
+};
+
+enum
+{
+  NEW_WINDOW,
+  NEW_WINDOW_WITH_DOCUMENT,
+  LAST_SIGNAL,
+};
+
+
+
 /* class functions */
 static void              mousepad_window_class_init                   (MousepadWindowClass    *klass);
 static void              mousepad_window_init                         (MousepadWindow         *window);
@@ -79,8 +94,6 @@ static void              mousepad_window_save_geometry_timer_destroy  (gpointer
 static gboolean          mousepad_window_save                         (MousepadWindow         *window,
                                                                        MousepadDocument       *document,
                                                                        gboolean                force_save_as);
-static void              mousepad_window_add                          (MousepadWindow         *window,
-                                                                       MousepadDocument       *document);
 static gboolean          mousepad_window_close_document               (MousepadWindow         *window,
                                                                        MousepadDocument       *document);
 static void              mousepad_window_set_title                    (MousepadWindow         *window,
@@ -92,11 +105,16 @@ static void              mousepad_window_toggle_overwrite             (MousepadW
 static void              mousepad_window_page_notified                (GtkNotebook            *notebook,
                                                                        GParamSpec             *pspec,
                                                                        MousepadWindow         *window);
-static void              mousepad_window_tab_removed                  (GtkNotebook            *notebook,
-                                                                       MousepadDocument       *document,
-                                                                       MousepadWindow         *window);
 static void              mousepad_window_page_reordered               (GtkNotebook            *notebook,
-                                                                       GtkNotebookPage        *page,
+                                                                       GtkWidget              *page,
+                                                                       guint                   page_num,
+                                                                       MousepadWindow         *window);
+static void              mousepad_window_page_added                   (GtkNotebook            *notebook,
+                                                                       GtkWidget              *page,
+                                                                       guint                   page_num,
+                                                                       MousepadWindow         *window);
+static void              mousepad_window_page_removed                 (GtkNotebook            *notebook,
+                                                                       GtkWidget              *page,
                                                                        guint                   page_num,
                                                                        MousepadWindow         *window);
 static void              mousepad_window_tab_popup_position           (GtkMenu                *menu,
@@ -128,6 +146,8 @@ static void              mousepad_window_can_redo                     (MousepadW
 
 /* menu updaters */
 static void              mousepad_window_update_actions               (MousepadWindow         *window);
+static void              mousepad_window_update_sensitivity           (MousepadWindow         *window,
+                                                                       gboolean                sensitive);
 static gboolean          mousepad_window_update_gomenu_idle           (gpointer                user_data);
 static void              mousepad_window_update_gomenu_idle_destroy   (gpointer                user_data);
 static void              mousepad_window_update_gomenu                (MousepadWindow         *window);
@@ -143,7 +163,19 @@ static void              mousepad_window_recent_menu_idle_destroy     (gpointer
 static void              mousepad_window_recent_menu                  (MousepadWindow         *window);
 static void              mousepad_window_recent_clear                 (MousepadWindow         *window);
 
+/* dnd */
+static void              mousepad_window_drag_data_received           (GtkWidget              *widget,
+		                                                       GdkDragContext         *context,
+		                                                       gint                    x,
+		                                                       gint                    y,
+		                                                       GtkSelectionData       *selection_data,
+		                                                       guint                   info,
+		                                                       guint                   time,
+		                                                       MousepadWindow         *window);
+
 /* actions */
+static void              mousepad_window_action_open_new_tab          (GtkAction              *action,
+                                                                       MousepadWindow         *window);
 static void              mousepad_window_action_open_new_window       (GtkAction              *action,
                                                                        MousepadWindow         *window);
 static void              mousepad_window_action_open_file             (GtkAction              *action,
@@ -160,14 +192,12 @@ static void              mousepad_window_action_reload                (GtkAction
                                                                        MousepadWindow         *window);
 static void              mousepad_window_action_print                 (GtkAction              *action,
                                                                        MousepadWindow         *window);
+static void              mousepad_window_action_detach                (GtkAction              *action,
+                                                                       MousepadWindow         *window);
 static void              mousepad_window_action_close_tab             (GtkAction              *action,
                                                                        MousepadWindow         *window);
 static void              mousepad_window_action_close                 (GtkAction              *action,
                                                                        MousepadWindow         *window);
-static void              mousepad_window_action_close_all_windows     (GtkAction              *action,
-                                                                       MousepadWindow         *window);
-static void              mousepad_window_action_open_new_tab          (GtkAction              *action,
-                                                                       MousepadWindow         *window);
 static void              mousepad_window_action_undo                  (GtkAction              *action,
                                                                        MousepadWindow         *window);
 static void              mousepad_window_action_redo                  (GtkAction              *action,
@@ -246,6 +276,8 @@ struct _MousepadWindow
 
   /* UI manager */
   GtkUIManager        *ui_manager;
+  guint                gomenu_merge_id;
+  guint                recent_merge_id;
 
   /* recent items manager */
   GtkRecentManager    *recent_manager;
@@ -280,9 +312,9 @@ static const GtkActionEntry action_entries[] =
     { "save-file-as", GTK_STOCK_SAVE_AS, N_("Save _As"), NULL, N_("Save current document as another file"), G_CALLBACK (mousepad_window_action_save_file_as), },
     { "reload", GTK_STOCK_REFRESH, N_("Re_load"), NULL, N_("Reload this document."), G_CALLBACK (mousepad_window_action_reload), },
     { "print-document", GTK_STOCK_PRINT, N_("_Print"), "<control>P", N_("Prin the current page"), G_CALLBACK (mousepad_window_action_print), },
+    { "detach-tab", NULL, N_("_Detach Tab"), "<control>D", N_("Move the current document to a new window"), G_CALLBACK (mousepad_window_action_detach), },
     { "close-tab", GTK_STOCK_CLOSE, N_("C_lose Tab"), "<control>W", N_("Close the current file"), G_CALLBACK (mousepad_window_action_close_tab), },
     { "close-window", GTK_STOCK_QUIT, N_("_Close Window"), "<control>Q", N_("Quit the program"), G_CALLBACK (mousepad_window_action_close), },
-    { "close-all-windows", NULL, N_("Close _All Windows"), "<control><shift>W", N_("Close all Mousepad windows"), G_CALLBACK (mousepad_window_action_close_all_windows), },
 
   { "edit-menu", NULL, N_("_Edit"), NULL, NULL, NULL, },
     { "undo", GTK_STOCK_UNDO, N_("_Undo"), "<control>Z", N_("Undo the last action"), G_CALLBACK (mousepad_window_action_undo), },
@@ -321,10 +353,17 @@ static const GtkToggleActionEntry toggle_action_entries[] =
   { "auto-indent", NULL, N_("_Auto Indent"), NULL, NULL, G_CALLBACK (mousepad_window_action_auto_indent), FALSE, },
 };
 
+static const GtkTargetEntry drop_targets[] =
+{
+  { "text/uri-list", 0, TARGET_TEXT_URI_LIST },
+  { "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, TARGET_GTK_NOTEBOOK_TAB },
+};
+
 
 
 static GObjectClass *mousepad_window_parent_class;
-static gboolean      lock_menu_updates = FALSE;
+static guint         window_signals[LAST_SIGNAL];
+static gint          lock_menu_updates = 0;
 
 
 GtkWidget *
@@ -370,6 +409,23 @@ mousepad_window_class_init (MousepadWindowClass *klass)
 
   gtkwidget_class = GTK_WIDGET_CLASS (klass);
   gtkwidget_class->configure_event = mousepad_window_configure_event;
+
+  window_signals[NEW_WINDOW] =
+    g_signal_new (I_("new-window"),
+                  G_TYPE_FROM_CLASS (gobject_class),
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  g_cclosure_marshal_VOID__VOID,
+                  G_TYPE_NONE, 0);
+
+  window_signals[NEW_WINDOW_WITH_DOCUMENT] =
+    g_signal_new (I_("new-window-with-document"),
+                  G_TYPE_FROM_CLASS (gobject_class),
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  g_cclosure_marshal_VOID__OBJECT,
+                  G_TYPE_NONE, 1,
+                  G_TYPE_OBJECT);
 }
 
 
@@ -390,6 +446,8 @@ mousepad_window_init (MousepadWindow *window)
   window->save_geometry_timer_id = 0;
   window->update_recent_menu_id = 0;
   window->update_go_menu_id = 0;
+  window->gomenu_merge_id = 0;
+  window->recent_merge_id = 0;
   window->search_bar = NULL;
   window->statusbar = NULL;
   window->active = NULL;
@@ -464,7 +522,11 @@ mousepad_window_init (MousepadWindow *window)
   if (G_UNLIKELY (geteuid () == 0))
     {
       /* install default settings for the root warning text box */
-      gtk_rc_parse_string ("style\"mousepad-window-root-style\"{bg[NORMAL]=\"#b4254b\"\nfg[NORMAL]=\"#fefefe\"}\n"
+      gtk_rc_parse_string ("style\"mousepad-window-root-style\"\n"
+                           "  {\n"
+                           "    bg[NORMAL]=\"#b4254b\"\n"
+                           "    fg[NORMAL]=\"#fefefe\"\n"
+                           "  }\n"
                            "widget\"MousepadWindow.*.root-warning\"style\"mousepad-window-root-style\"\n"
                            "widget\"MousepadWindow.*.root-warning.GtkLabel\"style\"mousepad-window-root-style\"\n");
 
@@ -493,17 +555,15 @@ mousepad_window_init (MousepadWindow *window)
                                    "show-tabs", FALSE,
                                    "tab-hborder", 0,
                                    "tab-vborder", 0,
+                                   "group-id", 0,
                                    NULL);
 
   /* connect signals to the notebooks */
-  g_signal_connect (G_OBJECT (window->notebook), "notify::page",
-                    G_CALLBACK (mousepad_window_page_notified), window);
-  g_signal_connect (G_OBJECT (window->notebook), "remove",
-                    G_CALLBACK (mousepad_window_tab_removed), window);
-  g_signal_connect (G_OBJECT (window->notebook), "page-reordered",
-                    G_CALLBACK (mousepad_window_page_reordered), window);
-  g_signal_connect (G_OBJECT (window->notebook), "button-press-event",
-                    G_CALLBACK (mousepad_window_tab_popup), window);
+  g_signal_connect (G_OBJECT (window->notebook), "notify::page", G_CALLBACK (mousepad_window_page_notified), window);
+  g_signal_connect (G_OBJECT (window->notebook), "page-reordered", G_CALLBACK (mousepad_window_page_reordered), window);
+  g_signal_connect (G_OBJECT (window->notebook), "page-added", G_CALLBACK (mousepad_window_page_added), window);
+  g_signal_connect (G_OBJECT (window->notebook), "page-removed", G_CALLBACK (mousepad_window_page_removed), window);
+  g_signal_connect (G_OBJECT (window->notebook), "button-press-event", G_CALLBACK (mousepad_window_tab_popup), window);
 
   /* append and show the notebook */
   gtk_table_attach (GTK_TABLE (window->table), window->notebook, 0, 1, 3, 4, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0);
@@ -514,6 +574,10 @@ mousepad_window_init (MousepadWindow *window)
   g_object_get (G_OBJECT (window->preferences), "last-statusbar-visible", &visible, NULL);
   action = gtk_action_group_get_action (window->window_actions, "statusbar");
   gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+
+  /* allow drops in the window */
+  gtk_drag_dest_set (GTK_WIDGET (window), GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, drop_targets, G_N_ELEMENTS (drop_targets), GDK_ACTION_COPY | GDK_ACTION_MOVE);
+  g_signal_connect (G_OBJECT (window), "drag-data-received", G_CALLBACK (mousepad_window_drag_data_received), window);
 }
 
 
@@ -635,6 +699,7 @@ mousepad_window_menu_item_selected (GtkWidget      *menu_item,
 {
   GtkAction *action;
   gchar     *tooltip;
+  gint       id;
 
   /* we can only display tooltips if we have a statusbar */
   if (G_LIKELY (window->statusbar != NULL))
@@ -648,7 +713,8 @@ mousepad_window_menu_item_selected (GtkWidget      *menu_item,
           if (G_LIKELY (tooltip != NULL))
             {
               /* show the tooltip */
-              mousepad_statusbar_set_text (MOUSEPAD_STATUSBAR (window->statusbar), tooltip);
+              id = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->statusbar), "tooltip");
+              gtk_statusbar_push (GTK_STATUSBAR (window->statusbar), id, tooltip);
 
               /* cleanup */
               g_free (tooltip);
@@ -663,11 +729,14 @@ static void
 mousepad_window_menu_item_deselected (GtkWidget      *menu_item,
                                       MousepadWindow *window)
 {
+  gint id;
+
   /* we can only undisplay tooltips if we have a statusbar */
   if (G_LIKELY (window->statusbar != NULL))
     {
-      /* hide the tip from the statusbar */
-      mousepad_statusbar_set_text (MOUSEPAD_STATUSBAR (window->statusbar), NULL);
+      /* drop the last tooltip from the statusbar */
+      id = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->statusbar), "tooltip");
+      gtk_statusbar_pop (GTK_STATUSBAR (window->statusbar), id);
     }
 }
 
@@ -737,7 +806,6 @@ mousepad_window_open_tab (MousepadWindow *window,
   GError      *error = NULL;
   gboolean     succeed = TRUE;
   gint         npages = 0, i;
-  gchar       *font_name;
   const gchar *opened_filename;
 
   /* get the number of page in the notebook */
@@ -777,11 +845,6 @@ mousepad_window_open_tab (MousepadWindow *window,
     {
       /* add the document to the notebook and connect some signals */
       mousepad_window_add (window, MOUSEPAD_DOCUMENT (document));
-
-      /* set the textview font */
-      g_object_get (G_OBJECT (window->preferences), "font-name", &font_name, NULL);
-      mousepad_document_set_font (MOUSEPAD_DOCUMENT (document), font_name);
-      g_free (font_name);
     }
   else
     {
@@ -807,12 +870,11 @@ mousepad_window_open_files (MousepadWindow  *window,
   gchar *filename = NULL;
 
   _mousepad_return_val_if_fail (MOUSEPAD_IS_WINDOW (window), FALSE);
-  _mousepad_return_val_if_fail (working_directory != NULL, FALSE);
   _mousepad_return_val_if_fail (filenames != NULL, FALSE);
   _mousepad_return_val_if_fail (*filenames != NULL, FALSE);
 
   /* block menu updates */
-  lock_menu_updates = TRUE;
+  lock_menu_updates++;
 
   /* walk through all the filenames */
   for (n = 0; filenames[n] != NULL; ++n)
@@ -838,10 +900,9 @@ mousepad_window_open_files (MousepadWindow  *window,
     }
 
   /* allow menu updates again */
-  lock_menu_updates = FALSE;
+  lock_menu_updates--;
 
-  /* check if there were tabs opened, if not we return false and in
-   * window-application we open an empty tab */
+  /* check if the window contains tabs */
   npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook));
   if (G_UNLIKELY (npages == 0))
     return FALSE;
@@ -945,37 +1006,44 @@ mousepad_window_save (MousepadWindow   *window,
 
 
 
-static void
+void
 mousepad_window_add (MousepadWindow   *window,
                      MousepadDocument *document)
 {
   GtkWidget        *label;
   gboolean          always_show_tabs;
-  gboolean          word_wrap;
+  gboolean          word_wrap, auto_indent, line_numbers;
   gint              page, npages;
+  gchar            *font_name;
   MousepadDocument *active;
 
   _mousepad_return_if_fail (MOUSEPAD_IS_WINDOW (window));
   _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (document));
+  _mousepad_return_if_fail (GTK_IS_NOTEBOOK (window->notebook));
 
   /* create the tab label */
   label = mousepad_document_get_tab_label (document);
 
-  /* signals for the document */
-  g_signal_connect (G_OBJECT (document), "close-tab", G_CALLBACK (mousepad_window_button_close_tab), window);
-  g_signal_connect (G_OBJECT (document), "selection-changed", G_CALLBACK (mousepad_window_selection_changed), window);
-  g_signal_connect (G_OBJECT (document), "modified-changed", G_CALLBACK (mousepad_window_modified_changed), window);
-  g_signal_connect (G_OBJECT (document), "cursor-changed", G_CALLBACK (mousepad_window_cursor_changed), window);
-  g_signal_connect (G_OBJECT (document), "overwrite-changed", G_CALLBACK (mousepad_window_overwrite_changed), window);
-  g_signal_connect_swapped (G_OBJECT (document), "can-undo", G_CALLBACK (mousepad_window_can_undo), window);
-  g_signal_connect_swapped (G_OBJECT (document), "can-redo", G_CALLBACK (mousepad_window_can_redo), window);
-
-  /* insert the page right from the active tab */
+  /* get the current page number */
   page = gtk_notebook_get_current_page (GTK_NOTEBOOK (window->notebook));
+
+  /* update the sensitivity of the actions if this the first tab */
+  if (page == -1)
+    {
+      /* update the menu sensitivity */
+      mousepad_window_update_sensitivity (window, TRUE);
+
+      /* show the statusbar items */
+      if (window->statusbar)
+        mousepad_statusbar_visible (MOUSEPAD_STATUSBAR (window->statusbar), TRUE);
+    }
+
+  /* insert the page right of the active tab */
   page = gtk_notebook_insert_page (GTK_NOTEBOOK (window->notebook), GTK_WIDGET (document), label, page + 1);
 
-  /* allow tab reordering */
+  /* allow tab reordering and detaching */
   gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (window->notebook), GTK_WIDGET (document), TRUE);
+  gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (window->notebook), GTK_WIDGET (document), TRUE);
 
   /* check if we should always display tabs */
   g_object_get (G_OBJECT (window->preferences), "misc-always-show-tabs", &always_show_tabs, NULL);
@@ -988,11 +1056,21 @@ mousepad_window_add (MousepadWindow   *window,
   GTK_WIDGET_UNSET_FLAGS (window->notebook, GTK_CAN_FOCUS);
 
   /* set the wrapping mode */
-  g_object_get (G_OBJECT (window->preferences), "word-wrap", &word_wrap, NULL);
+  g_object_get (G_OBJECT (window->preferences), "last-word-wrap", &word_wrap, NULL);
   mousepad_document_set_word_wrap (document, word_wrap);
 
-  /* rebuild the go menu */
-  mousepad_window_update_gomenu (window);
+  /* whether line numbers are visible */
+  g_object_get (G_OBJECT (window->preferences), "last-line-numbers", &line_numbers, NULL);
+  mousepad_document_set_line_numbers (document, line_numbers);
+
+  /* whether we indent lines */
+  g_object_get (G_OBJECT (window->preferences), "last-auto-indent", &auto_indent, NULL);
+  mousepad_document_set_auto_indent (document, auto_indent);
+
+  /* set the textview font */
+  g_object_get (G_OBJECT (window->preferences), "font-name", &font_name, NULL);
+  mousepad_document_set_font (document, font_name);
+  g_free (font_name);
 
   /* show the document */
   gtk_widget_show (GTK_WIDGET (document));
@@ -1004,10 +1082,10 @@ mousepad_window_add (MousepadWindow   *window,
   gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), page);
 
   /* destroy the previous tab if it was not modified, untitled and the new tab is not untitled */
-  if (active != NULL &&
-      mousepad_document_get_modified (active) == FALSE &&
-      mousepad_document_get_filename (active) == NULL &&
-      mousepad_document_get_filename (document) != NULL)
+  if (active != NULL
+      && mousepad_document_get_modified (active) == FALSE
+      && mousepad_document_get_filename (active) == NULL
+      && mousepad_document_get_filename (document) != NULL)
     gtk_widget_destroy (GTK_WIDGET (active));
 }
 
@@ -1062,30 +1140,27 @@ static void
 mousepad_window_set_title (MousepadWindow   *window,
                            MousepadDocument *document)
 {
-  gchar       *string;
+  gchar       *string = NULL;
   const gchar *title;
   gboolean     show_full_path;
 
-  /* whether to show the full path in the window title */
-  g_object_get (G_OBJECT (window->preferences), "misc-show-full-path-in-title", &show_full_path, NULL);
+  if (G_LIKELY (document))
+    {
+      /* whether to show the full path in the window title */
+      g_object_get (G_OBJECT (window->preferences), "misc-show-full-path-in-title", &show_full_path, NULL);
 
-  /* the window title */
-  title = mousepad_document_get_title (document, show_full_path);
+      /* the window filename */
+      title = mousepad_document_get_title (document, show_full_path);
 
-  if (G_UNLIKELY (mousepad_document_get_readonly (document)))
-    {
-      string = g_strdup_printf ("%s [%s] - %s",
-                                title, _("Read Only"), PACKAGE_NAME);
-    }
-  else
-    {
-      string = g_strdup_printf ("%s%s - %s",
-                                mousepad_document_get_modified (document) ? "*" : "",
-                                title, PACKAGE_NAME);
+      /* build the title */
+      if (G_UNLIKELY (mousepad_document_get_readonly (document)))
+        string = g_strdup_printf ("%s [%s] - %s", title, _("Read Only"), PACKAGE_NAME);
+      else
+        string = g_strdup_printf ("%s%s - %s", mousepad_document_get_modified (document) ? "*" : "", title, PACKAGE_NAME);
     }
 
   /* set the window title */
-  gtk_window_set_title (GTK_WINDOW (window), string);
+  gtk_window_set_title (GTK_WINDOW (window), string ? string : PACKAGE_NAME);
 
   /* cleanup */
   g_free (string);
@@ -1113,22 +1188,23 @@ mousepad_window_page_notified (GtkNotebook    *notebook,
                                GParamSpec     *pspec,
                                MousepadWindow *window)
 {
-  gint              page_num;
+  gint page_num;
 
   _mousepad_return_if_fail (MOUSEPAD_IS_WINDOW (window));
 
-  /* get the notebook */
-  notebook = GTK_NOTEBOOK (window->notebook);
-
   /* get the current page */
   page_num = gtk_notebook_get_current_page (notebook);
 
-  if (G_LIKELY (page_num >= 0))
+  /* get the new document */
+  if (G_LIKELY (page_num != -1))
     window->active = MOUSEPAD_DOCUMENT (gtk_notebook_get_nth_page (notebook, page_num));
   else
-    window->active = NULL;
+    {
+      window->active = NULL;
+      _mousepad_assert_not_reached ();
+    }
 
-  if (G_LIKELY (window->active != NULL))
+  if (G_LIKELY (window->active))
     {
       /* set the window title */
       mousepad_window_set_title (window, window->active);
@@ -1144,21 +1220,75 @@ mousepad_window_page_notified (GtkNotebook    *notebook,
 
 
 static void
-mousepad_window_tab_removed (GtkNotebook      *notebook,
-                             MousepadDocument *document,
-                             MousepadWindow   *window)
+mousepad_window_page_reordered (GtkNotebook     *notebook,
+                                GtkWidget       *page,
+                                guint            page_num,
+                                MousepadWindow  *window)
+{
+  _mousepad_return_if_fail (MOUSEPAD_IS_WINDOW (window));
+  _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (page));
+
+  /* update the go menu */
+  mousepad_window_update_gomenu (window);
+}
+
+
+
+static void
+mousepad_window_page_added (GtkNotebook     *notebook,
+                            GtkWidget       *page,
+                            guint            page_num,
+                            MousepadWindow  *window)
+{
+  _mousepad_return_if_fail (MOUSEPAD_IS_WINDOW (window));
+  _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (page));
+
+  /* connect signals to the document for this window */
+  g_signal_connect (G_OBJECT (page), "close-tab", G_CALLBACK (mousepad_window_button_close_tab), window);
+  g_signal_connect (G_OBJECT (page), "selection-changed", G_CALLBACK (mousepad_window_selection_changed), window);
+  g_signal_connect (G_OBJECT (page), "modified-changed", G_CALLBACK (mousepad_window_modified_changed), window);
+  g_signal_connect (G_OBJECT (page), "cursor-changed", G_CALLBACK (mousepad_window_cursor_changed), window);
+  g_signal_connect (G_OBJECT (page), "overwrite-changed", G_CALLBACK (mousepad_window_overwrite_changed), window);
+  g_signal_connect_swapped (G_OBJECT (page), "can-undo", G_CALLBACK (mousepad_window_can_undo), window);
+  g_signal_connect_swapped (G_OBJECT (page), "can-redo", G_CALLBACK (mousepad_window_can_redo), window);
+
+  /* update the go menu */
+  mousepad_window_update_gomenu (window);
+
+  /* update the window actions */
+  mousepad_window_update_actions (window);
+
+}
+
+
+
+static void
+mousepad_window_page_removed (GtkNotebook     *notebook,
+                              GtkWidget       *page,
+                              guint            page_num,
+                              MousepadWindow  *window)
 {
   gboolean always_show_tabs;
   gint     npages;
 
-  npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook));
-
-  if (G_UNLIKELY (npages == 0))
-    {
-      /* destroy the window when there are no tabs */
-      gtk_widget_destroy (GTK_WIDGET (window));
-    }
-  else
+  _mousepad_return_if_fail (MOUSEPAD_IS_WINDOW (window));
+  _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (page));
+  _mousepad_return_if_fail (GTK_IS_NOTEBOOK (notebook));
+
+  /* disconnect the old document signals */
+  g_signal_handlers_disconnect_by_func (G_OBJECT (page), mousepad_window_button_close_tab, window);
+  g_signal_handlers_disconnect_by_func (G_OBJECT (page), mousepad_window_selection_changed, window);
+  g_signal_handlers_disconnect_by_func (G_OBJECT (page), mousepad_window_modified_changed, window);
+  g_signal_handlers_disconnect_by_func (G_OBJECT (page), mousepad_window_cursor_changed, window);
+  g_signal_handlers_disconnect_by_func (G_OBJECT (page), mousepad_window_overwrite_changed, window);
+  g_signal_handlers_disconnect_by_func (G_OBJECT (page), mousepad_window_can_undo, window);
+  g_signal_handlers_disconnect_by_func (G_OBJECT (page), mousepad_window_can_redo, window);
+
+  /* get the number of pages in this notebook */
+  npages = gtk_notebook_get_n_pages (notebook);
+
+  /* only update if there are pages in the window */
+  if (npages > 0)
     {
       /* check tabs should always be visible */
       g_object_get (G_OBJECT (window->preferences), "misc-always-show-tabs", &always_show_tabs, NULL);
@@ -1169,24 +1299,27 @@ mousepad_window_tab_removed (GtkNotebook      *notebook,
       /* don't focus the notebook */
       GTK_WIDGET_UNSET_FLAGS (window->notebook, GTK_CAN_FOCUS);
 
-      /* rebuild the go menu */
+      /* update the go menu */
       mousepad_window_update_gomenu (window);
 
-      /* update all document sensitive actions */
+      /* update the actions */
       mousepad_window_update_actions (window);
     }
-}
+  else
+    {
+      /* no tabs in the window, reset the active tab */
+      window->active = NULL;
 
+      /* set the new window title */
+      mousepad_window_set_title (window, NULL);
 
+      /* hide all the actions that are not relevant without tabs */
+      mousepad_window_update_sensitivity (window, FALSE);
 
-static void
-mousepad_window_page_reordered (GtkNotebook     *notebook,
-                                GtkNotebookPage *page,
-                                guint            page_num,
-                                MousepadWindow  *window)
-{
-  /* update the go menu */
-  mousepad_window_update_gomenu (window);
+      /* the statusbar items */
+      if (window->statusbar)
+        mousepad_statusbar_visible (MOUSEPAD_STATUSBAR (window->statusbar), FALSE);
+    }
 }
 
 
@@ -1361,34 +1494,37 @@ mousepad_window_update_actions (MousepadWindow *window)
   gboolean          has_selection;
   gboolean          active;
 
-  /* determine the number of pages */
-  n_pages = gtk_notebook_get_n_pages (notebook);
-
-  /* set sensitivity for the "Close Tab" action */
-  action = gtk_action_group_get_action (window->window_actions, "close-tab");
-  gtk_action_set_sensitive (action, (n_pages > 1));
-
-  /* update the actions for the current document */
+  /* active document */
   document = window->active;
+
+  /* update the actions for the active document */
   if (G_LIKELY (document != NULL))
     {
+      /* avoid menu actions */
+      lock_menu_updates++;
+
+      /* determine the number of pages and the current page number */
+      n_pages = gtk_notebook_get_n_pages (notebook);
       page_num = gtk_notebook_page_num (notebook, GTK_WIDGET (document));
 
       /* whether we cycle tabs */
       g_object_get (G_OBJECT (window->preferences), "misc-cycle-tabs", &cycle_tabs, NULL);
 
+      /* set the sensitivity of the back and forward buttons in the go menu */
       action = gtk_action_group_get_action (window->window_actions, "back");
       gtk_action_set_sensitive (action, (cycle_tabs && n_pages > 1) || (page_num > 0));
 
       action = gtk_action_group_get_action (window->window_actions, "forward");
       gtk_action_set_sensitive (action, (cycle_tabs && n_pages > 1 ) || (page_num < n_pages - 1));
 
+      /* set the reload and save sensitivity */
       action = gtk_action_group_get_action (window->window_actions, "save-file");
       gtk_action_set_sensitive (action, !mousepad_document_get_readonly (document));
 
       action = gtk_action_group_get_action (window->window_actions, "reload");
       gtk_action_set_sensitive (action, mousepad_document_get_filename (document) != NULL);
 
+      /* toggle the document settings */
       active = mousepad_document_get_word_wrap (document);
       action = gtk_action_group_get_action (window->window_actions, "word-wrap");
       gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), active);
@@ -1413,11 +1549,40 @@ mousepad_window_update_actions (MousepadWindow *window)
       action = g_object_get_data (G_OBJECT (document), I_("go-menu-action"));
       if (G_LIKELY (action != NULL))
         gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+
+      /* allow menu actions again */
+      lock_menu_updates--;
     }
 }
 
 
 
+static void
+mousepad_window_update_sensitivity (MousepadWindow *window,
+                                    gboolean        sensitive)
+{
+  gint         i;
+  GtkAction   *action;
+  const gchar *actions[] = {"edit-menu", "search-menu", "document-menu", "go-menu",
+                            "save-file", "save-file-as", "reload", "print-document",
+                            "detach-tab", "close-tab"};
+
+  /* walk through the actions */
+  for (i = 0; i < G_N_ELEMENTS (actions); i++)
+    {
+      /* get the action */
+      action = gtk_action_group_get_action (window->window_actions, actions[i]);
+
+      /* leave when the first action already has the right state */
+      if (G_LIKELY (i == 0 && (gtk_action_get_sensitive (action) == sensitive)))
+        break;
+
+      /* set the sensitivity */
+      gtk_action_set_sensitive (action, sensitive);
+    }
+}
+
+
 
 static gboolean
 mousepad_window_update_gomenu_idle (gpointer user_data)
@@ -1433,13 +1598,15 @@ mousepad_window_update_gomenu_idle (gpointer user_data)
   GtkRadioAction *action;
   GSList         *group = NULL;
   GList          *actions, *li;
-  static guint    ui_merge_id = 0;
 
   GDK_THREADS_ENTER ();
 
+  /* prevent menu updates */
+  lock_menu_updates++;
+
   /* remove the old merge */
-  if (ui_merge_id != 0)
-    gtk_ui_manager_remove_ui (window->ui_manager, ui_merge_id);
+  if (window->gomenu_merge_id != 0)
+    gtk_ui_manager_remove_ui (window->ui_manager, window->gomenu_merge_id);
 
   /* drop all the previous actions from the action group */
   actions = gtk_action_group_list_actions (window->gomenu_actions);
@@ -1448,7 +1615,7 @@ mousepad_window_update_gomenu_idle (gpointer user_data)
   g_list_free (actions);
 
   /* create a new merge id */
-  ui_merge_id = gtk_ui_manager_new_merge_id (window->ui_manager);
+  window->gomenu_merge_id = gtk_ui_manager_new_merge_id (window->ui_manager);
 
   /* walk through the notebook pages */
   npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook));
@@ -1484,7 +1651,7 @@ mousepad_window_update_gomenu_idle (gpointer user_data)
         /* add a menu item without accelerator */
         gtk_action_group_add_action (window->gomenu_actions, GTK_ACTION (action));
 
-      /* select this action */
+      /* select the active entry */
       if (gtk_notebook_get_current_page (GTK_NOTEBOOK (window->notebook)) == n)
         gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
 
@@ -1492,7 +1659,7 @@ mousepad_window_update_gomenu_idle (gpointer user_data)
       g_object_unref (G_OBJECT (action));
 
       /* add the action to the go menu */
-      gtk_ui_manager_add_ui (window->ui_manager, ui_merge_id,
+      gtk_ui_manager_add_ui (window->ui_manager, window->gomenu_merge_id,
                              "/main-menu/go-menu/placeholder-go-items",
                              name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
     }
@@ -1500,6 +1667,9 @@ mousepad_window_update_gomenu_idle (gpointer user_data)
   /* make sure the ui is up2date to avoid flickering */
   gtk_ui_manager_ensure_update (window->ui_manager);
 
+  /* release our lock */
+  lock_menu_updates--;
+
   GDK_THREADS_LEAVE ();
 
   return FALSE;
@@ -1554,10 +1724,12 @@ mousepad_window_recent_add (MousepadWindow *window,
   /* create an uri from the filename */
   uri = g_filename_to_uri (filename, NULL, NULL);
 
-  /* add it */
   if (G_LIKELY (uri != NULL))
     {
+      /* add the new recent info to the recent manager */
       gtk_recent_manager_add_full (window->recent_manager, uri, &info);
+
+      /* cleanup */
       g_free (uri);
     }
 }
@@ -1611,7 +1783,6 @@ static gboolean
 mousepad_window_recent_menu_idle (gpointer user_data)
 {
   MousepadWindow *window = MOUSEPAD_WINDOW (user_data);
-  static guint    ui_merge_id = 0;
   GList          *items, *li, *actions;
   GList          *filtered = NULL;
   GtkRecentInfo  *info;
@@ -1624,8 +1795,8 @@ mousepad_window_recent_menu_idle (gpointer user_data)
   GDK_THREADS_ENTER ();
 
   /* unmerge the ui controls from the previous update */
-  if (ui_merge_id != 0)
-    gtk_ui_manager_remove_ui (window->ui_manager, ui_merge_id);
+  if (window->recent_merge_id != 0)
+    gtk_ui_manager_remove_ui (window->ui_manager, window->recent_merge_id);
 
   /* drop all the previous actions from the action group */
   actions = gtk_action_group_list_actions (window->recent_actions);
@@ -1634,7 +1805,7 @@ mousepad_window_recent_menu_idle (gpointer user_data)
   g_list_free (actions);
 
   /* create a new merge id */
-  ui_merge_id = gtk_ui_manager_new_merge_id (window->ui_manager);
+  window->recent_merge_id = gtk_ui_manager_new_merge_id (window->ui_manager);
 
   /* get all the items in the manager */
   items = gtk_recent_manager_get_items (window->recent_manager);
@@ -1689,7 +1860,7 @@ mousepad_window_recent_menu_idle (gpointer user_data)
       gtk_action_group_add_action (window->recent_actions, action);
 
       /* add the action to the menu */
-      gtk_ui_manager_add_ui (window->ui_manager, ui_merge_id,
+      gtk_ui_manager_add_ui (window->ui_manager, window->recent_merge_id,
                              "/main-menu/file-menu/recent-menu/placeholder-recent-items",
                              name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
 
@@ -1788,28 +1959,93 @@ mousepad_window_recent_clear (MousepadWindow *window)
 
 
 /**
- * Menu Actions
- *
- * All those function should be sorted by the menu structure so it's
- * easy to find a function. They should also use the other window
- * functions as much as possible to avoid code duplication.
+ * Drag and drop functions
  **/
 static void
-mousepad_window_action_open_new_window (GtkAction      *action,
-                                        MousepadWindow *window)
+mousepad_window_drag_data_received (GtkWidget        *widget,
+		                    GdkDragContext   *context,
+		                    gint              x,
+		                    gint              y,
+		                    GtkSelectionData *selection_data,
+		                    guint             info,
+		                    guint             time,
+		                    MousepadWindow   *window)
 {
-  MousepadApplication *application;
-  GdkScreen           *screen;
+  gchar     **uris;
+  GtkWidget  *notebook, **document;
+  GtkWidget  *child, *label;
+  gint        i, n_pages;
+
+  _mousepad_return_if_fail (MOUSEPAD_IS_WINDOW (window));
 
-  screen = gtk_widget_get_screen (GTK_WIDGET (window));
+  /* we only accept text/uri-list drops with format 8 and atleast one byte of data */
+  if (info == TARGET_TEXT_URI_LIST && selection_data->format == 8 && selection_data->length > 0)
+    {
+      /* extract the uris from the data */
+      uris = g_uri_list_extract_uris ((const gchar *)selection_data->data);
+
+      /* open the files */
+      mousepad_window_open_files (window, NULL, uris);
+
+      /* cleanup */
+      g_strfreev (uris);
+
+      /* finish the drag */
+      gtk_drag_finish (context, TRUE, FALSE, time);
+    }
+  else if (info == TARGET_GTK_NOTEBOOK_TAB)
+    {
+      /* get the source notebook */
+      notebook = gtk_drag_get_source_widget (context);
+
+      /* get the document that has been dragged */
+      document = (GtkWidget **) selection_data->data;
+      g_object_ref (G_OBJECT (*document));
+
+      /* check */
+      _mousepad_return_if_fail (MOUSEPAD_IS_DOCUMENT (*document));
+
+      /* remove the document from the source window */
+      gtk_container_remove (GTK_CONTAINER (notebook), *document);
+
+      /* get the number of pages in the notebook */
+      n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook));
+
+      /* figure out where to insert the tab in the notebook */
+      for (i = 0; i < n_pages; i++)
+        {
+          /* get the child label */
+          child = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), i);
+          label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (window->notebook), child);
 
-  application = mousepad_application_get ();
-  mousepad_application_open_window (application, screen, NULL, NULL);
-  g_object_unref (G_OBJECT (application));
+          /* break if we have a matching drop position */
+          if (x < (label->allocation.x + label->allocation.width / 2))
+            break;
+        }
+
+      /* add the document to the new window */
+      mousepad_window_add (window, MOUSEPAD_DOCUMENT (*document));
+
+      /* move it to the correct position */
+      gtk_notebook_reorder_child (GTK_NOTEBOOK (window->notebook), *document, i);
+
+      /* release out reference on the document */
+      g_object_unref (G_OBJECT (*document));
+
+      /* finish the drag */
+      gtk_drag_finish (context, TRUE, TRUE, time);
+    }
 }
 
 
 
+/**
+ * Menu Actions
+ *
+ * All those function should be sorted by the menu structure so it's
+ * easy to find a function. They should also use the other window
+ * functions as much as possible to avoid code duplication.
+ **/
 static void
 mousepad_window_action_open_new_tab (GtkAction      *action,
                                      MousepadWindow *window)
@@ -1820,6 +2056,16 @@ mousepad_window_action_open_new_tab (GtkAction      *action,
 
 
 static void
+mousepad_window_action_open_new_window (GtkAction      *action,
+                                        MousepadWindow *window)
+{
+  /* emit the new window signal */
+  g_signal_emit (G_OBJECT (window), window_signals[NEW_WINDOW], 0);
+}
+
+
+
+static void
 mousepad_window_action_open_file (GtkAction      *action,
                                   MousepadWindow *window)
 {
@@ -1845,7 +2091,7 @@ mousepad_window_action_open_file (GtkAction      *action,
       filenames = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (chooser));
 
       /* block menu updates */
-      lock_menu_updates = TRUE;
+      lock_menu_updates++;
 
       /* open the selected files */
       for (li = filenames; li != NULL; li = li->next)
@@ -1866,7 +2112,7 @@ mousepad_window_action_open_file (GtkAction      *action,
       g_slist_free (filenames);
 
       /* allow menu updates again */
-      lock_menu_updates = FALSE;
+      lock_menu_updates--;
 
       /* update the menus */
       mousepad_window_recent_menu (window);
@@ -1940,13 +2186,13 @@ mousepad_window_action_clear_recent (GtkAction      *action,
   if (mousepad_dialogs_clear_recent (GTK_WINDOW (window)))
     {
       /* avoid updating the menu */
-      lock_menu_updates = TRUE;
+      lock_menu_updates++;
 
       /* clear the document history */
       mousepad_window_recent_clear (window);
 
       /* allow menu updates again */
-      lock_menu_updates = FALSE;
+      lock_menu_updates--;
 
       /* update the recent menu */
       mousepad_window_recent_menu (window);
@@ -2046,6 +2292,34 @@ mousepad_window_action_print (GtkAction      *action,
 
 
 static void
+mousepad_window_action_detach (GtkAction      *action,
+                               MousepadWindow *window)
+{
+  MousepadDocument *document;
+
+  /* get the active tab */
+  document = window->active;
+
+  /* only detach when there are more then 2 tabs */
+  if (document && gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)) >= 2)
+    {
+      /* take a reference */
+      g_object_ref (G_OBJECT (document));
+
+      /* remove the document from the active window */
+      gtk_container_remove (GTK_CONTAINER (window->notebook), GTK_WIDGET (document));
+
+      /* emit the new window with document signal */
+      g_signal_emit (G_OBJECT (window), window_signals[NEW_WINDOW_WITH_DOCUMENT], 0, document);
+
+      /* release our reference */
+      g_object_unref (G_OBJECT (document));
+    }
+}
+
+
+
+static void
 mousepad_window_action_close_tab (GtkAction      *action,
                                   MousepadWindow *window)
 {
@@ -2069,10 +2343,9 @@ mousepad_window_action_close (GtkAction      *action,
   npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)) - 1;
 
   /* prevent menu updates */
-  lock_menu_updates = TRUE;
+  lock_menu_updates++;
 
-  /* close all the tabs, one by one. the window will close
-   * when all the tabs are closed */
+  /* ask what to do with the modified document in this window */
   for (i = npages; i >= 0; --i)
     {
       document = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), i);
@@ -2086,36 +2359,19 @@ mousepad_window_action_close (GtkAction      *action,
           if (!mousepad_window_close_document (window, MOUSEPAD_DOCUMENT (document)))
             {
               /* allow updates again */
-              lock_menu_updates = FALSE;
+              lock_menu_updates--;
 
               /* update the go menu */
               mousepad_window_update_gomenu (window);
 
-              break;
+              /* leave the close function */
+              return;
             }
         }
     }
-}
-
-
-
-static void
-mousepad_window_action_close_all_windows (GtkAction      *action,
-                                          MousepadWindow *window)
-{
-  MousepadApplication *application;
-  GList               *windows, *li;
 
-  /* query the list of currently open windows */
-  application = mousepad_application_get ();
-  windows = mousepad_application_get_windows (application);
-  g_object_unref (G_OBJECT (application));
-
-  /* close all open windows */
-  for (li = windows; li != NULL; li = li->next)
-    mousepad_window_action_close (NULL, MOUSEPAD_WINDOW (li->data));
-
-  g_list_free (windows);
+  /* destroy the window */
+  gtk_widget_destroy (GTK_WIDGET (window));
 }
 
 
@@ -2365,8 +2621,7 @@ static void
 mousepad_window_action_statusbar (GtkToggleAction *action,
                                   MousepadWindow  *window)
 {
-  gboolean          active;
-  MousepadDocument *document;
+  gboolean active;
 
   /* determine the new state of the action */
   active = gtk_toggle_action_get_active (action);
@@ -2390,9 +2645,14 @@ mousepad_window_action_statusbar (GtkToggleAction *action,
                                 G_CALLBACK (mousepad_window_toggle_overwrite), window);
 
       /* set the statsbar text */
-      document = window->active;
-      if (document != NULL)
-        mousepad_document_send_statusbar_signals (document);
+      if (window->active != NULL)
+        {
+          /* show the statusbar items */
+          mousepad_statusbar_visible (MOUSEPAD_STATUSBAR (window->statusbar), TRUE);
+
+          /* update the statusbar items */
+          mousepad_document_send_statusbar_signals (window->active);
+        }
     }
 
   /* set the spacing above the statusbar */
@@ -2410,10 +2670,15 @@ mousepad_window_action_word_wrap (GtkToggleAction *action,
 {
   gboolean word_wrap;
 
+  /* leave when menu updates are locked */
+  if (lock_menu_updates)
+    return;
+
+  /* get the current state */
   word_wrap = gtk_toggle_action_get_active (action);
 
   /* store this as the last used wrap mode */
-  g_object_set (G_OBJECT (window->preferences), "word-wrap", word_wrap, NULL);
+  g_object_set (G_OBJECT (window->preferences), "last-word-wrap", word_wrap, NULL);
 
   /* set the wrapping mode of the current document */
   if (G_LIKELY (window->active != NULL))
@@ -2428,8 +2693,17 @@ mousepad_window_action_line_numbers (GtkToggleAction *action,
 {
   gboolean line_numbers;
 
+  /* leave when menu updates are locked */
+  if (lock_menu_updates)
+    return;
+
+  /* get the current state */
   line_numbers = gtk_toggle_action_get_active (action);
 
+  /* save as the last used line number setting */
+  g_object_set (G_OBJECT (window->preferences), "last-line-numbers", line_numbers, NULL);
+
+  /* update the active document */
   if (G_LIKELY (window->active != NULL))
     mousepad_document_set_line_numbers (window->active, line_numbers);
 }
@@ -2442,8 +2716,17 @@ mousepad_window_action_auto_indent (GtkToggleAction *action,
 {
   gboolean auto_indent;
 
+  /* leave when menu updates are locked */
+  if (lock_menu_updates)
+    return;
+
+  /* get the current state */
   auto_indent = gtk_toggle_action_get_active (action);
 
+  /* save as the last auto indent mode */
+  g_object_set (G_OBJECT (window->preferences), "last-auto-indent", auto_indent, NULL);
+
+  /* update the active document */
   if (G_LIKELY (window->active != NULL))
     mousepad_document_set_auto_indent (window->active, auto_indent);
 }
@@ -2490,8 +2773,14 @@ static void
 mousepad_window_action_goto (GtkRadioAction *action,
                              GtkNotebook    *notebook)
 {
+  gint page;
+
+  /* leave when the menu is locked */
+  if (lock_menu_updates)
+    return;
+
   /* get the page number from the action value */
-  gint page = gtk_radio_action_get_current_value (action);
+  page = gtk_radio_action_get_current_value (action);
 
   /* set the page */
   gtk_notebook_set_current_page (notebook, page);
diff --git a/mousepad/mousepad-window.h b/mousepad/mousepad-window.h
index 2324bc0..f6de694 100644
--- a/mousepad/mousepad-window.h
+++ b/mousepad/mousepad-window.h
@@ -22,6 +22,8 @@
 
 G_BEGIN_DECLS
 
+#include <mousepad/mousepad-document.h>
+
 #define MOUSEPAD_TYPE_WINDOW            (mousepad_window_get_type ())
 #define MOUSEPAD_WINDOW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), MOUSEPAD_TYPE_WINDOW, MousepadWindow))
 #define MOUSEPAD_WINDOW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), MOUSEPAD_TYPE_WINDOW, MousepadWindowClass))
@@ -36,6 +38,9 @@ GType           mousepad_window_get_type         (void) G_GNUC_CONST;
 
 GtkWidget      *mousepad_window_new              (void);
 
+void            mousepad_window_add              (MousepadWindow   *window,
+                                                  MousepadDocument *document);
+
 gboolean        mousepad_window_open_tab         (MousepadWindow  *window,
                                                   const gchar     *filename);
 


More information about the Xfce4-commits mailing list