[gedit/wip/gtkapp] Remove gedit_applucation_get_default etc



commit ebed3db444f2517a8c51cf4d20233ff3ba85877d
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Nov 24 11:56:57 2012 +0100

    Remove gedit_applucation_get_default etc
    
    Use g(tk)_application methods

 docs/reference/gedit-sections.txt                |    3 -
 gedit/gedit-app-osx.c                            |    6 +-
 gedit/gedit-app.c                                |  113 +---------------------
 gedit/gedit-app.h                                |    5 -
 gedit/gedit-close-confirmation-dialog.c          |    7 +-
 gedit/gedit-commands-file.c                      |    4 +-
 gedit/gedit-commands-help.c                      |    2 +-
 gedit/gedit-encodings-dialog.c                   |    2 +-
 gedit/gedit-preferences-dialog.c                 |    4 +-
 gedit/gedit-settings.c                           |  101 ++++++++++----------
 gedit/gedit-tab.c                                |   20 +++--
 gedit/gedit-view.c                               |    2 +-
 gedit/gedit-window.c                             |   14 ++-
 gedit/gedit.c                                    |   29 +++++-
 plugins/checkupdate/gedit-check-update-plugin.c  |    2 +-
 plugins/externaltools/tools/filelookup.py        |    4 +-
 plugins/externaltools/tools/manager.py           |    4 +-
 plugins/externaltools/tools/windowactivatable.py |    6 +-
 plugins/filebrowser/gedit-file-browser-plugin.c  |    4 +-
 plugins/snippets/snippets/manager.py             |   10 +-
 plugins/sort/gedit-sort-plugin.c                 |    2 +-
 plugins/spell/gedit-spell-language-dialog.c      |    2 +-
 plugins/time/gedit-time-plugin.c                 |    2 +-
 23 files changed, 128 insertions(+), 220 deletions(-)
---
diff --git a/docs/reference/gedit-sections.txt b/docs/reference/gedit-sections.txt
index 72046ba..afb35d4 100644
--- a/docs/reference/gedit-sections.txt
+++ b/docs/reference/gedit-sections.txt
@@ -4,10 +4,7 @@ GeditAppPrivate
 <TITLE>GeditApp</TITLE>
 GeditApp
 GeditLockdownMask
-gedit_app_get_default
 gedit_app_create_window
-gedit_app_get_windows
-gedit_app_get_active_window
 gedit_app_get_documents
 gedit_app_get_views
 gedit_app_get_lockdown
