diff options
author | mbkma <[email protected]> | 2021-02-12 10:29:05 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2021-03-02 22:19:58 +0100 |
commit | c7101aa8603f288065ad9ed8150623d0270feb68 (patch) | |
tree | 3eb2c147d0db991011423b208742983fe9eaa92e /pluma/pluma-app.c | |
parent | c0c513f3ef7e7ea432e799d8a5e10cfe94d38908 (diff) | |
download | pluma-c7101aa8603f288065ad9ed8150623d0270feb68.tar.bz2 pluma-c7101aa8603f288065ad9ed8150623d0270feb68.tar.xz |
code formating fixes
pluma-app.c: tabs to spaces
pluma-view.c: tabs to spaces, move code around
pluma-window.c: tabs to spaces
Diffstat (limited to 'pluma/pluma-app.c')
-rw-r--r-- | pluma/pluma-app.c | 952 |
1 files changed, 473 insertions, 479 deletions
diff --git a/pluma/pluma-app.c b/pluma/pluma-app.c index ef4e3fe4..0069d928 100644 --- a/pluma/pluma-app.c +++ b/pluma/pluma-app.c @@ -51,29 +51,29 @@ #include "pluma-app-activatable.h" #include "pluma-plugins-engine.h" -#define PLUMA_PAGE_SETUP_FILE "pluma-page-setup" -#define PLUMA_PRINT_SETTINGS_FILE "pluma-print-settings" +#define PLUMA_PAGE_SETUP_FILE "pluma-page-setup" +#define PLUMA_PRINT_SETTINGS_FILE "pluma-print-settings" /* Properties */ enum { - PROP_0, - PROP_LOCKDOWN + PROP_0, + PROP_LOCKDOWN }; struct _PlumaAppPrivate { - GList *windows; - PlumaWindow *active_window; + GList *windows; + PlumaWindow *active_window; - PlumaLockdownMask lockdown; + PlumaLockdownMask lockdown; - GtkPageSetup *page_setup; - GtkPrintSettings *print_settings; + GtkPageSetup *page_setup; + GtkPrintSettings *print_settings; - GSettings *window_settings; + GSettings *window_settings; - PeasExtensionSet *extensions; + PeasExtensionSet *extensions; }; G_DEFINE_TYPE_WITH_PRIVATE (PlumaApp, pluma_app, G_TYPE_OBJECT) @@ -81,320 +81,317 @@ G_DEFINE_TYPE_WITH_PRIVATE (PlumaApp, pluma_app, G_TYPE_OBJECT) static void pluma_app_finalize (GObject *object) { - PlumaApp *app = PLUMA_APP (object); + PlumaApp *app = PLUMA_APP (object); - g_list_free (app->priv->windows); + g_list_free (app->priv->windows); - if (app->priv->page_setup) - g_object_unref (app->priv->page_setup); - if (app->priv->print_settings) - g_object_unref (app->priv->print_settings); + if (app->priv->page_setup) + g_object_unref (app->priv->page_setup); + if (app->priv->print_settings) + g_object_unref (app->priv->print_settings); - G_OBJECT_CLASS (pluma_app_parent_class)->finalize (object); + G_OBJECT_CLASS (pluma_app_parent_class)->finalize (object); } static void pluma_app_dispose (GObject *object) { - PlumaApp *app = PLUMA_APP (object); + PlumaApp *app = PLUMA_APP (object); - g_clear_object (&app->priv->window_settings); + g_clear_object (&app->priv->window_settings); g_clear_object (&app->priv->extensions); - G_OBJECT_CLASS (pluma_app_parent_class)->dispose (object); + G_OBJECT_CLASS (pluma_app_parent_class)->dispose (object); } static void pluma_app_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) + guint prop_id, + GValue *value, + GParamSpec *pspec) { - PlumaApp *app = PLUMA_APP (object); + PlumaApp *app = PLUMA_APP (object); - switch (prop_id) - { - case PROP_LOCKDOWN: - g_value_set_flags (value, pluma_app_get_lockdown (app)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } + switch (prop_id) + { + case PROP_LOCKDOWN: + g_value_set_flags (value, pluma_app_get_lockdown (app)); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } } static void pluma_app_class_init (PlumaAppClass *klass) { - GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->finalize = pluma_app_finalize; - object_class->dispose = pluma_app_dispose; - object_class->get_property = pluma_app_get_property; + object_class->finalize = pluma_app_finalize; + object_class->dispose = pluma_app_dispose; + object_class->get_property = pluma_app_get_property; - g_object_class_install_property (object_class, - PROP_LOCKDOWN, - g_param_spec_flags ("lockdown", - "Lockdown", - "The lockdown mask", - PLUMA_TYPE_LOCKDOWN_MASK, - 0, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, + PROP_LOCKDOWN, + g_param_spec_flags ("lockdown", + "Lockdown", + "The lockdown mask", + PLUMA_TYPE_LOCKDOWN_MASK, + 0, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS)); } static gboolean ensure_user_config_dir (void) { - gchar *config_dir; - gboolean ret = TRUE; - gint res; + gchar *config_dir; + gboolean ret = TRUE; + gint res; - config_dir = pluma_dirs_get_user_config_dir (); - if (config_dir == NULL) - { - g_warning ("Could not get config directory\n"); - return FALSE; - } + config_dir = pluma_dirs_get_user_config_dir (); + if (config_dir == NULL) + { + g_warning ("Could not get config directory\n"); + return FALSE; + } - res = g_mkdir_with_parents (config_dir, 0755); - if (res < 0) - { - g_warning ("Could not create config directory\n"); - ret = FALSE; - } + res = g_mkdir_with_parents (config_dir, 0755); + if (res < 0) + { + g_warning ("Could not create config directory\n"); + ret = FALSE; + } - g_free (config_dir); + g_free (config_dir); - return ret; + return ret; } static void load_accels (void) { - gchar *filename; + gchar *filename; - filename = pluma_dirs_get_user_accels_file (); - if (filename != NULL) - { - pluma_debug_message (DEBUG_APP, "Loading keybindings from %s\n", filename); - gtk_accel_map_load (filename); - g_free (filename); - } + filename = pluma_dirs_get_user_accels_file (); + if (filename != NULL) + { + pluma_debug_message (DEBUG_APP, "Loading keybindings from %s\n", filename); + gtk_accel_map_load (filename); + g_free (filename); + } } static void save_accels (void) { - gchar *filename; + gchar *filename; - filename = pluma_dirs_get_user_accels_file (); - if (filename != NULL) - { - pluma_debug_message (DEBUG_APP, "Saving keybindings in %s\n", filename); - gtk_accel_map_save (filename); - g_free (filename); - } + filename = pluma_dirs_get_user_accels_file (); + if (filename != NULL) + { + pluma_debug_message (DEBUG_APP, "Saving keybindings in %s\n", filename); + gtk_accel_map_save (filename); + g_free (filename); + } } static gchar * get_page_setup_file (void) { - gchar *config_dir; - gchar *setup = NULL; + gchar *config_dir; + gchar *setup = NULL; - config_dir = pluma_dirs_get_user_config_dir (); + config_dir = pluma_dirs_get_user_config_dir (); - if (config_dir != NULL) - { - setup = g_build_filename (config_dir, - PLUMA_PAGE_SETUP_FILE, - NULL); - g_free (config_dir); - } + if (config_dir != NULL) + { + setup = g_build_filename (config_dir, + PLUMA_PAGE_SETUP_FILE, + NULL); + g_free (config_dir); + } - return setup; + return setup; } static void load_page_setup (PlumaApp *app) { - gchar *filename; - GError *error = NULL; + gchar *filename; + GError *error = NULL; - g_return_if_fail (app->priv->page_setup == NULL); + g_return_if_fail (app->priv->page_setup == NULL); - filename = get_page_setup_file (); + filename = get_page_setup_file (); - app->priv->page_setup = gtk_page_setup_new_from_file (filename, - &error); - if (error) - { - /* Ignore file not found error */ - if (error->domain != G_FILE_ERROR || - error->code != G_FILE_ERROR_NOENT) - { - g_warning ("%s", error->message); - } + app->priv->page_setup = gtk_page_setup_new_from_file (filename, &error); + if (error) + { + /* Ignore file not found error */ + if (error->domain != G_FILE_ERROR || + error->code != G_FILE_ERROR_NOENT) + { + g_warning ("%s", error->message); + } - g_error_free (error); - } + g_error_free (error); + } - g_free (filename); + g_free (filename); - /* fall back to default settings */ - if (app->priv->page_setup == NULL) - app->priv->page_setup = gtk_page_setup_new (); + /* fall back to default settings */ + if (app->priv->page_setup == NULL) + app->priv->page_setup = gtk_page_setup_new (); } static void save_page_setup (PlumaApp *app) { - gchar *filename; - GError *error = NULL; + gchar *filename; + GError *error = NULL; - if (app->priv->page_setup == NULL) - return; + if (app->priv->page_setup == NULL) + return; - filename = get_page_setup_file (); + filename = get_page_setup_file (); - gtk_page_setup_to_file (app->priv->page_setup, - filename, - &error); - if (error) - { - g_warning ("%s", error->message); - g_error_free (error); - } + gtk_page_setup_to_file (app->priv->page_setup, + filename, + &error); + if (error) + { + g_warning ("%s", error->message); + g_error_free (error); + } - g_free (filename); + g_free (filename); } static gchar * get_print_settings_file (void) { - gchar *config_dir; - gchar *settings = NULL; + gchar *config_dir; + gchar *settings = NULL; - config_dir = pluma_dirs_get_user_config_dir (); + config_dir = pluma_dirs_get_user_config_dir (); - if (config_dir != NULL) - { - settings = g_build_filename (config_dir, - PLUMA_PRINT_SETTINGS_FILE, - NULL); - g_free (config_dir); - } + if (config_dir != NULL) + { + settings = g_build_filename (config_dir, + PLUMA_PRINT_SETTINGS_FILE, + NULL); + g_free (config_dir); + } - return settings; + return settings; } static void load_print_settings (PlumaApp *app) { - gchar *filename; - GError *error = NULL; + gchar *filename; + GError *error = NULL; - g_return_if_fail (app->priv->print_settings == NULL); + g_return_if_fail (app->priv->print_settings == NULL); - filename = get_print_settings_file (); + filename = get_print_settings_file (); - app->priv->print_settings = gtk_print_settings_new_from_file (filename, - &error); - if (error) - { - /* Ignore file not found error */ - if (error->domain != G_FILE_ERROR || - error->code != G_FILE_ERROR_NOENT) - { - g_warning ("%s", error->message); - } + app->priv->print_settings = gtk_print_settings_new_from_file (filename, + &error); + if (error) + { + /* Ignore file not found error */ + if (error->domain != G_FILE_ERROR || + error->code != G_FILE_ERROR_NOENT) + { + g_warning ("%s", error->message); + } - g_error_free (error); - } + g_error_free (error); + } - g_free (filename); + g_free (filename); - /* fall back to default settings */ - if (app->priv->print_settings == NULL) - app->priv->print_settings = gtk_print_settings_new (); + /* fall back to default settings */ + if (app->priv->print_settings == NULL) + app->priv->print_settings = gtk_print_settings_new (); } static void save_print_settings (PlumaApp *app) { - gchar *filename; - GError *error = NULL; + gchar *filename; + GError *error = NULL; - if (app->priv->print_settings == NULL) - return; + if (app->priv->print_settings == NULL) + return; - filename = get_print_settings_file (); + filename = get_print_settings_file (); - gtk_print_settings_to_file (app->priv->print_settings, - filename, - &error); - if (error) - { - g_warning ("%s", error->message); - g_error_free (error); - } + gtk_print_settings_to_file (app->priv->print_settings, + filename, + &error); + if (error) + { + g_warning ("%s", error->message); + g_error_free (error); + } - g_free (filename); + g_free (filename); } static void extension_added (PeasExtensionSet *extensions, - PeasPluginInfo *info, - PeasExtension *exten, - PlumaApp *app) + PeasPluginInfo *info, + PeasExtension *exten, + PlumaApp *app) { - peas_extension_call (exten, "activate"); + peas_extension_call (exten, "activate"); } static void extension_removed (PeasExtensionSet *extensions, - PeasPluginInfo *info, - PeasExtension *exten, - PlumaApp *app) + PeasPluginInfo *info, + PeasExtension *exten, + PlumaApp *app) { - peas_extension_call (exten, "deactivate"); + peas_extension_call (exten, "deactivate"); } static void pluma_app_init (PlumaApp *app) { - PlumaSettings *settings; + PlumaSettings *settings; - app->priv = pluma_app_get_instance_private (app); + app->priv = pluma_app_get_instance_private (app); - load_accels (); + load_accels (); - /* Load/init settings */ - settings = _pluma_settings_get_singleton (); - app->priv->window_settings = g_settings_new (PLUMA_SCHEMA_ID); + /* Load/init settings */ + settings = _pluma_settings_get_singleton (); + app->priv->window_settings = g_settings_new (PLUMA_SCHEMA_ID); - /* initial lockdown state */ - app->priv->lockdown = pluma_settings_get_lockdown (settings); + /* initial lockdown state */ + app->priv->lockdown = pluma_settings_get_lockdown (settings); - app->priv->extensions = peas_extension_set_new (PEAS_ENGINE (pluma_plugins_engine_get_default ()), - PLUMA_TYPE_APP_ACTIVATABLE, - "app", app, - NULL); + app->priv->extensions = peas_extension_set_new (PEAS_ENGINE (pluma_plugins_engine_get_default ()), + PLUMA_TYPE_APP_ACTIVATABLE, + "app", app, + NULL); - g_signal_connect (app->priv->extensions, - "extension-added", - G_CALLBACK (extension_added), - app); + g_signal_connect (app->priv->extensions, "extension-added", + G_CALLBACK (extension_added), + app); - g_signal_connect (app->priv->extensions, - "extension-removed", - G_CALLBACK (extension_removed), - app); + g_signal_connect (app->priv->extensions, "extension-removed", + G_CALLBACK (extension_removed), + app); - peas_extension_set_call (app->priv->extensions, "activate"); + peas_extension_set_call (app->priv->extensions, "activate"); } /** @@ -408,37 +405,36 @@ pluma_app_init (PlumaApp *app) PlumaApp * pluma_app_get_default (void) { - static PlumaApp *app = NULL; + static PlumaApp *app = NULL; - if (app != NULL) - return app; + if (app != NULL) + return app; - app = PLUMA_APP (g_object_new (PLUMA_TYPE_APP, NULL)); + app = PLUMA_APP (g_object_new (PLUMA_TYPE_APP, NULL)); - g_object_add_weak_pointer (G_OBJECT (app), - (gpointer) &app); + g_object_add_weak_pointer (G_OBJECT (app), (gpointer) &app); - return app; + return app; } static void set_active_window (PlumaApp *app, PlumaWindow *window) { - app->priv->active_window = window; + app->priv->active_window = window; } static gboolean window_focus_in_event (PlumaWindow *window, - GdkEventFocus *event, - PlumaApp *app) + GdkEventFocus *event, + PlumaApp *app) { - /* updates active_view and active_child when a new toplevel receives focus */ - g_return_val_if_fail (PLUMA_IS_WINDOW (window), FALSE); + /* updates active_view and active_child when a new toplevel receives focus */ + g_return_val_if_fail (PLUMA_IS_WINDOW (window), FALSE); - set_active_window (app, window); + set_active_window (app, window); - return FALSE; + return FALSE; } static gboolean @@ -446,155 +442,153 @@ window_delete_event (PlumaWindow *window, GdkEvent *event, PlumaApp *app) { - PlumaWindowState ws; + PlumaWindowState ws; - ws = pluma_window_get_state (window); + ws = pluma_window_get_state (window); - if (ws & - (PLUMA_WINDOW_STATE_SAVING | - PLUMA_WINDOW_STATE_PRINTING | - PLUMA_WINDOW_STATE_SAVING_SESSION)) - return TRUE; + if (ws & + (PLUMA_WINDOW_STATE_SAVING | + PLUMA_WINDOW_STATE_PRINTING | + PLUMA_WINDOW_STATE_SAVING_SESSION)) + return TRUE; - _pluma_cmd_file_quit (NULL, window); + _pluma_cmd_file_quit (NULL, window); - /* Do not destroy the window */ - return TRUE; + /* Do not destroy the window */ + return TRUE; } static void window_destroy (PlumaWindow *window, - PlumaApp *app) + PlumaApp *app) { - app->priv->windows = g_list_remove (app->priv->windows, - window); + app->priv->windows = g_list_remove (app->priv->windows, window); - if (window == app->priv->active_window) - { - set_active_window (app, app->priv->windows != NULL ? app->priv->windows->data : NULL); - } + if (window == app->priv->active_window) + { + set_active_window (app, app->priv->windows != NULL ? app->priv->windows->data : NULL); + } /* CHECK: I don't think we have to disconnect this function, since windows is being destroyed */ /* - g_signal_handlers_disconnect_by_func (window, - G_CALLBACK (window_focus_in_event), - app); - g_signal_handlers_disconnect_by_func (window, - G_CALLBACK (window_destroy), - app); + g_signal_handlers_disconnect_by_func (window, + G_CALLBACK (window_focus_in_event), + app); + g_signal_handlers_disconnect_by_func (window, + G_CALLBACK (window_destroy), + app); */ - if (app->priv->windows == NULL) - { - /* Last window is gone... save some settings and exit */ - ensure_user_config_dir (); + if (app->priv->windows == NULL) + { + /* Last window is gone... save some settings and exit */ + ensure_user_config_dir (); - save_accels (); - save_page_setup (app); - save_print_settings (app); + save_accels (); + save_page_setup (app); + save_print_settings (app); - gtk_main_quit (); - } + gtk_main_quit (); + } } /* Generates a unique string for a window role */ static gchar * gen_role (void) { - static gint serial; + static gint serial; - return g_strdup_printf ("pluma-window-%" G_GINT64_FORMAT "-%d-%s", - g_get_real_time (), - serial++, - g_get_host_name ()); + return g_strdup_printf ("pluma-window-%" G_GINT64_FORMAT "-%d-%s", + g_get_real_time (), + serial++, + g_get_host_name ()); } static PlumaWindow * pluma_app_create_window_real (PlumaApp *app, - gboolean set_geometry, - const gchar *role) -{ - PlumaWindow *window; - - pluma_debug (DEBUG_APP); - - /* - * We need to be careful here, there is a race condition: - * when another pluma is launched it checks active_window, - * so we must do our best to ensure that active_window - * is never NULL when at least a window exists. - */ - if (app->priv->windows == NULL) - { - window = g_object_new (PLUMA_TYPE_WINDOW, NULL); - set_active_window (app, window); - } - else - { - window = g_object_new (PLUMA_TYPE_WINDOW, NULL); - } - - app->priv->windows = g_list_prepend (app->priv->windows, - window); - - pluma_debug_message (DEBUG_APP, "Window created"); - - if (role != NULL) - { - gtk_window_set_role (GTK_WINDOW (window), role); - } - else - { - gchar *newrole; - - newrole = gen_role (); - gtk_window_set_role (GTK_WINDOW (window), newrole); - g_free (newrole); - } - - if (set_geometry) - { - GdkWindowState state; - gint w, h; - - state = g_settings_get_int (app->priv->window_settings, - PLUMA_SETTINGS_WINDOW_STATE); - - if ((state & GDK_WINDOW_STATE_MAXIMIZED) != 0) - { - _pluma_window_get_default_size (&w, &h); - gtk_window_set_default_size (GTK_WINDOW (window), w, h); - gtk_window_maximize (GTK_WINDOW (window)); - } - else - { - g_settings_get (app->priv->window_settings, - PLUMA_SETTINGS_WINDOW_SIZE, - "(ii)", &w, &h); - gtk_window_set_default_size (GTK_WINDOW (window), w, h); - gtk_window_unmaximize (GTK_WINDOW (window)); - } - - if ((state & GDK_WINDOW_STATE_STICKY ) != 0) - gtk_window_stick (GTK_WINDOW (window)); - else - gtk_window_unstick (GTK_WINDOW (window)); - } - - g_signal_connect (window, - "focus_in_event", - G_CALLBACK (window_focus_in_event), - app); - g_signal_connect (window, - "delete_event", - G_CALLBACK (window_delete_event), - app); - g_signal_connect (window, - "destroy", - G_CALLBACK (window_destroy), - app); - - return window; + gboolean set_geometry, + const gchar *role) +{ + PlumaWindow *window; + + pluma_debug (DEBUG_APP); + + /* + * We need to be careful here, there is a race condition: + * when another pluma is launched it checks active_window, + * so we must do our best to ensure that active_window + * is never NULL when at least a window exists. + */ + if (app->priv->windows == NULL) + { + window = g_object_new (PLUMA_TYPE_WINDOW, NULL); + set_active_window (app, window); + } + else + { + window = g_object_new (PLUMA_TYPE_WINDOW, NULL); + } + + app->priv->windows = g_list_prepend (app->priv->windows, window); + + pluma_debug_message (DEBUG_APP, "Window created"); + + if (role != NULL) + { + gtk_window_set_role (GTK_WINDOW (window), role); + } + else + { + gchar *newrole; + + newrole = gen_role (); + gtk_window_set_role (GTK_WINDOW (window), newrole); + g_free (newrole); + } + + if (set_geometry) + { + GdkWindowState state; + gint w, h; + + state = g_settings_get_int (app->priv->window_settings, + PLUMA_SETTINGS_WINDOW_STATE); + + if ((state & GDK_WINDOW_STATE_MAXIMIZED) != 0) + { + _pluma_window_get_default_size (&w, &h); + gtk_window_set_default_size (GTK_WINDOW (window), w, h); + gtk_window_maximize (GTK_WINDOW (window)); + } + else + { + g_settings_get (app->priv->window_settings, + PLUMA_SETTINGS_WINDOW_SIZE, + "(ii)", &w, &h); + gtk_window_set_default_size (GTK_WINDOW (window), w, h); + gtk_window_unmaximize (GTK_WINDOW (window)); + } + + if ((state & GDK_WINDOW_STATE_STICKY ) != 0) + gtk_window_stick (GTK_WINDOW (window)); + else + gtk_window_unstick (GTK_WINDOW (window)); + } + + g_signal_connect (window, + "focus_in_event", + G_CALLBACK (window_focus_in_event), + app); + g_signal_connect (window, + "delete_event", + G_CALLBACK (window_delete_event), + app); + g_signal_connect (window, + "destroy", + G_CALLBACK (window_destroy), + app); + + return window; } /** @@ -608,16 +602,16 @@ pluma_app_create_window_real (PlumaApp *app, */ PlumaWindow * pluma_app_create_window (PlumaApp *app, - GdkScreen *screen) + GdkScreen *screen) { - PlumaWindow *window; + PlumaWindow *window; - window = pluma_app_create_window_real (app, TRUE, NULL); + window = pluma_app_create_window_real (app, TRUE, NULL); - if (screen != NULL) - gtk_window_set_screen (GTK_WINDOW (window), screen); + if (screen != NULL) + gtk_window_set_screen (GTK_WINDOW (window), screen); - return window; + return window; } /* @@ -626,13 +620,13 @@ pluma_app_create_window (PlumaApp *app, */ PlumaWindow * _pluma_app_restore_window (PlumaApp *app, - const gchar *role) + const gchar *role) { - PlumaWindow *window; + PlumaWindow *window; - window = pluma_app_create_window_real (app, FALSE, role); + window = pluma_app_create_window_real (app, FALSE, role); - return window; + return window; } /** @@ -647,9 +641,9 @@ _pluma_app_restore_window (PlumaApp *app, const GList * pluma_app_get_windows (PlumaApp *app) { - g_return_val_if_fail (PLUMA_IS_APP (app), NULL); + g_return_val_if_fail (PLUMA_IS_APP (app), NULL); - return app->priv->windows; + return app->priv->windows; } /** @@ -663,62 +657,62 @@ pluma_app_get_windows (PlumaApp *app) PlumaWindow * pluma_app_get_active_window (PlumaApp *app) { - g_return_val_if_fail (PLUMA_IS_APP (app), NULL); + g_return_val_if_fail (PLUMA_IS_APP (app), NULL); - /* make sure our active window is always realized: - * this is needed on startup if we launch two pluma 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)); + /* make sure our active window is always realized: + * this is needed on startup if we launch two pluma 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; + return app->priv->active_window; } static gboolean is_in_viewport (PlumaWindow *window, - GdkScreen *screen, - gint workspace, - gint viewport_x, - gint viewport_y) -{ - GdkWindow *gdkwindow; - gint ws; - gint sc_width, sc_height; - gint x, y, width, height; - gint vp_x, vp_y; - - /* Check for workspace match */ - ws = pluma_utils_get_window_workspace (GTK_WINDOW (window)); - if (ws != workspace && ws != PLUMA_ALL_WORKSPACES) - return FALSE; - - /* Check for viewport match */ - gdkwindow = gtk_widget_get_window (GTK_WIDGET (window)); - gdk_window_get_position (gdkwindow, &x, &y); - - width = gdk_window_get_width(gdkwindow); - height = gdk_window_get_height(gdkwindow); - - pluma_utils_get_current_viewport (screen, &vp_x, &vp_y); - x += vp_x; - y += vp_y; - - if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) - { - sc_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)); - sc_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)); - } - else - { - return TRUE; - } - - return x + width * .25 >= viewport_x && - x + width * .75 <= viewport_x + sc_width && - y >= viewport_y && - y + height <= viewport_y + sc_height; + GdkScreen *screen, + gint workspace, + gint viewport_x, + gint viewport_y) +{ + GdkWindow *gdkwindow; + gint ws; + gint sc_width, sc_height; + gint x, y, width, height; + gint vp_x, vp_y; + + /* Check for workspace match */ + ws = pluma_utils_get_window_workspace (GTK_WINDOW (window)); + if (ws != workspace && ws != PLUMA_ALL_WORKSPACES) + return FALSE; + + /* Check for viewport match */ + gdkwindow = gtk_widget_get_window (GTK_WIDGET (window)); + gdk_window_get_position (gdkwindow, &x, &y); + + width = gdk_window_get_width(gdkwindow); + height = gdk_window_get_height(gdkwindow); + + pluma_utils_get_current_viewport (screen, &vp_x, &vp_y); + x += vp_x; + y += vp_y; + + if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) + { + sc_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)); + sc_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)); + } + else + { + return TRUE; + } + + return x + width * .25 >= viewport_x && + x + width * .75 <= viewport_x + sc_width && + y >= viewport_y && + y + height <= viewport_y + sc_height; } /** @@ -737,36 +731,36 @@ is_in_viewport (PlumaWindow *window, */ PlumaWindow * _pluma_app_get_window_in_viewport (PlumaApp *app, - GdkScreen *screen, - gint workspace, - gint viewport_x, - gint viewport_y) + GdkScreen *screen, + gint workspace, + gint viewport_x, + gint viewport_y) { - PlumaWindow *window; + PlumaWindow *window; - GList *l; + GList *l; - g_return_val_if_fail (PLUMA_IS_APP (app), NULL); + g_return_val_if_fail (PLUMA_IS_APP (app), NULL); - /* first try if the active window */ - window = app->priv->active_window; + /* first try if the active window */ + window = app->priv->active_window; - g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL); + g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL); - if (is_in_viewport (window, screen, workspace, viewport_x, viewport_y)) - return window; + if (is_in_viewport (window, screen, workspace, viewport_x, viewport_y)) + return window; - /* otherwise try to see if there is a window on this workspace */ - for (l = app->priv->windows; l != NULL; l = l->next) - { - window = l->data; + /* otherwise try to see if there is a window on this workspace */ + for (l = app->priv->windows; l != NULL; l = l->next) + { + window = l->data; - if (is_in_viewport (window, screen, workspace, viewport_x, viewport_y)) - return window; - } + if (is_in_viewport (window, screen, workspace, viewport_x, viewport_y)) + return window; + } - /* no window on this workspace... create a new one */ - return pluma_app_create_window (app, screen); + /* no window on this workspace... create a new one */ + return pluma_app_create_window (app, screen); } /** @@ -779,24 +773,24 @@ _pluma_app_get_window_in_viewport (PlumaApp *app, * a newly allocated list of #PlumaDocument objects */ GList * -pluma_app_get_documents (PlumaApp *app) +pluma_app_get_documents (PlumaApp *app) { - GList *res = NULL; - GList *windows; + GList *res = NULL; + GList *windows; - g_return_val_if_fail (PLUMA_IS_APP (app), NULL); + g_return_val_if_fail (PLUMA_IS_APP (app), NULL); - windows = app->priv->windows; + windows = app->priv->windows; - while (windows != NULL) - { - res = g_list_concat (res, - pluma_window_get_documents (PLUMA_WINDOW (windows->data))); + while (windows != NULL) + { + res = g_list_concat (res, + pluma_window_get_documents (PLUMA_WINDOW (windows->data))); - windows = g_list_next (windows); - } + windows = g_list_next (windows); + } - return res; + return res; } /** @@ -811,22 +805,22 @@ pluma_app_get_documents (PlumaApp *app) GList * pluma_app_get_views (PlumaApp *app) { - GList *res = NULL; - GList *windows; + GList *res = NULL; + GList *windows; - g_return_val_if_fail (PLUMA_IS_APP (app), NULL); + g_return_val_if_fail (PLUMA_IS_APP (app), NULL); - windows = app->priv->windows; + windows = app->priv->windows; - while (windows != NULL) - { - res = g_list_concat (res, - pluma_window_get_views (PLUMA_WINDOW (windows->data))); + while (windows != NULL) + { + res = g_list_concat (res, + pluma_window_get_views (PLUMA_WINDOW (windows->data))); - windows = g_list_next (windows); - } + windows = g_list_next (windows); + } - return res; + return res; } /** @@ -840,96 +834,96 @@ pluma_app_get_views (PlumaApp *app) PlumaLockdownMask pluma_app_get_lockdown (PlumaApp *app) { - g_return_val_if_fail (PLUMA_IS_APP (app), PLUMA_LOCKDOWN_ALL); + g_return_val_if_fail (PLUMA_IS_APP (app), PLUMA_LOCKDOWN_ALL); - return app->priv->lockdown; + return app->priv->lockdown; } static void app_lockdown_changed (PlumaApp *app) { - GList *l; + GList *l; - for (l = app->priv->windows; l != NULL; l = l->next) - _pluma_window_set_lockdown (PLUMA_WINDOW (l->data), - app->priv->lockdown); + for (l = app->priv->windows; l != NULL; l = l->next) + _pluma_window_set_lockdown (PLUMA_WINDOW (l->data), + app->priv->lockdown); - g_object_notify (G_OBJECT (app), "lockdown"); + g_object_notify (G_OBJECT (app), "lockdown"); } void _pluma_app_set_lockdown (PlumaApp *app, - PlumaLockdownMask lockdown) + PlumaLockdownMask lockdown) { - g_return_if_fail (PLUMA_IS_APP (app)); + g_return_if_fail (PLUMA_IS_APP (app)); - app->priv->lockdown = lockdown; + app->priv->lockdown = lockdown; - app_lockdown_changed (app); + app_lockdown_changed (app); } void _pluma_app_set_lockdown_bit (PlumaApp *app, - PlumaLockdownMask bit, - gboolean value) + PlumaLockdownMask bit, + gboolean value) { - g_return_if_fail (PLUMA_IS_APP (app)); + g_return_if_fail (PLUMA_IS_APP (app)); - if (value) - app->priv->lockdown |= bit; - else - app->priv->lockdown &= ~bit; + if (value) + app->priv->lockdown |= bit; + else + app->priv->lockdown &= ~bit; - app_lockdown_changed (app); + app_lockdown_changed (app); } /* Returns a copy */ GtkPageSetup * _pluma_app_get_default_page_setup (PlumaApp *app) { - g_return_val_if_fail (PLUMA_IS_APP (app), NULL); + g_return_val_if_fail (PLUMA_IS_APP (app), NULL); - if (app->priv->page_setup == NULL) - load_page_setup (app); + if (app->priv->page_setup == NULL) + load_page_setup (app); - return gtk_page_setup_copy (app->priv->page_setup); + return gtk_page_setup_copy (app->priv->page_setup); } void _pluma_app_set_default_page_setup (PlumaApp *app, - GtkPageSetup *page_setup) + GtkPageSetup *page_setup) { - g_return_if_fail (PLUMA_IS_APP (app)); - g_return_if_fail (GTK_IS_PAGE_SETUP (page_setup)); + g_return_if_fail (PLUMA_IS_APP (app)); + g_return_if_fail (GTK_IS_PAGE_SETUP (page_setup)); - if (app->priv->page_setup != NULL) - g_object_unref (app->priv->page_setup); + if (app->priv->page_setup != NULL) + g_object_unref (app->priv->page_setup); - app->priv->page_setup = g_object_ref (page_setup); + app->priv->page_setup = g_object_ref (page_setup); } /* Returns a copy */ GtkPrintSettings * _pluma_app_get_default_print_settings (PlumaApp *app) { - g_return_val_if_fail (PLUMA_IS_APP (app), NULL); + g_return_val_if_fail (PLUMA_IS_APP (app), NULL); - if (app->priv->print_settings == NULL) - load_print_settings (app); + if (app->priv->print_settings == NULL) + load_print_settings (app); - return gtk_print_settings_copy (app->priv->print_settings); + return gtk_print_settings_copy (app->priv->print_settings); } void _pluma_app_set_default_print_settings (PlumaApp *app, - GtkPrintSettings *settings) + GtkPrintSettings *settings) { - g_return_if_fail (PLUMA_IS_APP (app)); - g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings)); + g_return_if_fail (PLUMA_IS_APP (app)); + g_return_if_fail (GTK_IS_PRINT_SETTINGS (settings)); - if (app->priv->print_settings != NULL) - g_object_unref (app->priv->print_settings); + if (app->priv->print_settings != NULL) + g_object_unref (app->priv->print_settings); - app->priv->print_settings = g_object_ref (settings); + app->priv->print_settings = g_object_ref (settings); } |