[Xfce4-commits] <mousepad:master> * Use G_DEFINE_TYPE. * Properly set the emission stage for all signals. * Remove some unused code. * Fix assert when dropping a file in the editor window. * Small typo in the menu tooltips.

Nick Schermer noreply at xfce.org
Sat May 5 21:31:10 CEST 2012


Updating branch refs/heads/master
         to a8924e11dad4f268f699ce42abd348ba4dcb2492 (commit)
       from b93f219eb75efb3769f5d1a150831a4a1f09291d (commit)

commit a8924e11dad4f268f699ce42abd348ba4dcb2492
Author: Nick Schermer <nick at xfce.org>
Date:   Mon Jan 14 11:33:17 2008 +0000

    * Use G_DEFINE_TYPE.
    * Properly set the emission stage for all signals.
    * Remove some unused code.
    * Fix assert when dropping a file in the editor window.
    * Small typo in the menu tooltips.
    
    
    (Old svn revision: 26570)

 mousepad/mousepad-application.c     |   27 +--------------
 mousepad/mousepad-dbus.c            |   26 +--------------
 mousepad/mousepad-document.c        |   32 +++--------------
 mousepad/mousepad-encoding-dialog.c |   27 +--------------
 mousepad/mousepad-file.c            |   33 ++++--------------
 mousepad/mousepad-preferences.c     |   25 +-------------
 mousepad/mousepad-print.c           |   25 +-------------
 mousepad/mousepad-private.h         |    8 ++--
 mousepad/mousepad-replace-dialog.c  |   29 ++--------------
 mousepad/mousepad-search-bar.c      |   28 ++-------------
 mousepad/mousepad-statusbar.c       |   29 +++-------------
 mousepad/mousepad-undo.c            |   29 ++--------------
 mousepad/mousepad-view.c            |   25 +-------------
 mousepad/mousepad-window.c          |   63 ++++++++++------------------------
 14 files changed, 62 insertions(+), 344 deletions(-)

diff --git a/mousepad/mousepad-application.c b/mousepad/mousepad-application.c
index da50fe0..b308d15 100644
--- a/mousepad/mousepad-application.c
+++ b/mousepad/mousepad-application.c
@@ -43,8 +43,6 @@ static void        mousepad_application_new_window                (MousepadWindo
 
 
 
-
-
 struct _MousepadApplicationClass
 {
   GObjectClass __parent__;
@@ -60,28 +58,7 @@ struct _MousepadApplication
 
 
 
-static GObjectClass *mousepad_application_parent_class;
-
-
-
-GType
-mousepad_application_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (G_TYPE_OBJECT,
-                                            I_("MousepadApplication"),
-                                            sizeof (MousepadApplicationClass),
-                                            (GClassInitFunc) mousepad_application_class_init,
-                                            sizeof (MousepadApplication),
-                                            (GInstanceInitFunc) mousepad_application_init,
-                                            0);
-    }
-
-  return type;
-}
+G_DEFINE_TYPE (MousepadApplication, mousepad_application, G_TYPE_OBJECT);
 
 
 
@@ -90,8 +67,6 @@ mousepad_application_class_init (MousepadApplicationClass *klass)
 {
   GObjectClass *gobject_class;
 
-  mousepad_application_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_application_finalize;
 }
diff --git a/mousepad/mousepad-dbus.c b/mousepad/mousepad-dbus.c
index e85389e..9b6380c 100644
--- a/mousepad/mousepad-dbus.c
+++ b/mousepad/mousepad-dbus.c
@@ -65,28 +65,7 @@ struct _MousepadDBusService
 
 
 
-static GObjectClass *mousepad_dbus_service_parent_class;
-
-
-
-GType
-mousepad_dbus_service_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (G_TYPE_OBJECT,
-                                            I_("MousepadDBusService"),
-                                            sizeof (MousepadDBusServiceClass),
-                                            (GClassInitFunc) mousepad_dbus_service_class_init,
-                                            sizeof (MousepadDBusService),
-                                            (GInstanceInitFunc) mousepad_dbus_service_init,
-                                            0);
-    }
-
-  return type;
-}
+G_DEFINE_TYPE (MousepadDBusService, mousepad_dbus_service, G_TYPE_OBJECT);
 
 
 
@@ -96,9 +75,6 @@ mousepad_dbus_service_class_init (MousepadDBusServiceClass *klass)
   extern const DBusGObjectInfo  dbus_glib_mousepad_dbus_service_object_info;
   GObjectClass                 *gobject_class;
 