diff --git a/gedit/gedit-app-osx.c b/gedit/gedit-app-osx.c
index 27bdd2e..466db13 100644
--- a/gedit/gedit-app-osx.c
+++ b/gedit/gedit-app-osx.c
@@ -380,7 +380,7 @@ on_osx_block_termination (GtkOSXApplication *osxapp,
 	GtkAction *action;
 	GeditWindow *window;
 
-	window = gedit_app_get_active_window (GEDIT_APP (app));
+	window = gtk_appliction_get_active_window (GTK_APPLICATION (app));
 
 	// Synthesize quit-all
 	manager = gedit_window_get_ui_manager (window);
@@ -412,8 +412,8 @@ on_osx_open_files (GtkOSXApplication  *osxapp,
 	{
 		GSList *files;
 		GeditWindow *window;
-		
-		window = gedit_app_get_active_window (GEDIT_APP (app));
+
+		window = gtk_application_get_active_window (GTK_APPLICATION (app));
 
 		files = gedit_commands_load_locations (window,
 		                                       locations,
diff --git a/gedit/gedit-app.c b/gedit/gedit-app.c
index 6b5ca62..5dd4f15 100644
--- a/gedit/gedit-app.c
+++ b/gedit/gedit-app.c
@@ -56,16 +56,6 @@
 #include "gedit-app-activatable.h"
 #include "gedit-plugins-engine.h"
 
-#ifdef OS_OSX
-#include "gedit-app-osx.h"
-#else
-#ifdef G_OS_WIN32
-#include "gedit-app-win32.h"
-#else
-#include "gedit-app-x11.h"
-#endif
-#endif
-
 #ifndef ENABLE_GVFS_METADATA
 #include "gedit-metadata-manager.h"
 #define METADATA_FILE "gedit-metadata.xml"
@@ -100,8 +90,6 @@ struct _GeditAppPrivate
 	PeasExtensionSet  *extensions;
 };
 
-static GeditApp *app_instance = NULL;
-
 static gboolean help = FALSE;
 static gboolean version = FALSE;
 static gboolean list_encodings = FALSE;
@@ -254,27 +242,6 @@ gedit_app_get_property (GObject    *object,
 	}
 }
 
-static GObject *
-gedit_app_constructor (GType                  gtype,
-                       guint                  n_construct_params,
-                       GObjectConstructParam *construct_params)
-{
-	if (!app_instance)
-	{
-		GObject *obj = G_OBJECT_CLASS (
-			gedit_app_parent_class)->constructor (gtype,
-			                                      n_construct_params,
-			                                      construct_params);
-
-		app_instance = GEDIT_APP (obj);
-		g_object_add_weak_pointer (obj, (gpointer *) &app_instance);
-
-		return obj;
-	}
-
-	return g_object_ref (app_instance);
-}
-
 static gboolean
 gedit_app_last_window_destroyed_impl (GeditApp    *app,
                                       GeditWindow *window)
@@ -915,6 +882,8 @@ load_accels (void)
 static void
 gedit_app_constructed (GObject *object)
 {
+	G_OBJECT_CLASS (gedit_app_parent_class)->constructed (object);
+
 	load_accels ();
 }
 
@@ -1049,7 +1018,6 @@ gedit_app_class_init (GeditAppClass *klass)
 	object_class->finalize = gedit_app_finalize;
 	object_class->dispose = gedit_app_dispose;
 	object_class->get_property = gedit_app_get_property;
-	object_class->constructor = gedit_app_constructor;
 	object_class->constructed = gedit_app_constructed;
 
 	app_class->startup = gedit_app_startup;
@@ -1152,41 +1120,6 @@ gedit_app_init (GeditApp *app)
 	app->priv->lockdown = gedit_settings_get_lockdown (GEDIT_SETTINGS (app->priv->settings));
 }
 
-/* FIXME: lets kill this method */
-/**
- * gedit_app_get_default:
- *
- * Returns the #GeditApp object. This object is a singleton and
- * represents the running gedit instance.
- *
- * Return value: (transfer none): the #GeditApp pointer
- */
-GeditApp *
-gedit_app_get_default (void)
-{
-	GType type;
-
-	if (app_instance != NULL)
-	{
-		return app_instance;
-	}
-
-#ifdef OS_OSX
-	type = GEDIT_TYPE_APP_OSX;
-#else
-#ifdef G_OS_WIN32
-	type = GEDIT_TYPE_APP_WIN32;
-#else
-	type = GEDIT_TYPE_APP_X11;
-#endif
-#endif
-
-	return GEDIT_APP (g_object_new (type,
-	                                "application-id", "org.gnome.Gedit",
-	                                "flags", G_APPLICATION_HANDLES_COMMAND_LINE,
-	                                NULL));
-}
-
 /* Generates a unique string for a window role */
 static gchar *
 gen_role (void)
@@ -1305,48 +1238,6 @@ _gedit_app_restore_window (GeditApp    *app,
 	return window;
 }
 
-/* FIXME: lets kill this method */
-/**
- * gedit_app_get_windows:
- * @app: the #GeditApp
- *
- * Returns all the windows currently present in #GeditApp.
- *
- * Return value: (element-type Gedit.Window) (transfer none): the list of #GeditWindows objects.
- * The list should not be freed
- */
-const GList *
-gedit_app_get_windows (GeditApp *app)
-{
-	g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
-
-	return gtk_application_get_windows (GTK_APPLICATION (app));
-}
-
-/**
- * gedit_app_get_active_window:
- * @app: the #GeditApp
- *
- * Retrives the #GeditWindow currently active.
- *
- * Return value: (transfer none): the active #GeditWindow
- */
-GeditWindow *
-gedit_app_get_active_window (GeditApp *app)
-{
-	g_return_val_if_fail (GEDIT_IS_APP (app), NULL);
-
-	/* make sure our active window is always realized:
-	 * this is needed on startup if we launch two gedit fast
-	 * enough that the second instance comes up before the
-	 * first one shows its window.
-	 */
-	if (!gtk_widget_get_realized (GTK_WIDGET (app->priv->active_window)))
-		gtk_widget_realize (GTK_WIDGET (app->priv->active_window));
-
-	return app->priv->active_window;
-}
-
 static gboolean
 is_in_viewport (GeditWindow  *window,
 		GdkScreen    *screen,
diff --git a/gedit/gedit-app.h b/gedit/gedit-app.h
index 8808fe6..6a71bf2 100644
--- a/gedit/gedit-app.h
+++ b/gedit/gedit-app.h
@@ -100,14 +100,9 @@ typedef enum
 /* Public methods */
 GType 		 gedit_app_get_type 			(void) G_GNUC_CONST;
 
-GeditApp 	*gedit_app_get_default			(void);
-
 GeditWindow	*gedit_app_create_window		(GeditApp    *app,
 							 GdkScreen   *screen);
 
-const GList	*gedit_app_get_windows			(GeditApp    *app);
-GeditWindow	*gedit_app_get_active_window		(GeditApp    *app);
-
 /* Returns a newly allocated list with all the documents */
 GList		*gedit_app_get_documents		(GeditApp    *app);
 
diff --git a/gedit/gedit-close-confirmation-dialog.c b/gedit/gedit-close-confirmation-dialog.c
index 52f76fe..f8e41d8 100644
--- a/gedit/gedit-close-confirmation-dialog.c
+++ b/gedit/gedit-close-confirmation-dialog.c
@@ -190,13 +190,14 @@ set_logout_mode (GeditCloseConfirmationDialog *dlg,
 static void 
 gedit_close_confirmation_dialog_init (GeditCloseConfirmationDialog *dlg)
 {
+	GeditLockdownMask lockdown;
 	AtkObject *atk_obj;
 
 	dlg->priv = GEDIT_CLOSE_CONFIRMATION_DIALOG_GET_PRIVATE (dlg);
 
-	dlg->priv->disable_save_to_disk = 
-			gedit_app_get_lockdown (gedit_app_get_default ()) 
-			& GEDIT_LOCKDOWN_SAVE_TO_DISK;
+	lockdown = gedit_app_get_lockdown (GEDIT_APP (g_application_get_default ()));
+
+	dlg->priv->disable_save_to_disk = lockdown & GEDIT_LOCKDOWN_SAVE_TO_DISK;
 
 	gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);		
 	gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dlg))),