-  /* determine the parent type class */
-  mousepad_dbus_service_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_dbus_service_finalize;
 
diff --git a/mousepad/mousepad-document.c b/mousepad/mousepad-document.c
index f2d2b68..d637297 100644
--- a/mousepad/mousepad-document.c
+++ b/mousepad/mousepad-document.c
@@ -103,8 +103,7 @@ struct _MousepadDocumentPrivate
 
 
 
-static GObjectClass *mousepad_document_parent_class;
-static guint         document_signals[LAST_SIGNAL];
+static guint document_signals[LAST_SIGNAL];
 
 
 
@@ -116,24 +115,7 @@ mousepad_document_new (void)
 
 
 
-GType
-mousepad_document_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (GTK_TYPE_SCROLLED_WINDOW,
-                                            I_("MousepadDocument"),
-                                            sizeof (MousepadDocumentClass),
-                                            (GClassInitFunc) mousepad_document_class_init,
-                                            sizeof (MousepadDocument),
-                                            (GInstanceInitFunc) mousepad_document_init,
-                                            0);
-    }
-
-  return type;
-}
+G_DEFINE_TYPE (MousepadDocument, mousepad_document, GTK_TYPE_SCROLLED_WINDOW);
 
 
 
@@ -144,15 +126,13 @@ mousepad_document_class_init (MousepadDocumentClass *klass)
 
   g_type_class_add_private (klass, sizeof (MousepadDocumentPrivate));
 