diff --git a/gedit/gedit-commands-file.c b/gedit/gedit-commands-file.c
index a2c5daf..81d4afd 100644
--- a/gedit/gedit-commands-file.c
+++ b/gedit/gedit-commands-file.c
@@ -1933,8 +1933,8 @@ quit_all ()
 	GList *item;
 	GeditApp *app;
 
-	app = gedit_app_get_default ();
-	windows = g_list_copy ((GList *)gedit_app_get_windows (app));
+	app = GEDIT_APP (g_application_get_default ());
+	windows = g_list_copy (gtk_application_get_windows (GTK_APPLICATION (app)));
 
 	for (item = windows; item; item = g_list_next (item))
 	{
diff --git a/gedit/gedit-commands-help.c b/gedit/gedit-commands-help.c
index db159b7..d244d91 100644
--- a/gedit/gedit-commands-help.c
+++ b/gedit/gedit-commands-help.c
@@ -48,7 +48,7 @@ _gedit_cmd_help_contents (GtkAction   *action,
 {
 	gedit_debug (DEBUG_COMMANDS);
 
-	gedit_app_show_help (gedit_app_get_default (),
+	gedit_app_show_help (GEDIT_APP (g_application_get_default ()),
 	                     GTK_WINDOW (window),
 	                     NULL,
 	                     NULL);
diff --git a/gedit/gedit-encodings-dialog.c b/gedit/gedit-encodings-dialog.c
index 82fdfbc..8b20a62 100644
--- a/gedit/gedit-encodings-dialog.c
+++ b/gedit/gedit-encodings-dialog.c
@@ -290,7 +290,7 @@ response_handler (GtkDialog            *dialog,
 {
 	if (response_id == GTK_RESPONSE_HELP)
 	{
-		gedit_app_show_help (gedit_app_get_default(),
+		gedit_app_show_help (GEDIT_APP (g_application_get_default ()),
 		                     GTK_WINDOW (dialog),
 		                     "gedit",
 		                     NULL);
diff --git a/gedit/gedit-preferences-dialog.c b/gedit/gedit-preferences-dialog.c
index c8b64ff..ab6ada7 100644
--- a/gedit/gedit-preferences-dialog.c
+++ b/gedit/gedit-preferences-dialog.c
@@ -161,7 +161,7 @@ dialog_response_handler (GtkDialog *dlg,
 	switch (res_id)
 	{
 		case GTK_RESPONSE_HELP:
-			gedit_app_show_help (gedit_app_get_default (),
+			gedit_app_show_help (GEDIT_APP (g_application_get_default ()),
 			                     GTK_WINDOW (dlg),
 			                     NULL,
 			                     "index#configure-gedit");
@@ -430,7 +430,7 @@ setup_font_colors_page_font_section (GeditPreferencesDialog *dlg)
 				      ATK_RELATION_CONTROLLER_FOR);
 
 	/* Get values */
-	settings = _gedit_app_get_settings (gedit_app_get_default ());
+	settings = _gedit_app_get_settings (GEDIT_APP (g_application_get_default ()));
 	system_font = gedit_settings_get_system_font (GEDIT_SETTINGS (settings));
 	use_default_font = g_settings_get_boolean (dlg->priv->editor,
 						   GEDIT_SETTINGS_USE_DEFAULT_FONT);
diff --git a/gedit/gedit-settings.c b/gedit/gedit-settings.c
index 410d216..4cedc30 100644
--- a/gedit/gedit-settings.c
+++ b/gedit/gedit-settings.c
@@ -88,8 +88,8 @@ on_lockdown_changed (GSettings   *settings,
 	GeditApp *app;
 	
 	locked = g_settings_get_boolean (settings, key);
-	app = gedit_app_get_default ();
-	
+	app = GEDIT_APP (g_application_get_default ());
+
 	if (strcmp (key, GEDIT_SETTINGS_LOCKDOWN_COMMAND_LINE) == 0)
 	{
 		_gedit_app_set_lockdown_bit (app, 
@@ -124,9 +124,9 @@ set_font (GeditSettings *gs,
 	guint ts;
 	
 	g_settings_get (gs->priv->editor, GEDIT_SETTINGS_TABS_SIZE, "u", &ts);
-	
-	views = gedit_app_get_views (gedit_app_get_default ());
-	
+
+	views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
+
 	for (l = views; l != NULL; l = g_list_next (l))
 	{
 		/* Note: we use def=FALSE to avoid GeditView to query dconf */
@@ -242,7 +242,8 @@ on_scheme_changed (GSettings     *settings,
 		}
 	}
 
-	docs = gedit_app_get_documents (gedit_app_get_default ());
+	docs = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
+
 	for (l = docs; l != NULL; l = g_list_next (l))
 	{
 		g_return_if_fail (GTK_SOURCE_IS_BUFFER (l->data));
@@ -263,9 +264,9 @@ on_auto_save_changed (GSettings     *settings,
 	gboolean auto_save;
 	
 	auto_save = g_settings_get_boolean (settings, key);
-	
-	docs = gedit_app_get_documents (gedit_app_get_default ());
-	
+
+	docs = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
+
 	for (l = docs; l != NULL; l = g_list_next (l))
 	{
 		GeditTab *tab = gedit_tab_get_from_document (GEDIT_DOCUMENT (l->data));
@@ -285,9 +286,9 @@ on_auto_save_interval_changed (GSettings     *settings,
 	gint auto_save_interval;
 	
 	g_settings_get (settings, key, "u", &auto_save_interval);
-	
-	docs = gedit_app_get_documents (gedit_app_get_default ());
-	
+
+	docs = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
+
 	for (l = docs; l != NULL; l = g_list_next (l))
 	{
 		GeditTab *tab = gedit_tab_get_from_document (GEDIT_DOCUMENT (l->data));
@@ -309,9 +310,9 @@ on_undo_actions_limit_changed (GSettings     *settings,
 	ul = g_settings_get_int (settings, key);
 	
 	ul = CLAMP (ul, -1, 250);
-	
-	docs = gedit_app_get_documents (gedit_app_get_default ());
-	
+
+	docs = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
+
 	for (l = docs; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_buffer_set_max_undo_levels (GTK_SOURCE_BUFFER (l->data),
@@ -331,8 +332,8 @@ on_wrap_mode_changed (GSettings     *settings,
 
 	wrap_mode = g_settings_get_enum (settings, key);
 
-	views = gedit_app_get_views (gedit_app_get_default ());
-	
+	views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
+
 	for (l = views; l != NULL; l = g_list_next (l))
 	{
 		gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (l->data),
@@ -353,9 +354,9 @@ on_tabs_size_changed (GSettings     *settings,
 	g_settings_get (settings, key, "u", &ts);
 	
 	ts = CLAMP (ts, 1, 24);
-	
-	views = gedit_app_get_views (gedit_app_get_default ());
-	
+
+	views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
+
 	for (l = views; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_view_set_tab_width (GTK_SOURCE_VIEW (l->data),
@@ -374,9 +375,9 @@ on_insert_spaces_changed (GSettings     *settings,
 	gboolean spaces;
 	
 	spaces = g_settings_get_boolean (settings, key);
-	
-	views = gedit_app_get_views (gedit_app_get_default ());
-	
+
+	views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
+
 	for (l = views; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_view_set_insert_spaces_instead_of_tabs (
@@ -396,9 +397,9 @@ on_auto_indent_changed (GSettings     *settings,
 	gboolean enable;
 	
 	enable = g_settings_get_boolean (settings, key);
-	
-	views = gedit_app_get_views (gedit_app_get_default ());
-	
+
+	views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
+
 	for (l = views; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_view_set_auto_indent (GTK_SOURCE_VIEW (l->data),
@@ -417,9 +418,9 @@ on_display_line_numbers_changed (GSettings     *settings,
 	gboolean line_numbers;
 	
 	line_numbers = g_settings_get_boolean (settings, key);
-	
-	views = gedit_app_get_views (gedit_app_get_default ());
-	
+
+	views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
+
 	for (l = views; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_view_set_show_line_numbers (GTK_SOURCE_VIEW (l->data),
@@ -438,9 +439,9 @@ on_hl_current_line_changed (GSettings     *settings,
 	gboolean hl;
 	
 	hl = g_settings_get_boolean (settings, key);
-	
-	views = gedit_app_get_views (gedit_app_get_default ());
-	
+
+	views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
+
 	for (l = views; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW (l->data),
@@ -459,9 +460,9 @@ on_bracket_matching_changed (GSettings     *settings,
 	gboolean enable;
 	
 	enable = g_settings_get_boolean (settings, key);
-	
-	docs = gedit_app_get_documents (gedit_app_get_default ());
-	
+
+	docs = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
+
 	for (l = docs; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_buffer_set_highlight_matching_brackets (GTK_SOURCE_BUFFER (l->data),
@@ -480,9 +481,9 @@ on_display_right_margin_changed (GSettings     *settings,
 	gboolean display;
 	
 	display = g_settings_get_boolean (settings, key);
-	
-	views = gedit_app_get_views (gedit_app_get_default ());
-	
+
+	views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
+
 	for (l = views; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_view_set_show_right_margin (GTK_SOURCE_VIEW (l->data),
@@ -503,9 +504,9 @@ on_right_margin_position_changed (GSettings     *settings,
 	g_settings_get (settings, key, "u", &pos);
 	
 	pos = CLAMP (pos, 1, 160);
-	
-	views = gedit_app_get_views (gedit_app_get_default ());
-	
+
+	views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
+
 	for (l = views; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_view_set_right_margin_position (GTK_SOURCE_VIEW (l->data),
@@ -525,8 +526,8 @@ on_smart_home_end_changed (GSettings     *settings,
 
 	smart_he = g_settings_get_enum (settings, key);
 
-	views = gedit_app_get_views (gedit_app_get_default ());
-	
+	views = gedit_app_get_views (GEDIT_APP (g_application_get_default ()));
+
 	for (l = views; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_view_set_smart_home_end (GTK_SOURCE_VIEW (l->data),
@@ -546,9 +547,9 @@ on_syntax_highlighting_changed (GSettings     *settings,
 	gboolean enable;
 	
 	enable = g_settings_get_boolean (settings, key);
-	
-	docs = gedit_app_get_documents (gedit_app_get_default ());
-	
+
+	docs = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
+
 	for (l = docs; l != NULL; l = g_list_next (l))
 	{
 		gtk_source_buffer_set_highlight_syntax (GTK_SOURCE_BUFFER (l->data),
@@ -558,7 +559,7 @@ on_syntax_highlighting_changed (GSettings     *settings,
 	g_list_free (docs);
 
 	/* update the sensitivity of the Higlight Mode menu item */
-	windows = gedit_app_get_windows (gedit_app_get_default ());
+	windows = gtk_application_get_windows (GTK_APPLICATION (g_application_get_default ()));
 	while (windows != NULL)
 	{
 		GtkUIManager *ui;
@@ -584,9 +585,9 @@ on_search_highlighting_changed (GSettings     *settings,
 	gboolean enable;
 	
 	enable = g_settings_get_boolean (settings, key);
-	
-	docs = gedit_app_get_documents (gedit_app_get_default ());
-	
+
+	docs = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
+
 	for (l = docs; l != NULL; l = g_list_next (l))
 	{
 		gedit_document_set_enable_search_highlighting  (GEDIT_DOCUMENT (l->data),
diff --git a/gedit/gedit-tab.c b/gedit/gedit-tab.c
index c1cae23..2440d45 100644
--- a/gedit/gedit-tab.c
+++ b/gedit/gedit-tab.c
@@ -1089,7 +1089,7 @@ document_loaded (GeditDocument *document,
 			GList *all_documents;
 			GList *l;
 
-			all_documents = gedit_app_get_documents (gedit_app_get_default ());
+			all_documents = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
 
 			for (l = all_documents; l != NULL; l = g_list_next (l))
 			{
@@ -1652,8 +1652,10 @@ gedit_tab_init (GeditTab *tab)
 					    GEDIT_SETTINGS_AUTO_SAVE);
 	g_settings_get (tab->priv->editor, GEDIT_SETTINGS_AUTO_SAVE_INTERVAL,
 			"u", &auto_save_interval);
-	
-	lockdown = gedit_app_get_lockdown (gedit_app_get_default ());
+
+	GeditApp *app = GEDIT_APP (g_application_get_default ());
+
+	lockdown = gedit_app_get_lockdown (app);
 	tab->priv->auto_save = auto_save &&
 			       !(lockdown & GEDIT_LOCKDOWN_SAVE_TO_DISK);
 	tab->priv->auto_save = (tab->priv->auto_save != FALSE);
@@ -2429,7 +2431,7 @@ get_page_setup (GeditTab *tab)
 
 	if (data == NULL)
 	{
-		return _gedit_app_get_default_page_setup (gedit_app_get_default());
+		return _gedit_app_get_default_page_setup (GEDIT_APP (g_application_get_default ()));
 	}
 	else
 	{
@@ -2452,7 +2454,7 @@ get_print_settings (GeditTab *tab)
 
 	if (data == NULL)
 	{
-		settings = _gedit_app_get_default_print_settings (gedit_app_get_default());
+		settings = _gedit_app_get_default_print_settings (GEDIT_APP (g_application_get_default ()));
 	}
 	else
 	{
@@ -2508,7 +2510,7 @@ store_print_settings (GeditTab      *tab,
 				(GDestroyNotify)g_object_unref);
 
 	/* make them the default */
-	_gedit_app_set_default_print_settings (gedit_app_get_default (),
+	_gedit_app_set_default_print_settings (GEDIT_APP (g_application_get_default ()),
 					       settings);
 
 	page_setup = gedit_print_job_get_page_setup (job);
@@ -2520,7 +2522,7 @@ store_print_settings (GeditTab      *tab,
 				(GDestroyNotify)g_object_unref);
 
 	/* make it the default */
-	_gedit_app_set_default_page_setup (gedit_app_get_default (),
+	_gedit_app_set_default_page_setup (GEDIT_APP (g_application_get_default ()),
 					   page_setup);
 }
 
@@ -2892,9 +2894,11 @@ gedit_tab_set_auto_save_enabled	(GeditTab *tab,
 	g_return_if_fail (GEDIT_IS_TAB (tab));
 
 	/* Force disabling when lockdown is active */
-	lockdown = gedit_app_get_lockdown (gedit_app_get_default());
+	lockdown = gedit_app_get_lockdown (GEDIT_APP (g_application_get_default ()));
 	if (lockdown & GEDIT_LOCKDOWN_SAVE_TO_DISK)
+	{
 		enable = FALSE;
+	}
 	
 	doc = gedit_tab_get_document (tab);
 
diff --git a/gedit/gedit-view.c b/gedit/gedit-view.c
index 629bc19..d79f888 100644
--- a/gedit/gedit-view.c
+++ b/gedit/gedit-view.c
@@ -1046,7 +1046,7 @@ gedit_view_set_font (GeditView   *view,
 		GObject *settings;
 		gchar *font;
 
-		settings = _gedit_app_get_settings (gedit_app_get_default ());
+		settings = _gedit_app_get_settings (GEDIT_APP (g_application_get_default ()));
 		font = gedit_settings_get_system_font (GEDIT_SETTINGS (settings));
 
 		font_desc = pango_font_description_from_string (font);
diff --git a/gedit/gedit-window.c b/gedit/gedit-window.c
index 5b5e040..943949b 100644
--- a/gedit/gedit-window.c
+++ b/gedit/gedit-window.c
@@ -347,7 +347,7 @@ gedit_window_key_press_event (GtkWidget   *widget,
 
 	if (!handled)
 	{
-		return gedit_app_process_window_event (gedit_app_get_default (),
+		return gedit_app_process_window_event (GEDIT_APP (g_application_get_default ()),
 		                                       GEDIT_WINDOW (widget),
 		                                       (GdkEvent *)event);
 	}
@@ -676,7 +676,7 @@ set_sensitivity_according_to_tab (GeditWindow *window,
 	enable_syntax_highlighting = g_settings_get_boolean (window->priv->editor_settings,
 							     GEDIT_SETTINGS_SYNTAX_HIGHLIGHTING);
 
-	lockdown = gedit_app_get_lockdown (gedit_app_get_default ());
+	lockdown = gedit_app_get_lockdown (GEDIT_APP (g_application_get_default ()));
 
 	state = gedit_tab_get_state (tab);
 	state_normal = (state == GEDIT_TAB_STATE_NORMAL);
@@ -2160,7 +2160,7 @@ clone_window (GeditWindow *origin)
 
 	gedit_debug (DEBUG_WINDOW);
 
-	app = gedit_app_get_default ();
+	app = GEDIT_APP (g_application_get_default ());
 
 	screen = gtk_window_get_screen (GTK_WINDOW (origin));
 	window = gedit_app_create_window (app, screen);
@@ -2299,7 +2299,7 @@ set_title (GeditWindow *window)
 
 	if (tab == NULL)
 	{
-		gedit_app_set_window_title (gedit_app_get_default (),
+		gedit_app_set_window_title (GEDIT_APP (g_application_get_default ()),
 		                            window,
 		                            "gedit");
 		return;
@@ -2389,7 +2389,9 @@ set_title (GeditWindow *window)
 		}
 	}
 
-	gedit_app_set_window_title (gedit_app_get_default (), window, title);
+	gedit_app_set_window_title (GEDIT_APP (g_application_get_default ()),
+				    window,
+				    title);
 
 	g_free (dirname);
 	g_free (name);
@@ -2642,7 +2644,7 @@ set_sensitivity_according_to_window_state (GeditWindow *window)
 	GeditNotebook *notebook;
 	gint i;
 
-	lockdown = gedit_app_get_lockdown (gedit_app_get_default ());
+	lockdown = gedit_app_get_lockdown (GEDIT_APP (g_application_get_default ()));
 
 	/* We disable File->Quit/SaveAll/CloseAll while printing to avoid to have two
 	   operations (save and print/print preview) that uses the message area at
diff --git a/gedit/gedit.c b/gedit/gedit.c
index 84a3b00..1f5e0de 100644
--- a/gedit/gedit.c
+++ b/gedit/gedit.c
@@ -31,21 +31,42 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
-
 #include <glib.h>
-
 #include "gedit-app.h"
+#ifdef OS_OSX
+#include "gedit-app-osx.h"
+#else
+#ifdef G_OS_WIN32
+#include "gedit-app-win32.h"
+#else
+#include "gedit-app-x11.h"
+#endif
+#endif
 
 int
 main (int argc, char *argv[])
 {
+	GType type;
 	GeditApp *app;
 	gint status;
 
-	app = gedit_app_get_default ();
+#ifdef OS_OSX
+	type = GEDIT_TYPE_APP_OSX;
+#else
+#ifdef G_OS_WIN32
+	type = GEDIT_TYPE_APP_WIN32;
+#else
+	type = GEDIT_TYPE_APP_X11;
+#endif
+#endif
+
+	app = g_object_new (type,
+	                    "application-id", "org.gnome.Gedit",
+	                    "flags", G_APPLICATION_HANDLES_COMMAND_LINE,
+	                    NULL);
+
 	status = g_application_run (G_APPLICATION (app), argc, argv);
 
-	/* Cleanup */
 	g_object_unref (app);
 
 	return status;
diff --git a/plugins/checkupdate/gedit-check-update-plugin.c b/plugins/checkupdate/gedit-check-update-plugin.c
index 72bfbc8..d915195 100644
--- a/plugins/checkupdate/gedit-check-update-plugin.c
+++ b/plugins/checkupdate/gedit-check-update-plugin.c
@@ -238,7 +238,7 @@ on_response_cb (GtkWidget              *infobar,
 		GError *error = NULL;
 
 #ifdef OS_OSX
-		gedit_app_osx_show_url (GEDIT_APP_OSX (gedit_app_get_default ()),
+		gedit_app_osx_show_url (GEDIT_APP_OSX (g_application_get_default ()),
 		                        plugin->priv->url);
 #else
 		gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (plugin->priv->window)),
diff --git a/plugins/externaltools/tools/filelookup.py b/plugins/externaltools/tools/filelookup.py
index 43b9710..cc9fa3a 100644
--- a/plugins/externaltools/tools/filelookup.py
+++ b/plugins/externaltools/tools/filelookup.py
@@ -109,7 +109,7 @@ class OpenDocumentRelPathFileLookupProvider(FileLookupProvider):
         if path.startswith('/'):
             return None
 
-        for doc in Gedit.App.get_default().get_documents():
+        for doc in Gio.Application.get_default().get_documents():
             if doc.is_local():
                 location = doc.get_location()
                 if location:
@@ -134,7 +134,7 @@ class OpenDocumentFileLookupProvider(FileLookupProvider):
         if path.startswith('/'):
             return None
 
-        for doc in Gedit.App.get_default().get_documents():
+        for doc in Gio.Application.get_default().get_documents():
             if doc.is_local():
                 location = doc.get_location()
                 if location and location.get_uri().endswith(path):
diff --git a/plugins/externaltools/tools/manager.py b/plugins/externaltools/tools/manager.py
index 84a016e..ef22de1 100644
--- a/plugins/externaltools/tools/manager.py
+++ b/plugins/externaltools/tools/manager.py
@@ -23,7 +23,7 @@ from .library import *
 from .functions import *
 import hashlib
 from xml.sax import saxutils
-from gi.repository import GObject, Gtk, GtkSource, Gedit
+from gi.repository import Gio, GObject, Gtk, GtkSource, Gedit
 
 class LanguagesPopup(Gtk.Window):
     __gtype_name__ = "LanguagePopup"
@@ -866,7 +866,7 @@ class Manager(GObject.Object):
 
     def on_tool_manager_dialog_response(self, dialog, response):
         if response == Gtk.ResponseType.HELP:
-            Gedit.App.get_default().show_help(self.dialog, 'gedit', 'gedit-plugins-external-tools')
+            Gio.Application.get_default().show_help(self.dialog, 'gedit', 'gedit-plugins-external-tools')
             return
 
         self.save_current_tool()
diff --git a/plugins/externaltools/tools/windowactivatable.py b/plugins/externaltools/tools/windowactivatable.py
index cfd99f0..c0a2cf5 100644
--- a/plugins/externaltools/tools/windowactivatable.py
+++ b/plugins/externaltools/tools/windowactivatable.py
@@ -18,7 +18,7 @@
 
 __all__ = ('ExternalToolsPlugin', 'Manager', 'OutputPanel', 'Capture', 'UniqueById')
 
-from gi.repository import GObject, Gtk, Gedit, PeasGtk
+from gi.repository import Gio, GObject, Gtk, Gedit, PeasGtk
 from .manager import Manager
 from .library import ToolLibrary
 from .outputpanel import OutputPanel
@@ -238,7 +238,7 @@ class WindowActivatable(GObject.Object, Gedit.WindowActivatable):
             self._manager.dialog.connect('destroy', self.on_manager_destroy)
             self._manager.connect('tools-updated', self.on_manager_tools_updated)
 
-        window = Gedit.App.get_default().get_active_window()
+        window = Gio.Application.get_default().get_active_window()
         self._manager.run(window)
 
         return self._manager.dialog
@@ -253,7 +253,7 @@ class WindowActivatable(GObject.Object, Gedit.WindowActivatable):
         self._manager = None
 
     def on_manager_tools_updated(self, manager):
-        for window in Gedit.App.get_default().get_windows():
+        for window in Gio.Application.get_default().get_windows():
             window._external_tools_window_activatable.menu.update()
 
 # ex:ts=4:et:
diff --git a/plugins/filebrowser/gedit-file-browser-plugin.c b/plugins/filebrowser/gedit-file-browser-plugin.c
index dc4be43..53f4ab2 100644
--- a/plugins/filebrowser/gedit-file-browser-plugin.c
+++ b/plugins/filebrowser/gedit-file-browser-plugin.c
@@ -906,15 +906,13 @@ on_rename_cb (GeditFileBrowserStore *store,
 	      GFile                 *newfile,
 	      GeditWindow           *window)
 {
-	GeditApp *app;
 	GList *documents;
 	GList *item;
 	GeditDocument *doc;
 	GFile *docfile;
 
 	/* Find all documents and set its uri to newuri where it matches olduri */
-	app = gedit_app_get_default ();
-	documents = gedit_app_get_documents (app);
+	documents = gedit_app_get_documents (GEDIT_APP (g_application_get_default ()));
 
 	for (item = documents; item; item = item->next)
 	{
diff --git a/plugins/snippets/snippets/manager.py b/plugins/snippets/snippets/manager.py
index 80df05f..dcd1355 100644
--- a/plugins/snippets/snippets/manager.py
+++ b/plugins/snippets/snippets/manager.py
@@ -87,8 +87,7 @@ class Manager(Gtk.Dialog, Gtk.Buildable):
                         self.tree_view.expand_row(path, False)
 
         def build_model(self, force_reload = False):
-                window = Gedit.App.get_default().get_active_window()
-
+                window = Gio.Application.get_default().get_active_window()
                 if window:
                         view = window.get_active_view()
 
@@ -599,10 +598,9 @@ class Manager(Gtk.Dialog, Gtk.Buildable):
 
         def do_response(self, resp):
                 if resp == Gtk.ResponseType.HELP:
-                        Gedit.App.get_default().show_help(self, 'gedit', 'gedit-plugins-snippets')
-                        return
-
-                self.destroy()
+                        Gio.Application.get_default().show_help(self, 'gedit', 'gedit-plugins-snippets')
+                else:
+                        self.destroy()
 
         def on_cell_editing_started(self, renderer, editable, path):
                 piter = self.model.get_iter(path)
diff --git a/plugins/sort/gedit-sort-plugin.c b/plugins/sort/gedit-sort-plugin.c
index 504ae4a..a1cf98e 100644
--- a/plugins/sort/gedit-sort-plugin.c
+++ b/plugins/sort/gedit-sort-plugin.c
@@ -106,7 +106,7 @@ sort_dialog_response_handler (GtkDialog       *dlg,
 			break;
 
 		case GTK_RESPONSE_HELP:
-			gedit_app_show_help (gedit_app_get_default (),
+			gedit_app_show_help (GEDIT_APP (g_application_get_default ()),
 					     GTK_WINDOW (dlg),
 					     NULL,
 					     "gedit-sort-plugin");
diff --git a/plugins/spell/gedit-spell-language-dialog.c b/plugins/spell/gedit-spell-language-dialog.c
index 36f5d8f..b5b647a 100644
--- a/plugins/spell/gedit-spell-language-dialog.c
+++ b/plugins/spell/gedit-spell-language-dialog.c
@@ -70,7 +70,7 @@ dialog_response_handler (GtkDialog *dlg,
 {
 	if (res_id == GTK_RESPONSE_HELP)
 	{
-		gedit_app_show_help (gedit_app_get_default (),
+		gedit_app_show_help (GEDIT_APP (g_application_get_default ()),
 				     GTK_WINDOW (dlg),
 				     NULL,
 				     "gedit-spell-checker-plugin");
diff --git a/plugins/time/gedit-time-plugin.c b/plugins/time/gedit-time-plugin.c
index 0fd5fcc..f7b1f29 100644
--- a/plugins/time/gedit-time-plugin.c
+++ b/plugins/time/gedit-time-plugin.c
@@ -940,7 +940,7 @@ choose_format_dialog_response_cb (GtkWidget          *widget,
 		case GTK_RESPONSE_HELP:
 		{
 			gedit_debug_message (DEBUG_PLUGINS, "GTK_RESPONSE_HELP");
-			gedit_app_show_help (gedit_app_get_default (),
+			gedit_app_show_help (GEDIT_APP (g_application_get_default ()),
 					     GTK_WINDOW (widget),
 					     NULL,
 					     "gedit-plugins-insert-date-time");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]