-  mousepad_document_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_document_finalize;
 
   document_signals[CLOSE_TAB] =
     g_signal_new (I_("close-tab"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
@@ -160,7 +140,7 @@ mousepad_document_class_init (MousepadDocumentClass *klass)
   document_signals[CURSOR_CHANGED] =
     g_signal_new (I_("cursor-changed"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   _mousepad_marshal_VOID__INT_INT_INT,
                   G_TYPE_NONE, 3, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
@@ -168,7 +148,7 @@ mousepad_document_class_init (MousepadDocumentClass *klass)
   document_signals[SELECTION_CHANGED] =
     g_signal_new (I_("selection-changed"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__INT,
                   G_TYPE_NONE, 1, G_TYPE_INT);
@@ -176,7 +156,7 @@ mousepad_document_class_init (MousepadDocumentClass *klass)
   document_signals[OVERWRITE_CHANGED] =
     g_signal_new (I_("overwrite-changed"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__BOOLEAN,
                   G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
diff --git a/mousepad/mousepad-encoding-dialog.c b/mousepad/mousepad-encoding-dialog.c
index 238e1fb..ae965a6 100644
--- a/mousepad/mousepad-encoding-dialog.c
+++ b/mousepad/mousepad-encoding-dialog.c
@@ -173,37 +173,14 @@ static const gchar *encodings[] =
 
 
 
-static GObjectClass *mousepad_encoding_dialog_parent_class;
-
-
-
-GType
-mousepad_encoding_dialog_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (GTK_TYPE_DIALOG,
-                                            I_("MousepadEncodingDialog"),
-                                            sizeof (MousepadEncodingDialogClass),
-                                            (GClassInitFunc) mousepad_encoding_dialog_class_init,
-                                            sizeof (MousepadEncodingDialog),
-                                            (GInstanceInitFunc) mousepad_encoding_dialog_init,
-                                            0);
-    }
-
-  return type;
-}
+G_DEFINE_TYPE (MousepadEncodingDialog, mousepad_encoding_dialog, GTK_TYPE_DIALOG);
 
 
 
 static void
 mousepad_encoding_dialog_class_init (MousepadEncodingDialogClass *klass)
 {
-  GObjectClass   *gobject_class;
-
-  mousepad_encoding_dialog_parent_class = g_type_class_peek_parent (klass);
+  GObjectClass *gobject_class;
 
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_encoding_dialog_finalize;
diff --git a/mousepad/mousepad-file.c b/mousepad/mousepad-file.c
index 15efa86..64ceb3c 100644
--- a/mousepad/mousepad-file.c
+++ b/mousepad/mousepad-file.c
@@ -39,7 +39,7 @@
 
 enum
 {
-  EXTERNALLY_MODIFIED,
+  /* EXTERNALLY_MODIFIED, */
   FILENAME_CHANGED,
   LAST_SIGNAL
 };
@@ -80,29 +80,11 @@ static void  mousepad_file_finalize         (GObject            *object);
 
 
 
-static GObjectClass *mousepad_file_parent_class;
-static guint         file_signals[LAST_SIGNAL];
+static guint file_signals[LAST_SIGNAL];
 
 
 
-GType
-mousepad_file_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (G_TYPE_OBJECT,
-                                            I_("MousepadFile"),
-                                            sizeof (MousepadFileClass),
-                                            (GClassInitFunc) mousepad_file_class_init,
-                                            sizeof (MousepadFile),
-                                            (GInstanceInitFunc) mousepad_file_init,
-                                            0);
-    }
-
-  return type;
-}
+G_DEFINE_TYPE (MousepadFile, mousepad_file, G_TYPE_OBJECT);
 
 
 
@@ -111,23 +93,24 @@ mousepad_file_class_init (MousepadFileClass *klass)
 {
   GObjectClass *gobject_class;
 
-  mousepad_file_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_file_finalize;
 
+#if 0
+  /* TODO implement this signal */
   file_signals[EXTERNALLY_MODIFIED] =
     g_signal_new (I_("externally-modified"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__BOOLEAN,
                   G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
+#endif
 
   file_signals[FILENAME_CHANGED] =
     g_signal_new (I_("filename-changed"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__STRING,
                   G_TYPE_NONE, 1, G_TYPE_STRING);
diff --git a/mousepad/mousepad-preferences.c b/mousepad/mousepad-preferences.c
index 86b6b3c..ab1e3c1 100644
--- a/mousepad/mousepad-preferences.c
+++ b/mousepad/mousepad-preferences.c
@@ -117,9 +117,6 @@ struct _MousepadPreferences
 
 
 
-static GObjectClass *mousepad_preferences_parent_class;
-
-
 /**
  * transform_string_to_boolean:
  * @const GValue : String #GValue.
@@ -153,24 +150,7 @@ transform_string_to_int (const GValue *src,
 
 
 
-GType
-mousepad_preferences_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (G_TYPE_OBJECT,
-                                            I_("MousepadPreferences"),
-                                            sizeof (MousepadPreferencesClass),
-                                            (GClassInitFunc) mousepad_preferences_class_init,
-                                            sizeof (MousepadPreferences),
-                                            (GInstanceInitFunc) mousepad_preferences_init,
-                                            0);
-    }
-
-  return type;
-}
+G_DEFINE_TYPE (MousepadPreferences, mousepad_preferences, G_TYPE_OBJECT);
 
 
 
@@ -179,9 +159,6 @@ mousepad_preferences_class_init (MousepadPreferencesClass *klass)
 {
   GObjectClass *gobject_class;
 
-  /* determine the parent type class */
-  mousepad_preferences_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_preferences_finalize;
   gobject_class->get_property = mousepad_preferences_get_property;
diff --git a/mousepad/mousepad-print.c b/mousepad/mousepad-print.c
index cbb4e9a..1a1ba60 100644
--- a/mousepad/mousepad-print.c
+++ b/mousepad/mousepad-print.c
@@ -100,28 +100,7 @@ struct _MousepadPrint
 
 
 
-static GObjectClass *mousepad_print_parent_class;
-
-
-
-GType
-mousepad_print_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (GTK_TYPE_PRINT_OPERATION,
-                                            I_("MousepadPrint"),
-                                            sizeof (MousepadPrintClass),
-                                            (GClassInitFunc) mousepad_print_class_init,
-                                            sizeof (MousepadPrint),
-                                            (GInstanceInitFunc) mousepad_print_init,
-                                            0);
-    }
-
-  return type;
-}
+G_DEFINE_TYPE (MousepadPrint, mousepad_print, GTK_TYPE_PRINT_OPERATION);
 
 
 
@@ -131,8 +110,6 @@ mousepad_print_class_init (MousepadPrintClass *klass)
   GObjectClass           *gobject_class;
   GtkPrintOperationClass *gtkprintoperation_class;
 
-  mousepad_print_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_print_finalize;
 
diff --git a/mousepad/mousepad-private.h b/mousepad/mousepad-private.h
index c6d6730..5ba0333 100644
--- a/mousepad/mousepad-private.h
+++ b/mousepad/mousepad-private.h
@@ -31,10 +31,10 @@ G_BEGIN_DECLS
 #define MOUSEPAD_HAS_FLAG(flags,flag)   (((flags) & (flag)) != 0)
 
 /* for personal testing */
-#define TIMER_START  GTimer *__FUNCTION__timer = g_timer_new();
-#define TIMER_SPLIT  g_print ("%s (%s:%d): %.2f ms\n", __FUNCTION__, __FILE__, __LINE__, g_timer_elapsed (__FUNCTION__timer, NULL) * 1000);
-#define TIMER_STOP   TIMER_SPLIT g_timer_destroy (__FUNCTION__timer);
-#define PRINT_LINE   g_print ("%d (%s)\n", __LINE__, __FUNCTION__);
+#define TIMER_START    GTimer *__FUNCTION__timer = g_timer_new();
+#define TIMER_SPLIT    g_print ("%s: %.2f ms\n", G_STRLOC, g_timer_elapsed (__FUNCTION__timer, NULL) * 1000);
+#define TIMER_STOP     TIMER_SPLIT g_timer_destroy (__FUNCTION__timer);
+#define PRINT_LOCATION g_print ("%s\n", G_STRLOC);
 
 /* optimize the properties */
 #define MOUSEPAD_PARAM_READWRITE (G_PARAM_READWRITE | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
diff --git a/mousepad/mousepad-replace-dialog.c b/mousepad/mousepad-replace-dialog.c
index b9827d5..aa6bb41 100644
--- a/mousepad/mousepad-replace-dialog.c
+++ b/mousepad/mousepad-replace-dialog.c
@@ -105,31 +105,12 @@ enum
 
 
 
-static GObjectClass *mousepad_replace_dialog_parent_class;
-static GSList       *history_list = NULL;
-static guint         dialog_signals[LAST_SIGNAL];
+static GSList *history_list = NULL;
+static guint   dialog_signals[LAST_SIGNAL];
 
 
 
-GType
-mousepad_replace_dialog_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (GTK_TYPE_DIALOG,
-                                            I_("MousepadReplaceDialog"),
-                                            sizeof (MousepadReplaceDialogClass),
-                                            (GClassInitFunc) mousepad_replace_dialog_class_init,
-                                            sizeof (MousepadReplaceDialog),
-                                            (GInstanceInitFunc) mousepad_replace_dialog_init,
-                                            0);
-    }
-
-  return type;
-}
-
+G_DEFINE_TYPE (MousepadReplaceDialog, mousepad_replace_dialog, GTK_TYPE_DIALOG);
 
 
 static void
@@ -138,8 +119,6 @@ mousepad_replace_dialog_class_init (MousepadReplaceDialogClass *klass)
   GObjectClass   *gobject_class;
   GtkWidgetClass *gtkwidget_class;
 
-  mousepad_replace_dialog_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_replace_dialog_finalize;
 
@@ -149,7 +128,7 @@ mousepad_replace_dialog_class_init (MousepadReplaceDialogClass *klass)
   dialog_signals[SEARCH] =
     g_signal_new (I_("search"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   _mousepad_marshal_INT__FLAGS_STRING_STRING,
                   G_TYPE_INT, 3,
diff --git a/mousepad/mousepad-search-bar.c b/mousepad/mousepad-search-bar.c
index be06618..803a5a2 100644
--- a/mousepad/mousepad-search-bar.c
+++ b/mousepad/mousepad-search-bar.c
@@ -92,8 +92,7 @@ struct _MousepadSearchBar
 
 
 
-static GObjectClass *mousepad_search_bar_parent_class;
-static guint         search_bar_signals[LAST_SIGNAL];
+static guint search_bar_signals[LAST_SIGNAL];
 
 
 
@@ -108,24 +107,7 @@ mousepad_search_bar_new (void)
 
 
 
-GType
-mousepad_search_bar_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (GTK_TYPE_TOOLBAR,
-                                            I_("MousepadSearchBar"),
-                                            sizeof (MousepadSearchBarClass),
-                                            (GClassInitFunc) mousepad_search_bar_class_init,
-                                            sizeof (MousepadSearchBar),
-                                            (GInstanceInitFunc) mousepad_search_bar_init,
-                                            0);
-    }
-
-  return type;
-}
+G_DEFINE_TYPE (MousepadSearchBar, mousepad_search_bar, GTK_TYPE_TOOLBAR);
 
 
 
@@ -135,8 +117,6 @@ mousepad_search_bar_class_init (MousepadSearchBarClass *klass)
   GObjectClass  *gobject_class;
   GtkBindingSet *binding_set;
 
-  mousepad_search_bar_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_search_bar_finalize;
 
@@ -144,7 +124,7 @@ mousepad_search_bar_class_init (MousepadSearchBarClass *klass)
   search_bar_signals[HIDE_BAR] =
     g_signal_new (I_("hide-bar"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS | G_SIGNAL_ACTION,
+                  G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
@@ -152,7 +132,7 @@ mousepad_search_bar_class_init (MousepadSearchBarClass *klass)
   search_bar_signals[SEARCH] =
     g_signal_new (I_("search"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   _mousepad_marshal_INT__FLAGS_STRING_STRING,
                   G_TYPE_INT, 3,
diff --git a/mousepad/mousepad-statusbar.c b/mousepad/mousepad-statusbar.c
index 462c98a..712bdd1 100644
--- a/mousepad/mousepad-statusbar.c
+++ b/mousepad/mousepad-statusbar.c
@@ -63,31 +63,14 @@ static guint statusbar_signals[LAST_SIGNAL];
 
 
 
-GtkWidget *
-mousepad_statusbar_new (void)
-{
-  return g_object_new (MOUSEPAD_TYPE_STATUSBAR, NULL);
-}
+G_DEFINE_TYPE (MousepadStatusbar, mousepad_statusbar, GTK_TYPE_STATUSBAR);
 
 
 
-GType
-mousepad_statusbar_get_type (void)
+GtkWidget *
+mousepad_statusbar_new (void)
 {
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (GTK_TYPE_STATUSBAR,
-                                            I_("MousepadStatusbar"),
-                                            sizeof (MousepadStatusbarClass),
-                                            (GClassInitFunc) mousepad_statusbar_class_init,
-                                            sizeof (MousepadStatusbar),
-                                            (GInstanceInitFunc) mousepad_statusbar_init,
-                                            0);
-    }
-
-  return type;
+  return g_object_new (MOUSEPAD_TYPE_STATUSBAR, NULL);
 }
 
 
@@ -95,14 +78,14 @@ 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);
 
   statusbar_signals[ENABLE_OVERWRITE] =
     g_signal_new (I_("enable-overwrite"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__BOOLEAN,
                   G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
diff --git a/mousepad/mousepad-undo.c b/mousepad/mousepad-undo.c
index 2a98693..5b28e3b 100644
--- a/mousepad/mousepad-undo.c
+++ b/mousepad/mousepad-undo.c
@@ -156,30 +156,11 @@ struct _MousepadUndoStep
 
 
 
-static GObjectClass *mousepad_undo_parent_class;
-static guint         undo_signals[LAST_SIGNAL];
+static guint undo_signals[LAST_SIGNAL];
 
 
 
-GType
-mousepad_undo_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (G_TYPE_OBJECT,
-                                            I_("MousepadUndo"),
-                                            sizeof (MousepadUndoClass),
-                                            (GClassInitFunc) mousepad_undo_class_init,
-                                            sizeof (MousepadUndo),
-                                            (GInstanceInitFunc) mousepad_undo_init,
-                                            0);
-    }
-
-  return type;
-}
-
+G_DEFINE_TYPE (MousepadUndo, mousepad_undo, G_TYPE_OBJECT);
 
 
 static void
@@ -187,15 +168,13 @@ mousepad_undo_class_init (MousepadUndoClass *klass)
 {
   GObjectClass *gobject_class;
 
-  mousepad_undo_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_undo_finalize;
 
   undo_signals[CAN_UNDO] =
     g_signal_new (I_("can-undo"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__BOOLEAN,
                   G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
@@ -203,7 +182,7 @@ mousepad_undo_class_init (MousepadUndoClass *klass)
   undo_signals[CAN_REDO] =
     g_signal_new (I_("can-redo"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__BOOLEAN,
                   G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
diff --git a/mousepad/mousepad-view.c b/mousepad/mousepad-view.c
index 5e97b57..99e3386 100644
--- a/mousepad/mousepad-view.c
+++ b/mousepad/mousepad-view.c
@@ -131,28 +131,7 @@ struct _MousepadView
 
 
 
-static GObjectClass *mousepad_view_parent_class;
-
-
-
-GType
-mousepad_view_get_type (void)
-{
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (GTK_TYPE_TEXT_VIEW,
-                                            I_("MousepadView"),
-                                            sizeof (MousepadViewClass),
-                                            (GClassInitFunc) mousepad_view_class_init,
-                                            sizeof (MousepadView),
-                                            (GInstanceInitFunc) mousepad_view_init,
-                                            0);
-    }
-
-  return type;
-}
+G_DEFINE_TYPE (MousepadView, mousepad_view, GTK_TYPE_TEXT_VIEW);
 
 
 
@@ -162,8 +141,6 @@ mousepad_view_class_init (MousepadViewClass *klass)
   GObjectClass   *gobject_class;
   GtkWidgetClass *widget_class;
 
-  mousepad_view_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->finalize = mousepad_view_finalize;
 
diff --git a/mousepad/mousepad-window.c b/mousepad/mousepad-window.c
index 32cc765..8b551c3 100644
--- a/mousepad/mousepad-window.c
+++ b/mousepad/mousepad-window.c
@@ -63,7 +63,6 @@ enum
 {
   NEW_WINDOW,
   NEW_WINDOW_WITH_DOCUMENT,
-  HAS_DOCUMENTS,
   LAST_SIGNAL,
 };
 
@@ -398,7 +397,7 @@ static const GtkActionEntry action_entries[] =
     { "save-as", GTK_STOCK_SAVE_AS, N_("Save _As..."), "<shift><control>S", N_("Save current document as another file"), G_CALLBACK (mousepad_window_action_save_as), },
     { "save-all", NULL, N_("Save A_ll"), NULL, N_("Save all document in this window"), G_CALLBACK (mousepad_window_action_save_all), },
     { "revert", GTK_STOCK_REVERT_TO_SAVED, N_("Re_vert"), NULL, N_("Revert to the saved version of the file"), G_CALLBACK (mousepad_window_action_revert), },
-    { "print", GTK_STOCK_PRINT, N_("_Print..."), "<control>P", N_("Prin the current document"), G_CALLBACK (mousepad_window_action_print), },
+    { "print", GTK_STOCK_PRINT, N_("_Print..."), "<control>P", N_("Print the current document"), G_CALLBACK (mousepad_window_action_print), },
     { "detach", NULL, N_("_Detach Tab"), "<control>D", N_("Move the current document to a new window"), G_CALLBACK (mousepad_window_action_detach), },
     { "close", GTK_STOCK_CLOSE, N_("Close _Tab"), "<control>W", N_("Close the current document"), G_CALLBACK (mousepad_window_action_close), },
     { "close-window", GTK_STOCK_QUIT, N_("_Close Window"), "<control>Q", N_("Close this window"), G_CALLBACK (mousepad_window_action_close_window), },
@@ -437,8 +436,8 @@ static const GtkActionEntry action_entries[] =
       { "line-up", NULL, N_("Line _Up"), NULL, N_("Move the selection one line up"), G_CALLBACK (mousepad_window_action_move_line_up), },
       { "line-down", NULL, N_("Line _Down"), NULL, N_("Move the selection one line down"), G_CALLBACK (mousepad_window_action_move_line_down), },
     { "duplicate", NULL, N_("D_uplicate Line / Selection"), NULL, N_("Duplicate the current line or selection"), G_CALLBACK (mousepad_window_action_duplicate), },
-    { "increase-indent", GTK_STOCK_INDENT, N_("_Increase Indent"), NULL, N_("Increase indent of selection or line"), G_CALLBACK (mousepad_window_action_increase_indent), },
-    { "decrease-indent", GTK_STOCK_UNINDENT, N_("_Decrease Indent"), NULL, N_("Decrease indent of selection or line"), G_CALLBACK (mousepad_window_action_decrease_indent), },
+    { "increase-indent", GTK_STOCK_INDENT, N_("_Increase Indent"), NULL, N_("Increase the indentation of the selection or current line"), G_CALLBACK (mousepad_window_action_increase_indent), },
+    { "decrease-indent", GTK_STOCK_UNINDENT, N_("_Decrease Indent"), NULL, N_("Decrease the indentation of the selection or current line"), G_CALLBACK (mousepad_window_action_decrease_indent), },
 
   { "document-menu", NULL, N_("_Document"), NULL, NULL, NULL, },
     { "tab-size-menu", NULL, N_("Tab _Size"), NULL, NULL, NULL, },
@@ -473,39 +472,21 @@ static const GtkRadioActionEntry radio_action_entries[] =
 
 
 /* global variables */
-static GObjectClass *mousepad_window_parent_class;
-static guint         window_signals[LAST_SIGNAL];
-static gint          lock_menu_updates = 0;
-static GSList       *clipboard_history = NULL;
-static guint         clipboard_history_ref_count = 0;
+static guint   window_signals[LAST_SIGNAL];
+static gint    lock_menu_updates = 0;
+static GSList *clipboard_history = NULL;
+static guint   clipboard_history_ref_count = 0;
 
 
 
-GtkWidget *
-mousepad_window_new (void)
-{
-  return g_object_new (MOUSEPAD_TYPE_WINDOW, NULL);
-}
+G_DEFINE_TYPE (MousepadWindow, mousepad_window, GTK_TYPE_WINDOW);
 
 
 
-GType
-mousepad_window_get_type (void)
+GtkWidget *
+mousepad_window_new (void)
 {
-  static GType type = G_TYPE_INVALID;
-
-  if (G_UNLIKELY (type == G_TYPE_INVALID))
-    {
-      type = g_type_register_static_simple (GTK_TYPE_WINDOW,
-                                            I_("MousepadWindow"),
-                                            sizeof (MousepadWindowClass),
-                                            (GClassInitFunc) mousepad_window_class_init,
-                                            sizeof (MousepadWindow),
-                                            (GInstanceInitFunc) mousepad_window_init,
-                                            0);
-    }
-
-  return type;
+  return g_object_new (MOUSEPAD_TYPE_WINDOW, NULL);
 }
 
 
@@ -516,8 +497,6 @@ mousepad_window_class_init (MousepadWindowClass *klass)
   GObjectClass   *gobject_class;
   GtkWidgetClass *gtkwidget_class;
 
-  mousepad_window_parent_class = g_type_class_peek_parent (klass);
-
   gobject_class = G_OBJECT_CLASS (klass);
   gobject_class->dispose = mousepad_window_dispose;
   gobject_class->finalize = mousepad_window_finalize;
@@ -528,7 +507,7 @@ mousepad_window_class_init (MousepadWindowClass *klass)
   window_signals[NEW_WINDOW] =
     g_signal_new (I_("new-window"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
@@ -536,21 +515,12 @@ mousepad_window_class_init (MousepadWindowClass *klass)
   window_signals[NEW_WINDOW_WITH_DOCUMENT] =
     g_signal_new (I_("new-window-with-document"),
                   G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
+                  G_SIGNAL_RUN_LAST,
                   0, NULL, NULL,
                   _mousepad_marshal_VOID__OBJECT_INT_INT,
                   G_TYPE_NONE, 3,
                   G_TYPE_OBJECT,
                   G_TYPE_INT, G_TYPE_INT);
-
-  window_signals[HAS_DOCUMENTS] =
-    g_signal_new (I_("has-documents"),
-                  G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_NO_HOOKS,
-                  0, NULL, NULL,
-                  g_cclosure_marshal_VOID__BOOLEAN,
-                  G_TYPE_NONE, 1,
-                  G_TYPE_BOOLEAN);
 }
 
 
@@ -997,6 +967,9 @@ mousepad_window_open_file (MousepadWindow *window,
   /* new document */
   document = mousepad_document_new ();
 
+  /* make sure it's not a floating object */
+  g_object_ref_sink (G_OBJECT (document));
+
   /* set the filename */
   mousepad_file_set_filename (document->file, filename);
 
@@ -1751,6 +1724,8 @@ mousepad_window_menu_templates_fill (MousepadWindow *window,
             dirs_list = g_slist_insert_sorted (dirs_list, absolute_path, (GCompareFunc) strcmp);
           else if (g_file_test (absolute_path, G_FILE_TEST_IS_REGULAR))
             files_list = g_slist_insert_sorted (files_list, absolute_path, (GCompareFunc) strcmp);
+          else
+            g_free (absolute_path);
         }
 
       /* close the directory */
@@ -2617,7 +2592,7 @@ mousepad_window_drag_data_received (GtkWidget        *widget,
       working_directory = g_get_current_dir ();
 
       /* open the files */
-      mousepad_window_open_files (window, NULL, uris);
+      mousepad_window_open_files (window, working_directory, uris);
 
       /* cleanup */
       g_free (working_directory);


More information about the Xfce4-commits mailing list