summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormbkma <[email protected]>2021-02-12 10:29:05 +0100
committerraveit65 <[email protected]>2021-03-02 22:19:58 +0100
commitc7101aa8603f288065ad9ed8150623d0270feb68 (patch)
tree3eb2c147d0db991011423b208742983fe9eaa92e
parentc0c513f3ef7e7ea432e799d8a5e10cfe94d38908 (diff)
downloadpluma-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
-rw-r--r--pluma/pluma-app-activatable.c20
-rw-r--r--pluma/pluma-app-activatable.h20
-rw-r--r--pluma/pluma-app.c952
-rw-r--r--pluma/pluma-view-activatable.c20
-rw-r--r--pluma/pluma-view-activatable.h20
-rw-r--r--pluma/pluma-view.c3654
-rw-r--r--pluma/pluma-window-activatable.c20
-rw-r--r--pluma/pluma-window-activatable.h20
-rw-r--r--pluma/pluma-window.c6679
9 files changed, 5672 insertions, 5733 deletions
diff --git a/pluma/pluma-app-activatable.c b/pluma/pluma-app-activatable.c
index 3d68d9fe..8e43b615 100644
--- a/pluma/pluma-app-activatable.c
+++ b/pluma/pluma-app-activatable.c
@@ -5,18 +5,18 @@
* Copyright (C) 2010 Steve Frécinaux
* Copyright (C) 2010 Jesse van den Kieboom
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see https://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see https://www.gnu.org/licenses/.
*/
#include <config.h>
diff --git a/pluma/pluma-app-activatable.h b/pluma/pluma-app-activatable.h
index 0362f546..36072ada 100644
--- a/pluma/pluma-app-activatable.h
+++ b/pluma/pluma-app-activatable.h
@@ -5,18 +5,18 @@
* Copyright (C) 2010 - Steve Frécinaux
* Copyright (C) 2010 - Jesse van den Kieboom
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see https://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see https://www.gnu.org/licenses/.
*/
#ifndef __PLUMA_APP_ACTIVATABLE_H__
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);
}
diff --git a/pluma/pluma-view-activatable.c b/pluma/pluma-view-activatable.c
index ad29dee8..83c1ff03 100644
--- a/pluma/pluma-view-activatable.c
+++ b/pluma/pluma-view-activatable.c
@@ -4,18 +4,18 @@
*
* Copyright (C) 2010 Steve Frécinaux
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see https://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see https://www.gnu.org/licenses/.
*/
#include <config.h>
diff --git a/pluma/pluma-view-activatable.h b/pluma/pluma-view-activatable.h
index 4fc170c8..5a6635b9 100644
--- a/pluma/pluma-view-activatable.h
+++ b/pluma/pluma-view-activatable.h
@@ -4,18 +4,18 @@
*
* Copyright (C) 2010 - Steve Frécinaux
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see https://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see https://www.gnu.org/licenses/.
*/
#ifndef __PLUMA_VIEW_ACTIVATABLE_H__
diff --git a/pluma/pluma-view.c b/pluma/pluma-view.c
index d09599a7..905df5d7 100644
--- a/pluma/pluma-view.c
+++ b/pluma/pluma-view.c
@@ -54,369 +54,369 @@
#define PLUMA_VIEW_SCROLL_MARGIN 0.02
#define PLUMA_VIEW_SEARCH_DIALOG_TIMEOUT (30*1000) /* 30 seconds */
-#define MIN_SEARCH_COMPLETION_KEY_LEN 3
+#define MIN_SEARCH_COMPLETION_KEY_LEN 3
/* Local variables */
static gboolean middle_or_right_down = FALSE;
typedef enum
{
- GOTO_LINE,
- SEARCH
+ GOTO_LINE,
+ SEARCH
} SearchMode;
enum
{
- TARGET_URI_LIST = 100
+ TARGET_URI_LIST = 100
};
struct _PlumaViewPrivate
{
- GSettings *editor_settings;
- GSettings *interface_settings;
+ GSettings *editor_settings;
+ GSettings *interface_settings;
- SearchMode search_mode;
+ SearchMode search_mode;
- GtkTextIter start_search_iter;
+ GtkTextIter start_search_iter;
- /* used to restore the search state if an
- * incremental search is cancelled
- */
- gchar *old_search_text;
- guint old_search_flags;
+ /* used to restore the search state if an
+ * incremental search is cancelled
+ */
+ gchar *old_search_text;
+ guint old_search_flags;
- /* used to remeber the state of the last
- * incremental search (the document search
- * state may be changed by the search dialog)
- */
- guint search_flags;
- gboolean wrap_around;
+ /* used to remeber the state of the last
+ * incremental search (the document search
+ * state may be changed by the search dialog)
+ */
+ guint search_flags;
+ gboolean wrap_around;
- GtkWidget *search_window;
- GtkWidget *search_entry;
+ GtkWidget *search_window;
+ GtkWidget *search_entry;
- guint typeselect_flush_timeout;
- guint search_entry_changed_id;
+ guint typeselect_flush_timeout;
+ guint search_entry_changed_id;
- gboolean disable_popdown;
+ gboolean disable_popdown;
- GtkTextBuffer *current_buffer;
+ GtkTextBuffer *current_buffer;
- GtkCssProvider *css_provider;
- PangoFontDescription *font_desc;
+ GtkCssProvider *css_provider;
+ PangoFontDescription *font_desc;
- PeasExtensionSet *extensions;
+ PeasExtensionSet *extensions;
};
/* The search entry completion is shared among all the views */
GtkListStore *search_completion_model = NULL;
-static void pluma_view_dispose (GObject *object);
+static void pluma_view_dispose (GObject *object);
-static void pluma_view_finalize (GObject *object);
+static void pluma_view_finalize (GObject *object);
-static gint pluma_view_focus_out (GtkWidget *widget,
- GdkEventFocus *event);
+static gint pluma_view_focus_out (GtkWidget *widget,
+ GdkEventFocus *event);
static gboolean pluma_view_scroll_event (GtkWidget *widget,
GdkEventScroll *event);
-static gboolean pluma_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint timestamp);
+static gboolean pluma_view_drag_motion (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint timestamp);
static void pluma_view_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint timestamp);
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint timestamp);
-static gboolean pluma_view_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint timestamp);
+static gboolean pluma_view_drag_drop (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint timestamp);
-static void pluma_view_realize (GtkWidget *widget);
+static void pluma_view_realize (GtkWidget *widget);
-static void pluma_view_unrealize (GtkWidget *widget);
+static void pluma_view_unrealize (GtkWidget *widget);
-static gboolean pluma_view_button_press_event (GtkWidget *widget,
- GdkEventButton *event);
+static gboolean pluma_view_button_press_event (GtkWidget *widget,
+ GdkEventButton *event);
-static gboolean pluma_view_button_release_event (GtkWidget *widget,
- GdkEventButton *event);
+static gboolean pluma_view_button_release_event (GtkWidget *widget,
+ GdkEventButton *event);
-static void pluma_view_populate_popup (GtkTextView *text_view,
- GtkWidget *widget);
+static void pluma_view_populate_popup (GtkTextView *text_view,
+ GtkWidget *widget);
-static gboolean start_interactive_search (PlumaView *view);
+static gboolean start_interactive_search (PlumaView *view);
-static gboolean start_interactive_goto_line (PlumaView *view);
+static gboolean start_interactive_goto_line (PlumaView *view);
-static gboolean reset_searched_text (PlumaView *view);
+static gboolean reset_searched_text (PlumaView *view);
-static void hide_search_window (PlumaView *view,
- gboolean cancel);
+static void hide_search_window (PlumaView *view,
+ gboolean cancel);
-static gboolean pluma_view_draw (GtkWidget *widget,
- cairo_t *cr);
+static gboolean pluma_view_draw (GtkWidget *widget,
+ cairo_t *cr);
-static void search_highlight_updated_cb (PlumaDocument *doc,
- GtkTextIter *start,
- GtkTextIter *end,
- PlumaView *view);
+static void search_highlight_updated_cb (PlumaDocument *doc,
+ GtkTextIter *start,
+ GtkTextIter *end,
+ PlumaView *view);
-static void pluma_view_delete_from_cursor (GtkTextView *text_view,
- GtkDeleteType type,
- gint count);
+static void pluma_view_delete_from_cursor (GtkTextView *text_view,
+ GtkDeleteType type,
+ gint count);
G_DEFINE_TYPE_WITH_PRIVATE (PlumaView, pluma_view, GTK_SOURCE_TYPE_VIEW)
/* Signals */
enum
{
- START_INTERACTIVE_SEARCH,
- START_INTERACTIVE_GOTO_LINE,
- RESET_SEARCHED_TEXT,
- DROP_URIS,
- LAST_SIGNAL
+ START_INTERACTIVE_SEARCH,
+ START_INTERACTIVE_GOTO_LINE,
+ RESET_SEARCHED_TEXT,
+ DROP_URIS,
+ LAST_SIGNAL
};
static guint view_signals [LAST_SIGNAL] = { 0 };
typedef enum
{
- PLUMA_SEARCH_ENTRY_NORMAL,
- PLUMA_SEARCH_ENTRY_NOT_FOUND
+ PLUMA_SEARCH_ENTRY_NORMAL,
+ PLUMA_SEARCH_ENTRY_NOT_FOUND
} PlumaSearchEntryState;
static void
document_read_only_notify_handler (PlumaDocument *document,
- GParamSpec *pspec,
- PlumaView *view)
+ GParamSpec *pspec,
+ PlumaView *view)
{
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- gtk_text_view_set_editable (GTK_TEXT_VIEW (view),
- !pluma_document_get_readonly (document));
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view),
+ !pluma_document_get_readonly (document));
}
static gboolean
pluma_view_scroll_event (GtkWidget *widget,
GdkEventScroll *event)
{
- if (event->direction == GDK_SCROLL_UP)
- {
- event->delta_x = 0;
- event->delta_y = -1;
- }
- else if (event->direction == GDK_SCROLL_DOWN)
- {
- event->delta_x = 0;
- event->delta_y = 1;
- }
- else if (event->direction == GDK_SCROLL_LEFT)
- {
- event->delta_x = -1;
- event->delta_y = 0;
- }
- else if (event->direction == GDK_SCROLL_RIGHT)
- {
- event->delta_x = 1;
- event->delta_y = 0;
- }
-
- event->direction = GDK_SCROLL_SMOOTH;
-
- return FALSE;
+ if (event->direction == GDK_SCROLL_UP)
+ {
+ event->delta_x = 0;
+ event->delta_y = -1;
+ }
+ else if (event->direction == GDK_SCROLL_DOWN)
+ {
+ event->delta_x = 0;
+ event->delta_y = 1;
+ }
+ else if (event->direction == GDK_SCROLL_LEFT)
+ {
+ event->delta_x = -1;
+ event->delta_y = 0;
+ }
+ else if (event->direction == GDK_SCROLL_RIGHT)
+ {
+ event->delta_x = 1;
+ event->delta_y = 0;
+ }
+
+ event->direction = GDK_SCROLL_SMOOTH;
+
+ return FALSE;
}
static void
pluma_view_class_init (PlumaViewClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
- GtkTextViewClass *text_view_class = GTK_TEXT_VIEW_CLASS (klass);
-
- GtkBindingSet *binding_set;
-
- object_class->dispose = pluma_view_dispose;
- object_class->finalize = pluma_view_finalize;
-
- widget_class->focus_out_event = pluma_view_focus_out;
- widget_class->draw = pluma_view_draw;
- widget_class->scroll_event = pluma_view_scroll_event;
-
- /*
- * Override the gtk_text_view_drag_motion and drag_drop
- * functions to get URIs
- *
- * If the mime type is text/uri-list, then we will accept
- * the potential drop, or request the data (depending on the
- * function).
- *
- * If the drag context has any other mime type, then pass the
- * information onto the GtkTextView's standard handlers.
- * (widget_class->function_name).
- *
- * See bug #89881 for details
- */
- widget_class->drag_motion = pluma_view_drag_motion;
- widget_class->drag_data_received = pluma_view_drag_data_received;
- widget_class->drag_drop = pluma_view_drag_drop;
- widget_class->button_press_event = pluma_view_button_press_event;
- widget_class->button_release_event = pluma_view_button_release_event;
-
- widget_class->realize = pluma_view_realize;
- widget_class->unrealize = pluma_view_unrealize;
-
- text_view_class->populate_popup = pluma_view_populate_popup;
- klass->start_interactive_search = start_interactive_search;
- klass->start_interactive_goto_line = start_interactive_goto_line;
- klass->reset_searched_text = reset_searched_text;
-
- text_view_class->delete_from_cursor = pluma_view_delete_from_cursor;
-
- view_signals[START_INTERACTIVE_SEARCH] =
- g_signal_new ("start_interactive_search",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (PlumaViewClass, start_interactive_search),
- NULL, NULL, NULL,
- G_TYPE_BOOLEAN, 0);
-
- view_signals[START_INTERACTIVE_GOTO_LINE] =
- g_signal_new ("start_interactive_goto_line",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (PlumaViewClass, start_interactive_goto_line),
- NULL, NULL, NULL,
- G_TYPE_BOOLEAN, 0);
-
- view_signals[RESET_SEARCHED_TEXT] =
- g_signal_new ("reset_searched_text",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (PlumaViewClass, reset_searched_text),
- NULL, NULL, NULL,
- G_TYPE_BOOLEAN, 0);
-
- /* A new signal DROP_URIS has been added to allow plugins to intercept
- * the default dnd behaviour of 'text/uri-list'. PlumaView now handles
- * dnd in the default handlers of drag_drop, drag_motion and
- * drag_data_received. The view emits drop_uris from drag_data_received
- * if valid uris have been dropped. Plugins should connect to
- * drag_motion, drag_drop and drag_data_received to change this
- * default behaviour. They should _NOT_ use this signal because this
- * will not prevent pluma from loading the uri
- */
- view_signals[DROP_URIS] =
- g_signal_new ("drop_uris",
- G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- G_STRUCT_OFFSET (PlumaViewClass, drop_uris),
- NULL, NULL, NULL,
- G_TYPE_NONE, 1, G_TYPE_STRV);
-
- binding_set = gtk_binding_set_by_class (klass);
-
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_k,
- GDK_CONTROL_MASK,
- "start_interactive_search", 0);
-
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_i,
- GDK_CONTROL_MASK,
- "start_interactive_goto_line", 0);
-
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_k,
- GDK_CONTROL_MASK | GDK_SHIFT_MASK,
- "reset_searched_text", 0);
-
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_d,
- GDK_CONTROL_MASK,
- "delete_from_cursor", 2,
- G_TYPE_ENUM, GTK_DELETE_PARAGRAPHS,
- G_TYPE_INT, 1);
-
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_u,
- GDK_CONTROL_MASK,
- "change_case", 1,
- G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_UPPER);
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_l,
- GDK_CONTROL_MASK,
- "change_case", 1,
- G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_LOWER);
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_u,
- GDK_MOD1_MASK,
- "change_case", 1,
- G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_TOGGLE);
- gtk_binding_entry_add_signal (binding_set,
- GDK_KEY_l,
- GDK_MOD1_MASK,
- "change_case", 1,
- G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_TITLE);
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkTextViewClass *text_view_class = GTK_TEXT_VIEW_CLASS (klass);
+
+ GtkBindingSet *binding_set;
+
+ object_class->dispose = pluma_view_dispose;
+ object_class->finalize = pluma_view_finalize;
+
+ widget_class->focus_out_event = pluma_view_focus_out;
+ widget_class->draw = pluma_view_draw;
+ widget_class->scroll_event = pluma_view_scroll_event;
+
+ /*
+ * Override the gtk_text_view_drag_motion and drag_drop
+ * functions to get URIs
+ *
+ * If the mime type is text/uri-list, then we will accept
+ * the potential drop, or request the data (depending on the
+ * function).
+ *
+ * If the drag context has any other mime type, then pass the
+ * information onto the GtkTextView's standard handlers.
+ * (widget_class->function_name).
+ *
+ * See bug #89881 for details
+ */
+ widget_class->drag_motion = pluma_view_drag_motion;
+ widget_class->drag_data_received = pluma_view_drag_data_received;
+ widget_class->drag_drop = pluma_view_drag_drop;
+ widget_class->button_press_event = pluma_view_button_press_event;
+ widget_class->button_release_event = pluma_view_button_release_event;
+
+ widget_class->realize = pluma_view_realize;
+ widget_class->unrealize = pluma_view_unrealize;
+
+ text_view_class->populate_popup = pluma_view_populate_popup;
+ klass->start_interactive_search = start_interactive_search;
+ klass->start_interactive_goto_line = start_interactive_goto_line;
+ klass->reset_searched_text = reset_searched_text;
+
+ text_view_class->delete_from_cursor = pluma_view_delete_from_cursor;
+
+ view_signals[START_INTERACTIVE_SEARCH] =
+ g_signal_new ("start_interactive_search",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (PlumaViewClass, start_interactive_search),
+ NULL, NULL, NULL,
+ G_TYPE_BOOLEAN, 0);
+
+ view_signals[START_INTERACTIVE_GOTO_LINE] =
+ g_signal_new ("start_interactive_goto_line",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (PlumaViewClass, start_interactive_goto_line),
+ NULL, NULL, NULL,
+ G_TYPE_BOOLEAN, 0);
+
+ view_signals[RESET_SEARCHED_TEXT] =
+ g_signal_new ("reset_searched_text",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (PlumaViewClass, reset_searched_text),
+ NULL, NULL, NULL,
+ G_TYPE_BOOLEAN, 0);
+
+ /* A new signal DROP_URIS has been added to allow plugins to intercept
+ * the default dnd behaviour of 'text/uri-list'. PlumaView now handles
+ * dnd in the default handlers of drag_drop, drag_motion and
+ * drag_data_received. The view emits drop_uris from drag_data_received
+ * if valid uris have been dropped. Plugins should connect to
+ * drag_motion, drag_drop and drag_data_received to change this
+ * default behaviour. They should _NOT_ use this signal because this
+ * will not prevent pluma from loading the uri
+ */
+ view_signals[DROP_URIS] =
+ g_signal_new ("drop_uris",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (PlumaViewClass, drop_uris),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 1, G_TYPE_STRV);
+
+ binding_set = gtk_binding_set_by_class (klass);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_k,
+ GDK_CONTROL_MASK,
+ "start_interactive_search", 0);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_i,
+ GDK_CONTROL_MASK,
+ "start_interactive_goto_line", 0);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_k,
+ GDK_CONTROL_MASK | GDK_SHIFT_MASK,
+ "reset_searched_text", 0);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_d,
+ GDK_CONTROL_MASK,
+ "delete_from_cursor", 2,
+ G_TYPE_ENUM, GTK_DELETE_PARAGRAPHS,
+ G_TYPE_INT, 1);
+
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_u,
+ GDK_CONTROL_MASK,
+ "change_case", 1,
+ G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_UPPER);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_l,
+ GDK_CONTROL_MASK,
+ "change_case", 1,
+ G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_LOWER);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_u,
+ GDK_MOD1_MASK,
+ "change_case", 1,
+ G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_TOGGLE);
+ gtk_binding_entry_add_signal (binding_set,
+ GDK_KEY_l,
+ GDK_MOD1_MASK,
+ "change_case", 1,
+ G_TYPE_ENUM, GTK_SOURCE_CHANGE_CASE_TITLE);
}
static void
current_buffer_removed (PlumaView *view)
{
- if (view->priv->current_buffer)
- {
- g_signal_handlers_disconnect_by_func (view->priv->current_buffer,
- document_read_only_notify_handler,
- view);
- g_signal_handlers_disconnect_by_func (view->priv->current_buffer,
- search_highlight_updated_cb,
- view);
-
- g_object_unref (view->priv->current_buffer);
- view->priv->current_buffer = NULL;
- }
+ if (view->priv->current_buffer)
+ {
+ g_signal_handlers_disconnect_by_func (view->priv->current_buffer,
+ document_read_only_notify_handler,
+ view);
+ g_signal_handlers_disconnect_by_func (view->priv->current_buffer,
+ search_highlight_updated_cb,
+ view);
+
+ g_object_unref (view->priv->current_buffer);
+ view->priv->current_buffer = NULL;
+ }
}
static void
on_notify_buffer_cb (PlumaView *view,
- GParamSpec *arg1,
- gpointer userdata)
+ GParamSpec *arg1,
+ gpointer userdata)
{
- GtkTextBuffer *buffer;
+ GtkTextBuffer *buffer;
- current_buffer_removed (view);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ current_buffer_removed (view);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- if (buffer == NULL || !PLUMA_IS_DOCUMENT (buffer))
- return;
+ if (buffer == NULL || !PLUMA_IS_DOCUMENT (buffer))
+ return;
- view->priv->current_buffer = g_object_ref (buffer);
- g_signal_connect (buffer,
- "notify::read-only",
- G_CALLBACK (document_read_only_notify_handler),
- view);
+ view->priv->current_buffer = g_object_ref (buffer);
+ g_signal_connect (buffer,
+ "notify::read-only",
+ G_CALLBACK (document_read_only_notify_handler),
+ view);
- gtk_text_view_set_editable (GTK_TEXT_VIEW (view),
- !pluma_document_get_readonly (PLUMA_DOCUMENT (buffer)));
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (view),
+ !pluma_document_get_readonly (PLUMA_DOCUMENT (buffer)));
- g_signal_connect (buffer,
- "search_highlight_updated",
- G_CALLBACK (search_highlight_updated_cb),
- view);
+ g_signal_connect (buffer,
+ "search_highlight_updated",
+ G_CALLBACK (search_highlight_updated_cb),
+ view);
/* We only activate the extensions when the right buffer is set,
- * because most plugins will expect this behaviour, and we won't
- * change the buffer later anyway. */
- peas_extension_set_call (view->priv->extensions, "activate", view);
+ * because most plugins will expect this behaviour, and we won't
+ * change the buffer later anyway. */
+ peas_extension_set_call (view->priv->extensions, "activate", view);
}
#ifdef GTK_SOURCE_VERSION_3_24
@@ -425,34 +425,35 @@ pluma_set_source_space_drawer_by_level (GtkSourceView *view,
gint level,
GtkSourceSpaceTypeFlags type)
{
- GtkSourceSpaceLocationFlags locs[] = {GTK_SOURCE_SPACE_LOCATION_LEADING,
- GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT,
- GTK_SOURCE_SPACE_LOCATION_TRAILING};
- /* this array links the level to the location */
- GtkSourceSpaceLocationFlags levels[] = {0,
- GTK_SOURCE_SPACE_LOCATION_TRAILING,
- GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT |
- GTK_SOURCE_SPACE_LOCATION_TRAILING |
- GTK_SOURCE_SPACE_LOCATION_LEADING
- };
-
- gint i;
-
- GtkSourceSpaceDrawer *drawer = gtk_source_view_get_space_drawer (view);
-
- if (level >= G_N_ELEMENTS(levels) || level < 0)
- level = 0;
-
- for (i = 0 ; i < G_N_ELEMENTS(locs) ; i++ ) {
- GtkSourceSpaceTypeFlags f;
- f = gtk_source_space_drawer_get_types_for_locations (drawer,
- locs[i]);
- if (locs[i] & levels[level])
- f |= type;
- else
- f &= ~type;
- gtk_source_space_drawer_set_types_for_locations (drawer, locs[i], f);
- }
+ GtkSourceSpaceLocationFlags locs[] = {GTK_SOURCE_SPACE_LOCATION_LEADING,
+ GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT,
+ GTK_SOURCE_SPACE_LOCATION_TRAILING};
+ /* this array links the level to the location */
+ GtkSourceSpaceLocationFlags levels[] =
+ {0,
+ GTK_SOURCE_SPACE_LOCATION_TRAILING,
+ GTK_SOURCE_SPACE_LOCATION_INSIDE_TEXT |
+ GTK_SOURCE_SPACE_LOCATION_TRAILING |
+ GTK_SOURCE_SPACE_LOCATION_LEADING
+ };
+
+ gint i;
+
+ GtkSourceSpaceDrawer *drawer = gtk_source_view_get_space_drawer (view);
+
+ if (level >= G_N_ELEMENTS(levels) || level < 0)
+ level = 0;
+
+ for (i = 0 ; i < G_N_ELEMENTS(locs) ; i++ ) {
+ GtkSourceSpaceTypeFlags f;
+ f = gtk_source_space_drawer_get_types_for_locations (drawer,
+ locs[i]);
+ if (locs[i] & levels[level])
+ f |= type;
+ else
+ f &= ~type;
+ gtk_source_space_drawer_set_types_for_locations (drawer, locs[i], f);
+ }
}
#endif
@@ -460,172 +461,165 @@ pluma_set_source_space_drawer_by_level (GtkSourceView *view,
static void
pluma_set_source_space_drawer (GSettings *settings, GtkSourceView *view)
{
- pluma_set_source_space_drawer_by_level (view,
- g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_SPACE),
- GTK_SOURCE_SPACE_TYPE_SPACE);
- pluma_set_source_space_drawer_by_level (view,
- g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_TAB),
- GTK_SOURCE_SPACE_TYPE_TAB);
- pluma_set_source_space_drawer_by_level (view,
- g_settings_get_boolean (settings, PLUMA_SETTINGS_DRAWER_NEWLINE) ? 2 : 0,
- GTK_SOURCE_SPACE_TYPE_NEWLINE);
- pluma_set_source_space_drawer_by_level (view,
- g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_NBSP),
- GTK_SOURCE_SPACE_TYPE_NBSP);
- gtk_source_space_drawer_set_enable_matrix (gtk_source_view_get_space_drawer (view),
- TRUE);
+ pluma_set_source_space_drawer_by_level (view,
+ g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_SPACE),
+ GTK_SOURCE_SPACE_TYPE_SPACE);
+ pluma_set_source_space_drawer_by_level (view,
+ g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_TAB),
+ GTK_SOURCE_SPACE_TYPE_TAB);
+ pluma_set_source_space_drawer_by_level (view,
+ g_settings_get_boolean (settings, PLUMA_SETTINGS_DRAWER_NEWLINE) ? 2 : 0,
+ GTK_SOURCE_SPACE_TYPE_NEWLINE);
+ pluma_set_source_space_drawer_by_level (view,
+ g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_NBSP),
+ GTK_SOURCE_SPACE_TYPE_NBSP);
+ gtk_source_space_drawer_set_enable_matrix (gtk_source_view_get_space_drawer (view),
+ TRUE);
}
#else
static void
pluma_set_source_space_drawer (GSettings *settings, GtkSourceView *view)
{
- GtkSourceDrawSpacesFlags flags = 0;
+ GtkSourceDrawSpacesFlags flags = 0;
- if (g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_SPACE) > 0)
- flags |= GTK_SOURCE_DRAW_SPACES_SPACE;
- if (g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_TAB) > 0)
- flags |= GTK_SOURCE_DRAW_SPACES_TAB;
- if (g_settings_get_boolean (settings, PLUMA_SETTINGS_DRAWER_NEWLINE))
- flags |= GTK_SOURCE_DRAW_SPACES_NEWLINE;
- if (g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_NBSP) > 0)
- flags |= GTK_SOURCE_DRAW_SPACES_NBSP;
+ if (g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_SPACE) > 0)
+ flags |= GTK_SOURCE_DRAW_SPACES_SPACE;
+ if (g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_TAB) > 0)
+ flags |= GTK_SOURCE_DRAW_SPACES_TAB;
+ if (g_settings_get_boolean (settings, PLUMA_SETTINGS_DRAWER_NEWLINE))
+ flags |= GTK_SOURCE_DRAW_SPACES_NEWLINE;
+ if (g_settings_get_enum (settings, PLUMA_SETTINGS_DRAWER_NBSP) > 0)
+ flags |= GTK_SOURCE_DRAW_SPACES_NBSP;
- flags |= GTK_SOURCE_DRAW_SPACES_TRAILING |
- GTK_SOURCE_DRAW_SPACES_TEXT |
- GTK_SOURCE_DRAW_SPACES_LEADING;
+ flags |= GTK_SOURCE_DRAW_SPACES_TRAILING |
+ GTK_SOURCE_DRAW_SPACES_TEXT |
+ GTK_SOURCE_DRAW_SPACES_LEADING;
- gtk_source_view_set_draw_spaces (view, flags);
+ gtk_source_view_set_draw_spaces (view, flags);
}
#endif
static void
pluma_view_init (PlumaView *view)
{
- PlumaSettings *settings;
- GtkTargetList *tl;
- gboolean use_default_font;
- gboolean display_line_numbers;
- gboolean auto_indent;
- gboolean insert_spaces;
- gboolean display_right_margin;
- gboolean hl_current_line;
- guint tabs_size;
- guint right_margin_position;
- GtkWrapMode wrap_mode;
- GtkSourceSmartHomeEndType smart_home_end;
- GtkStyleContext *context;
-
- pluma_debug (DEBUG_VIEW);
-
- view->priv = pluma_view_get_instance_private (view);
-
- settings = _pluma_settings_get_singleton ();
- view->priv->editor_settings = g_settings_new (PLUMA_SCHEMA_ID);
- view->priv->interface_settings = g_settings_new ("org.mate.interface");
-
- view->priv->css_provider = gtk_css_provider_new ();
- context = gtk_widget_get_style_context (GTK_WIDGET (view));
- gtk_style_context_add_class (context, "pluma-view");
-
- gtk_style_context_add_provider (context,
- GTK_STYLE_PROVIDER (view->priv->css_provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
-
-
- /* Get setting values */
- use_default_font = g_settings_get_boolean (view->priv->editor_settings,
- PLUMA_SETTINGS_USE_DEFAULT_FONT);
-
- /*
- * Set tab, fonts, wrap mode, colors, etc. according
- * to preferences
- */
- if (!use_default_font)
- {
- gchar *editor_font;
-
- editor_font = g_settings_get_string (view->priv->editor_settings,
- PLUMA_SETTINGS_EDITOR_FONT);
-
-
- pluma_view_set_font (view, FALSE, editor_font);
-
- g_free (editor_font);
- }
- else
- {
- pluma_view_set_font (view, TRUE, NULL);
- }
-
- display_line_numbers = g_settings_get_boolean (view->priv->editor_settings,
- PLUMA_SETTINGS_DISPLAY_LINE_NUMBERS);
- auto_indent = g_settings_get_boolean (view->priv->editor_settings,
- PLUMA_SETTINGS_AUTO_INDENT);
- tabs_size = g_settings_get_uint (view->priv->editor_settings, PLUMA_SETTINGS_TABS_SIZE);
- insert_spaces = g_settings_get_boolean (view->priv->editor_settings,
- PLUMA_SETTINGS_INSERT_SPACES);
- display_right_margin = g_settings_get_boolean (view->priv->editor_settings,
- PLUMA_SETTINGS_DISPLAY_RIGHT_MARGIN);
- right_margin_position = g_settings_get_uint (view->priv->editor_settings,
- PLUMA_SETTINGS_RIGHT_MARGIN_POSITION);
- hl_current_line = g_settings_get_boolean (view->priv->editor_settings,
- PLUMA_SETTINGS_HIGHLIGHT_CURRENT_LINE);
-
- wrap_mode = pluma_settings_get_wrap_mode (view->priv->editor_settings,
- PLUMA_SETTINGS_WRAP_MODE);
-
- smart_home_end = pluma_settings_get_smart_home_end (settings);
-
- g_object_set (G_OBJECT (view),
- "wrap_mode", wrap_mode,
- "show_line_numbers", display_line_numbers,
- "auto_indent", auto_indent,
- "tab_width", tabs_size,
- "insert_spaces_instead_of_tabs", insert_spaces,
- "show_right_margin", display_right_margin,
- "right_margin_position", right_margin_position,
- "highlight_current_line", hl_current_line,
- "smart_home_end", smart_home_end,
- "indent_on_tab", TRUE,
- NULL);
-
- g_settings_bind (view->priv->editor_settings,
- PLUMA_SETTINGS_BACKGROUND_PATTERN,
- view,
- "background-pattern",
- G_SETTINGS_BIND_DEFAULT);
-
- pluma_set_source_space_drawer (view->priv->editor_settings, GTK_SOURCE_VIEW (view));
-
- view->priv->typeselect_flush_timeout = 0;
- view->priv->wrap_around = TRUE;
-
- /* Drag and drop support */
- tl = gtk_drag_dest_get_target_list (GTK_WIDGET (view));
-
- if (tl != NULL)
- gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
-
- view->priv->extensions =
- peas_extension_set_new (PEAS_ENGINE (pluma_plugins_engine_get_default ()),
- PLUMA_TYPE_VIEW_ACTIVATABLE,
- "view", view,
- NULL);
-
- /* Act on buffer change */
- g_signal_connect (view,
- "notify::buffer",
- G_CALLBACK (on_notify_buffer_cb),
- NULL);
+ PlumaSettings *settings;
+ GtkTargetList *tl;
+ gboolean use_default_font;
+ gboolean display_line_numbers;
+ gboolean auto_indent;
+ gboolean insert_spaces;
+ gboolean display_right_margin;
+ gboolean hl_current_line;
+ guint tabs_size;
+ guint right_margin_position;
+ GtkWrapMode wrap_mode;
+ GtkSourceSmartHomeEndType smart_home_end;
+ GtkStyleContext *context;
+
+ pluma_debug (DEBUG_VIEW);
+
+ view->priv = pluma_view_get_instance_private (view);
+
+ settings = _pluma_settings_get_singleton ();
+ view->priv->editor_settings = g_settings_new (PLUMA_SCHEMA_ID);
+ view->priv->interface_settings = g_settings_new ("org.mate.interface");
+
+ view->priv->css_provider = gtk_css_provider_new ();
+ context = gtk_widget_get_style_context (GTK_WIDGET (view));
+ gtk_style_context_add_class (context, "pluma-view");
+
+ gtk_style_context_add_provider (context,
+ GTK_STYLE_PROVIDER (view->priv->css_provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+
+
+ /* Get setting values */
+ use_default_font = g_settings_get_boolean (view->priv->editor_settings,
+ PLUMA_SETTINGS_USE_DEFAULT_FONT);
+
+ /*
+ * Set tab, fonts, wrap mode, colors, etc. according
+ * to preferences
+ */
+ if (!use_default_font)
+ {
+ gchar *editor_font;
+
+ editor_font = g_settings_get_string (view->priv->editor_settings,
+ PLUMA_SETTINGS_EDITOR_FONT);
+
+ pluma_view_set_font (view, FALSE, editor_font);
+
+ g_free (editor_font);
+ }
+ else
+ {
+ pluma_view_set_font (view, TRUE, NULL);
+ }
+
+ display_line_numbers = g_settings_get_boolean (view->priv->editor_settings, PLUMA_SETTINGS_DISPLAY_LINE_NUMBERS);
+ auto_indent = g_settings_get_boolean (view->priv->editor_settings, PLUMA_SETTINGS_AUTO_INDENT);
+ tabs_size = g_settings_get_uint (view->priv->editor_settings, PLUMA_SETTINGS_TABS_SIZE);
+ insert_spaces = g_settings_get_boolean (view->priv->editor_settings, PLUMA_SETTINGS_INSERT_SPACES);
+ display_right_margin = g_settings_get_boolean (view->priv->editor_settings, PLUMA_SETTINGS_DISPLAY_RIGHT_MARGIN);
+ right_margin_position = g_settings_get_uint (view->priv->editor_settings, PLUMA_SETTINGS_RIGHT_MARGIN_POSITION);
+ hl_current_line = g_settings_get_boolean (view->priv->editor_settings, PLUMA_SETTINGS_HIGHLIGHT_CURRENT_LINE);
+
+ wrap_mode = pluma_settings_get_wrap_mode (view->priv->editor_settings, PLUMA_SETTINGS_WRAP_MODE);
+
+ smart_home_end = pluma_settings_get_smart_home_end (settings);
+
+ g_object_set (G_OBJECT (view),
+ "wrap_mode", wrap_mode,
+ "show_line_numbers", display_line_numbers,
+ "auto_indent", auto_indent,
+ "tab_width", tabs_size,
+ "insert_spaces_instead_of_tabs", insert_spaces,
+ "show_right_margin", display_right_margin,
+ "right_margin_position", right_margin_position,
+ "highlight_current_line", hl_current_line,
+ "smart_home_end", smart_home_end,
+ "indent_on_tab", TRUE,
+ NULL);
+
+ g_settings_bind (view->priv->editor_settings,
+ PLUMA_SETTINGS_BACKGROUND_PATTERN,
+ view,
+ "background-pattern",
+ G_SETTINGS_BIND_DEFAULT);
+
+ pluma_set_source_space_drawer (view->priv->editor_settings, GTK_SOURCE_VIEW (view));
+
+ view->priv->typeselect_flush_timeout = 0;
+ view->priv->wrap_around = TRUE;
+
+ /* Drag and drop support */
+ tl = gtk_drag_dest_get_target_list (GTK_WIDGET (view));
+
+ if (tl != NULL)
+ gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
+
+ view->priv->extensions =
+ peas_extension_set_new (PEAS_ENGINE (pluma_plugins_engine_get_default ()),
+ PLUMA_TYPE_VIEW_ACTIVATABLE,
+ "view", view,
+ NULL);
+
+
+ /* Act on buffer change */
+ g_signal_connect (view,
+ "notify::buffer",
+ G_CALLBACK (on_notify_buffer_cb),
+ NULL);
}
static void
pluma_view_dispose (GObject *object)
{
- PlumaView *view;
+ PlumaView *view;
- view = PLUMA_VIEW (object);
+ view = PLUMA_VIEW (object);
if (view->priv->extensions != NULL)
{
@@ -633,62 +627,62 @@ pluma_view_dispose (GObject *object)
view->priv->extensions = NULL;
}
- if (view->priv->search_window != NULL)
- {
- gtk_widget_destroy (view->priv->search_window);
- view->priv->search_window = NULL;
- view->priv->search_entry = NULL;
+ if (view->priv->search_window != NULL)
+ {
+ gtk_widget_destroy (view->priv->search_window);
+ view->priv->search_window = NULL;
+ view->priv->search_entry = NULL;
- if (view->priv->typeselect_flush_timeout != 0)
- {
- g_source_remove (view->priv->typeselect_flush_timeout);
- view->priv->typeselect_flush_timeout = 0;
- }
- }
+ if (view->priv->typeselect_flush_timeout != 0)
+ {
+ g_source_remove (view->priv->typeselect_flush_timeout);
+ view->priv->typeselect_flush_timeout = 0;
+ }
+ }
- g_clear_object (&view->priv->editor_settings);
- g_clear_object (&view->priv->interface_settings);
+ g_clear_object (&view->priv->editor_settings);
+ g_clear_object (&view->priv->interface_settings);
- /* Disconnect notify buffer because the destroy of the textview will
- set the buffer to NULL, and we call get_buffer in the notify which
- would reinstate a GtkTextBuffer which we don't want */
- current_buffer_removed (view);
- g_signal_handlers_disconnect_by_func (view, on_notify_buffer_cb, NULL);
+ /* Disconnect notify buffer because the destroy of the textview will
+ set the buffer to NULL, and we call get_buffer in the notify which
+ would reinstate a GtkTextBuffer which we don't want */
+ current_buffer_removed (view);
+ g_signal_handlers_disconnect_by_func (view, on_notify_buffer_cb, NULL);
- g_clear_object (&view->priv->css_provider);
- g_clear_pointer (&view->priv->font_desc, pango_font_description_free);
+ g_clear_object (&view->priv->css_provider);
+ g_clear_pointer (&view->priv->font_desc, pango_font_description_free);
- (* G_OBJECT_CLASS (pluma_view_parent_class)->dispose) (object);
+ (* G_OBJECT_CLASS (pluma_view_parent_class)->dispose) (object);
}
static void
pluma_view_finalize (GObject *object)
{
- PlumaView *view;
+ PlumaView *view;
- view = PLUMA_VIEW (object);
+ view = PLUMA_VIEW (object);
- current_buffer_removed (view);
+ current_buffer_removed (view);
- g_free (view->priv->old_search_text);
+ g_free (view->priv->old_search_text);
- (* G_OBJECT_CLASS (pluma_view_parent_class)->finalize) (object);
+ (* G_OBJECT_CLASS (pluma_view_parent_class)->finalize) (object);
}
static gint
pluma_view_focus_out (GtkWidget *widget, GdkEventFocus *event)
{
- PlumaView *view = PLUMA_VIEW (widget);
+ PlumaView *view = PLUMA_VIEW (widget);
- gtk_widget_queue_draw (widget);
+ gtk_widget_queue_draw (widget);
- /* hide interactive search dialog */
- if (view->priv->search_window != NULL)
- hide_search_window (view, FALSE);
+ /* hide interactive search dialog */
+ if (view->priv->search_window != NULL)
+ hide_search_window (view, FALSE);
- (* GTK_WIDGET_CLASS (pluma_view_parent_class)->focus_out_event) (widget, event);
+ (* GTK_WIDGET_CLASS (pluma_view_parent_class)->focus_out_event) (widget, event);
- return FALSE;
+ return FALSE;
}
/**
@@ -703,101 +697,97 @@ pluma_view_focus_out (GtkWidget *widget, GdkEventFocus *event)
GtkWidget *
pluma_view_new (PlumaDocument *doc)
{
- GtkWidget *view;
+ GtkWidget *view;
- pluma_debug_message (DEBUG_VIEW, "START");
+ pluma_debug_message (DEBUG_VIEW, "START");
- g_return_val_if_fail (PLUMA_IS_DOCUMENT (doc), NULL);
+ g_return_val_if_fail (PLUMA_IS_DOCUMENT (doc), NULL);
- view = GTK_WIDGET (g_object_new (PLUMA_TYPE_VIEW, "buffer", doc, NULL));
+ view = GTK_WIDGET (g_object_new (PLUMA_TYPE_VIEW, "buffer", doc, NULL));
- pluma_debug_message (DEBUG_VIEW, "END: %d", G_OBJECT (view)->ref_count);
+ pluma_debug_message (DEBUG_VIEW, "END: %d", G_OBJECT (view)->ref_count);
- gtk_widget_show_all (view);
+ gtk_widget_show_all (view);
- return view;
+ return view;
}
void
pluma_view_cut_clipboard (PlumaView *view)
{
- GtkTextBuffer *buffer;
- GtkClipboard *clipboard;
+ GtkTextBuffer *buffer;
+ GtkClipboard *clipboard;
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
- GDK_SELECTION_CLIPBOARD);
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
+ GDK_SELECTION_CLIPBOARD);
- /* FIXME: what is default editability of a buffer? */
- gtk_text_buffer_cut_clipboard (buffer,
- clipboard,
- !pluma_document_get_readonly (
- PLUMA_DOCUMENT (buffer)));
+ /* FIXME: what is default editability of a buffer? */
+ gtk_text_buffer_cut_clipboard (buffer,
+ clipboard,
+ !pluma_document_get_readonly (PLUMA_DOCUMENT (buffer)));
- gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
- gtk_text_buffer_get_insert (buffer),
- PLUMA_VIEW_SCROLL_MARGIN,
- FALSE,
- 0.0,
- 0.0);
+ gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
+ gtk_text_buffer_get_insert (buffer),
+ PLUMA_VIEW_SCROLL_MARGIN,
+ FALSE,
+ 0.0,
+ 0.0);
}
void
pluma_view_copy_clipboard (PlumaView *view)
{
- GtkTextBuffer *buffer;
- GtkClipboard *clipboard;
+ GtkTextBuffer *buffer;
+ GtkClipboard *clipboard;
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
- GDK_SELECTION_CLIPBOARD);
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view), GDK_SELECTION_CLIPBOARD);
- gtk_text_buffer_copy_clipboard (buffer, clipboard);
+ gtk_text_buffer_copy_clipboard (buffer, clipboard);
- /* on copy do not scroll, we are already on screen */
+ /* on copy do not scroll, we are already on screen */
}
void
pluma_view_paste_clipboard (PlumaView *view)
{
- GtkTextBuffer *buffer;
- GtkClipboard *clipboard;
+ GtkTextBuffer *buffer;
+ GtkClipboard *clipboard;
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view),
- GDK_SELECTION_CLIPBOARD);
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (view), GDK_SELECTION_CLIPBOARD);
- /* FIXME: what is default editability of a buffer? */
- gtk_text_buffer_paste_clipboard (buffer,
- clipboard,
- NULL,
- !pluma_document_get_readonly (
- PLUMA_DOCUMENT (buffer)));
+ /* FIXME: what is default editability of a buffer? */
+ gtk_text_buffer_paste_clipboard (buffer,
+ clipboard,
+ NULL,
+ !pluma_document_get_readonly (PLUMA_DOCUMENT (buffer)));
- gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
- gtk_text_buffer_get_insert (buffer),
- PLUMA_VIEW_SCROLL_MARGIN,
- FALSE,
- 0.0,
- 0.0);
+ gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
+ gtk_text_buffer_get_insert (buffer),
+ PLUMA_VIEW_SCROLL_MARGIN,
+ FALSE,
+ 0.0,
+ 0.0);
}
/**
@@ -810,103 +800,102 @@ pluma_view_paste_clipboard (PlumaView *view)
void
pluma_view_delete_selection (PlumaView *view)
{
- GtkTextBuffer *buffer = NULL;
+ GtkTextBuffer *buffer = NULL;
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- /* FIXME: what is default editability of a buffer? */
- gtk_text_buffer_delete_selection (buffer,
- TRUE,
- !pluma_document_get_readonly (
- PLUMA_DOCUMENT (buffer)));
+ /* FIXME: what is default editability of a buffer? */
+ gtk_text_buffer_delete_selection (buffer,
+ TRUE,
+ !pluma_document_get_readonly (PLUMA_DOCUMENT (buffer)));
- gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
- gtk_text_buffer_get_insert (buffer),
- PLUMA_VIEW_SCROLL_MARGIN,
- FALSE,
- 0.0,
- 0.0);
+ gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
+ gtk_text_buffer_get_insert (buffer),
+ PLUMA_VIEW_SCROLL_MARGIN,
+ FALSE,
+ 0.0,
+ 0.0);
}
void
pluma_view_upper_case_selection (PlumaView *view)
{
- GtkTextBuffer *buffer = NULL;
- GtkTextIter start, end;
+ GtkTextBuffer *buffer = NULL;
+ GtkTextIter start, end;
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
- {
- gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_UPPER, &start, &end);
- }
+ if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ {
+ gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_UPPER, &start, &end);
+ }
}
void
pluma_view_lower_case_selection (PlumaView *view)
{
- GtkTextBuffer *buffer = NULL;
- GtkTextIter start, end;
+ GtkTextBuffer *buffer = NULL;
+ GtkTextIter start, end;
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
- {
- gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_LOWER, &start, &end);
- }
+ if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ {
+ gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_LOWER, &start, &end);
+ }
}
void
pluma_view_invert_case_selection (PlumaView *view)
{
- GtkTextBuffer *buffer = NULL;
- GtkTextIter start, end;
+ GtkTextBuffer *buffer = NULL;
+ GtkTextIter start, end;
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
- {
- gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_TOGGLE, &start, &end);
- }
+ if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ {
+ gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_TOGGLE, &start, &end);
+ }
}
void
pluma_view_title_case_selection (PlumaView *view)
{
- GtkTextBuffer *buffer = NULL;
- GtkTextIter start, end;
+ GtkTextBuffer *buffer = NULL;
+ GtkTextIter start, end;
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
- {
- gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_TITLE, &start, &end);
- }
+ if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ {
+ gtk_source_buffer_change_case (GTK_SOURCE_BUFFER (buffer), GTK_SOURCE_CHANGE_CASE_TITLE, &start, &end);
+ }
}
/**
@@ -918,18 +907,18 @@ pluma_view_title_case_selection (PlumaView *view)
void
pluma_view_select_all (PlumaView *view)
{
- GtkTextBuffer *buffer = NULL;
- GtkTextIter start, end;
+ GtkTextBuffer *buffer = NULL;
+ GtkTextIter start, end;
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- gtk_text_buffer_get_bounds (buffer, &start, &end);
- gtk_text_buffer_select_range (buffer, &start, &end);
+ gtk_text_buffer_get_bounds (buffer, &start, &end);
+ gtk_text_buffer_select_range (buffer, &start, &end);
}
/**
@@ -941,38 +930,38 @@ pluma_view_select_all (PlumaView *view)
void
pluma_view_scroll_to_cursor (PlumaView *view)
{
- GtkTextBuffer* buffer = NULL;
+ GtkTextBuffer* buffer = NULL;
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- g_return_if_fail (buffer != NULL);
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ g_return_if_fail (buffer != NULL);
- gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
- gtk_text_buffer_get_insert (buffer),
- 0.25,
- FALSE,
- 0.0,
- 0.0);
+ gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (view),
+ gtk_text_buffer_get_insert (buffer),
+ 0.25,
+ FALSE,
+ 0.0,
+ 0.0);
}
static void
update_css_provider (PlumaView *view)
{
- gchar *str;
- gchar *css;
+ gchar *str;
+ gchar *css;
- g_assert (PLUMA_IS_VIEW (view));
- g_assert (view->priv->font_desc != NULL);
+ g_assert (PLUMA_IS_VIEW (view));
+ g_assert (view->priv->font_desc != NULL);
- str = pluma_pango_font_description_to_css (view->priv->font_desc);
- css = g_strdup_printf ("textview { %s }", str ? str : "");
- gtk_css_provider_load_from_data (view->priv->css_provider, css, -1, NULL);
+ str = pluma_pango_font_description_to_css (view->priv->font_desc);
+ css = g_strdup_printf ("textview { %s }", str ? str : "");
+ gtk_css_provider_load_from_data (view->priv->css_provider, css, -1, NULL);
- g_free (css);
- g_free (str);
+ g_free (css);
+ g_free (str);
}
/* FIXME this is an issue for introspection */
@@ -987,1603 +976,1600 @@ update_css_provider (PlumaView *view)
**/
void
pluma_view_set_font (PlumaView *view,
- gboolean def,
- const gchar *font_name)
+ gboolean def,
+ const gchar *font_name)
{
- pluma_debug (DEBUG_VIEW);
+ pluma_debug (DEBUG_VIEW);
- g_return_if_fail (PLUMA_IS_VIEW (view));
+ g_return_if_fail (PLUMA_IS_VIEW (view));
- g_clear_pointer (&view->priv->font_desc, pango_font_description_free);
+ g_clear_pointer (&view->priv->font_desc, pango_font_description_free);
- if (def)
- {
- PlumaSettings *settings;
- gchar *font;
+ if (def)
+ {
+ PlumaSettings *settings;
+ gchar *font;
- settings = _pluma_settings_get_singleton ();
- font = pluma_settings_get_system_font (settings);
- view->priv->font_desc = pango_font_description_from_string (font);
- g_free (font);
- }
- else
- {
- g_return_if_fail (font_name != NULL);
+ settings = _pluma_settings_get_singleton ();
+ font = pluma_settings_get_system_font (settings);
+ view->priv->font_desc = pango_font_description_from_string (font);
+ g_free (font);
+ }
+ else
+ {
+ g_return_if_fail (font_name != NULL);
- view->priv->font_desc = pango_font_description_from_string (font_name);
- }
+ view->priv->font_desc = pango_font_description_from_string (font_name);
+ }
- g_return_if_fail (view->priv->font_desc != NULL);
+ g_return_if_fail (view->priv->font_desc != NULL);
- update_css_provider (view);
+ update_css_provider (view);
}
static void
add_search_completion_entry (const gchar *str)
{
- gchar *text;
- gboolean valid;
- GtkTreeModel *model;
- GtkTreeIter iter;
+ gchar *text;
+ gboolean valid;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
- if (str == NULL)
- return;
+ if (str == NULL)
+ return;
- text = pluma_utils_unescape_search_text (str);
+ text = pluma_utils_unescape_search_text (str);
- if (g_utf8_strlen (text, -1) < MIN_SEARCH_COMPLETION_KEY_LEN)
- {
- g_free (text);
- return;
- }
+ if (g_utf8_strlen (text, -1) < MIN_SEARCH_COMPLETION_KEY_LEN)
+ {
+ g_free (text);
+ return;
+ }
- g_return_if_fail (GTK_IS_TREE_MODEL (search_completion_model));
+ g_return_if_fail (GTK_IS_TREE_MODEL (search_completion_model));
- model = GTK_TREE_MODEL (search_completion_model);
+ model = GTK_TREE_MODEL (search_completion_model);
- /* Get the first iter in the list */
- valid = gtk_tree_model_get_iter_first (model, &iter);
+ /* Get the first iter in the list */
+ valid = gtk_tree_model_get_iter_first (model, &iter);
- while (valid)
- {
- /* Walk through the list, reading each row */
- gchar *str_data;
+ while (valid)
+ {
+ /* Walk through the list, reading each row */
+ gchar *str_data;
- gtk_tree_model_get (model,
- &iter,
- 0,
- &str_data,
- -1);
+ gtk_tree_model_get (model,
+ &iter,
+ 0,
+ &str_data,
+ -1);
- if (strcmp (text, str_data) == 0)
- {
- g_free (text);
- g_free (str_data);
- gtk_list_store_move_after (GTK_LIST_STORE (model),
- &iter,
- NULL);
+ if (strcmp (text, str_data) == 0)
+ {
+ g_free (text);
+ g_free (str_data);
+ gtk_list_store_move_after (GTK_LIST_STORE (model),
+ &iter,
+ NULL);
- return;
- }
+ return;
+ }
- g_free (str_data);
+ g_free (str_data);
- valid = gtk_tree_model_iter_next (model, &iter);
- }
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
- gtk_list_store_prepend (GTK_LIST_STORE (model), &iter);
- gtk_list_store_set (GTK_LIST_STORE (model),
- &iter,
- 0,
- text,
- -1);
+ gtk_list_store_prepend (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (model),
+ &iter,
+ 0,
+ text,
+ -1);
- g_free (text);
+ g_free (text);
}
static void
set_entry_state (GtkWidget *entry,
PlumaSearchEntryState state)
{
- GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (entry));
+ GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (entry));
- if (state == PLUMA_SEARCH_ENTRY_NOT_FOUND)
- {
- gtk_style_context_add_class (context, GTK_STYLE_CLASS_ERROR);
- }
- else /* reset */
- {
- gtk_style_context_remove_class (context, GTK_STYLE_CLASS_ERROR);
- }
+ if (state == PLUMA_SEARCH_ENTRY_NOT_FOUND)
+ {
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_ERROR);
+ }
+ else /* reset */
+ {
+ gtk_style_context_remove_class (context, GTK_STYLE_CLASS_ERROR);
+ }
}
static gboolean
run_search (PlumaView *view,
const gchar *entry_text,
- gboolean search_backward,
- gboolean wrap_around,
+ gboolean search_backward,
+ gboolean wrap_around,
gboolean typing)
{
- GtkTextIter start_iter;
- GtkTextIter match_start;
- GtkTextIter match_end;
- gboolean found = FALSE;
- PlumaDocument *doc;
-
- g_return_val_if_fail (view->priv->search_mode == SEARCH, FALSE);
-
- doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
-
- start_iter = view->priv->start_search_iter;
-
- if (*entry_text != '\0')
- {
- if (!search_backward)
- {
- if (!typing)
- {
- /* forward and _NOT_ typing */
- gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
- &start_iter,
- &match_end);
-
- gtk_text_iter_order (&match_end, &start_iter);
- }
-
- /* run search */
- found = pluma_document_search_forward (doc,
- &start_iter,
- NULL,
- &match_start,
- &match_end);
- }
- else if (!typing)
- {
- /* backward and not typing */
- gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
- &start_iter,
- &match_end);
-
- /* run search */
- found = pluma_document_search_backward (doc,
- NULL,
- &start_iter,
- &match_start,
- &match_end);
- }
- else
- {
- /* backward (while typing) */
- g_return_val_if_reached (FALSE);
-
- }
-
- if (!found && wrap_around)
- {
- if (!search_backward)
- found = pluma_document_search_forward (doc,
- NULL,
- NULL, /* FIXME: set the end_inter */
- &match_start,
- &match_end);
- else
- found = pluma_document_search_backward (doc,
- NULL, /* FIXME: set the start_inter */
- NULL,
- &match_start,
- &match_end);
- }
- }
- else
- {
- gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
- &start_iter,
- NULL);
- }
-
- if (found)
- {
- gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc),
- &match_start);
-
- gtk_text_buffer_move_mark_by_name (GTK_TEXT_BUFFER (doc),
- "selection_bound", &match_end);
- }
- else
- {
- if (typing)
- {
- gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc),
- &view->priv->start_search_iter);
- }
- }
-
- if (found || (*entry_text == '\0'))
- {
- pluma_view_scroll_to_cursor (view);
-
- set_entry_state (view->priv->search_entry,
- PLUMA_SEARCH_ENTRY_NORMAL);
- }
- else
- {
- set_entry_state (view->priv->search_entry,
- PLUMA_SEARCH_ENTRY_NOT_FOUND);
- }
-
- return found;
+ GtkTextIter start_iter;
+ GtkTextIter match_start;
+ GtkTextIter match_end;
+ gboolean found = FALSE;
+ PlumaDocument *doc;
+
+ g_return_val_if_fail (view->priv->search_mode == SEARCH, FALSE);
+
+ doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+ start_iter = view->priv->start_search_iter;
+
+ if (*entry_text != '\0')
+ {
+ if (!search_backward)
+ {
+ if (!typing)
+ {
+ /* forward and _NOT_ typing */
+ gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
+ &start_iter,
+ &match_end);
+
+ gtk_text_iter_order (&match_end, &start_iter);
+ }
+
+ /* run search */
+ found = pluma_document_search_forward (doc,
+ &start_iter,
+ NULL,
+ &match_start,
+ &match_end);
+ }
+ else if (!typing)
+ {
+ /* backward and not typing */
+ gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
+ &start_iter,
+ &match_end);
+
+ /* run search */
+ found = pluma_document_search_backward (doc,
+ NULL,
+ &start_iter,
+ &match_start,
+ &match_end);
+ }
+ else
+ {
+ /* backward (while typing) */
+ g_return_val_if_reached (FALSE);
+
+ }
+
+ if (!found && wrap_around)
+ {
+ if (!search_backward)
+ found = pluma_document_search_forward (doc,
+ NULL,
+ NULL, /* FIXME: set the end_inter */
+ &match_start,
+ &match_end);
+ else
+ found = pluma_document_search_backward (doc,
+ NULL, /* FIXME: set the start_inter */
+ NULL,
+ &match_start,
+ &match_end);
+ }
+ }
+ else
+ {
+ gtk_text_buffer_get_selection_bounds (GTK_TEXT_BUFFER (doc),
+ &start_iter,
+ NULL);
+ }
+
+ if (found)
+ {
+ gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc), &match_start);
+
+ gtk_text_buffer_move_mark_by_name (GTK_TEXT_BUFFER (doc),
+ "selection_bound",
+ &match_end);
+ }
+ else
+ {
+ if (typing)
+ {
+ gtk_text_buffer_place_cursor (GTK_TEXT_BUFFER (doc),
+ &view->priv->start_search_iter);
+ }
+ }
+
+ if (found || (*entry_text == '\0'))
+ {
+ pluma_view_scroll_to_cursor (view);
+
+ set_entry_state (view->priv->search_entry,
+ PLUMA_SEARCH_ENTRY_NORMAL);
+ }
+ else
+ {
+ set_entry_state (view->priv->search_entry,
+ PLUMA_SEARCH_ENTRY_NOT_FOUND);
+ }
+
+ return found;
}
/* Cut and paste from gtkwindow.c */
static void
send_focus_change (GtkWidget *widget,
- gboolean in)
+ gboolean in)
{
- GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
+ GdkEvent *fevent = gdk_event_new (GDK_FOCUS_CHANGE);
- g_object_ref (widget);
+ g_object_ref (widget);
- fevent->focus_change.type = GDK_FOCUS_CHANGE;
- fevent->focus_change.window = g_object_ref (gtk_widget_get_window (widget));
- fevent->focus_change.in = in;
+ fevent->focus_change.type = GDK_FOCUS_CHANGE;
+ fevent->focus_change.window = g_object_ref (gtk_widget_get_window (widget));
+ fevent->focus_change.in = in;
- gtk_widget_event (widget, fevent);
+ gtk_widget_event (widget, fevent);
- g_object_notify (G_OBJECT (widget), "has-focus");
+ g_object_notify (G_OBJECT (widget), "has-focus");
- g_object_unref (widget);
- gdk_event_free (fevent);
+ g_object_unref (widget);
+ gdk_event_free (fevent);
}
static void
hide_search_window (PlumaView *view, gboolean cancel)
{
- if (view->priv->disable_popdown)
- return;
+ if (view->priv->disable_popdown)
+ return;
- if (view->priv->search_entry_changed_id != 0)
- {
- g_signal_handler_disconnect (view->priv->search_entry,
- view->priv->search_entry_changed_id);
- view->priv->search_entry_changed_id = 0;
- }
+ if (view->priv->search_entry_changed_id != 0)
+ {
+ g_signal_handler_disconnect (view->priv->search_entry,
+ view->priv->search_entry_changed_id);
+ view->priv->search_entry_changed_id = 0;
+ }
- if (view->priv->typeselect_flush_timeout != 0)
- {
- g_source_remove (view->priv->typeselect_flush_timeout);
- view->priv->typeselect_flush_timeout = 0;
- }
+ if (view->priv->typeselect_flush_timeout != 0)
+ {
+ g_source_remove (view->priv->typeselect_flush_timeout);
+ view->priv->typeselect_flush_timeout = 0;
+ }
- /* send focus-in event */
- send_focus_change (GTK_WIDGET (view->priv->search_entry), FALSE);
- gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), TRUE);
- gtk_widget_hide (view->priv->search_window);
+ /* send focus-in event */
+ send_focus_change (GTK_WIDGET (view->priv->search_entry), FALSE);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), TRUE);
+ gtk_widget_hide (view->priv->search_window);
- if (cancel)
- {
- GtkTextBuffer *buffer;
+ if (cancel)
+ {
+ GtkTextBuffer *buffer;
- buffer = GTK_TEXT_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
- gtk_text_buffer_place_cursor (buffer, &view->priv->start_search_iter);
+ buffer = GTK_TEXT_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+ gtk_text_buffer_place_cursor (buffer, &view->priv->start_search_iter);
- pluma_view_scroll_to_cursor (view);
- }
+ pluma_view_scroll_to_cursor (view);
+ }
- /* make sure a focus event is sent for the edit area */
- send_focus_change (GTK_WIDGET (view), TRUE);
+ /* make sure a focus event is sent for the edit area */
+ send_focus_change (GTK_WIDGET (view), TRUE);
}
static gboolean
search_entry_flush_timeout (PlumaView *view)
{
- view->priv->typeselect_flush_timeout = 0;
- hide_search_window (view, FALSE);
+ view->priv->typeselect_flush_timeout = 0;
+ hide_search_window (view, FALSE);
- return FALSE;
+ return FALSE;
}
static void
update_search_window_position (PlumaView *view)
{
- gint x, y;
- gint view_x, view_y;
- GdkWindow *view_window = gtk_widget_get_window (GTK_WIDGET (view));
+ gint x, y;
+ gint view_x, view_y;
+ GdkWindow *view_window = gtk_widget_get_window (GTK_WIDGET (view));
- gtk_widget_realize (view->priv->search_window);
+ gtk_widget_realize (view->priv->search_window);
- gdk_window_get_origin (view_window, &view_x, &view_y);
+ gdk_window_get_origin (view_window, &view_x, &view_y);
- x = MAX (12, view_x + 12);
- y = MAX (12, view_y - 12);
+ x = MAX (12, view_x + 12);
+ y = MAX (12, view_y - 12);
- gtk_window_move (GTK_WINDOW (view->priv->search_window), x, y);
+ gtk_window_move (GTK_WINDOW (view->priv->search_window), x, y);
}
static gboolean
search_window_delete_event (GtkWidget *widget,
- GdkEventAny *event,
- PlumaView *view)
+ GdkEventAny *event,
+ PlumaView *view)
{
- hide_search_window (view, FALSE);
+ hide_search_window (view, FALSE);
- return TRUE;
+ return TRUE;
}
static gboolean
search_window_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- PlumaView *view)
+ GdkEventButton *event,
+ PlumaView *view)
{
- hide_search_window (view, FALSE);
+ hide_search_window (view, FALSE);
- gtk_propagate_event (GTK_WIDGET (view), (GdkEvent *)event);
+ gtk_propagate_event (GTK_WIDGET (view), (GdkEvent *)event);
- return FALSE;
+ return FALSE;
}
static void
-extension_added (PeasExtensionSet *extensions,
- PeasPluginInfo *info,
- PeasExtension *exten,
- PlumaView *view)
+search_again (PlumaView *view,
+ gboolean search_backward)
{
- pluma_view_activatable_activate (PLUMA_VIEW_ACTIVATABLE (exten));
-}
+ const gchar *entry_text;
-static void
-extension_removed (PeasExtensionSet *extensions,
- PeasPluginInfo *info,
- PeasExtension *exten,
- PlumaView *view)
-{
- pluma_view_activatable_deactivate (PLUMA_VIEW_ACTIVATABLE (exten));
-}
+ g_return_if_fail (view->priv->search_mode == SEARCH);
-static void
-pluma_view_realize (GtkWidget *widget)
-{
- PlumaView *view = PLUMA_VIEW (widget);
+ /* SEARCH mode */
+ /* renew the flush timeout */
+ if (view->priv->typeselect_flush_timeout != 0)
+ {
+ g_source_remove (view->priv->typeselect_flush_timeout);
+ view->priv->typeselect_flush_timeout =
+ g_timeout_add (PLUMA_VIEW_SEARCH_DIALOG_TIMEOUT,
+ (GSourceFunc)search_entry_flush_timeout,
+ view);
+ }
- GTK_WIDGET_CLASS (pluma_view_parent_class)->realize (widget);
+ entry_text = gtk_entry_get_text (GTK_ENTRY (view->priv->search_entry));
- g_signal_connect (view->priv->extensions,
- "extension-added",
- G_CALLBACK (extension_added),
- view);
- g_signal_connect (view->priv->extensions,
- "extension-removed",
- G_CALLBACK (extension_removed),
- view);
+ add_search_completion_entry (entry_text);
- /* We only activate the extensions when the view is realized,
- * because most plugins will expect this behaviour, and we won't
- * change the buffer later anyway. */
- peas_extension_set_foreach (view->priv->extensions,
- (PeasExtensionSetForeachFunc) extension_added,
- view);
+ run_search (view,
+ entry_text,
+ search_backward,
+ view->priv->wrap_around,
+ FALSE);
}
-static void
-pluma_view_unrealize (GtkWidget *widget)
+static gboolean
+search_window_scroll_event (GtkWidget *widget,
+ GdkEventScroll *event,
+ PlumaView *view)
{
- PlumaView *view = PLUMA_VIEW (widget);
+ gboolean retval = FALSE;
- g_signal_handlers_disconnect_by_func (view->priv->extensions, extension_added, view);
- g_signal_handlers_disconnect_by_func (view->priv->extensions, extension_removed, view);
+ if (view->priv->search_mode == GOTO_LINE)
+ return retval;
- /* We need to deactivate the extension on unrealize because it is not
- mandatory that a view has been realized when we dispose it, leading
- to deactivating the plugin without being activated */
- peas_extension_set_foreach (view->priv->extensions,
- (PeasExtensionSetForeachFunc) extension_removed,
- view);
+ /* SEARCH mode */
+ if (event->direction == GDK_SCROLL_UP)
+ {
+ search_again (view, TRUE);
+ retval = TRUE;
+ }
+ else if (event->direction == GDK_SCROLL_DOWN)
+ {
+ search_again (view, FALSE);
+ retval = TRUE;
+ }
- GTK_WIDGET_CLASS (pluma_view_parent_class)->unrealize (widget);
+ return retval;
}
-static void
-search_again (PlumaView *view,
- gboolean search_backward)
+static gboolean
+search_window_key_press_event (GtkWidget *widget,
+ GdkEventKey *event,
+ PlumaView *view)
{
- const gchar *entry_text;
+ gboolean retval = FALSE;
+ guint modifiers;
- g_return_if_fail (view->priv->search_mode == SEARCH);
+ modifiers = gtk_accelerator_get_default_mod_mask ();
- /* SEARCH mode */
- /* renew the flush timeout */
- if (view->priv->typeselect_flush_timeout != 0)
- {
- g_source_remove (view->priv->typeselect_flush_timeout);
- view->priv->typeselect_flush_timeout =
- g_timeout_add (PLUMA_VIEW_SEARCH_DIALOG_TIMEOUT,
- (GSourceFunc)search_entry_flush_timeout,
- view);
- }
+ /* Close window */
+ if (event->keyval == GDK_KEY_Tab)
+ {
+ hide_search_window (view, FALSE);
+ retval = TRUE;
+ }
- entry_text = gtk_entry_get_text (GTK_ENTRY (view->priv->search_entry));
+ /* Close window and cancel the search */
+ if (event->keyval == GDK_KEY_Escape)
+ {
+ if (view->priv->search_mode == SEARCH)
+ {
+ PlumaDocument *doc;
- add_search_completion_entry (entry_text);
+ /* restore document search so that Find Next does the right thing */
+ doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+ pluma_document_set_search_text (doc,
+ view->priv->old_search_text,
+ view->priv->old_search_flags);
- run_search (view,
- entry_text,
- search_backward,
- view->priv->wrap_around,
- FALSE);
-}
+ }
-static gboolean
-search_window_scroll_event (GtkWidget *widget,
- GdkEventScroll *event,
- PlumaView *view)
-{
- gboolean retval = FALSE;
+ hide_search_window (view, TRUE);
+ retval = TRUE;
+ }
- if (view->priv->search_mode == GOTO_LINE)
- return retval;
+ if (view->priv->search_mode == GOTO_LINE)
+ return retval;
- /* SEARCH mode */
- if (event->direction == GDK_SCROLL_UP)
- {
- search_again (view, TRUE);
- retval = TRUE;
- }
- else if (event->direction == GDK_SCROLL_DOWN)
- {
- search_again (view, FALSE);
- retval = TRUE;
- }
+ /* SEARCH mode */
- return retval;
-}
+ /* select previous matching iter */
+ if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up)
+ {
+ search_again (view, TRUE);
+ retval = TRUE;
+ }
-static gboolean
-search_window_key_press_event (GtkWidget *widget,
- GdkEventKey *event,
- PlumaView *view)
-{
- gboolean retval = FALSE;
- guint modifiers;
-
- modifiers = gtk_accelerator_get_default_mod_mask ();
-
- /* Close window */
- if (event->keyval == GDK_KEY_Tab)
- {
- hide_search_window (view, FALSE);
- retval = TRUE;
- }
-
- /* Close window and cancel the search */
- if (event->keyval == GDK_KEY_Escape)
- {
- if (view->priv->search_mode == SEARCH)
- {
- PlumaDocument *doc;
-
- /* restore document search so that Find Next does the right thing */
- doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
- pluma_document_set_search_text (doc,
- view->priv->old_search_text,
- view->priv->old_search_flags);
-
- }
-
- hide_search_window (view, TRUE);
- retval = TRUE;
- }
-
- if (view->priv->search_mode == GOTO_LINE)
- return retval;
-
- /* SEARCH mode */
-
- /* select previous matching iter */
- if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up)
- {
- search_again (view, TRUE);
- retval = TRUE;
- }
-
- if (((event->state & modifiers) == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) &&
- (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G))
- {
- search_again (view, TRUE);
- retval = TRUE;
- }
-
- /* select next matching iter */
- if (event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down)
- {
- search_again (view, FALSE);
- retval = TRUE;
- }
-
- if (((event->state & modifiers) == GDK_CONTROL_MASK) &&
- (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G))
- {
- search_again (view, FALSE);
- retval = TRUE;
- }
-
- return retval;
+ if (((event->state & modifiers) == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) &&
+ (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G))
+ {
+ search_again (view, TRUE);
+ retval = TRUE;
+ }
+
+ /* select next matching iter */
+ if (event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down)
+ {
+ search_again (view, FALSE);
+ retval = TRUE;
+ }
+
+ if (((event->state & modifiers) == GDK_CONTROL_MASK) &&
+ (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G))
+ {
+ search_again (view, FALSE);
+ retval = TRUE;
+ }
+
+ return retval;
}
static void
search_entry_activate (GtkEntry *entry,
- PlumaView *view)
+ PlumaView *view)
{
- hide_search_window (view, FALSE);
+ hide_search_window (view, FALSE);
}
static void
wrap_around_menu_item_toggled (GtkCheckMenuItem *checkmenuitem,
- PlumaView *view)
+ PlumaView *view)
{
- view->priv->wrap_around = gtk_check_menu_item_get_active (checkmenuitem);
+ view->priv->wrap_around = gtk_check_menu_item_get_active (checkmenuitem);
}
static void
match_entire_word_menu_item_toggled (GtkCheckMenuItem *checkmenuitem,
- PlumaView *view)
+ PlumaView *view)
{
- PLUMA_SEARCH_SET_ENTIRE_WORD (view->priv->search_flags,
- gtk_check_menu_item_get_active (checkmenuitem));
+ PLUMA_SEARCH_SET_ENTIRE_WORD (view->priv->search_flags,
+ gtk_check_menu_item_get_active (checkmenuitem));
}
static void
match_case_menu_item_toggled (GtkCheckMenuItem *checkmenuitem,
- PlumaView *view)
+ PlumaView *view)
{
- PLUMA_SEARCH_SET_CASE_SENSITIVE (view->priv->search_flags,
- gtk_check_menu_item_get_active (checkmenuitem));
+ PLUMA_SEARCH_SET_CASE_SENSITIVE (view->priv->search_flags,
+ gtk_check_menu_item_get_active (checkmenuitem));
}
static void
parse_escapes_menu_item_toggled (GtkCheckMenuItem *checkmenuitem,
- PlumaView *view)
+ PlumaView *view)
{
- PLUMA_SEARCH_SET_PARSE_ESCAPES (view->priv->search_flags,
- gtk_check_menu_item_get_active (checkmenuitem));
+ PLUMA_SEARCH_SET_PARSE_ESCAPES (view->priv->search_flags,
+ gtk_check_menu_item_get_active (checkmenuitem));
}
static gboolean
real_search_enable_popdown (gpointer data)
{
- PlumaView *view = (PlumaView *)data;
+ PlumaView *view = (PlumaView *)data;
- view->priv->disable_popdown = FALSE;
+ view->priv->disable_popdown = FALSE;
- return FALSE;
+ return FALSE;
}
static void
search_enable_popdown (GtkWidget *widget,
- PlumaView *view)
+ PlumaView *view)
{
- g_timeout_add (200, real_search_enable_popdown, view);
+ g_timeout_add (200, real_search_enable_popdown, view);
- /* renew the flush timeout */
- if (view->priv->typeselect_flush_timeout != 0)
- g_source_remove (view->priv->typeselect_flush_timeout);
+ /* renew the flush timeout */
+ if (view->priv->typeselect_flush_timeout != 0)
+ g_source_remove (view->priv->typeselect_flush_timeout);
- view->priv->typeselect_flush_timeout =
- g_timeout_add (PLUMA_VIEW_SEARCH_DIALOG_TIMEOUT,
- (GSourceFunc)search_entry_flush_timeout,
- view);
+ view->priv->typeselect_flush_timeout =
+ g_timeout_add (PLUMA_VIEW_SEARCH_DIALOG_TIMEOUT,
+ (GSourceFunc)search_entry_flush_timeout,
+ view);
}
static void
search_entry_populate_popup (GtkEntry *entry,
- GtkMenu *menu,
- PlumaView *view)
-{
- GtkWidget *menu_item;
-
- view->priv->disable_popdown = TRUE;
- g_signal_connect (menu, "hide",
- G_CALLBACK (search_enable_popdown), view);
-
- if (view->priv->search_mode == GOTO_LINE)
- return;
-
- /* separator */
- menu_item = gtk_menu_item_new ();
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
- gtk_widget_show (menu_item);
-
- /* create "Wrap Around" menu item. */
- menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Wrap Around"));
- g_signal_connect (G_OBJECT (menu_item), "toggled",
- G_CALLBACK (wrap_around_menu_item_toggled),
- view);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- view->priv->wrap_around);
- gtk_widget_show (menu_item);
-
- /* create "Match Entire Word Only" menu item. */
- menu_item = gtk_check_menu_item_new_with_mnemonic (_("Match _Entire Word Only"));
- g_signal_connect (G_OBJECT (menu_item), "toggled",
- G_CALLBACK (match_entire_word_menu_item_toggled),
- view);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- PLUMA_SEARCH_IS_ENTIRE_WORD (view->priv->search_flags));
- gtk_widget_show (menu_item);
-
- /* create "Match Case" menu item. */
- menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Match Case"));
- g_signal_connect (G_OBJECT (menu_item), "toggled",
- G_CALLBACK (match_case_menu_item_toggled),
- view);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- PLUMA_SEARCH_IS_CASE_SENSITIVE (view->priv->search_flags));
- gtk_widget_show (menu_item);
-
- /* create "Parse escapes" menu item. */
- menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Parse escape sequences (e.g. \n)"));
- g_signal_connect (G_OBJECT (menu_item), "toggled",
- G_CALLBACK (parse_escapes_menu_item_toggled),
- view);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
- PLUMA_SEARCH_IS_PARSE_ESCAPES (view->priv->search_flags));
- gtk_widget_show (menu_item);
+ GtkMenu *menu,
+ PlumaView *view)
+{
+ GtkWidget *menu_item;
+
+ view->priv->disable_popdown = TRUE;
+ g_signal_connect (menu, "hide",
+ G_CALLBACK (search_enable_popdown), view);
+
+ if (view->priv->search_mode == GOTO_LINE)
+ return;
+
+ /* separator */
+ menu_item = gtk_menu_item_new ();
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_widget_show (menu_item);
+
+ /* create "Wrap Around" menu item. */
+ menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Wrap Around"));
+ g_signal_connect (G_OBJECT (menu_item), "toggled",
+ G_CALLBACK (wrap_around_menu_item_toggled),
+ view);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
+ view->priv->wrap_around);
+ gtk_widget_show (menu_item);
+
+ /* create "Match Entire Word Only" menu item. */
+ menu_item = gtk_check_menu_item_new_with_mnemonic (_("Match _Entire Word Only"));
+ g_signal_connect (G_OBJECT (menu_item), "toggled",
+ G_CALLBACK (match_entire_word_menu_item_toggled),
+ view);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
+ PLUMA_SEARCH_IS_ENTIRE_WORD (view->priv->search_flags));
+ gtk_widget_show (menu_item);
+
+ /* create "Match Case" menu item. */
+ menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Match Case"));
+ g_signal_connect (G_OBJECT (menu_item), "toggled",
+ G_CALLBACK (match_case_menu_item_toggled),
+ view);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
+ PLUMA_SEARCH_IS_CASE_SENSITIVE (view->priv->search_flags));
+ gtk_widget_show (menu_item);
+
+ /* create "Parse escapes" menu item. */
+ menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Parse escape sequences (e.g. \n)"));
+ g_signal_connect (G_OBJECT (menu_item), "toggled",
+ G_CALLBACK (parse_escapes_menu_item_toggled),
+ view);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), menu_item);
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
+ PLUMA_SEARCH_IS_PARSE_ESCAPES (view->priv->search_flags));
+ gtk_widget_show (menu_item);
}
static void
search_entry_insert_text (GtkEditable *editable,
- const gchar *text,
- gint length,
- gint *position,
- PlumaView *view)
+ const gchar *text,
+ gint length,
+ gint *position,
+ PlumaView *view)
{
- if (view->priv->search_mode == GOTO_LINE)
- {
- gunichar c;
- const gchar *p;
- const gchar *end;
- const gchar *next;
+ if (view->priv->search_mode == GOTO_LINE)
+ {
+ gunichar c;
+ const gchar *p;
+ const gchar *end;
+ const gchar *next;
- p = text;
- end = text + length;
+ p = text;
+ end = text + length;
- if (p == end)
- return;
+ if (p == end)
+ return;
- c = g_utf8_get_char (p);
+ c = g_utf8_get_char (p);
- if (((c == '-' || c == '+') && *position == 0) ||
- (c == ':' && *position != 0))
- {
- gchar *s = NULL;
+ if (((c == '-' || c == '+') && *position == 0) ||
+ (c == ':' && *position != 0))
+ {
+ gchar *s = NULL;
- if (c == ':')
- {
- s = gtk_editable_get_chars (editable, 0, -1);
- s = g_utf8_strchr (s, -1, ':');
- }
+ if (c == ':')
+ {
+ s = gtk_editable_get_chars (editable, 0, -1);
+ s = g_utf8_strchr (s, -1, ':');
+ }
- if (s == NULL || s == p)
- {
- next = g_utf8_next_char (p);
- p = next;
- }
+ if (s == NULL || s == p)
+ {
+ next = g_utf8_next_char (p);
+ p = next;
+ }
- g_free (s);
- }
+ g_free (s);
+ }
- while (p != end)
- {
- next = g_utf8_next_char (p);
+ while (p != end)
+ {
+ next = g_utf8_next_char (p);
- c = g_utf8_get_char (p);
+ c = g_utf8_get_char (p);
- if (!g_unichar_isdigit (c)) {
- g_signal_stop_emission_by_name (editable, "insert_text");
- gtk_widget_error_bell (view->priv->search_entry);
- break;
- }
+ if (!g_unichar_isdigit (c)) {
+ g_signal_stop_emission_by_name (editable, "insert_text");
+ gtk_widget_error_bell (view->priv->search_entry);
+ break;
+ }
- p = next;
- }
- }
- else
- {
- /* SEARCH mode */
- static gboolean insert_text = FALSE;
- gchar *escaped_text;
- gint new_len;
+ p = next;
+ }
+ }
+ else
+ {
+ /* SEARCH mode */
+ static gboolean insert_text = FALSE;
+ gchar *escaped_text;
+ gint new_len;
- pluma_debug_message (DEBUG_SEARCH, "Text: %s", text);
+ pluma_debug_message (DEBUG_SEARCH, "Text: %s", text);
- /* To avoid recursive behavior */
- if (insert_text)
- return;
+ /* To avoid recursive behavior */
+ if (insert_text)
+ return;
- escaped_text = pluma_utils_escape_search_text (text);
+ escaped_text = pluma_utils_escape_search_text (text);
- pluma_debug_message (DEBUG_SEARCH, "Escaped Text: %s", escaped_text);
+ pluma_debug_message (DEBUG_SEARCH, "Escaped Text: %s", escaped_text);
- new_len = strlen (escaped_text);
+ new_len = strlen (escaped_text);
- if (new_len == length)
- {
- g_free (escaped_text);
- return;
- }
+ if (new_len == length)
+ {
+ g_free (escaped_text);
+ return;
+ }
- insert_text = TRUE;
+ insert_text = TRUE;
- g_signal_stop_emission_by_name (editable, "insert_text");
+ g_signal_stop_emission_by_name (editable, "insert_text");
- gtk_editable_insert_text (editable, escaped_text, new_len, position);
+ gtk_editable_insert_text (editable, escaped_text, new_len, position);
- insert_text = FALSE;
+ insert_text = FALSE;
- g_free (escaped_text);
- }
+ g_free (escaped_text);
+ }
}
static void
customize_for_search_mode (PlumaView *view)
{
- if (view->priv->search_mode == SEARCH)
- {
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (view->priv->search_entry),
- GTK_ENTRY_ICON_PRIMARY,
- "edit-find");
+ if (view->priv->search_mode == SEARCH)
+ {
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (view->priv->search_entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ "edit-find");
- gtk_widget_set_tooltip_text (view->priv->search_entry,
- _("String you want to search for"));
- }
- else
- {
- gtk_entry_set_icon_from_icon_name (GTK_ENTRY (view->priv->search_entry),
- GTK_ENTRY_ICON_PRIMARY,
- "go-jump");
+ gtk_widget_set_tooltip_text (view->priv->search_entry,
+ _("String you want to search for"));
+ }
+ else
+ {
+ gtk_entry_set_icon_from_icon_name (GTK_ENTRY (view->priv->search_entry),
+ GTK_ENTRY_ICON_PRIMARY,
+ "go-jump");
- gtk_widget_set_tooltip_text (view->priv->search_entry,
- _("Line you want to move the cursor to"));
- }
+ gtk_widget_set_tooltip_text (view->priv->search_entry,
+ _("Line you want to move the cursor to"));
+ }
}
static gboolean
completion_func (GtkEntryCompletion *completion,
const char *key,
- GtkTreeIter *iter,
- gpointer data)
+ GtkTreeIter *iter,
+ gpointer data)
{
- gchar *item = NULL;
- gboolean ret = FALSE;
- GtkTreeModel *model;
- PlumaViewPrivate *priv = (PlumaViewPrivate *)data;
- const gchar *real_key;
+ gchar *item = NULL;
+ gboolean ret = FALSE;
+ GtkTreeModel *model;
+ PlumaViewPrivate *priv = (PlumaViewPrivate *)data;
+ const gchar *real_key;
- if (priv->search_mode == GOTO_LINE)
- return FALSE;
+ if (priv->search_mode == GOTO_LINE)
+ return FALSE;
- real_key = gtk_entry_get_text (GTK_ENTRY (gtk_entry_completion_get_entry (completion)));
+ real_key = gtk_entry_get_text (GTK_ENTRY (gtk_entry_completion_get_entry (completion)));
- if (g_utf8_strlen (real_key, -1) <= MIN_SEARCH_COMPLETION_KEY_LEN)
- return FALSE;
+ if (g_utf8_strlen (real_key, -1) <= MIN_SEARCH_COMPLETION_KEY_LEN)
+ return FALSE;
- model = gtk_entry_completion_get_model (completion);
- g_return_val_if_fail (gtk_tree_model_get_column_type (model, 0) == G_TYPE_STRING,
- FALSE);
+ model = gtk_entry_completion_get_model (completion);
+ g_return_val_if_fail (gtk_tree_model_get_column_type (model, 0) == G_TYPE_STRING,
+ FALSE);
- gtk_tree_model_get (model,
- iter,
- 0,
- &item,
- -1);
+ gtk_tree_model_get (model,
+ iter,
+ 0,
+ &item,
+ -1);
- if (item == NULL)
- return FALSE;
+ if (item == NULL)
+ return FALSE;
- if (PLUMA_SEARCH_IS_CASE_SENSITIVE (priv->search_flags))
- {
- if (!strncmp (real_key, item, strlen (real_key)))
- ret = TRUE;
- }
- else
- {
- gchar *normalized_string;
- gchar *case_normalized_string;
+ if (PLUMA_SEARCH_IS_CASE_SENSITIVE (priv->search_flags))
+ {
+ if (!strncmp (real_key, item, strlen (real_key)))
+ ret = TRUE;
+ }
+ else
+ {
+ gchar *normalized_string;
+ gchar *case_normalized_string;
- normalized_string = g_utf8_normalize (item, -1, G_NORMALIZE_ALL);
- case_normalized_string = g_utf8_casefold (normalized_string, -1);
+ normalized_string = g_utf8_normalize (item, -1, G_NORMALIZE_ALL);
+ case_normalized_string = g_utf8_casefold (normalized_string, -1);
- if (!strncmp (key, case_normalized_string, strlen (key)))
- ret = TRUE;
+ if (!strncmp (key, case_normalized_string, strlen (key)))
+ ret = TRUE;
- g_free (normalized_string);
- g_free (case_normalized_string);
+ g_free (normalized_string);
+ g_free (case_normalized_string);
- }
+ }
- g_free (item);
+ g_free (item);
- return ret;
+ return ret;
}
static void
ensure_search_window (PlumaView *view)
{
- GtkWidget *frame;
- GtkWidget *vbox;
- GtkWidget *toplevel;
- GtkEntryCompletion *completion;
- GtkWindowGroup *group;
- GtkWindowGroup *search_group;
-
- toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
- group = gtk_window_get_group (GTK_WINDOW (toplevel));
- if (view->priv->search_window != NULL)
- search_group = gtk_window_get_group (GTK_WINDOW (view->priv->search_window));
-
- if (view->priv->search_window != NULL)
- {
- if (group)
- gtk_window_group_add_window (group,
- GTK_WINDOW (view->priv->search_window));
- else if (search_group)
- gtk_window_group_remove_window (search_group,
- GTK_WINDOW (view->priv->search_window));
-
- customize_for_search_mode (view);
-
- return;
- }
-
- view->priv->search_window = gtk_window_new (GTK_WINDOW_POPUP);
-
- if (group)
- gtk_window_group_add_window (group,
- GTK_WINDOW (view->priv->search_window));
-
- gtk_window_set_modal (GTK_WINDOW (view->priv->search_window), TRUE);
-
- g_signal_connect (view->priv->search_window, "delete_event",
- G_CALLBACK (search_window_delete_event),
- view);
- g_signal_connect (view->priv->search_window, "key_press_event",
- G_CALLBACK (search_window_key_press_event),
- view);
- g_signal_connect (view->priv->search_window, "button_press_event",
- G_CALLBACK (search_window_button_press_event),
- view);
- g_signal_connect (view->priv->search_window, "scroll_event",
- G_CALLBACK (search_window_scroll_event),
- view);
-
- frame = gtk_frame_new (NULL);
- gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
- gtk_widget_show (frame);
- gtk_container_add (GTK_CONTAINER (view->priv->search_window), frame);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_widget_show (vbox);
- gtk_container_add (GTK_CONTAINER (frame), vbox);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
-
- /* add entry */
- view->priv->search_entry = gtk_entry_new ();
- gtk_widget_show (view->priv->search_entry);
-
- g_signal_connect (view->priv->search_entry, "populate_popup",
- G_CALLBACK (search_entry_populate_popup),
- view);
- g_signal_connect (view->priv->search_entry, "activate",
- G_CALLBACK (search_entry_activate),
- view);
- g_signal_connect (view->priv->search_entry,
- "insert_text",
- G_CALLBACK (search_entry_insert_text),
- view);
-
- gtk_container_add (GTK_CONTAINER (vbox),
- view->priv->search_entry);
-
- if (search_completion_model == NULL)
- {
- /* Create a tree model and use it as the completion model */
- search_completion_model = gtk_list_store_new (1, G_TYPE_STRING);
- }
-
- /* Create the completion object for the search entry */
- completion = gtk_entry_completion_new ();
- gtk_entry_completion_set_model (completion,
- GTK_TREE_MODEL (search_completion_model));
-
- /* Use model column 0 as the text column */
- gtk_entry_completion_set_text_column (completion, 0);
-
- gtk_entry_completion_set_minimum_key_length (completion,
- MIN_SEARCH_COMPLETION_KEY_LEN);
-
- gtk_entry_completion_set_popup_completion (completion, FALSE);
- gtk_entry_completion_set_inline_completion (completion, TRUE);
-
- gtk_entry_completion_set_match_func (completion,
- completion_func,
- view->priv,
- NULL);
-
- /* Assign the completion to the entry */
- gtk_entry_set_completion (GTK_ENTRY (view->priv->search_entry),
- completion);
- g_object_unref (completion);
-
- gtk_widget_realize (view->priv->search_entry);
-
- customize_for_search_mode (view);
+ GtkWidget *frame;
+ GtkWidget *vbox;
+ GtkWidget *toplevel;
+ GtkEntryCompletion *completion;
+ GtkWindowGroup *group;
+ GtkWindowGroup *search_group;
+
+ toplevel = gtk_widget_get_toplevel (GTK_WIDGET (view));
+ group = gtk_window_get_group (GTK_WINDOW (toplevel));
+ if (view->priv->search_window != NULL)
+ search_group = gtk_window_get_group (GTK_WINDOW (view->priv->search_window));
+
+ if (view->priv->search_window != NULL)
+ {
+ if (group)
+ gtk_window_group_add_window (group,
+ GTK_WINDOW (view->priv->search_window));
+ else if (search_group)
+ gtk_window_group_remove_window (search_group,
+ GTK_WINDOW (view->priv->search_window));
+
+ customize_for_search_mode (view);
+
+ return;
+ }
+
+ view->priv->search_window = gtk_window_new (GTK_WINDOW_POPUP);
+
+ if (group)
+ gtk_window_group_add_window (group,
+ GTK_WINDOW (view->priv->search_window));
+
+ gtk_window_set_modal (GTK_WINDOW (view->priv->search_window), TRUE);
+
+ g_signal_connect (view->priv->search_window, "delete_event",
+ G_CALLBACK (search_window_delete_event),
+ view);
+ g_signal_connect (view->priv->search_window, "key_press_event",
+ G_CALLBACK (search_window_key_press_event),
+ view);
+ g_signal_connect (view->priv->search_window, "button_press_event",
+ G_CALLBACK (search_window_button_press_event),
+ view);
+ g_signal_connect (view->priv->search_window, "scroll_event",
+ G_CALLBACK (search_window_scroll_event),
+ view);
+
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
+ gtk_widget_show (frame);
+ gtk_container_add (GTK_CONTAINER (view->priv->search_window), frame);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_widget_show (vbox);
+ gtk_container_add (GTK_CONTAINER (frame), vbox);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
+
+ /* add entry */
+ view->priv->search_entry = gtk_entry_new ();
+ gtk_widget_show (view->priv->search_entry);
+
+ g_signal_connect (view->priv->search_entry, "populate_popup",
+ G_CALLBACK (search_entry_populate_popup),
+ view);
+ g_signal_connect (view->priv->search_entry, "activate",
+ G_CALLBACK (search_entry_activate),
+ view);
+ g_signal_connect (view->priv->search_entry,
+ "insert_text",
+ G_CALLBACK (search_entry_insert_text),
+ view);
+
+ gtk_container_add (GTK_CONTAINER (vbox),
+ view->priv->search_entry);
+
+ if (search_completion_model == NULL)
+ {
+ /* Create a tree model and use it as the completion model */
+ search_completion_model = gtk_list_store_new (1, G_TYPE_STRING);
+ }
+
+ /* Create the completion object for the search entry */
+ completion = gtk_entry_completion_new ();
+ gtk_entry_completion_set_model (completion,
+ GTK_TREE_MODEL (search_completion_model));
+
+ /* Use model column 0 as the text column */
+ gtk_entry_completion_set_text_column (completion, 0);
+
+ gtk_entry_completion_set_minimum_key_length (completion,
+ MIN_SEARCH_COMPLETION_KEY_LEN);
+
+ gtk_entry_completion_set_popup_completion (completion, FALSE);
+ gtk_entry_completion_set_inline_completion (completion, TRUE);
+
+ gtk_entry_completion_set_match_func (completion,
+ completion_func,
+ view->priv,
+ NULL);
+
+ /* Assign the completion to the entry */
+ gtk_entry_set_completion (GTK_ENTRY (view->priv->search_entry),
+ completion);
+ g_object_unref (completion);
+
+ gtk_widget_realize (view->priv->search_entry);
+
+ customize_for_search_mode (view);
}
static gboolean
get_selected_text (GtkTextBuffer *doc, gchar **selected_text, gint *len)
{
- GtkTextIter start, end;
+ GtkTextIter start, end;
- g_return_val_if_fail (selected_text != NULL, FALSE);
- g_return_val_if_fail (*selected_text == NULL, FALSE);
+ g_return_val_if_fail (selected_text != NULL, FALSE);
+ g_return_val_if_fail (*selected_text == NULL, FALSE);
- if (!gtk_text_buffer_get_selection_bounds (doc, &start, &end))
- {
- if (len != NULL)
- len = 0;
+ if (!gtk_text_buffer_get_selection_bounds (doc, &start, &end))
+ {
+ if (len != NULL)
+ len = 0;
- return FALSE;
- }
+ return FALSE;
+ }
- *selected_text = gtk_text_buffer_get_slice (doc, &start, &end, TRUE);
+ *selected_text = gtk_text_buffer_get_slice (doc, &start, &end, TRUE);
- if (len != NULL)
- *len = g_utf8_strlen (*selected_text, -1);
+ if (len != NULL)
+ *len = g_utf8_strlen (*selected_text, -1);
- return TRUE;
+ return TRUE;
}
static void
init_search_entry (PlumaView *view)
{
- GtkTextBuffer *buffer;
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ GtkTextBuffer *buffer;
- if (view->priv->search_mode == GOTO_LINE)
- {
- gint line;
- gchar *line_str;
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- line = gtk_text_iter_get_line (&view->priv->start_search_iter);
+ if (view->priv->search_mode == GOTO_LINE)
+ {
+ gint line;
+ gchar *line_str;
- line_str = g_strdup_printf ("%d", line + 1);
+ line = gtk_text_iter_get_line (&view->priv->start_search_iter);
- gtk_entry_set_text (GTK_ENTRY (view->priv->search_entry),
- line_str);
+ line_str = g_strdup_printf ("%d", line + 1);
- g_free (line_str);
+ gtk_entry_set_text (GTK_ENTRY (view->priv->search_entry),
+ line_str);
- return;
- }
- else
- {
- /* SEARCH mode */
- gboolean selection_exists;
- gchar *find_text = NULL;
- gchar *old_find_text;
- guint old_find_flags = 0;
- gint sel_len = 0;
+ g_free (line_str);
- old_find_text = pluma_document_get_search_text (PLUMA_DOCUMENT (buffer),
- &old_find_flags);
- if (old_find_text != NULL)
- {
- g_free (view->priv->old_search_text);
- view->priv->old_search_text = old_find_text;
- add_search_completion_entry (old_find_text);
- }
+ return;
+ }
+ else
+ {
+ /* SEARCH mode */
+ gboolean selection_exists;
+ gchar *find_text = NULL;
+ gchar *old_find_text;
+ guint old_find_flags = 0;
+ gint sel_len = 0;
+
+ old_find_text = pluma_document_get_search_text (PLUMA_DOCUMENT (buffer),
+ &old_find_flags);
+ if (old_find_text != NULL)
+ {
+ g_free (view->priv->old_search_text);
+ view->priv->old_search_text = old_find_text;
+ add_search_completion_entry (old_find_text);
+ }
- if (old_find_flags != 0)
- {
- view->priv->old_search_flags = old_find_flags;
- }
+ if (old_find_flags != 0)
+ {
+ view->priv->old_search_flags = old_find_flags;
+ }
- selection_exists = get_selected_text (buffer,
- &find_text,
- &sel_len);
+ selection_exists = get_selected_text (buffer,
+ &find_text,
+ &sel_len);
- if (selection_exists && (find_text != NULL) && (sel_len <= 160))
- {
- gtk_entry_set_text (GTK_ENTRY (view->priv->search_entry),
- find_text);
- }
- else
- {
- gtk_entry_set_text (GTK_ENTRY (view->priv->search_entry),
- "");
- }
+ if (selection_exists && (find_text != NULL) && (sel_len <= 160))
+ {
+ gtk_entry_set_text (GTK_ENTRY (view->priv->search_entry), find_text);
+ }
+ else
+ {
+ gtk_entry_set_text (GTK_ENTRY (view->priv->search_entry), "");
+ }
- g_free (find_text);
- }
+ g_free (find_text);
+ }
}
static void
search_init (GtkWidget *entry,
- PlumaView *view)
-{
- PlumaDocument *doc;
- const gchar *entry_text;
-
- /* renew the flush timeout */
- if (view->priv->typeselect_flush_timeout != 0)
- {
- g_source_remove (view->priv->typeselect_flush_timeout);
- view->priv->typeselect_flush_timeout =
- g_timeout_add (PLUMA_VIEW_SEARCH_DIALOG_TIMEOUT,
- (GSourceFunc)search_entry_flush_timeout,
- view);
- }
-
- doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
-
- entry_text = gtk_entry_get_text (GTK_ENTRY (entry));
-
- if (view->priv->search_mode == SEARCH)
- {
- gchar *search_text;
- guint search_flags;
-
- search_text = pluma_document_get_search_text (doc, &search_flags);
-
- if ((search_text == NULL) ||
- (strcmp (search_text, entry_text) != 0) ||
- search_flags != view->priv->search_flags)
- {
- pluma_document_set_search_text (doc,
- entry_text,
- view->priv->search_flags);
- }
-
- g_free (search_text);
-
- run_search (view,
- entry_text,
- FALSE,
- view->priv->wrap_around,
- TRUE);
- }
- else
- {
- if (*entry_text != '\0')
- {
- gboolean moved, moved_offset;
- gint line;
- gint offset_line = 0;
- gint line_offset = 0;
- gchar **split_text = NULL;
- const gchar *text;
-
- split_text = g_strsplit (entry_text, ":", -1);
-
- if (g_strv_length (split_text) > 1)
- {
- text = split_text[0];
- }
- else
- {
- text = entry_text;
- }
-
- if (*text == '-')
- {
- gint cur_line = gtk_text_iter_get_line (&view->priv->start_search_iter);
-
- if (*(text + 1) != '\0')
- offset_line = MAX (atoi (text + 1), 0);
-
- line = MAX (cur_line - offset_line, 0);
- }
- else if (*entry_text == '+')
- {
- gint cur_line = gtk_text_iter_get_line (&view->priv->start_search_iter);
-
- if (*(text + 1) != '\0')
- offset_line = MAX (atoi (text + 1), 0);
-
- line = cur_line + offset_line;
- }
- else
- {
- line = MAX (atoi (text) - 1, 0);
- }
-
- if (split_text[1] != NULL)
- {
- line_offset = atoi (split_text[1]);
- }
-
- g_strfreev (split_text);
-
- moved = pluma_document_goto_line (doc, line);
- moved_offset = pluma_document_goto_line_offset (doc, line,
- line_offset);
-
- pluma_view_scroll_to_cursor (view);
-
- if (!moved || !moved_offset)
- set_entry_state (view->priv->search_entry,
- PLUMA_SEARCH_ENTRY_NOT_FOUND);
- else
- set_entry_state (view->priv->search_entry,
- PLUMA_SEARCH_ENTRY_NORMAL);
- }
- }
+ PlumaView *view)
+{
+ PlumaDocument *doc;
+ const gchar *entry_text;
+
+ /* renew the flush timeout */
+ if (view->priv->typeselect_flush_timeout != 0)
+ {
+ g_source_remove (view->priv->typeselect_flush_timeout);
+ view->priv->typeselect_flush_timeout =
+ g_timeout_add (PLUMA_VIEW_SEARCH_DIALOG_TIMEOUT,
+ (GSourceFunc)search_entry_flush_timeout,
+ view);
+ }
+
+ doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+ entry_text = gtk_entry_get_text (GTK_ENTRY (entry));
+
+ if (view->priv->search_mode == SEARCH)
+ {
+ gchar *search_text;
+ guint search_flags;
+
+ search_text = pluma_document_get_search_text (doc, &search_flags);
+
+ if ((search_text == NULL) ||
+ (strcmp (search_text, entry_text) != 0) ||
+ search_flags != view->priv->search_flags)
+ {
+ pluma_document_set_search_text (doc,
+ entry_text,
+ view->priv->search_flags);
+ }
+
+ g_free (search_text);
+
+ run_search (view,
+ entry_text,
+ FALSE,
+ view->priv->wrap_around,
+ TRUE);
+ }
+ else
+ {
+ if (*entry_text != '\0')
+ {
+ gboolean moved, moved_offset;
+ gint line;
+ gint offset_line = 0;
+ gint line_offset = 0;
+ gchar **split_text = NULL;
+ const gchar *text;
+
+ split_text = g_strsplit (entry_text, ":", -1);
+
+ if (g_strv_length (split_text) > 1)
+ {
+ text = split_text[0];
+ }
+ else
+ {
+ text = entry_text;
+ }
+
+ if (*text == '-')
+ {
+ gint cur_line = gtk_text_iter_get_line (&view->priv->start_search_iter);
+
+ if (*(text + 1) != '\0')
+ offset_line = MAX (atoi (text + 1), 0);
+
+ line = MAX (cur_line - offset_line, 0);
+ }
+ else if (*entry_text == '+')
+ {
+ gint cur_line = gtk_text_iter_get_line (&view->priv->start_search_iter);
+
+ if (*(text + 1) != '\0')
+ offset_line = MAX (atoi (text + 1), 0);
+
+ line = cur_line + offset_line;
+ }
+ else
+ {
+ line = MAX (atoi (text) - 1, 0);
+ }
+
+ if (split_text[1] != NULL)
+ {
+ line_offset = atoi (split_text[1]);
+ }
+
+ g_strfreev (split_text);
+
+ moved = pluma_document_goto_line (doc, line);
+ moved_offset = pluma_document_goto_line_offset (doc, line, line_offset);
+
+ pluma_view_scroll_to_cursor (view);
+
+ if (!moved || !moved_offset)
+ set_entry_state (view->priv->search_entry,
+ PLUMA_SEARCH_ENTRY_NOT_FOUND);
+ else
+ set_entry_state (view->priv->search_entry,
+ PLUMA_SEARCH_ENTRY_NORMAL);
+ }
+ }
}
static gboolean
start_interactive_search_real (PlumaView *view)
{
- GtkTextBuffer *buffer;
+ GtkTextBuffer *buffer;
- if ((view->priv->search_window != NULL) &&
- gtk_widget_get_visible (view->priv->search_window))
- return TRUE;
+ if ((view->priv->search_window != NULL) &&
+ gtk_widget_get_visible (view->priv->search_window))
+ return TRUE;
- if (!gtk_widget_has_focus (GTK_WIDGET (view)))
- return FALSE;
+ if (!gtk_widget_has_focus (GTK_WIDGET (view)))
+ return FALSE;
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
- if (view->priv->search_mode == SEARCH)
- gtk_text_buffer_get_selection_bounds (buffer, &view->priv->start_search_iter, NULL);
- else
- gtk_text_buffer_get_iter_at_mark (buffer,
- &view->priv->start_search_iter,
- gtk_text_buffer_get_insert (buffer));
+ if (view->priv->search_mode == SEARCH)
+ gtk_text_buffer_get_selection_bounds (buffer, &view->priv->start_search_iter, NULL);
+ else
+ gtk_text_buffer_get_iter_at_mark (buffer,
+ &view->priv->start_search_iter,
+ gtk_text_buffer_get_insert (buffer));
- ensure_search_window (view);
+ ensure_search_window (view);
- /* done, show it */
- update_search_window_position (view);
- gtk_widget_show (view->priv->search_window);
+ /* done, show it */
+ update_search_window_position (view);
+ gtk_widget_show (view->priv->search_window);
- if (view->priv->search_entry_changed_id == 0)
- {
- view->priv->search_entry_changed_id =
- g_signal_connect (view->priv->search_entry,
- "changed",
- G_CALLBACK (search_init),
- view);
- }
+ if (view->priv->search_entry_changed_id == 0)
+ {
+ view->priv->search_entry_changed_id =
+ g_signal_connect (view->priv->search_entry,
+ "changed",
+ G_CALLBACK (search_init),
+ view);
+ }
- init_search_entry (view);
+ init_search_entry (view);
- view->priv->typeselect_flush_timeout =
- g_timeout_add (PLUMA_VIEW_SEARCH_DIALOG_TIMEOUT,
- (GSourceFunc) search_entry_flush_timeout,
- view);
+ view->priv->typeselect_flush_timeout =
+ g_timeout_add (PLUMA_VIEW_SEARCH_DIALOG_TIMEOUT,
+ (GSourceFunc) search_entry_flush_timeout,
+ view);
- gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
- gtk_widget_grab_focus (view->priv->search_entry);
+ gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (view), FALSE);
+ gtk_widget_grab_focus (view->priv->search_entry);
- send_focus_change (view->priv->search_entry, TRUE);
+ send_focus_change (view->priv->search_entry, TRUE);
- return TRUE;
+ return TRUE;
}
static gboolean
reset_searched_text (PlumaView *view)
{
- PlumaDocument *doc;
+ PlumaDocument *doc;
- doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+ doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
- pluma_document_set_search_text (doc, "", PLUMA_SEARCH_DONT_SET_FLAGS);
+ pluma_document_set_search_text (doc, "", PLUMA_SEARCH_DONT_SET_FLAGS);
- return TRUE;
+ return TRUE;
}
static gboolean
start_interactive_search (PlumaView *view)
{
- view->priv->search_mode = SEARCH;
+ view->priv->search_mode = SEARCH;
- return start_interactive_search_real (view);
+ return start_interactive_search_real (view);
}
static gboolean
start_interactive_goto_line (PlumaView *view)
{
- view->priv->search_mode = GOTO_LINE;
+ view->priv->search_mode = GOTO_LINE;
- return start_interactive_search_real (view);
+ return start_interactive_search_real (view);
}
static gboolean
-pluma_view_draw (GtkWidget *widget,
- cairo_t *cr)
+pluma_view_draw (GtkWidget *widget,
+ cairo_t *cr)
{
- GtkTextView *text_view;
- PlumaDocument *doc;
- GdkWindow *window;
-
- text_view = GTK_TEXT_VIEW (widget);
+ GtkTextView *text_view;
+ PlumaDocument *doc;
+ GdkWindow *window;
- doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (text_view));
- window = gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT);
- if (gtk_cairo_should_draw_window (cr, window) &&
- pluma_document_get_enable_search_highlighting (doc))
- {
- GdkRectangle visible_rect;
- GtkTextIter iter1, iter2;
+ text_view = GTK_TEXT_VIEW (widget);
- gtk_text_view_get_visible_rect (text_view, &visible_rect);
- gtk_text_view_get_line_at_y (text_view, &iter1,
- visible_rect.y, NULL);
- gtk_text_view_get_line_at_y (text_view, &iter2,
- visible_rect.y
- + visible_rect.height, NULL);
- gtk_text_iter_forward_line (&iter2);
+ doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (text_view));
+ window = gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT);
- _pluma_document_search_region (doc,
- &iter1,
- &iter2);
- }
+ if (gtk_cairo_should_draw_window (cr, window) &&
+ pluma_document_get_enable_search_highlighting (doc))
+ {
+ GdkRectangle visible_rect;
+ GtkTextIter iter1, iter2;
+
+ gtk_text_view_get_visible_rect (text_view, &visible_rect);
+ gtk_text_view_get_line_at_y (text_view, &iter1,
+ visible_rect.y, NULL);
+ gtk_text_view_get_line_at_y (text_view, &iter2,
+ visible_rect.y
+ + visible_rect.height, NULL);
+ gtk_text_iter_forward_line (&iter2);
+
+ _pluma_document_search_region (doc,
+ &iter1,
+ &iter2);
+ }
- return GTK_WIDGET_CLASS (pluma_view_parent_class)->draw (widget, cr);
+ return GTK_WIDGET_CLASS (pluma_view_parent_class)->draw (widget, cr);
}
static GdkAtom
drag_get_uri_target (GtkWidget *widget,
- GdkDragContext *context)
+ GdkDragContext *context)
{
- GdkAtom target;
- GtkTargetList *tl;
+ GdkAtom target;
+ GtkTargetList *tl;
- tl = gtk_target_list_new (NULL, 0);
- gtk_target_list_add_uri_targets (tl, 0);
+ tl = gtk_target_list_new (NULL, 0);
+ gtk_target_list_add_uri_targets (tl, 0);
- target = gtk_drag_dest_find_target (widget, context, tl);
- gtk_target_list_unref (tl);
+ target = gtk_drag_dest_find_target (widget, context, tl);
+ gtk_target_list_unref (tl);
- return target;
+ return target;
}
static gboolean
pluma_view_drag_motion (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint timestamp)
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint timestamp)
{
- gboolean result;
+ gboolean result;
- /* Chain up to allow textview to scroll and position dnd mark, note
- * that this needs to be checked if gtksourceview or gtktextview
- * changes drag_motion behaviour */
- result = GTK_WIDGET_CLASS (pluma_view_parent_class)->drag_motion (widget, context, x, y, timestamp);
+ /* Chain up to allow textview to scroll and position dnd mark, note
+ * that this needs to be checked if gtksourceview or gtktextview
+ * changes drag_motion behaviour */
+ result = GTK_WIDGET_CLASS (pluma_view_parent_class)->drag_motion (widget, context, x, y, timestamp);
- /* If this is a URL, deal with it here */
- if (drag_get_uri_target (widget, context) != GDK_NONE)
- {
- gdk_drag_status (context,
- gdk_drag_context_get_suggested_action (context),
- timestamp);
- result = TRUE;
- }
+ /* If this is a URL, deal with it here */
+ if (drag_get_uri_target (widget, context) != GDK_NONE)
+ {
+ gdk_drag_status (context,
+ gdk_drag_context_get_suggested_action (context),
+ timestamp);
+ result = TRUE;
+ }
- return result;
+ return result;
}
static void
pluma_view_drag_data_received (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint timestamp)
-{
- gchar **uri_list;
-
- /* If this is an URL emit DROP_URIS, otherwise chain up the signal */
- if (info == TARGET_URI_LIST)
- {
- uri_list = pluma_utils_drop_get_uris (selection_data);
-
- if (uri_list != NULL)
- {
- g_signal_emit (widget, view_signals[DROP_URIS], 0, uri_list);
- g_strfreev (uri_list);
-
- gtk_drag_finish (context, TRUE, FALSE, timestamp);
- }
- }
- else
- {
- GTK_WIDGET_CLASS (pluma_view_parent_class)->drag_data_received (widget, context, x, y, selection_data, info, timestamp);
- }
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint timestamp)
+{
+ gchar **uri_list;
+
+ /* If this is an URL emit DROP_URIS, otherwise chain up the signal */
+ if (info == TARGET_URI_LIST)
+ {
+ uri_list = pluma_utils_drop_get_uris (selection_data);
+
+ if (uri_list != NULL)
+ {
+ g_signal_emit (widget, view_signals[DROP_URIS], 0, uri_list);
+ g_strfreev (uri_list);
+
+ gtk_drag_finish (context, TRUE, FALSE, timestamp);
+ }
+ }
+ else
+ {
+ GTK_WIDGET_CLASS (pluma_view_parent_class)->drag_data_received (widget, context, x, y, selection_data, info, timestamp);
+ }
}
static gboolean
pluma_view_drag_drop (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- guint timestamp)
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ guint timestamp)
{
- gboolean result;
- GdkAtom target;
+ gboolean result;
+ GdkAtom target;
- /* If this is a URL, just get the drag data */
- target = drag_get_uri_target (widget, context);
+ /* If this is a URL, just get the drag data */
+ target = drag_get_uri_target (widget, context);
- if (target != GDK_NONE)
- {
- gtk_drag_get_data (widget, context, target, timestamp);
- result = TRUE;
- }
- else
- {
- /* Chain up */
- result = GTK_WIDGET_CLASS (pluma_view_parent_class)->drag_drop (widget, context, x, y, timestamp);
- }
+ if (target != GDK_NONE)
+ {
+ gtk_drag_get_data (widget, context, target, timestamp);
+ result = TRUE;
+ }
+ else
+ {
+ /* Chain up */
+ result = GTK_WIDGET_CLASS (pluma_view_parent_class)->drag_drop (widget, context, x, y, timestamp);
+ }
- return result;
+ return result;
}
static GtkWidget *
create_line_numbers_menu (GtkWidget *view)
{
- GtkWidget *menu;
- GtkWidget *item;
+ GtkWidget *menu;
+ GtkWidget *item;
- menu = gtk_menu_new ();
+ menu = gtk_menu_new ();
- item = gtk_check_menu_item_new_with_mnemonic (_("_Display line numbers"));
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
- gtk_source_view_get_show_line_numbers (GTK_SOURCE_VIEW (view)));
+ item = gtk_check_menu_item_new_with_mnemonic (_("_Display line numbers"));
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item),
+ gtk_source_view_get_show_line_numbers (GTK_SOURCE_VIEW (view)));
- g_settings_bind (PLUMA_VIEW (view)->priv->editor_settings,
- PLUMA_SETTINGS_DISPLAY_LINE_NUMBERS,
- item,
- "active",
- G_SETTINGS_BIND_SET);
+ g_settings_bind (PLUMA_VIEW (view)->priv->editor_settings,
+ PLUMA_SETTINGS_DISPLAY_LINE_NUMBERS,
+ item,
+ "active",
+ G_SETTINGS_BIND_SET);
- gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+ gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
- gtk_widget_show_all (menu);
+ gtk_widget_show_all (menu);
- return menu;
+ return menu;
}
static void
show_line_numbers_menu (GtkWidget *view,
- GdkEventButton *event)
+ GdkEventButton *event)
+{
+ GtkWidget *menu;
+
+ menu = create_line_numbers_menu (view);
+
+ gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
+}
+
+static void
+extension_added (PeasExtensionSet *extensions,
+ PeasPluginInfo *info,
+ PeasExtension *exten,
+ PlumaView *view)
+{
+ pluma_view_activatable_activate (PLUMA_VIEW_ACTIVATABLE (exten));
+}
+
+static void
+extension_removed (PeasExtensionSet *extensions,
+ PeasPluginInfo *info,
+ PeasExtension *exten,
+ PlumaView *view)
+{
+ pluma_view_activatable_deactivate (PLUMA_VIEW_ACTIVATABLE (exten));
+}
+
+static void
+pluma_view_realize (GtkWidget *widget)
+{
+ PlumaView *view = PLUMA_VIEW (widget);
+
+ GTK_WIDGET_CLASS (pluma_view_parent_class)->realize (widget);
+
+ g_signal_connect (view->priv->extensions, "extension-added",
+ G_CALLBACK (extension_added),
+ view);
+ g_signal_connect (view->priv->extensions, "extension-removed",
+ G_CALLBACK (extension_removed),
+ view);
+
+ /* We only activate the extensions when the view is realized,
+ * because most plugins will expect this behaviour, and we won't
+ * change the buffer later anyway. */
+ peas_extension_set_foreach (view->priv->extensions,
+ (PeasExtensionSetForeachFunc) extension_added,
+ view);
+}
+
+static void
+pluma_view_unrealize (GtkWidget *widget)
{
- GtkWidget *menu;
+ PlumaView *view = PLUMA_VIEW (widget);
- menu = create_line_numbers_menu (view);
+ g_signal_handlers_disconnect_by_func (view->priv->extensions, extension_added, view);
+ g_signal_handlers_disconnect_by_func (view->priv->extensions, extension_removed, view);
- gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
+ /* We need to deactivate the extension on unrealize because it is not
+ mandatory that a view has been realized when we dispose it, leading
+ to deactivating the plugin without being activated */
+ peas_extension_set_foreach (view->priv->extensions,
+ (PeasExtensionSetForeachFunc) extension_removed,
+ view);
+
+ GTK_WIDGET_CLASS (pluma_view_parent_class)->unrealize (widget);
}
+
static gboolean
pluma_view_button_press_event (GtkWidget *widget, GdkEventButton *event)
{
- static gchar *primtxt = "";
+ static gchar *primtxt = "";
- gchar *txt_clip = gtk_clipboard_wait_for_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY));
+ gchar *txt_clip = gtk_clipboard_wait_for_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY));
- if (txt_clip)
- {
- primtxt = g_strdup (txt_clip);
- g_free (txt_clip);
- }
- else
- gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY), primtxt, strlen (primtxt));
+ if (txt_clip)
+ {
+ primtxt = g_strdup (txt_clip);
+ g_free (txt_clip);
+ }
+ else
+ gtk_clipboard_set_text (gtk_clipboard_get (GDK_SELECTION_PRIMARY), primtxt, strlen (primtxt));
- if ((event->type == GDK_BUTTON_PRESS) &&
- (event->window == gtk_text_view_get_window (GTK_TEXT_VIEW (widget),
- GTK_TEXT_WINDOW_LEFT)))
- {
- if (event->button == 3)
- show_line_numbers_menu (widget, event);
+ if ((event->type == GDK_BUTTON_PRESS) &&
+ (event->window == gtk_text_view_get_window (GTK_TEXT_VIEW (widget),
+ GTK_TEXT_WINDOW_LEFT)))
+ {
+ if (event->button == 3)
+ show_line_numbers_menu (widget, event);
- return TRUE;
- }
+ return TRUE;
+ }
- if ((event->button == 2) || (event->button == 3))
- {
- if (middle_or_right_down)
- {
- middle_or_right_down = FALSE;
- return TRUE;
- }
- else
- middle_or_right_down = TRUE;
- }
+ if ((event->button == 2) || (event->button == 3))
+ {
+ if (middle_or_right_down)
+ {
+ middle_or_right_down = FALSE;
+ return TRUE;
+ }
+ else
+ middle_or_right_down = TRUE;
+ }
- if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1) &&
- (event->window == gtk_text_view_get_window (GTK_TEXT_VIEW (widget), GTK_TEXT_WINDOW_TEXT)))
- return TRUE;
+ if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1) &&
+ (event->window == gtk_text_view_get_window (GTK_TEXT_VIEW (widget), GTK_TEXT_WINDOW_TEXT)))
+ return TRUE;
- return GTK_WIDGET_CLASS (pluma_view_parent_class)->button_press_event (widget, event);
+ return GTK_WIDGET_CLASS (pluma_view_parent_class)->button_press_event (widget, event);
}
static gboolean
pluma_view_button_release_event (GtkWidget *widget, GdkEventButton *event)
{
- if (event->button == 2)
- middle_or_right_down = FALSE;
+ if (event->button == 2)
+ middle_or_right_down = FALSE;
- return GTK_WIDGET_CLASS (pluma_view_parent_class)->button_release_event (widget, event);
+ return GTK_WIDGET_CLASS (pluma_view_parent_class)->button_release_event (widget, event);
}
static void
pluma_view_populate_popup (GtkTextView *text_view, GtkWidget *widget)
{
- middle_or_right_down = FALSE;
+ middle_or_right_down = FALSE;
}
static void
search_highlight_updated_cb (PlumaDocument *doc,
- GtkTextIter *start,
- GtkTextIter *end,
- PlumaView *view)
-{
- GdkRectangle visible_rect;
- GdkRectangle updated_rect;
- GdkRectangle redraw_rect;
- gint y;
- gint height;
- GtkTextView *text_view;
-
- text_view = GTK_TEXT_VIEW (view);
-
- g_return_if_fail (pluma_document_get_enable_search_highlighting (
- PLUMA_DOCUMENT (gtk_text_view_get_buffer (text_view))));
-
- /* get visible area */
- gtk_text_view_get_visible_rect (text_view, &visible_rect);
-
- /* get updated rectangle */
- gtk_text_view_get_line_yrange (text_view, start, &y, &height);
- updated_rect.y = y;
- gtk_text_view_get_line_yrange (text_view, end, &y, &height);
- updated_rect.height = y + height - updated_rect.y;
- updated_rect.x = visible_rect.x;
- updated_rect.width = visible_rect.width;
-
- /* intersect both rectangles to see whether we need to queue a redraw */
- if (gdk_rectangle_intersect (&updated_rect, &visible_rect, &redraw_rect))
- {
- GdkRectangle widget_rect;
-
- gtk_text_view_buffer_to_window_coords (text_view,
- GTK_TEXT_WINDOW_WIDGET,
- redraw_rect.x,
- redraw_rect.y,
- &widget_rect.x,
- &widget_rect.y);
-
- widget_rect.width = redraw_rect.width;
- widget_rect.height = redraw_rect.height;
-
- gtk_widget_queue_draw_area (GTK_WIDGET (text_view),
- widget_rect.x,
- widget_rect.y,
- widget_rect.width,
- widget_rect.height);
- }
+ GtkTextIter *start,
+ GtkTextIter *end,
+ PlumaView *view)
+{
+ GdkRectangle visible_rect;
+ GdkRectangle updated_rect;
+ GdkRectangle redraw_rect;
+ gint y;
+ gint height;
+ GtkTextView *text_view;
+
+ text_view = GTK_TEXT_VIEW (view);
+
+ g_return_if_fail (pluma_document_get_enable_search_highlighting (
+ PLUMA_DOCUMENT (gtk_text_view_get_buffer (text_view))));
+
+ /* get visible area */
+ gtk_text_view_get_visible_rect (text_view, &visible_rect);
+
+ /* get updated rectangle */
+ gtk_text_view_get_line_yrange (text_view, start, &y, &height);
+ updated_rect.y = y;
+ gtk_text_view_get_line_yrange (text_view, end, &y, &height);
+ updated_rect.height = y + height - updated_rect.y;
+ updated_rect.x = visible_rect.x;
+ updated_rect.width = visible_rect.width;
+
+ /* intersect both rectangles to see whether we need to queue a redraw */
+ if (gdk_rectangle_intersect (&updated_rect, &visible_rect, &redraw_rect))
+ {
+ GdkRectangle widget_rect;
+
+ gtk_text_view_buffer_to_window_coords (text_view,
+ GTK_TEXT_WINDOW_WIDGET,
+ redraw_rect.x,
+ redraw_rect.y,
+ &widget_rect.x,
+ &widget_rect.y);
+
+ widget_rect.width = redraw_rect.width;
+ widget_rect.height = redraw_rect.height;
+
+ gtk_widget_queue_draw_area (GTK_WIDGET (text_view),
+ widget_rect.x,
+ widget_rect.y,
+ widget_rect.width,
+ widget_rect.height);
+ }
}
static void
delete_line (GtkTextView *text_view,
- gint count)
-{
- GtkTextIter start;
- GtkTextIter end;
- GtkTextBuffer *buffer;
-
- buffer = gtk_text_view_get_buffer (text_view);
-
- gtk_text_view_reset_im_context (text_view);
-
- /* If there is a selection delete the selected lines and
- * ignore count */
- if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
- {
- gtk_text_iter_order (&start, &end);
-
- if (gtk_text_iter_starts_line (&end))
- {
- /* Do no delete the line with the cursor if the cursor
- * is at the beginning of the line */
- count = 0;
- }
- else
- count = 1;
- }
-
- gtk_text_iter_set_line_offset (&start, 0);
-
- if (count > 0)
- {
- gtk_text_iter_forward_lines (&end, count);
-
- if (gtk_text_iter_is_end (&end))
- {
- if (gtk_text_iter_backward_line (&start) && !gtk_text_iter_ends_line (&start))
- gtk_text_iter_forward_to_line_end (&start);
- }
- }
- else if (count < 0)
- {
- if (!gtk_text_iter_ends_line (&end))
- gtk_text_iter_forward_to_line_end (&end);
-
- while (count < 0)
- {
- if (!gtk_text_iter_backward_line (&start))
- break;
-
- ++count;
- }
-
- if (count == 0)
- {
- if (!gtk_text_iter_ends_line (&start))
- gtk_text_iter_forward_to_line_end (&start);
- }
- else
- gtk_text_iter_forward_line (&end);
- }
-
- if (!gtk_text_iter_equal (&start, &end))
- {
- GtkTextIter cur = start;
- gtk_text_iter_set_line_offset (&cur, 0);
-
- gtk_text_buffer_begin_user_action (buffer);
-
- gtk_text_buffer_place_cursor (buffer, &cur);
-
- gtk_text_buffer_delete_interactive (buffer,
- &start,
- &end,
- gtk_text_view_get_editable (text_view));
-
- gtk_text_buffer_end_user_action (buffer);
-
- gtk_text_view_scroll_mark_onscreen (text_view,
- gtk_text_buffer_get_insert (buffer));
- }
- else
- {
- gtk_widget_error_bell (GTK_WIDGET (text_view));
- }
+ gint count)
+{
+ GtkTextIter start;
+ GtkTextIter end;
+ GtkTextBuffer *buffer;
+
+ buffer = gtk_text_view_get_buffer (text_view);
+
+ gtk_text_view_reset_im_context (text_view);
+
+ /* If there is a selection delete the selected lines and
+ * ignore count */
+ if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
+ {
+ gtk_text_iter_order (&start, &end);
+
+ if (gtk_text_iter_starts_line (&end))
+ {
+ /* Do no delete the line with the cursor if the cursor
+ * is at the beginning of the line */
+ count = 0;
+ }
+ else
+ count = 1;
+ }
+
+ gtk_text_iter_set_line_offset (&start, 0);
+
+ if (count > 0)
+ {
+ gtk_text_iter_forward_lines (&end, count);
+
+ if (gtk_text_iter_is_end (&end))
+ {
+ if (gtk_text_iter_backward_line (&start) && !gtk_text_iter_ends_line (&start))
+ gtk_text_iter_forward_to_line_end (&start);
+ }
+ }
+ else if (count < 0)
+ {
+ if (!gtk_text_iter_ends_line (&end))
+ gtk_text_iter_forward_to_line_end (&end);
+
+ while (count < 0)
+ {
+ if (!gtk_text_iter_backward_line (&start))
+ break;
+
+ ++count;
+ }
+
+ if (count == 0)
+ {
+ if (!gtk_text_iter_ends_line (&start))
+ gtk_text_iter_forward_to_line_end (&start);
+ }
+ else
+ gtk_text_iter_forward_line (&end);
+ }
+
+ if (!gtk_text_iter_equal (&start, &end))
+ {
+ GtkTextIter cur = start;
+ gtk_text_iter_set_line_offset (&cur, 0);
+
+ gtk_text_buffer_begin_user_action (buffer);
+
+ gtk_text_buffer_place_cursor (buffer, &cur);
+
+ gtk_text_buffer_delete_interactive (buffer,
+ &start,
+ &end,
+ gtk_text_view_get_editable (text_view));
+
+ gtk_text_buffer_end_user_action (buffer);
+
+ gtk_text_view_scroll_mark_onscreen (text_view,
+ gtk_text_buffer_get_insert (buffer));
+ }
+ else
+ {
+ gtk_widget_error_bell (GTK_WIDGET (text_view));
+ }
}
static void
pluma_view_delete_from_cursor (GtkTextView *text_view,
- GtkDeleteType type,
- gint count)
-{
- /* We override the standard handler for delete_from_cursor since
- the GTK_DELETE_PARAGRAPHS case is not implemented as we like (i.e. it
- does not remove the carriage return in the previous line)
- */
- switch (type)
- {
- case GTK_DELETE_PARAGRAPHS:
- delete_line (text_view, count);
- break;
- default:
- GTK_TEXT_VIEW_CLASS (pluma_view_parent_class)->delete_from_cursor(text_view, type, count);
- break;
- }
+ GtkDeleteType type,
+ gint count)
+{
+ /* We override the standard handler for delete_from_cursor since
+ the GTK_DELETE_PARAGRAPHS case is not implemented as we like (i.e. it
+ does not remove the carriage return in the previous line)
+ */
+ switch (type)
+ {
+ case GTK_DELETE_PARAGRAPHS:
+ delete_line (text_view, count);
+ break;
+ default:
+ GTK_TEXT_VIEW_CLASS (pluma_view_parent_class)->delete_from_cursor(text_view, type, count);
+ break;
+ }
}
diff --git a/pluma/pluma-window-activatable.c b/pluma/pluma-window-activatable.c
index 74597b2a..7de75254 100644
--- a/pluma/pluma-window-activatable.c
+++ b/pluma/pluma-window-activatable.c
@@ -4,18 +4,18 @@
*
* Copyright (C) 2010 Steve Frécinaux
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see https://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see https://www.gnu.org/licenses/.
*/
#include <config.h>
diff --git a/pluma/pluma-window-activatable.h b/pluma/pluma-window-activatable.h
index de95b05d..9646507c 100644
--- a/pluma/pluma-window-activatable.h
+++ b/pluma/pluma-window-activatable.h
@@ -4,18 +4,18 @@
*
* Copyright (C) 2010 - Steve Frécinaux
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Library General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Library General Public License for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Library General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see https://www.gnu.org/licenses/.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see https://www.gnu.org/licenses/.
*/
#ifndef __PLUMA_WINDOW_ACTIVATABLE_H__
diff --git a/pluma/pluma-window.c b/pluma/pluma-window.c
index e797b6e0..e28bf7ec 100644
--- a/pluma/pluma-window.c
+++ b/pluma/pluma-window.c
@@ -67,8 +67,8 @@
#define LANGUAGE_DATA "PlumaWindowLanguageData"
#define FULLSCREEN_ANIMATION_SPEED 4
-#define PLUMA_WINDOW_DEFAULT_WIDTH 650
-#define PLUMA_WINDOW_DEFAULT_HEIGHT 500
+#define PLUMA_WINDOW_DEFAULT_WIDTH 650
+#define PLUMA_WINDOW_DEFAULT_HEIGHT 500
/* Local variables */
static gboolean cansave = TRUE;
@@ -76,214 +76,214 @@ static gboolean cansave = TRUE;
/* Signals */
enum
{
- TAB_ADDED,
- TAB_REMOVED,
- TABS_REORDERED,
- ACTIVE_TAB_CHANGED,
- ACTIVE_TAB_STATE_CHANGED,
- LAST_SIGNAL
+ TAB_ADDED,
+ TAB_REMOVED,
+ TABS_REORDERED,
+ ACTIVE_TAB_CHANGED,
+ ACTIVE_TAB_STATE_CHANGED,
+ LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
enum
{
- PROP_0,
- PROP_STATE
+ PROP_0,
+ PROP_STATE
};
enum
{
- TARGET_URI_LIST = 100
+ TARGET_URI_LIST = 100
};
G_DEFINE_TYPE_WITH_PRIVATE (PlumaWindow, pluma_window, GTK_TYPE_WINDOW)
-static void recent_manager_changed (GtkRecentManager *manager,
- PlumaWindow *window);
+static void recent_manager_changed (GtkRecentManager *manager,
+ PlumaWindow *window);
static void
pluma_window_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- PlumaWindow *window = PLUMA_WINDOW (object);
+ PlumaWindow *window = PLUMA_WINDOW (object);
- switch (prop_id)
- {
- case PROP_STATE:
- g_value_set_enum (value,
- pluma_window_get_state (window));
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
+ switch (prop_id)
+ {
+ case PROP_STATE:
+ g_value_set_enum (value,
+ pluma_window_get_state (window));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
}
static void
save_panes_state (PlumaWindow *window)
{
- gint pane_page;
+ gint pane_page;
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- g_settings_set (window->priv->editor_settings, PLUMA_SETTINGS_WINDOW_SIZE,
- "(ii)", window->priv->width, window->priv->height);
+ g_settings_set (window->priv->editor_settings, PLUMA_SETTINGS_WINDOW_SIZE,
+ "(ii)", window->priv->width, window->priv->height);
- g_settings_set_int (window->priv->editor_settings, PLUMA_SETTINGS_WINDOW_STATE,
- window->priv->window_state);
+ g_settings_set_int (window->priv->editor_settings, PLUMA_SETTINGS_WINDOW_STATE,
+ window->priv->window_state);
- if (window->priv->side_panel_size > 0)
- g_settings_set_int (window->priv->editor_settings,
- PLUMA_SETTINGS_SIDE_PANEL_SIZE,
- window->priv->side_panel_size);
+ if (window->priv->side_panel_size > 0)
+ g_settings_set_int (window->priv->editor_settings,
+ PLUMA_SETTINGS_SIDE_PANEL_SIZE,
+ window->priv->side_panel_size);
- pane_page = _pluma_panel_get_active_item_id (PLUMA_PANEL (window->priv->side_panel));
- if (pane_page != 0)
- g_settings_set_int (window->priv->editor_settings,
- PLUMA_SETTINGS_SIDE_PANEL_ACTIVE_PAGE,
- pane_page);
+ pane_page = _pluma_panel_get_active_item_id (PLUMA_PANEL (window->priv->side_panel));
+ if (pane_page != 0)
+ g_settings_set_int (window->priv->editor_settings,
+ PLUMA_SETTINGS_SIDE_PANEL_ACTIVE_PAGE,
+ pane_page);
- if (window->priv->bottom_panel_size > 0)
- g_settings_set_int (window->priv->editor_settings,
- PLUMA_SETTINGS_BOTTOM_PANEL_SIZE,
- window->priv->bottom_panel_size);
+ if (window->priv->bottom_panel_size > 0)
+ g_settings_set_int (window->priv->editor_settings,
+ PLUMA_SETTINGS_BOTTOM_PANEL_SIZE,
+ window->priv->bottom_panel_size);
- pane_page = _pluma_panel_get_active_item_id (PLUMA_PANEL (window->priv->bottom_panel));
- if (pane_page != 0)
- g_settings_set_int (window->priv->editor_settings,
- PLUMA_SETTINGS_BOTTOM_PANEL_ACTIVE_PAGE, pane_page);
+ pane_page = _pluma_panel_get_active_item_id (PLUMA_PANEL (window->priv->bottom_panel));
+ if (pane_page != 0)
+ g_settings_set_int (window->priv->editor_settings,
+ PLUMA_SETTINGS_BOTTOM_PANEL_ACTIVE_PAGE, pane_page);
}
static void
pluma_window_dispose (GObject *object)
{
- PlumaWindow *window;
+ PlumaWindow *window;
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- window = PLUMA_WINDOW (object);
+ window = PLUMA_WINDOW (object);
- /* Stop tracking removal of panes otherwise we always
- * end up with thinking we had no pane active, since they
- * should all be removed below */
- if (window->priv->bottom_panel_item_removed_handler_id != 0)
- {
- g_signal_handler_disconnect (window->priv->bottom_panel,
- window->priv->bottom_panel_item_removed_handler_id);
- window->priv->bottom_panel_item_removed_handler_id = 0;
- }
+ /* Stop tracking removal of panes otherwise we always
+ * end up with thinking we had no pane active, since they
+ * should all be removed below */
+ if (window->priv->bottom_panel_item_removed_handler_id != 0)
+ {
+ g_signal_handler_disconnect (window->priv->bottom_panel,
+ window->priv->bottom_panel_item_removed_handler_id);
+ window->priv->bottom_panel_item_removed_handler_id = 0;
+ }
- /* First of all, force collection so that plugins
- * really drop some of the references.
- */
- peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
+ /* First of all, force collection so that plugins
+ * really drop some of the references.
+ */
+ peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
- /* save the panes position and make sure to deactivate plugins
- * for this window, but only once */
- if (!window->priv->dispose_has_run)
- {
- save_panes_state (window);
+ /* save the panes position and make sure to deactivate plugins
+ * for this window, but only once */
+ if (!window->priv->dispose_has_run)
+ {
+ save_panes_state (window);
- /* Note that unreffing the extensions will automatically remove
- all extensions which in turn will deactivate the extension */
- g_object_unref (window->priv->extensions);
+ /* Note that unreffing the extensions will automatically remove
+ all extensions which in turn will deactivate the extension */
+ g_object_unref (window->priv->extensions);
- peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
+ peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
- window->priv->dispose_has_run = TRUE;
- }
+ window->priv->dispose_has_run = TRUE;
+ }
- if (window->priv->fullscreen_animation_timeout_id != 0)
- {
- g_source_remove (window->priv->fullscreen_animation_timeout_id);
- window->priv->fullscreen_animation_timeout_id = 0;
- }
+ if (window->priv->fullscreen_animation_timeout_id != 0)
+ {
+ g_source_remove (window->priv->fullscreen_animation_timeout_id);
+ window->priv->fullscreen_animation_timeout_id = 0;
+ }
- if (window->priv->fullscreen_controls != NULL)
- {
- gtk_widget_destroy (window->priv->fullscreen_controls);
+ if (window->priv->fullscreen_controls != NULL)
+ {
+ gtk_widget_destroy (window->priv->fullscreen_controls);
- window->priv->fullscreen_controls = NULL;
- }
+ window->priv->fullscreen_controls = NULL;
+ }
- if (window->priv->recents_handler_id != 0)
- {
- GtkRecentManager *recent_manager;
+ if (window->priv->recents_handler_id != 0)
+ {
+ GtkRecentManager *recent_manager;
- recent_manager = gtk_recent_manager_get_default ();
- g_signal_handler_disconnect (recent_manager,
- window->priv->recents_handler_id);
- window->priv->recents_handler_id = 0;
- }
+ recent_manager = gtk_recent_manager_get_default ();
+ g_signal_handler_disconnect (recent_manager,
+ window->priv->recents_handler_id);
+ window->priv->recents_handler_id = 0;
+ }
- if (window->priv->manager != NULL)
- {
- g_object_unref (window->priv->manager);
- window->priv->manager = NULL;
- }
+ if (window->priv->manager != NULL)
+ {
+ g_object_unref (window->priv->manager);
+ window->priv->manager = NULL;
+ }
- if (window->priv->message_bus != NULL)
- {
- g_object_unref (window->priv->message_bus);
- window->priv->message_bus = NULL;
- }
+ if (window->priv->message_bus != NULL)
+ {
+ g_object_unref (window->priv->message_bus);
+ window->priv->message_bus = NULL;
+ }
- if (window->priv->window_group != NULL)
- {
- g_object_unref (window->priv->window_group);
- window->priv->window_group = NULL;
- }
+ if (window->priv->window_group != NULL)
+ {
+ g_object_unref (window->priv->window_group);
+ window->priv->window_group = NULL;
+ }
- /* We must free the settings after saving the panels */
- g_clear_object (&window->priv->editor_settings);
+ /* We must free the settings after saving the panels */
+ g_clear_object (&window->priv->editor_settings);
- /* Now that there have broken some reference loops,
- * force collection again.
- */
- peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
+ /* Now that there have broken some reference loops,
+ * force collection again.
+ */
+ peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
- G_OBJECT_CLASS (pluma_window_parent_class)->dispose (object);
+ G_OBJECT_CLASS (pluma_window_parent_class)->dispose (object);
}
static void
pluma_window_finalize (GObject *object)
{
- PlumaWindow *window;
+ PlumaWindow *window;
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- window = PLUMA_WINDOW (object);
+ window = PLUMA_WINDOW (object);
- if (window->priv->default_location != NULL)
- g_object_unref (window->priv->default_location);
+ if (window->priv->default_location != NULL)
+ g_object_unref (window->priv->default_location);
- G_OBJECT_CLASS (pluma_window_parent_class)->finalize (object);
+ G_OBJECT_CLASS (pluma_window_parent_class)->finalize (object);
}
static gboolean
pluma_window_window_state_event (GtkWidget *widget,
- GdkEventWindowState *event)
+ GdkEventWindowState *event)
{
- PlumaWindow *window = PLUMA_WINDOW (widget);
+ PlumaWindow *window = PLUMA_WINDOW (widget);
- window->priv->window_state = event->new_window_state;
+ window->priv->window_state = event->new_window_state;
- return GTK_WIDGET_CLASS (pluma_window_parent_class)->window_state_event (widget, event);
+ return GTK_WIDGET_CLASS (pluma_window_parent_class)->window_state_event (widget, event);
}
static gboolean
pluma_window_configure_event (GtkWidget *widget,
- GdkEventConfigure *event)
+ GdkEventConfigure *event)
{
- PlumaWindow *window = PLUMA_WINDOW (widget);
+ PlumaWindow *window = PLUMA_WINDOW (widget);
- window->priv->width = event->width;
- window->priv->height = event->height;
+ window->priv->width = event->width;
+ window->priv->height = event->height;
- return GTK_WIDGET_CLASS (pluma_window_parent_class)->configure_event (widget, event);
+ return GTK_WIDGET_CLASS (pluma_window_parent_class)->configure_event (widget, event);
}
/*
@@ -296,214 +296,215 @@ pluma_window_configure_event (GtkWidget *widget,
*/
static gboolean
pluma_window_key_press_event (GtkWidget *widget,
- GdkEventKey *event)
-{
- static gpointer grand_parent_class = NULL;
- GtkWindow *window = GTK_WINDOW (widget);
- gboolean handled = FALSE;
- /* FIXME: avoid making a new gsettings variable here */
- GSettings *settings = g_settings_new (PLUMA_SCHEMA_ID);
-
- if (event->state & GDK_CONTROL_MASK)
- {
- gchar *font;
- gchar *tempsize;
- gint nsize;
-
- font = g_settings_get_string (settings, PLUMA_SETTINGS_EDITOR_FONT);
- tempsize = g_strdup (font);
-
- g_strreverse (tempsize);
- g_strcanon (tempsize, "1234567890", '\0');
- g_strreverse (tempsize);
-
- gchar tempfont [strlen (font)];
- strcpy (tempfont, font);
- tempfont [strlen (font) - strlen (tempsize)] = 0;
-
- sscanf (tempsize, "%d", &nsize);
-
- if ((event->keyval == GDK_KEY_plus) || (event->keyval == GDK_KEY_KP_Add))
- {
- nsize = nsize + 1;
- sprintf (tempsize, "%d", nsize);
-
- if (!g_settings_get_boolean (settings, PLUMA_SETTINGS_USE_DEFAULT_FONT) && (nsize < 73))
- {
- gchar *tmp = g_strconcat (tempfont, tempsize, NULL);
- g_settings_set_string (settings, PLUMA_SETTINGS_EDITOR_FONT, tmp);
- g_free (tmp);
- }
- }
- else if ((event->keyval == GDK_KEY_minus) || (event->keyval == GDK_KEY_KP_Subtract))
- {
- nsize = nsize - 1;
- sprintf (tempsize, "%d", nsize);
-
- if (!g_settings_get_boolean (settings, PLUMA_SETTINGS_USE_DEFAULT_FONT) && (nsize > 5))
- {
- gchar *tmp = g_strconcat (tempfont, tempsize, NULL);
- g_settings_set_string (settings, PLUMA_SETTINGS_EDITOR_FONT, tmp);
- g_free (tmp);
- }
- }
- else if (event->keyval == GDK_KEY_y)
- {
- g_settings_set_boolean (settings, PLUMA_SETTINGS_DISPLAY_LINE_NUMBERS, !g_settings_get_boolean (settings, PLUMA_SETTINGS_DISPLAY_LINE_NUMBERS));
- }
-
- if (g_settings_get_boolean (settings, PLUMA_SETTINGS_CTRL_TABS_SWITCH_TABS))
- {
- GtkNotebook *notebook = GTK_NOTEBOOK (_pluma_window_get_notebook (PLUMA_WINDOW (window)));
-
- int pages = gtk_notebook_get_n_pages (notebook);
- int page_num = gtk_notebook_get_current_page (notebook);
-
- if (event->keyval == GDK_KEY_ISO_Left_Tab)
- {
- if (page_num != 0)
- gtk_notebook_prev_page (notebook);
- else
- gtk_notebook_set_current_page (notebook, (pages - 1));
- handled = TRUE;
- }
-
- if (event->keyval == GDK_KEY_Tab)
- {
- if (page_num != (pages -1))
- gtk_notebook_next_page (notebook);
- else
- gtk_notebook_set_current_page (notebook, 0);
- handled = TRUE;
- }
- }
- g_free (font);
- g_free (tempsize);
- }
-
- g_object_unref (settings);
-
- if (grand_parent_class == NULL)
- grand_parent_class = g_type_class_peek_parent (pluma_window_parent_class);
-
- /* handle focus widget key events */
- if (!handled)
- handled = gtk_window_propagate_key_event (window, event);
-
- /* handle mnemonics and accelerators */
- if (!handled)
- handled = gtk_window_activate_key (window, event);
-
- /* Chain up, invokes binding set */
- if (!handled)
- handled = GTK_WIDGET_CLASS (grand_parent_class)->key_press_event (widget, event);
-
- return handled;
+ GdkEventKey *event)
+{
+ static gpointer grand_parent_class = NULL;
+ GtkWindow *window = GTK_WINDOW (widget);
+ gboolean handled = FALSE;
+ /* FIXME: avoid making a new gsettings variable here */
+ GSettings *settings = g_settings_new (PLUMA_SCHEMA_ID);
+
+ if (event->state & GDK_CONTROL_MASK)
+ {
+ gchar *font;
+ gchar *tempsize;
+ gint nsize;
+
+ font = g_settings_get_string (settings, PLUMA_SETTINGS_EDITOR_FONT);
+ tempsize = g_strdup (font);
+
+ g_strreverse (tempsize);
+ g_strcanon (tempsize, "1234567890", '\0');
+ g_strreverse (tempsize);
+
+ gchar tempfont [strlen (font)];
+ strcpy (tempfont, font);
+ tempfont [strlen (font) - strlen (tempsize)] = 0;
+
+ sscanf (tempsize, "%d", &nsize);
+
+ if ((event->keyval == GDK_KEY_plus) || (event->keyval == GDK_KEY_KP_Add))
+ {
+ nsize = nsize + 1;
+ sprintf (tempsize, "%d", nsize);
+
+ if (!g_settings_get_boolean (settings, PLUMA_SETTINGS_USE_DEFAULT_FONT) && (nsize < 73))
+ {
+ gchar *tmp = g_strconcat (tempfont, tempsize, NULL);
+ g_settings_set_string (settings, PLUMA_SETTINGS_EDITOR_FONT, tmp);
+ g_free (tmp);
+ }
+ }
+ else if ((event->keyval == GDK_KEY_minus) || (event->keyval == GDK_KEY_KP_Subtract))
+ {
+ nsize = nsize - 1;
+ sprintf (tempsize, "%d", nsize);
+
+ if (!g_settings_get_boolean (settings, PLUMA_SETTINGS_USE_DEFAULT_FONT) && (nsize > 5))
+ {
+ gchar *tmp = g_strconcat (tempfont, tempsize, NULL);
+ g_settings_set_string (settings, PLUMA_SETTINGS_EDITOR_FONT, tmp);
+ g_free (tmp);
+ }
+ }
+ else if (event->keyval == GDK_KEY_y)
+ {
+ g_settings_set_boolean (settings, PLUMA_SETTINGS_DISPLAY_LINE_NUMBERS,
+ !g_settings_get_boolean (settings, PLUMA_SETTINGS_DISPLAY_LINE_NUMBERS));
+ }
+
+ if (g_settings_get_boolean (settings, PLUMA_SETTINGS_CTRL_TABS_SWITCH_TABS))
+ {
+ GtkNotebook *notebook = GTK_NOTEBOOK (_pluma_window_get_notebook (PLUMA_WINDOW (window)));
+
+ int pages = gtk_notebook_get_n_pages (notebook);
+ int page_num = gtk_notebook_get_current_page (notebook);
+
+ if (event->keyval == GDK_KEY_ISO_Left_Tab)
+ {
+ if (page_num != 0)
+ gtk_notebook_prev_page (notebook);
+ else
+ gtk_notebook_set_current_page (notebook, (pages - 1));
+ handled = TRUE;
+ }
+
+ if (event->keyval == GDK_KEY_Tab)
+ {
+ if (page_num != (pages -1))
+ gtk_notebook_next_page (notebook);
+ else
+ gtk_notebook_set_current_page (notebook, 0);
+ handled = TRUE;
+ }
+ }
+ g_free (font);
+ g_free (tempsize);
+ }
+
+ g_object_unref (settings);
+
+ if (grand_parent_class == NULL)
+ grand_parent_class = g_type_class_peek_parent (pluma_window_parent_class);
+
+ /* handle focus widget key events */
+ if (!handled)
+ handled = gtk_window_propagate_key_event (window, event);
+
+ /* handle mnemonics and accelerators */
+ if (!handled)
+ handled = gtk_window_activate_key (window, event);
+
+ /* Chain up, invokes binding set */
+ if (!handled)
+ handled = GTK_WIDGET_CLASS (grand_parent_class)->key_press_event (widget, event);
+
+ return handled;
}
static void
pluma_window_tab_removed (PlumaWindow *window,
- PlumaTab *tab)
+ PlumaTab *tab)
{
- peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
+ peas_engine_garbage_collect (PEAS_ENGINE (pluma_plugins_engine_get_default ()));
}
static void
pluma_window_class_init (PlumaWindowClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-
- klass->tab_removed = pluma_window_tab_removed;
-
- object_class->dispose = pluma_window_dispose;
- object_class->finalize = pluma_window_finalize;
- object_class->get_property = pluma_window_get_property;
-
- widget_class->window_state_event = pluma_window_window_state_event;
- widget_class->configure_event = pluma_window_configure_event;
- widget_class->key_press_event = pluma_window_key_press_event;
-
- signals[TAB_ADDED] =
- g_signal_new ("tab_added",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (PlumaWindowClass, tab_added),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- PLUMA_TYPE_TAB);
- signals[TAB_REMOVED] =
- g_signal_new ("tab_removed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (PlumaWindowClass, tab_removed),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- PLUMA_TYPE_TAB);
- signals[TABS_REORDERED] =
- g_signal_new ("tabs_reordered",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (PlumaWindowClass, tabs_reordered),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
- signals[ACTIVE_TAB_CHANGED] =
- g_signal_new ("active_tab_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (PlumaWindowClass, active_tab_changed),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 1,
- PLUMA_TYPE_TAB);
- signals[ACTIVE_TAB_STATE_CHANGED] =
- g_signal_new ("active_tab_state_changed",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (PlumaWindowClass, active_tab_state_changed),
- NULL, NULL, NULL,
- G_TYPE_NONE,
- 0);
-
- g_object_class_install_property (object_class,
- PROP_STATE,
- g_param_spec_flags ("state",
- "State",
- "The window's state",
- PLUMA_TYPE_WINDOW_STATE,
- PLUMA_WINDOW_STATE_NORMAL,
- G_PARAM_READABLE |
- G_PARAM_STATIC_STRINGS));
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ klass->tab_removed = pluma_window_tab_removed;
+
+ object_class->dispose = pluma_window_dispose;
+ object_class->finalize = pluma_window_finalize;
+ object_class->get_property = pluma_window_get_property;
+
+ widget_class->window_state_event = pluma_window_window_state_event;
+ widget_class->configure_event = pluma_window_configure_event;
+ widget_class->key_press_event = pluma_window_key_press_event;
+
+ signals[TAB_ADDED] =
+ g_signal_new ("tab_added",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (PlumaWindowClass, tab_added),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ PLUMA_TYPE_TAB);
+ signals[TAB_REMOVED] =
+ g_signal_new ("tab_removed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (PlumaWindowClass, tab_removed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ PLUMA_TYPE_TAB);
+ signals[TABS_REORDERED] =
+ g_signal_new ("tabs_reordered",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (PlumaWindowClass, tabs_reordered),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
+ signals[ACTIVE_TAB_CHANGED] =
+ g_signal_new ("active_tab_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (PlumaWindowClass, active_tab_changed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 1,
+ PLUMA_TYPE_TAB);
+ signals[ACTIVE_TAB_STATE_CHANGED] =
+ g_signal_new ("active_tab_state_changed",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (PlumaWindowClass, active_tab_state_changed),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
+
+ g_object_class_install_property (object_class,
+ PROP_STATE,
+ g_param_spec_flags ("state",
+ "State",
+ "The window's state",
+ PLUMA_TYPE_WINDOW_STATE,
+ PLUMA_WINDOW_STATE_NORMAL,
+ G_PARAM_READABLE |
+ G_PARAM_STATIC_STRINGS));
}
static void
menu_item_select_cb (GtkMenuItem *proxy,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- GtkAction *action;
- char *message;
+ GtkAction *action;
+ char *message;
- action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
- g_return_if_fail (action != NULL);
+ action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (proxy));
+ g_return_if_fail (action != NULL);
- g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
- if (message)
- {
- gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar),
- window->priv->tip_message_cid, message);
- g_free (message);
- }
+ g_object_get (G_OBJECT (action), "tooltip", &message, NULL);
+ if (message)
+ {
+ gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar),
+ window->priv->tip_message_cid, message);
+ g_free (message);
+ }
}
static void
menu_item_deselect_cb (GtkMenuItem *proxy,
PlumaWindow *window)
{
- gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar),
- window->priv->tip_message_cid);
+ gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar),
+ window->priv->tip_message_cid);
}
static void
@@ -512,765 +513,757 @@ connect_proxy_cb (GtkUIManager *manager,
GtkWidget *proxy,
PlumaWindow *window)
{
- if (GTK_IS_MENU_ITEM (proxy))
- {
- g_signal_connect (proxy, "select",
- G_CALLBACK (menu_item_select_cb), window);
- g_signal_connect (proxy, "deselect",
- G_CALLBACK (menu_item_deselect_cb), window);
- }
+ if (GTK_IS_MENU_ITEM (proxy))
+ {
+ g_signal_connect (proxy, "select",
+ G_CALLBACK (menu_item_select_cb), window);
+ g_signal_connect (proxy, "deselect",
+ G_CALLBACK (menu_item_deselect_cb), window);
+ }
}
static void
disconnect_proxy_cb (GtkUIManager *manager,
- GtkAction *action,
- GtkWidget *proxy,
- PlumaWindow *window)
+ GtkAction *action,
+ GtkWidget *proxy,
+ PlumaWindow *window)
{
- if (GTK_IS_MENU_ITEM (proxy))
- {
- g_signal_handlers_disconnect_by_func
- (proxy, G_CALLBACK (menu_item_select_cb), window);
- g_signal_handlers_disconnect_by_func
- (proxy, G_CALLBACK (menu_item_deselect_cb), window);
- }
+ if (GTK_IS_MENU_ITEM (proxy))
+ {
+ g_signal_handlers_disconnect_by_func
+ (proxy, G_CALLBACK (menu_item_select_cb), window);
+ g_signal_handlers_disconnect_by_func
+ (proxy, G_CALLBACK (menu_item_deselect_cb), window);
+ }
}
static void
apply_toolbar_style (PlumaWindow *window,
- GtkWidget *toolbar)
-{
- switch (window->priv->toolbar_style)
- {
- case PLUMA_TOOLBAR_SYSTEM:
- pluma_debug_message (DEBUG_WINDOW, "PLUMA: SYSTEM");
- gtk_toolbar_unset_style (
- GTK_TOOLBAR (toolbar));
- break;
-
- case PLUMA_TOOLBAR_ICONS:
- pluma_debug_message (DEBUG_WINDOW, "PLUMA: ICONS");
- gtk_toolbar_set_style (
- GTK_TOOLBAR (toolbar),
- GTK_TOOLBAR_ICONS);
- break;
-
- case PLUMA_TOOLBAR_ICONS_AND_TEXT:
- pluma_debug_message (DEBUG_WINDOW, "PLUMA: ICONS_AND_TEXT");
- gtk_toolbar_set_style (
- GTK_TOOLBAR (toolbar),
- GTK_TOOLBAR_BOTH);
- break;
-
- case PLUMA_TOOLBAR_ICONS_BOTH_HORIZ:
- pluma_debug_message (DEBUG_WINDOW, "PLUMA: ICONS_BOTH_HORIZ");
- gtk_toolbar_set_style (
- GTK_TOOLBAR (toolbar),
- GTK_TOOLBAR_BOTH_HORIZ);
- break;
- }
+ GtkWidget *toolbar)
+{
+ switch (window->priv->toolbar_style)
+ {
+ case PLUMA_TOOLBAR_SYSTEM:
+ pluma_debug_message (DEBUG_WINDOW, "PLUMA: SYSTEM");
+ gtk_toolbar_unset_style (GTK_TOOLBAR (toolbar));
+ break;
+
+ case PLUMA_TOOLBAR_ICONS:
+ pluma_debug_message (DEBUG_WINDOW, "PLUMA: ICONS");
+ gtk_toolbar_set_style (GTK_TOOLBAR (toolbar),
+ GTK_TOOLBAR_ICONS);
+ break;
+
+ case PLUMA_TOOLBAR_ICONS_AND_TEXT:
+ pluma_debug_message (DEBUG_WINDOW, "PLUMA: ICONS_AND_TEXT");
+ gtk_toolbar_set_style (GTK_TOOLBAR (toolbar),
+ GTK_TOOLBAR_BOTH);
+ break;
+
+ case PLUMA_TOOLBAR_ICONS_BOTH_HORIZ:
+ pluma_debug_message (DEBUG_WINDOW, "PLUMA: ICONS_BOTH_HORIZ");
+ gtk_toolbar_set_style (GTK_TOOLBAR (toolbar),
+ GTK_TOOLBAR_BOTH_HORIZ);
+ break;
+ }
}
/* Returns TRUE if toolbar is visible */
static gboolean
set_toolbar_style (PlumaWindow *window,
- PlumaWindow *origin)
+ PlumaWindow *origin)
{
- gboolean visible;
- PlumaToolbarSetting style;
- GtkAction *action;
+ gboolean visible;
+ PlumaToolbarSetting style;
+ GtkAction *action;
- if (origin == NULL)
- visible = g_settings_get_boolean (window->priv->editor_settings,
- PLUMA_SETTINGS_TOOLBAR_VISIBLE);
- else
- visible = gtk_widget_get_visible (origin->priv->toolbar);
+ if (origin == NULL)
+ visible = g_settings_get_boolean (window->priv->editor_settings,
+ PLUMA_SETTINGS_TOOLBAR_VISIBLE);
+ else
+ visible = gtk_widget_get_visible (origin->priv->toolbar);
- /* Set visibility */
- if (visible)
- gtk_widget_show (window->priv->toolbar);
- else
- gtk_widget_hide (window->priv->toolbar);
+ /* Set visibility */
+ if (visible)
+ gtk_widget_show (window->priv->toolbar);
+ else
+ gtk_widget_hide (window->priv->toolbar);
- action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
- "ViewToolbar");
+ action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
+ "ViewToolbar");
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
- /* Set style */
- if (origin == NULL)
- {
- PlumaSettings *settings;
+ /* Set style */
+ if (origin == NULL)
+ {
+ PlumaSettings *settings;
- settings = _pluma_settings_get_singleton ();
- style = pluma_settings_get_toolbar_style (settings);
- }
- else
- {
- style = origin->priv->toolbar_style;
- }
+ settings = _pluma_settings_get_singleton ();
+ style = pluma_settings_get_toolbar_style (settings);
+ }
+ else
+ {
+ style = origin->priv->toolbar_style;
+ }
- window->priv->toolbar_style = style;
+ window->priv->toolbar_style = style;
- apply_toolbar_style (window, window->priv->toolbar);
+ apply_toolbar_style (window, window->priv->toolbar);
- return visible;
+ return visible;
}
static void
update_next_prev_doc_sensitivity (PlumaWindow *window,
- PlumaTab *tab)
+ PlumaTab *tab)
{
- gint tab_number;
- GtkNotebook *notebook;
- GtkAction *action;
+ gint tab_number;
+ GtkNotebook *notebook;
+ GtkAction *action;
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- notebook = GTK_NOTEBOOK (_pluma_window_get_notebook (window));
+ notebook = GTK_NOTEBOOK (_pluma_window_get_notebook (window));
- tab_number = gtk_notebook_page_num (notebook, GTK_WIDGET (tab));
- g_return_if_fail (tab_number >= 0);
+ tab_number = gtk_notebook_page_num (notebook, GTK_WIDGET (tab));
+ g_return_if_fail (tab_number >= 0);
- action = gtk_action_group_get_action (window->priv->action_group,
- "DocumentsPreviousDocument");
- gtk_action_set_sensitive (action, tab_number != 0);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "DocumentsPreviousDocument");
+ gtk_action_set_sensitive (action, tab_number != 0);
- action = gtk_action_group_get_action (window->priv->action_group,
- "DocumentsNextDocument");
- gtk_action_set_sensitive (action,
- tab_number < gtk_notebook_get_n_pages (notebook) - 1);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "DocumentsNextDocument");
+ gtk_action_set_sensitive (action,
+ tab_number < gtk_notebook_get_n_pages (notebook) - 1);
}
static void
update_next_prev_doc_sensitivity_per_window (PlumaWindow *window)
{
- PlumaTab *tab;
- GtkAction *action;
+ PlumaTab *tab;
+ GtkAction *action;
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- tab = pluma_window_get_active_tab (window);
- if (tab != NULL)
- {
- update_next_prev_doc_sensitivity (window, tab);
+ tab = pluma_window_get_active_tab (window);
+ if (tab != NULL)
+ {
+ update_next_prev_doc_sensitivity (window, tab);
- return;
- }
+ return;
+ }
- action = gtk_action_group_get_action (window->priv->action_group,
- "DocumentsPreviousDocument");
- gtk_action_set_sensitive (action, FALSE);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "DocumentsPreviousDocument");
+ gtk_action_set_sensitive (action, FALSE);
- action = gtk_action_group_get_action (window->priv->action_group,
- "DocumentsNextDocument");
- gtk_action_set_sensitive (action, FALSE);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "DocumentsNextDocument");
+ gtk_action_set_sensitive (action, FALSE);
}
static void
received_clipboard_contents (GtkClipboard *clipboard,
- GtkSelectionData *selection_data,
- PlumaWindow *window)
+ GtkSelectionData *selection_data,
+ PlumaWindow *window)
{
- gboolean sens;
- GtkAction *action;
+ gboolean sens;
+ GtkAction *action;
- /* getting clipboard contents is async, so we need to
- * get the current tab and its state */
+ /* getting clipboard contents is async, so we need to
+ * get the current tab and its state */
- if (window->priv->active_tab != NULL)
- {
- PlumaTabState state;
- gboolean state_normal;
+ if (window->priv->active_tab != NULL)
+ {
+ PlumaTabState state;
+ gboolean state_normal;
- state = pluma_tab_get_state (window->priv->active_tab);
- state_normal = (state == PLUMA_TAB_STATE_NORMAL);
+ state = pluma_tab_get_state (window->priv->active_tab);
+ state_normal = (state == PLUMA_TAB_STATE_NORMAL);
- sens = state_normal &&
- gtk_selection_data_targets_include_text (selection_data);
- }
- else
- {
- sens = FALSE;
- }
+ sens = state_normal &&
+ gtk_selection_data_targets_include_text (selection_data);
+ }
+ else
+ {
+ sens = FALSE;
+ }
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditPaste");
+ action = gtk_action_group_get_action (window->priv->action_group, "EditPaste");
- gtk_action_set_sensitive (action, sens);
+ gtk_action_set_sensitive (action, sens);
- g_object_unref (window);
+ g_object_unref (window);
}
static void
set_paste_sensitivity_according_to_clipboard (PlumaWindow *window,
- GtkClipboard *clipboard)
+ GtkClipboard *clipboard)
{
- GdkDisplay *display;
+ GdkDisplay *display;
- display = gtk_clipboard_get_display (clipboard);
+ display = gtk_clipboard_get_display (clipboard);
- if (gdk_display_supports_selection_notification (display))
- {
- gtk_clipboard_request_contents (clipboard,
- gdk_atom_intern_static_string ("TARGETS"),
- (GtkClipboardReceivedFunc) received_clipboard_contents,
- g_object_ref (window));
- }
- else
- {
- GtkAction *action;
+ if (gdk_display_supports_selection_notification (display))
+ {
+ gtk_clipboard_request_contents (clipboard,
+ gdk_atom_intern_static_string ("TARGETS"),
+ (GtkClipboardReceivedFunc) received_clipboard_contents,
+ g_object_ref (window));
+ }
+ else
+ {
+ GtkAction *action;
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditPaste");
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditPaste");
- /* XFIXES extension not availbale, make
- * Paste always sensitive */
- gtk_action_set_sensitive (action, TRUE);
- }
+ /* XFIXES extension not availbale, make
+ * Paste always sensitive */
+ gtk_action_set_sensitive (action, TRUE);
+ }
}
static void
set_sensitivity_according_to_tab (PlumaWindow *window,
- PlumaTab *tab)
-{
- PlumaDocument *doc;
- PlumaView *view;
- GtkAction *action;
- gboolean b;
- gboolean state_normal;
- gboolean editable;
- PlumaTabState state;
- GtkClipboard *clipboard;
- PlumaLockdownMask lockdown;
- gboolean enable_syntax_highlighting;
-
- g_return_if_fail (PLUMA_TAB (tab));
-
- pluma_debug (DEBUG_WINDOW);
-
- enable_syntax_highlighting = g_settings_get_boolean (window->priv->editor_settings,
- PLUMA_SETTINGS_SYNTAX_HIGHLIGHTING);
-
- lockdown = pluma_app_get_lockdown (pluma_app_get_default ());
-
- state = pluma_tab_get_state (tab);
- state_normal = (state == PLUMA_TAB_STATE_NORMAL);
-
- view = pluma_tab_get_view (tab);
- editable = gtk_text_view_get_editable (GTK_TEXT_VIEW (view));
-
- doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
-
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
- GDK_SELECTION_CLIPBOARD);
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "FileSave");
-
- if (state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) {
- gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), TRUE);
- }
-
- gtk_action_set_sensitive (action,
- (state_normal ||
- (state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) ||
- (state == PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW)) &&
- !pluma_document_get_readonly (doc) &&
- !(lockdown & PLUMA_LOCKDOWN_SAVE_TO_DISK) &&
- (cansave) &&
- (editable));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "FileSaveAs");
- gtk_action_set_sensitive (action,
- (state_normal ||
- (state == PLUMA_TAB_STATE_SAVING_ERROR) ||
- (state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) ||
- (state == PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW)) &&
- !(lockdown & PLUMA_LOCKDOWN_SAVE_TO_DISK));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "FileRevert");
- gtk_action_set_sensitive (action,
- (state_normal ||
- (state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION)) &&
- !pluma_document_is_untitled (doc));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "FilePrintPreview");
- gtk_action_set_sensitive (action,
- state_normal &&
- !(lockdown & PLUMA_LOCKDOWN_PRINTING));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "FilePrint");
- gtk_action_set_sensitive (action,
- (state_normal ||
- (state == PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW)) &&
- !(lockdown & PLUMA_LOCKDOWN_PRINTING));
-
- action = gtk_action_group_get_action (window->priv->close_action_group,
- "FileClose");
-
- gtk_action_set_sensitive (action,
- (state != PLUMA_TAB_STATE_CLOSING) &&
- (state != PLUMA_TAB_STATE_SAVING) &&
- (state != PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW) &&
- (state != PLUMA_TAB_STATE_PRINTING) &&
- (state != PLUMA_TAB_STATE_PRINT_PREVIEWING) &&
- (state != PLUMA_TAB_STATE_SAVING_ERROR));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditUndo");
- gtk_action_set_sensitive (action,
- state_normal &&
- gtk_source_buffer_can_undo (GTK_SOURCE_BUFFER (doc)));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditRedo");
- gtk_action_set_sensitive (action,
- state_normal &&
- gtk_source_buffer_can_redo (GTK_SOURCE_BUFFER (doc)));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditCut");
- gtk_action_set_sensitive (action,
- state_normal &&
- editable &&
- gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditCopy");
- gtk_action_set_sensitive (action,
- (state_normal ||
- state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) &&
- gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditPaste");
- if (state_normal && editable)
- {
- set_paste_sensitivity_according_to_clipboard (window,
- clipboard);
- }
- else
- {
- gtk_action_set_sensitive (action, FALSE);
- }
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditDelete");
- gtk_action_set_sensitive (action,
- state_normal &&
- editable &&
- gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "SearchFind");
- gtk_action_set_sensitive (action,
- (state_normal ||
- state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "SearchIncrementalSearch");
- gtk_action_set_sensitive (action,
- (state_normal ||
- state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "SearchReplace");
- gtk_action_set_sensitive (action,
- state_normal &&
- editable);
-
- b = pluma_document_get_can_search_again (doc);
- action = gtk_action_group_get_action (window->priv->action_group,
- "SearchFindNext");
- gtk_action_set_sensitive (action,
- (state_normal ||
- state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b);
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "SearchFindPrevious");
- gtk_action_set_sensitive (action,
- (state_normal ||
- state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b);
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "SearchClearHighlight");
- gtk_action_set_sensitive (action,
- (state_normal ||
- state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b);
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "SearchGoToLine");
- gtk_action_set_sensitive (action,
- (state_normal ||
- state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "ViewHighlightMode");
- gtk_action_set_sensitive (action,
- (state != PLUMA_TAB_STATE_CLOSING) &&
- enable_syntax_highlighting);
-
- update_next_prev_doc_sensitivity (window, tab);
-
- peas_extension_set_call (window->priv->extensions, "update_state");
+ PlumaTab *tab)
+{
+ PlumaDocument *doc;
+ PlumaView *view;
+ GtkAction *action;
+ gboolean b;
+ gboolean state_normal;
+ gboolean editable;
+ PlumaTabState state;
+ GtkClipboard *clipboard;
+ PlumaLockdownMask lockdown;
+ gboolean enable_syntax_highlighting;
+
+ g_return_if_fail (PLUMA_TAB (tab));
+
+ pluma_debug (DEBUG_WINDOW);
+
+ enable_syntax_highlighting = g_settings_get_boolean (window->priv->editor_settings,
+ PLUMA_SETTINGS_SYNTAX_HIGHLIGHTING);
+
+ lockdown = pluma_app_get_lockdown (pluma_app_get_default ());
+
+ state = pluma_tab_get_state (tab);
+ state_normal = (state == PLUMA_TAB_STATE_NORMAL);
+
+ view = pluma_tab_get_view (tab);
+ editable = gtk_text_view_get_editable (GTK_TEXT_VIEW (view));
+
+ doc = PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (window),
+ GDK_SELECTION_CLIPBOARD);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FileSave");
+
+ if (state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) {
+ gtk_text_buffer_set_modified (GTK_TEXT_BUFFER (doc), TRUE);
+ }
+
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ (state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) ||
+ (state == PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW)) &&
+ !pluma_document_get_readonly (doc) &&
+ !(lockdown & PLUMA_LOCKDOWN_SAVE_TO_DISK) &&
+ (cansave) &&
+ (editable));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FileSaveAs");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ (state == PLUMA_TAB_STATE_SAVING_ERROR) ||
+ (state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) ||
+ (state == PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW)) &&
+ !(lockdown & PLUMA_LOCKDOWN_SAVE_TO_DISK));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FileRevert");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ (state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION)) &&
+ !pluma_document_is_untitled (doc));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FilePrintPreview");
+ gtk_action_set_sensitive (action,
+ state_normal &&
+ !(lockdown & PLUMA_LOCKDOWN_PRINTING));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FilePrint");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ (state == PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW)) &&
+ !(lockdown & PLUMA_LOCKDOWN_PRINTING));
+
+ action = gtk_action_group_get_action (window->priv->close_action_group,
+ "FileClose");
+
+ gtk_action_set_sensitive (action,
+ (state != PLUMA_TAB_STATE_CLOSING) &&
+ (state != PLUMA_TAB_STATE_SAVING) &&
+ (state != PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW) &&
+ (state != PLUMA_TAB_STATE_PRINTING) &&
+ (state != PLUMA_TAB_STATE_PRINT_PREVIEWING) &&
+ (state != PLUMA_TAB_STATE_SAVING_ERROR));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditUndo");
+ gtk_action_set_sensitive (action,
+ state_normal &&
+ gtk_source_buffer_can_undo (GTK_SOURCE_BUFFER (doc)));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditRedo");
+ gtk_action_set_sensitive (action,
+ state_normal &&
+ gtk_source_buffer_can_redo (GTK_SOURCE_BUFFER (doc)));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditCut");
+ gtk_action_set_sensitive (action,
+ state_normal &&
+ editable &&
+ gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditCopy");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) &&
+ gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditPaste");
+ if (state_normal && editable)
+ {
+ set_paste_sensitivity_according_to_clipboard (window, clipboard);
+ }
+ else
+ {
+ gtk_action_set_sensitive (action, FALSE);
+ }
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditDelete");
+ gtk_action_set_sensitive (action,
+ state_normal &&
+ editable &&
+ gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "SearchFind");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "SearchIncrementalSearch");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "SearchReplace");
+ gtk_action_set_sensitive (action,
+ state_normal &&
+ editable);
+
+ b = pluma_document_get_can_search_again (doc);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "SearchFindNext");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "SearchFindPrevious");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "SearchClearHighlight");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) && b);
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "SearchGoToLine");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "ViewHighlightMode");
+ gtk_action_set_sensitive (action,
+ (state != PLUMA_TAB_STATE_CLOSING) &&
+ enable_syntax_highlighting);
+
+ update_next_prev_doc_sensitivity (window, tab);
+
+ peas_extension_set_call (window->priv->extensions, "update_state");
}
static void
language_toggled (GtkToggleAction *action,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- PlumaDocument *doc;
- GtkSourceLanguage *lang;
- const gchar *lang_id;
+ PlumaDocument *doc;
+ GtkSourceLanguage *lang;
+ const gchar *lang_id;
- if (gtk_toggle_action_get_active (action) == FALSE)
- return;
+ if (gtk_toggle_action_get_active (action) == FALSE)
+ return;
- doc = pluma_window_get_active_document (window);
- if (doc == NULL)
- return;
+ doc = pluma_window_get_active_document (window);
+ if (doc == NULL)
+ return;
- lang_id = gtk_action_get_name (GTK_ACTION (action));
+ lang_id = gtk_action_get_name (GTK_ACTION (action));
- if (strcmp (lang_id, LANGUAGE_NONE) == 0)
- {
- /* Normal (no highlighting) */
- lang = NULL;
- }
- else
- {
- lang = gtk_source_language_manager_get_language (
- pluma_get_language_manager (),
- lang_id);
- if (lang == NULL)
- {
- g_warning ("Could not get language %s\n", lang_id);
- }
- }
+ if (strcmp (lang_id, LANGUAGE_NONE) == 0)
+ {
+ /* Normal (no highlighting) */
+ lang = NULL;
+ }
+ else
+ {
+ lang = gtk_source_language_manager_get_language (pluma_get_language_manager (),
+ lang_id);
+ if (lang == NULL)
+ {
+ g_warning ("Could not get language %s\n", lang_id);
+ }
+ }
- pluma_document_set_language (doc, lang);
+ pluma_document_set_language (doc, lang);
}
static gchar *
escape_section_name (const gchar *name)
{
- gchar *ret;
+ gchar *ret;
- ret = g_markup_escape_text (name, -1);
+ ret = g_markup_escape_text (name, -1);
- /* Replace '/' with '-' to avoid problems in xml paths */
- g_strdelimit (ret, "/", '-');
+ /* Replace '/' with '-' to avoid problems in xml paths */
+ g_strdelimit (ret, "/", '-');
- return ret;
+ return ret;
}
static void
create_language_menu_item (GtkSourceLanguage *lang,
- gint index,
- guint ui_id,
- PlumaWindow *window)
-{
- GtkAction *section_action;
- GtkRadioAction *action;
- GtkAction *normal_action;
- GSList *group;
- const gchar *section;
- gchar *escaped_section;
- const gchar *lang_id;
- const gchar *lang_name;
- gchar *escaped_lang_name;
- gchar *tip;
- gchar *path;
-
- section = gtk_source_language_get_section (lang);
- escaped_section = escape_section_name (section);
-
- /* check if the section submenu exists or create it */
- section_action = gtk_action_group_get_action (window->priv->languages_action_group,
- escaped_section);
-
- if (section_action == NULL)
- {
- gchar *section_name;
-
- section_name = pluma_utils_escape_underscores (section, -1);
-
- section_action = gtk_action_new (escaped_section,
- section_name,
- NULL,
- NULL);
-
- g_free (section_name);
-
- gtk_action_group_add_action (window->priv->languages_action_group,
- section_action);
- g_object_unref (section_action);
-
- gtk_ui_manager_add_ui (window->priv->manager,
- ui_id,
- "/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder",
- escaped_section,
- escaped_section,
- GTK_UI_MANAGER_MENU,
- FALSE);
- }
-
- /* now add the language item to the section */
- lang_name = gtk_source_language_get_name (lang);
- lang_id = gtk_source_language_get_id (lang);
-
- escaped_lang_name = pluma_utils_escape_underscores (lang_name, -1);
-
- tip = g_strdup_printf (_("Use %s highlight mode"), lang_name);
- path = g_strdup_printf ("/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder/%s",
- escaped_section);
-
- action = gtk_radio_action_new (lang_id,
- escaped_lang_name,
- tip,
- NULL,
- index);
-
- g_free (escaped_lang_name);
-
- /* Action is added with a NULL accel to make the accel overridable */
- gtk_action_group_add_action_with_accel (window->priv->languages_action_group,
- GTK_ACTION (action),
- NULL);
- g_object_unref (action);
-
- /* add the action to the same radio group of the "Normal" action */
- normal_action = gtk_action_group_get_action (window->priv->languages_action_group,
- LANGUAGE_NONE);
- group = gtk_radio_action_get_group (GTK_RADIO_ACTION (normal_action));
- gtk_radio_action_set_group (action, group);
-
- g_signal_connect (action,
- "activate",
- G_CALLBACK (language_toggled),
- window);
-
- gtk_ui_manager_add_ui (window->priv->manager,
- ui_id,
- path,
- lang_id,
- lang_id,
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
-
- g_free (path);
- g_free (tip);
- g_free (escaped_section);
+ gint index,
+ guint ui_id,
+ PlumaWindow *window)
+{
+ GtkAction *section_action;
+ GtkRadioAction *action;
+ GtkAction *normal_action;
+ GSList *group;
+ const gchar *section;
+ gchar *escaped_section;
+ const gchar *lang_id;
+ const gchar *lang_name;
+ gchar *escaped_lang_name;
+ gchar *tip;
+ gchar *path;
+
+ section = gtk_source_language_get_section (lang);
+ escaped_section = escape_section_name (section);
+
+ /* check if the section submenu exists or create it */
+ section_action = gtk_action_group_get_action (window->priv->languages_action_group,
+ escaped_section);
+
+ if (section_action == NULL)
+ {
+ gchar *section_name;
+
+ section_name = pluma_utils_escape_underscores (section, -1);
+
+ section_action = gtk_action_new (escaped_section,
+ section_name,
+ NULL,
+ NULL);
+
+ g_free (section_name);
+
+ gtk_action_group_add_action (window->priv->languages_action_group,
+ section_action);
+ g_object_unref (section_action);
+
+ gtk_ui_manager_add_ui (window->priv->manager,
+ ui_id,
+ "/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder",
+ escaped_section,
+ escaped_section,
+ GTK_UI_MANAGER_MENU,
+ FALSE);
+ }
+
+ /* now add the language item to the section */
+ lang_name = gtk_source_language_get_name (lang);
+ lang_id = gtk_source_language_get_id (lang);
+
+ escaped_lang_name = pluma_utils_escape_underscores (lang_name, -1);
+
+ tip = g_strdup_printf (_("Use %s highlight mode"), lang_name);
+ path = g_strdup_printf ("/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder/%s",
+ escaped_section);
+
+ action = gtk_radio_action_new (lang_id,
+ escaped_lang_name,
+ tip,
+ NULL,
+ index);
+
+ g_free (escaped_lang_name);
+
+ /* Action is added with a NULL accel to make the accel overridable */
+ gtk_action_group_add_action_with_accel (window->priv->languages_action_group,
+ GTK_ACTION (action),
+ NULL);
+ g_object_unref (action);
+
+ /* add the action to the same radio group of the "Normal" action */
+ normal_action = gtk_action_group_get_action (window->priv->languages_action_group,
+ LANGUAGE_NONE);
+ group = gtk_radio_action_get_group (GTK_RADIO_ACTION (normal_action));
+ gtk_radio_action_set_group (action, group);
+
+ g_signal_connect (action,
+ "activate",
+ G_CALLBACK (language_toggled),
+ window);
+
+ gtk_ui_manager_add_ui (window->priv->manager,
+ ui_id,
+ path,
+ lang_id,
+ lang_id,
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+
+ g_free (path);
+ g_free (tip);
+ g_free (escaped_section);
}
static void
create_languages_menu (PlumaWindow *window)
{
- GtkRadioAction *action_none;
- GSList *languages;
- GSList *l;
- guint id;
- gint i;
+ GtkRadioAction *action_none;
+ GSList *languages;
+ GSList *l;
+ guint id;
+ gint i;
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- /* add the "Plain Text" item before all the others */
+ /* add the "Plain Text" item before all the others */
- /* Translators: "Plain Text" means that no highlight mode is selected in the
- * "View->Highlight Mode" submenu and so syntax highlighting is disabled */
- action_none = gtk_radio_action_new (LANGUAGE_NONE, _("Plain Text"),
- _("Disable syntax highlighting"),
- NULL,
- -1);
+ /* Translators: "Plain Text" means that no highlight mode is selected in the
+ * "View->Highlight Mode" submenu and so syntax highlighting is disabled */
+ action_none = gtk_radio_action_new (LANGUAGE_NONE, _("Plain Text"),
+ _("Disable syntax highlighting"),
+ NULL,
+ -1);
- gtk_action_group_add_action (window->priv->languages_action_group,
- GTK_ACTION (action_none));
- g_object_unref (action_none);
+ gtk_action_group_add_action (window->priv->languages_action_group,
+ GTK_ACTION (action_none));
+ g_object_unref (action_none);
- g_signal_connect (action_none,
- "activate",
- G_CALLBACK (language_toggled),
- window);
+ g_signal_connect (action_none,
+ "activate",
+ G_CALLBACK (language_toggled),
+ window);
- id = gtk_ui_manager_new_merge_id (window->priv->manager);
+ id = gtk_ui_manager_new_merge_id (window->priv->manager);
- gtk_ui_manager_add_ui (window->priv->manager,
- id,
- "/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder",
- LANGUAGE_NONE,
- LANGUAGE_NONE,
- GTK_UI_MANAGER_MENUITEM,
- TRUE);
+ gtk_ui_manager_add_ui (window->priv->manager,
+ id,
+ "/MenuBar/ViewMenu/ViewHighlightModeMenu/LanguagesMenuPlaceholder",
+ LANGUAGE_NONE,
+ LANGUAGE_NONE,
+ GTK_UI_MANAGER_MENUITEM,
+ TRUE);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_none), TRUE);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_none), TRUE);
- /* now add all the known languages */
- languages = pluma_language_manager_list_languages_sorted (
- pluma_get_language_manager (),
- FALSE);
+ /* now add all the known languages */
+ languages = pluma_language_manager_list_languages_sorted (pluma_get_language_manager (),
+ FALSE);
- for (l = languages, i = 0; l != NULL; l = l->next, ++i)
- {
- create_language_menu_item (l->data,
- i,
- id,
- window);
- }
+ for (l = languages, i = 0; l != NULL; l = l->next, ++i)
+ {
+ create_language_menu_item (l->data,
+ i,
+ id,
+ window);
+ }
- g_slist_free (languages);
+ g_slist_free (languages);
}
static void
update_languages_menu (PlumaWindow *window)
{
- PlumaDocument *doc;
- GList *actions;
- GList *l;
- GtkAction *action;
- GtkSourceLanguage *lang;
- const gchar *lang_id;
+ PlumaDocument *doc;
+ GList *actions;
+ GList *l;
+ GtkAction *action;
+ GtkSourceLanguage *lang;
+ const gchar *lang_id;
- doc = pluma_window_get_active_document (window);
- if (doc == NULL)
- return;
+ doc = pluma_window_get_active_document (window);
+ if (doc == NULL)
+ return;
- lang = pluma_document_get_language (doc);
- if (lang != NULL)
- lang_id = gtk_source_language_get_id (lang);
- else
- lang_id = LANGUAGE_NONE;
+ lang = pluma_document_get_language (doc);
+ if (lang != NULL)
+ lang_id = gtk_source_language_get_id (lang);
+ else
+ lang_id = LANGUAGE_NONE;
- actions = gtk_action_group_list_actions (window->priv->languages_action_group);
+ actions = gtk_action_group_list_actions (window->priv->languages_action_group);
- /* prevent recursion */
- for (l = actions; l != NULL; l = l->next)
- {
- g_signal_handlers_block_by_func (GTK_ACTION (l->data),
- G_CALLBACK (language_toggled),
- window);
- }
+ /* prevent recursion */
+ for (l = actions; l != NULL; l = l->next)
+ {
+ g_signal_handlers_block_by_func (GTK_ACTION (l->data),
+ G_CALLBACK (language_toggled),
+ window);
+ }
- action = gtk_action_group_get_action (window->priv->languages_action_group,
- lang_id);
+ action = gtk_action_group_get_action (window->priv->languages_action_group,
+ lang_id);
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
- for (l = actions; l != NULL; l = l->next)
- {
- g_signal_handlers_unblock_by_func (GTK_ACTION (l->data),
- G_CALLBACK (language_toggled),
- window);
- }
+ for (l = actions; l != NULL; l = l->next)
+ {
+ g_signal_handlers_unblock_by_func (GTK_ACTION (l->data),
+ G_CALLBACK (language_toggled),
+ window);
+ }
- g_list_free (actions);
+ g_list_free (actions);
}
void
_pluma_recent_add (PlumaWindow *window,
- const gchar *uri,
- const gchar *mime)
+ const gchar *uri,
+ const gchar *mime)
{
- GtkRecentManager *recent_manager;
- GtkRecentData recent_data;
+ GtkRecentManager *recent_manager;
+ GtkRecentData recent_data;
- static gchar *groups[2] = {
- "pluma",
- NULL
- };
+ static gchar *groups[2] = {
+ "pluma",
+ NULL
+ };
- recent_manager = gtk_recent_manager_get_default ();
+ recent_manager = gtk_recent_manager_get_default ();
- recent_data.display_name = NULL;
- recent_data.description = NULL;
- recent_data.mime_type = (gchar *) mime;
- recent_data.app_name = (gchar *) g_get_application_name ();
- recent_data.app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
- recent_data.groups = groups;
- recent_data.is_private = FALSE;
+ recent_data.display_name = NULL;
+ recent_data.description = NULL;
+ recent_data.mime_type = (gchar *) mime;
+ recent_data.app_name = (gchar *) g_get_application_name ();
+ recent_data.app_exec = g_strjoin (" ", g_get_prgname (), "%u", NULL);
+ recent_data.groups = groups;
+ recent_data.is_private = FALSE;
- gtk_recent_manager_add_full (recent_manager,
- uri,
- &recent_data);
+ gtk_recent_manager_add_full (recent_manager,
+ uri,
+ &recent_data);
- g_free (recent_data.app_exec);
+ g_free (recent_data.app_exec);
}
void
_pluma_recent_remove (PlumaWindow *window,
- const gchar *uri)
+ const gchar *uri)
{
- GtkRecentManager *recent_manager;
+ GtkRecentManager *recent_manager;
- recent_manager = gtk_recent_manager_get_default ();
+ recent_manager = gtk_recent_manager_get_default ();
- gtk_recent_manager_remove_item (recent_manager, uri, NULL);
+ gtk_recent_manager_remove_item (recent_manager, uri, NULL);
}
static void
open_recent_file (const gchar *uri,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- GSList *uris = NULL;
+ GSList *uris = NULL;
- uris = g_slist_prepend (uris, (gpointer) uri);
+ uris = g_slist_prepend (uris, (gpointer) uri);
- if (pluma_commands_load_uris (window, uris, NULL, 0) != 1)
- {
- _pluma_recent_remove (window, uri);
- }
+ if (pluma_commands_load_uris (window, uris, NULL, 0) != 1)
+ {
+ _pluma_recent_remove (window, uri);
+ }
- g_slist_free (uris);
+ g_slist_free (uris);
}
static void
recent_chooser_item_activated (GtkRecentChooser *chooser,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- gchar *uri;
+ gchar *uri;
- uri = gtk_recent_chooser_get_current_uri (chooser);
+ uri = gtk_recent_chooser_get_current_uri (chooser);
- open_recent_file (uri, window);
+ open_recent_file (uri, window);
- g_free (uri);
+ g_free (uri);
}
static void
recents_menu_activate (GtkAction *action,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- GtkRecentInfo *info;
- const gchar *uri;
+ GtkRecentInfo *info;
+ const gchar *uri;
- info = g_object_get_data (G_OBJECT (action), "gtk-recent-info");
- g_return_if_fail (info != NULL);
+ info = g_object_get_data (G_OBJECT (action), "gtk-recent-info");
+ g_return_if_fail (info != NULL);
- uri = gtk_recent_info_get_uri (info);
+ uri = gtk_recent_info_get_uri (info);
- open_recent_file (uri, window);
+ open_recent_file (uri, window);
}
static gint
sort_recents_mru (GtkRecentInfo *a, GtkRecentInfo *b)
{
- return (gtk_recent_info_get_modified (b) - gtk_recent_info_get_modified (a));
+ return (gtk_recent_info_get_modified (b) - gtk_recent_info_get_modified (a));
}
-static void update_recent_files_menu (PlumaWindow *window);
+static void update_recent_files_menu (PlumaWindow *window);
static void
recent_manager_changed (GtkRecentManager *manager,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- /* regenerate the menu when the model changes */
- update_recent_files_menu (window);
+ /* regenerate the menu when the model changes */
+ update_recent_files_menu (window);
}
/*
@@ -1280,902 +1273,896 @@ recent_manager_changed (GtkRecentManager *manager,
static void
update_recent_files_menu (PlumaWindow *window)
{
- PlumaWindowPrivate *p = window->priv;
- GtkRecentManager *recent_manager;
- guint max_recents;
- GList *actions, *l, *items;
- GList *filtered_items = NULL;
- gint i;
-
- pluma_debug (DEBUG_WINDOW);
-
- max_recents = g_settings_get_uint (window->priv->editor_settings, PLUMA_SETTINGS_MAX_RECENTS);
-
- g_return_if_fail (p->recents_action_group != NULL);
-
- if (p->recents_menu_ui_id != 0)
- gtk_ui_manager_remove_ui (p->manager,
- p->recents_menu_ui_id);
-
- actions = gtk_action_group_list_actions (p->recents_action_group);
- for (l = actions; l != NULL; l = l->next)
- {
- g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
- G_CALLBACK (recents_menu_activate),
- window);
- gtk_action_group_remove_action (p->recents_action_group,
- GTK_ACTION (l->data));
- }
- g_list_free (actions);
-
- p->recents_menu_ui_id = gtk_ui_manager_new_merge_id (p->manager);
-
- recent_manager = gtk_recent_manager_get_default ();
- items = gtk_recent_manager_get_items (recent_manager);
-
- /* filter */
- for (l = items; l != NULL; l = l->next)
- {
- GtkRecentInfo *info = l->data;
-
- if (!gtk_recent_info_has_group (info, "pluma"))
- continue;
-
- filtered_items = g_list_prepend (filtered_items, info);
- }
-
- /* sort */
- filtered_items = g_list_sort (filtered_items,
- (GCompareFunc) sort_recents_mru);
-
- i = 0;
- for (l = filtered_items; l != NULL; l = l->next)
- {
- gchar *action_name;
- const gchar *display_name;
- gchar *escaped;
- gchar *label;
- gchar *uri;
- gchar *ruri;
- gchar *tip;
- GtkAction *action;
- GtkRecentInfo *info = l->data;
-
- /* clamp */
- if (i >= max_recents)
- break;
-
- i++;
-
- action_name = g_strdup_printf ("recent-info-%d", i);
-
- display_name = gtk_recent_info_get_display_name (info);
- escaped = pluma_utils_escape_underscores (display_name, -1);
- if (i >= 10)
- label = g_strdup_printf ("%d. %s",
- i,
- escaped);
- else
- label = g_strdup_printf ("_%d. %s",
- i,
- escaped);
- g_free (escaped);
-
- /* gtk_recent_info_get_uri_display (info) is buggy and
- * works only for local files */
- uri = pluma_utils_uri_for_display (gtk_recent_info_get_uri (info));
- ruri = pluma_utils_replace_home_dir_with_tilde (uri);
- g_free (uri);
-
- /* Translators: %s is a URI */
- tip = g_strdup_printf (_("Open '%s'"), ruri);
- g_free (ruri);
-
- action = gtk_action_new (action_name,
- label,
- tip,
- NULL);
-
- g_object_set_data_full (G_OBJECT (action),
- "gtk-recent-info",
- gtk_recent_info_ref (info),
- (GDestroyNotify) gtk_recent_info_unref);
-
- g_signal_connect (action,
- "activate",
- G_CALLBACK (recents_menu_activate),
- window);
-
- gtk_action_group_add_action (p->recents_action_group,
- action);
- g_object_unref (action);
-
- gtk_ui_manager_add_ui (p->manager,
- p->recents_menu_ui_id,
- "/MenuBar/FileMenu/FileRecentsPlaceholder",
- action_name,
- action_name,
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
-
- g_free (action_name);
- g_free (label);
- g_free (tip);
- }
-
- g_list_free (filtered_items);
-
- g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
+ PlumaWindowPrivate *p = window->priv;
+ GtkRecentManager *recent_manager;
+ guint max_recents;
+ GList *actions, *l, *items;
+ GList *filtered_items = NULL;
+ gint i;
+
+ pluma_debug (DEBUG_WINDOW);
+
+ max_recents = g_settings_get_uint (window->priv->editor_settings, PLUMA_SETTINGS_MAX_RECENTS);
+
+ g_return_if_fail (p->recents_action_group != NULL);
+
+ if (p->recents_menu_ui_id != 0)
+ gtk_ui_manager_remove_ui (p->manager, p->recents_menu_ui_id);
+
+ actions = gtk_action_group_list_actions (p->recents_action_group);
+ for (l = actions; l != NULL; l = l->next)
+ {
+ g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
+ G_CALLBACK (recents_menu_activate),
+ window);
+ gtk_action_group_remove_action (p->recents_action_group,
+ GTK_ACTION (l->data));
+ }
+ g_list_free (actions);
+
+ p->recents_menu_ui_id = gtk_ui_manager_new_merge_id (p->manager);
+
+ recent_manager = gtk_recent_manager_get_default ();
+ items = gtk_recent_manager_get_items (recent_manager);
+
+ /* filter */
+ for (l = items; l != NULL; l = l->next)
+ {
+ GtkRecentInfo *info = l->data;
+
+ if (!gtk_recent_info_has_group (info, "pluma"))
+ continue;
+
+ filtered_items = g_list_prepend (filtered_items, info);
+ }
+
+ /* sort */
+ filtered_items = g_list_sort (filtered_items,
+ (GCompareFunc) sort_recents_mru);
+
+ i = 0;
+ for (l = filtered_items; l != NULL; l = l->next)
+ {
+ gchar *action_name;
+ const gchar *display_name;
+ gchar *escaped;
+ gchar *label;
+ gchar *uri;
+ gchar *ruri;
+ gchar *tip;
+ GtkAction *action;
+ GtkRecentInfo *info = l->data;
+
+ /* clamp */
+ if (i >= max_recents)
+ break;
+
+ i++;
+
+ action_name = g_strdup_printf ("recent-info-%d", i);
+
+ display_name = gtk_recent_info_get_display_name (info);
+ escaped = pluma_utils_escape_underscores (display_name, -1);
+ if (i >= 10)
+ label = g_strdup_printf ("%d. %s",
+ i,
+ escaped);
+ else
+ label = g_strdup_printf ("_%d. %s",
+ i,
+ escaped);
+ g_free (escaped);
+
+ /* gtk_recent_info_get_uri_display (info) is buggy and
+ * works only for local files */
+ uri = pluma_utils_uri_for_display (gtk_recent_info_get_uri (info));
+ ruri = pluma_utils_replace_home_dir_with_tilde (uri);
+ g_free (uri);
+
+ /* Translators: %s is a URI */
+ tip = g_strdup_printf (_("Open '%s'"), ruri);
+ g_free (ruri);
+
+ action = gtk_action_new (action_name,
+ label,
+ tip,
+ NULL);
+
+ g_object_set_data_full (G_OBJECT (action),
+ "gtk-recent-info",
+ gtk_recent_info_ref (info),
+ (GDestroyNotify) gtk_recent_info_unref);
+
+ g_signal_connect (action,
+ "activate",
+ G_CALLBACK (recents_menu_activate),
+ window);
+
+ gtk_action_group_add_action (p->recents_action_group,
+ action);
+ g_object_unref (action);
+
+ gtk_ui_manager_add_ui (p->manager,
+ p->recents_menu_ui_id,
+ "/MenuBar/FileMenu/FileRecentsPlaceholder",
+ action_name,
+ action_name,
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+
+ g_free (action_name);
+ g_free (label);
+ g_free (tip);
+ }
+
+ g_list_free (filtered_items);
+
+ g_list_free_full (items, (GDestroyNotify) gtk_recent_info_unref);
}
static void
set_non_homogeneus (GtkWidget *widget, gpointer data)
{
- gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (widget), FALSE);
+ gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (widget), FALSE);
}
static void
toolbar_visibility_changed (GtkWidget *toolbar,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- gboolean visible;
- GtkAction *action;
+ gboolean visible;
+ GtkAction *action;
- visible = gtk_widget_get_visible (toolbar);
+ visible = gtk_widget_get_visible (toolbar);
- g_settings_set_boolean (window->priv->editor_settings,
- PLUMA_SETTINGS_TOOLBAR_VISIBLE, visible);
+ g_settings_set_boolean (window->priv->editor_settings,
+ PLUMA_SETTINGS_TOOLBAR_VISIBLE, visible);
- action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
- "ViewToolbar");
+ action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
+ "ViewToolbar");
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
}
static GtkWidget *
setup_toolbar_open_button (PlumaWindow *window,
- GtkWidget *toolbar)
+ GtkWidget *toolbar)
{
- GtkRecentManager *recent_manager;
- GtkRecentFilter *filter;
- GtkWidget *toolbar_recent_menu;
- GtkToolItem *open_button;
- GtkAction *action;
- guint max_recents;
+ GtkRecentManager *recent_manager;
+ GtkRecentFilter *filter;
+ GtkWidget *toolbar_recent_menu;
+ GtkToolItem *open_button;
+ GtkAction *action;
+ guint max_recents;
- recent_manager = gtk_recent_manager_get_default ();
+ recent_manager = gtk_recent_manager_get_default ();
- max_recents = g_settings_get_uint (window->priv->editor_settings, PLUMA_SETTINGS_MAX_RECENTS);
+ max_recents = g_settings_get_uint (window->priv->editor_settings, PLUMA_SETTINGS_MAX_RECENTS);
- /* recent files menu tool button */
- toolbar_recent_menu = gtk_recent_chooser_menu_new_for_manager (recent_manager);
+ /* recent files menu tool button */
+ toolbar_recent_menu = gtk_recent_chooser_menu_new_for_manager (recent_manager);
- gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (toolbar_recent_menu),
- FALSE);
- gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (toolbar_recent_menu),
- GTK_RECENT_SORT_MRU);
- gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (toolbar_recent_menu),
- max_recents);
+ gtk_recent_chooser_set_local_only (GTK_RECENT_CHOOSER (toolbar_recent_menu),
+ FALSE);
+ gtk_recent_chooser_set_sort_type (GTK_RECENT_CHOOSER (toolbar_recent_menu),
+ GTK_RECENT_SORT_MRU);
+ gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (toolbar_recent_menu),
+ max_recents);
- filter = gtk_recent_filter_new ();
- gtk_recent_filter_add_group (filter, "pluma");
- gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (toolbar_recent_menu),
- filter);
+ filter = gtk_recent_filter_new ();
+ gtk_recent_filter_add_group (filter, "pluma");
+ gtk_recent_chooser_set_filter (GTK_RECENT_CHOOSER (toolbar_recent_menu),
+ filter);
- g_signal_connect (toolbar_recent_menu,
- "item_activated",
- G_CALLBACK (recent_chooser_item_activated),
- window);
+ g_signal_connect (toolbar_recent_menu,
+ "item_activated",
+ G_CALLBACK (recent_chooser_item_activated),
+ window);
- /* add the custom Open button to the toolbar */
- open_button = gtk_menu_tool_button_new (gtk_image_new_from_icon_name ("document-open",
- GTK_ICON_SIZE_MENU),
- _("Open a file"));
+ /* add the custom Open button to the toolbar */
+ open_button = gtk_menu_tool_button_new (gtk_image_new_from_icon_name ("document-open",
+ GTK_ICON_SIZE_MENU),
+ _("Open a file"));
- gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (open_button),
- toolbar_recent_menu);
+ gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (open_button),
+ toolbar_recent_menu);
- gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (open_button),
- _("Open a recently used file"));
+ gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (open_button),
+ _("Open a recently used file"));
- action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
- "FileOpen");
- g_object_set (action,
- "is_important", TRUE,
- "short_label", _("Open"),
- NULL);
- gtk_activatable_set_related_action (GTK_ACTIVATABLE (open_button),
- action);
+ action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
+ "FileOpen");
+ g_object_set (action,
+ "is_important", TRUE,
+ "short_label", _("Open"),
+ NULL);
+ gtk_activatable_set_related_action (GTK_ACTIVATABLE (open_button),
+ action);
- gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
- open_button,
- 1);
+ gtk_toolbar_insert (GTK_TOOLBAR (toolbar),
+ open_button,
+ 1);
- return toolbar_recent_menu;
+ return toolbar_recent_menu;
}
static void
create_menu_bar_and_toolbar (PlumaWindow *window,
- GtkWidget *main_box)
-{
- GtkActionGroup *action_group;
- GtkAction *action;
- GtkUIManager *manager;
- GtkRecentManager *recent_manager;
- GError *error = NULL;
-
- pluma_debug (DEBUG_WINDOW);
-
- manager = gtk_ui_manager_new ();
- window->priv->manager = manager;
-
- gtk_window_add_accel_group (GTK_WINDOW (window),
- gtk_ui_manager_get_accel_group (manager));
-
- action_group = gtk_action_group_new ("PlumaWindowAlwaysSensitiveActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- gtk_action_group_add_actions (action_group,
- pluma_always_sensitive_menu_entries,
- G_N_ELEMENTS (pluma_always_sensitive_menu_entries),
- window);
- gtk_action_group_add_toggle_actions (action_group,
- pluma_always_sensitive_toggle_menu_entries,
- G_N_ELEMENTS (pluma_always_sensitive_toggle_menu_entries),
- window);
-
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- g_object_unref (action_group);
- window->priv->always_sensitive_action_group = action_group;
-
- action_group = gtk_action_group_new ("PlumaWindowActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- gtk_action_group_add_actions (action_group,
- pluma_menu_entries,
- G_N_ELEMENTS (pluma_menu_entries),
- window);
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- g_object_unref (action_group);
- window->priv->action_group = action_group;
-
- /* set short labels to use in the toolbar */
- action = gtk_action_group_get_action (action_group, "FileSave");
- g_object_set (action, "short_label", _("Save"), NULL);
- action = gtk_action_group_get_action (action_group, "FilePrint");
- g_object_set (action, "short_label", _("Print"), NULL);
- action = gtk_action_group_get_action (action_group, "SearchFind");
- g_object_set (action, "short_label", _("Find"), NULL);
- action = gtk_action_group_get_action (action_group, "SearchReplace");
- g_object_set (action, "short_label", _("Replace"), NULL);
-
- /* set which actions should have priority on the toolbar */
- action = gtk_action_group_get_action (action_group, "FileSave");
- g_object_set (action, "is_important", TRUE, NULL);
- action = gtk_action_group_get_action (action_group, "EditUndo");
- g_object_set (action, "is_important", TRUE, NULL);
-
- action_group = gtk_action_group_new ("PlumaQuitWindowActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- gtk_action_group_add_actions (action_group,
- pluma_quit_menu_entries,
- G_N_ELEMENTS (pluma_quit_menu_entries),
- window);
-
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- g_object_unref (action_group);
- window->priv->quit_action_group = action_group;
-
- action_group = gtk_action_group_new ("PlumaCloseWindowActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- gtk_action_group_add_actions (action_group,
- pluma_close_menu_entries,
- G_N_ELEMENTS (pluma_close_menu_entries),
- window);
-
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- g_object_unref (action_group);
- window->priv->close_action_group = action_group;
-
- action_group = gtk_action_group_new ("PlumaWindowPanesActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- gtk_action_group_add_toggle_actions (action_group,
- pluma_panes_toggle_menu_entries,
- G_N_ELEMENTS (pluma_panes_toggle_menu_entries),
- window);
-
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- g_object_unref (action_group);
- window->priv->panes_action_group = action_group;
-
- /* now load the UI definition */
- gtk_ui_manager_add_ui_from_file (manager,
- PLUMA_DATADIR "/ui/pluma-ui.xml",
- &error);
- if (error != NULL)
- {
- g_warning ("Could not merge %s: %s",
- PLUMA_DATADIR "/ui/pluma-ui.xml",
- error->message);
- g_error_free (error);
- }
-
- /* show tooltips in the statusbar */
- g_signal_connect (manager,
- "connect_proxy",
- G_CALLBACK (connect_proxy_cb),
- window);
- g_signal_connect (manager,
- "disconnect_proxy",
- G_CALLBACK (disconnect_proxy_cb),
- window);
-
- /* recent files menu */
- action_group = gtk_action_group_new ("RecentFilesActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- window->priv->recents_action_group = action_group;
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- g_object_unref (action_group);
-
- recent_manager = gtk_recent_manager_get_default ();
- window->priv->recents_handler_id = g_signal_connect (recent_manager,
- "changed",
- G_CALLBACK (recent_manager_changed),
- window);
- update_recent_files_menu (window);
-
- /* languages menu */
- action_group = gtk_action_group_new ("LanguagesActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- window->priv->languages_action_group = action_group;
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- g_object_unref (action_group);
- create_languages_menu (window);
-
- /* list of open documents menu */
- action_group = gtk_action_group_new ("DocumentsListActions");
- gtk_action_group_set_translation_domain (action_group, NULL);
- window->priv->documents_list_action_group = action_group;
- gtk_ui_manager_insert_action_group (manager, action_group, 0);
- g_object_unref (action_group);
-
- window->priv->menubar = gtk_ui_manager_get_widget (manager, "/MenuBar");
- gtk_box_pack_start (GTK_BOX (main_box),
- window->priv->menubar,
- FALSE,
- FALSE,
- 0);
-
- window->priv->toolbar = gtk_ui_manager_get_widget (manager, "/ToolBar");
- gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->toolbar),
- GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
- gtk_box_pack_start (GTK_BOX (main_box),
- window->priv->toolbar,
- FALSE,
- FALSE,
- 0);
-
- set_toolbar_style (window, NULL);
-
- window->priv->toolbar_recent_menu = setup_toolbar_open_button (window,
- window->priv->toolbar);
-
- gtk_container_foreach (GTK_CONTAINER (window->priv->toolbar),
- (GtkCallback)set_non_homogeneus,
- NULL);
-
- g_signal_connect_after (G_OBJECT (window->priv->toolbar),
- "show",
- G_CALLBACK (toolbar_visibility_changed),
- window);
- g_signal_connect_after (G_OBJECT (window->priv->toolbar),
- "hide",
- G_CALLBACK (toolbar_visibility_changed),
- window);
+ GtkWidget *main_box)
+{
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ GtkUIManager *manager;
+ GtkRecentManager *recent_manager;
+ GError *error = NULL;
+ gchar *ui_file;
+
+ pluma_debug (DEBUG_WINDOW);
+
+ manager = gtk_ui_manager_new ();
+ window->priv->manager = manager;
+
+ gtk_window_add_accel_group (GTK_WINDOW (window),
+ gtk_ui_manager_get_accel_group (manager));
+
+ action_group = gtk_action_group_new ("PlumaWindowAlwaysSensitiveActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group,
+ pluma_always_sensitive_menu_entries,
+ G_N_ELEMENTS (pluma_always_sensitive_menu_entries),
+ window);
+ gtk_action_group_add_toggle_actions (action_group,
+ pluma_always_sensitive_toggle_menu_entries,
+ G_N_ELEMENTS (pluma_always_sensitive_toggle_menu_entries),
+ window);
+
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ g_object_unref (action_group);
+ window->priv->always_sensitive_action_group = action_group;
+
+ action_group = gtk_action_group_new ("PlumaWindowActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group,
+ pluma_menu_entries,
+ G_N_ELEMENTS (pluma_menu_entries),
+ window);
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ g_object_unref (action_group);
+ window->priv->action_group = action_group;
+
+ /* set short labels to use in the toolbar */
+ action = gtk_action_group_get_action (action_group, "FileSave");
+ g_object_set (action, "short_label", _("Save"), NULL);
+ action = gtk_action_group_get_action (action_group, "FilePrint");
+ g_object_set (action, "short_label", _("Print"), NULL);
+ action = gtk_action_group_get_action (action_group, "SearchFind");
+ g_object_set (action, "short_label", _("Find"), NULL);
+ action = gtk_action_group_get_action (action_group, "SearchReplace");
+ g_object_set (action, "short_label", _("Replace"), NULL);
+
+ /* set which actions should have priority on the toolbar */
+ action = gtk_action_group_get_action (action_group, "FileSave");
+ g_object_set (action, "is_important", TRUE, NULL);
+ action = gtk_action_group_get_action (action_group, "EditUndo");
+ g_object_set (action, "is_important", TRUE, NULL);
+
+ action_group = gtk_action_group_new ("PlumaQuitWindowActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group,
+ pluma_quit_menu_entries,
+ G_N_ELEMENTS (pluma_quit_menu_entries),
+ window);
+
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ g_object_unref (action_group);
+ window->priv->quit_action_group = action_group;
+
+ action_group = gtk_action_group_new ("PlumaCloseWindowActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_actions (action_group,
+ pluma_close_menu_entries,
+ G_N_ELEMENTS (pluma_close_menu_entries),
+ window);
+
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ g_object_unref (action_group);
+ window->priv->close_action_group = action_group;
+
+ action_group = gtk_action_group_new ("PlumaWindowPanesActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ gtk_action_group_add_toggle_actions (action_group,
+ pluma_panes_toggle_menu_entries,
+ G_N_ELEMENTS (pluma_panes_toggle_menu_entries),
+ window);
+
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ g_object_unref (action_group);
+ window->priv->panes_action_group = action_group;
+
+ /* now load the UI definition */
+ gtk_ui_manager_add_ui_from_file (manager,
+ PLUMA_DATADIR "/ui/pluma-ui.xml",
+ &error);
+ if (error != NULL)
+ {
+ g_warning ("Could not merge %s: %s",
+ PLUMA_DATADIR "/ui/pluma-ui.xml",
+ error->message);
+ g_error_free (error);
+ }
+
+ /* show tooltips in the statusbar */
+ g_signal_connect (manager,
+ "connect_proxy",
+ G_CALLBACK (connect_proxy_cb),
+ window);
+ g_signal_connect (manager,
+ "disconnect_proxy",
+ G_CALLBACK (disconnect_proxy_cb),
+ window);
+
+ /* recent files menu */
+ action_group = gtk_action_group_new ("RecentFilesActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ window->priv->recents_action_group = action_group;
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ g_object_unref (action_group);
+
+ recent_manager = gtk_recent_manager_get_default ();
+ window->priv->recents_handler_id = g_signal_connect (recent_manager,
+ "changed",
+ G_CALLBACK (recent_manager_changed),
+ window);
+ update_recent_files_menu (window);
+
+ /* languages menu */
+ action_group = gtk_action_group_new ("LanguagesActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ window->priv->languages_action_group = action_group;
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ g_object_unref (action_group);
+ create_languages_menu (window);
+
+ /* list of open documents menu */
+ action_group = gtk_action_group_new ("DocumentsListActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ window->priv->documents_list_action_group = action_group;
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ g_object_unref (action_group);
+
+ window->priv->menubar = gtk_ui_manager_get_widget (manager, "/MenuBar");
+ gtk_box_pack_start (GTK_BOX (main_box),
+ window->priv->menubar,
+ FALSE,
+ FALSE,
+ 0);
+
+ window->priv->toolbar = gtk_ui_manager_get_widget (manager, "/ToolBar");
+ gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->toolbar),
+ GTK_STYLE_CLASS_PRIMARY_TOOLBAR);
+ gtk_box_pack_start (GTK_BOX (main_box),
+ window->priv->toolbar,
+ FALSE,
+ FALSE,
+ 0);
+
+ set_toolbar_style (window, NULL);
+
+ window->priv->toolbar_recent_menu = setup_toolbar_open_button (window, window->priv->toolbar);
+
+ gtk_container_foreach (GTK_CONTAINER (window->priv->toolbar),
+ (GtkCallback)set_non_homogeneus,
+ NULL);
+
+ g_signal_connect_after (G_OBJECT (window->priv->toolbar),
+ "show",
+ G_CALLBACK (toolbar_visibility_changed),
+ window);
+ g_signal_connect_after (G_OBJECT (window->priv->toolbar),
+ "hide",
+ G_CALLBACK (toolbar_visibility_changed),
+ window);
}
static void
documents_list_menu_activate (GtkToggleAction *action,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- gint n;
+ gint n;
- if (gtk_toggle_action_get_active (action) == FALSE)
- return;
+ if (gtk_toggle_action_get_active (action) == FALSE)
+ return;
- n = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
- gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), n);
+ n = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), n);
}
static gchar *
get_menu_tip_for_tab (PlumaTab *tab)
{
- PlumaDocument *doc;
- gchar *uri;
- gchar *ruri;
- gchar *tip;
+ PlumaDocument *doc;
+ gchar *uri;
+ gchar *ruri;
+ gchar *tip;
- doc = pluma_tab_get_document (tab);
+ doc = pluma_tab_get_document (tab);
- uri = pluma_document_get_uri_for_display (doc);
- ruri = pluma_utils_replace_home_dir_with_tilde (uri);
- g_free (uri);
+ uri = pluma_document_get_uri_for_display (doc);
+ ruri = pluma_utils_replace_home_dir_with_tilde (uri);
+ g_free (uri);
- /* Translators: %s is a URI */
- tip = g_strdup_printf (_("Activate '%s'"), ruri);
- g_free (ruri);
+ /* Translators: %s is a URI */
+ tip = g_strdup_printf (_("Activate '%s'"), ruri);
+ g_free (ruri);
- return tip;
+ return tip;
}
static void
update_documents_list_menu (PlumaWindow *window)
{
- PlumaWindowPrivate *p = window->priv;
- GList *actions, *l;
- gint n, i;
- guint id;
- GSList *group = NULL;
-
- pluma_debug (DEBUG_WINDOW);
-
- g_return_if_fail (p->documents_list_action_group != NULL);
-
- if (p->documents_list_menu_ui_id != 0)
- gtk_ui_manager_remove_ui (p->manager,
- p->documents_list_menu_ui_id);
-
- actions = gtk_action_group_list_actions (p->documents_list_action_group);
- for (l = actions; l != NULL; l = l->next)
- {
- g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
- G_CALLBACK (documents_list_menu_activate),
- window);
- gtk_action_group_remove_action (p->documents_list_action_group,
- GTK_ACTION (l->data));
- }
- g_list_free (actions);
-
- n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (p->notebook));
-
- id = (n > 0) ? gtk_ui_manager_new_merge_id (p->manager) : 0;
-
- for (i = 0; i < n; i++)
- {
- GtkWidget *tab;
- GtkRadioAction *action;
- gchar *action_name;
- gchar *tab_name;
- gchar *name;
- gchar *tip;
- gchar *accel;
-
- tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (p->notebook), i);
-
- /* NOTE: the action is associated to the position of the tab in
- * the notebook not to the tab itself! This is needed to work
- * around the gtk+ bug #170727: gtk leaves around the accels
- * of the action. Since the accel depends on the tab position
- * the problem is worked around, action with the same name always
- * get the same accel.
- */
- action_name = g_strdup_printf ("Tab_%d", i);
- tab_name = _pluma_tab_get_name (PLUMA_TAB (tab));
- name = pluma_utils_escape_underscores (tab_name, -1);
- tip = get_menu_tip_for_tab (PLUMA_TAB (tab));
-
- /* alt + 1, 2, 3... 0 to switch to the first ten tabs */
- accel = (i < 10) ? g_strdup_printf ("<alt>%d", (i + 1) % 10) : NULL;
-
- action = gtk_radio_action_new (action_name,
- name,
- tip,
- NULL,
- i);
-
- if (group != NULL)
- gtk_radio_action_set_group (action, group);
-
- /* note that group changes each time we add an action, so it must be updated */
- group = gtk_radio_action_get_group (action);
-
- gtk_action_group_add_action_with_accel (p->documents_list_action_group,
- GTK_ACTION (action),
- accel);
-
- g_signal_connect (action,
- "activate",
- G_CALLBACK (documents_list_menu_activate),
- window);
-
- gtk_ui_manager_add_ui (p->manager,
- id,
- "/MenuBar/DocumentsMenu/DocumentsListPlaceholder",
- action_name, action_name,
- GTK_UI_MANAGER_MENUITEM,
- FALSE);
-
- if (PLUMA_TAB (tab) == p->active_tab)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-
- g_object_unref (action);
-
- g_free (action_name);
- g_free (tab_name);
- g_free (name);
- g_free (tip);
- g_free (accel);
- }
-
- p->documents_list_menu_ui_id = id;
+ PlumaWindowPrivate *p = window->priv;
+ GList *actions, *l;
+ gint n, i;
+ guint id;
+ GSList *group = NULL;
+
+ pluma_debug (DEBUG_WINDOW);
+
+ g_return_if_fail (p->documents_list_action_group != NULL);
+
+ if (p->documents_list_menu_ui_id != 0)
+ gtk_ui_manager_remove_ui (p->manager,
+ p->documents_list_menu_ui_id);
+
+ actions = gtk_action_group_list_actions (p->documents_list_action_group);
+ for (l = actions; l != NULL; l = l->next)
+ {
+ g_signal_handlers_disconnect_by_func (GTK_ACTION (l->data),
+ G_CALLBACK (documents_list_menu_activate),
+ window);
+ gtk_action_group_remove_action (p->documents_list_action_group,
+ GTK_ACTION (l->data));
+ }
+ g_list_free (actions);
+
+ n = gtk_notebook_get_n_pages (GTK_NOTEBOOK (p->notebook));
+
+ id = (n > 0) ? gtk_ui_manager_new_merge_id (p->manager) : 0;
+
+ for (i = 0; i < n; i++)
+ {
+ GtkWidget *tab;
+ GtkRadioAction *action;
+ gchar *action_name;
+ gchar *tab_name;
+ gchar *name;
+ gchar *tip;
+ gchar *accel;
+
+ tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (p->notebook), i);
+
+ /* NOTE: the action is associated to the position of the tab in
+ * the notebook not to the tab itself! This is needed to work
+ * around the gtk+ bug #170727: gtk leaves around the accels
+ * of the action. Since the accel depends on the tab position
+ * the problem is worked around, action with the same name always
+ * get the same accel.
+ */
+ action_name = g_strdup_printf ("Tab_%d", i);
+ tab_name = _pluma_tab_get_name (PLUMA_TAB (tab));
+ name = pluma_utils_escape_underscores (tab_name, -1);
+ tip = get_menu_tip_for_tab (PLUMA_TAB (tab));
+
+ /* alt + 1, 2, 3... 0 to switch to the first ten tabs */
+ accel = (i < 10) ? g_strdup_printf ("<alt>%d", (i + 1) % 10) : NULL;
+
+ action = gtk_radio_action_new (action_name,
+ name,
+ tip,
+ NULL,
+ i);
+
+ if (group != NULL)
+ gtk_radio_action_set_group (action, group);
+
+ /* note that group changes each time we add an action, so it must be updated */
+ group = gtk_radio_action_get_group (action);
+
+ gtk_action_group_add_action_with_accel (p->documents_list_action_group,
+ GTK_ACTION (action),
+ accel);
+
+ g_signal_connect (action,
+ "activate",
+ G_CALLBACK (documents_list_menu_activate),
+ window);
+
+ gtk_ui_manager_add_ui (p->manager,
+ id,
+ "/MenuBar/DocumentsMenu/DocumentsListPlaceholder",
+ action_name, action_name,
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+
+ if (PLUMA_TAB (tab) == p->active_tab)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+
+ g_object_unref (action);
+
+ g_free (action_name);
+ g_free (tab_name);
+ g_free (name);
+ g_free (tip);
+ g_free (accel);
+ }
+
+ p->documents_list_menu_ui_id = id;
}
/* Returns TRUE if status bar is visible */
static gboolean
set_statusbar_style (PlumaWindow *window,
- PlumaWindow *origin)
+ PlumaWindow *origin)
{
- GtkAction *action;
- gboolean visible;
+ GtkAction *action;
+ gboolean visible;
- if (origin == NULL)
- visible = g_settings_get_boolean (window->priv->editor_settings,
- PLUMA_SETTINGS_STATUSBAR_VISIBLE);
- else
- visible = gtk_widget_get_visible (origin->priv->statusbar);
+ if (origin == NULL)
+ visible = g_settings_get_boolean (window->priv->editor_settings,
+ PLUMA_SETTINGS_STATUSBAR_VISIBLE);
+ else
+ visible = gtk_widget_get_visible (origin->priv->statusbar);
- if (visible)
- gtk_widget_show (window->priv->statusbar);
- else
- gtk_widget_hide (window->priv->statusbar);
+ if (visible)
+ gtk_widget_show (window->priv->statusbar);
+ else
+ gtk_widget_hide (window->priv->statusbar);
- action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
- "ViewStatusbar");
+ action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
+ "ViewStatusbar");
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
- return visible;
+ return visible;
}
static void
statusbar_visibility_changed (GtkWidget *statusbar,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- gboolean visible;
- GtkAction *action;
+ gboolean visible;
+ GtkAction *action;
- visible = gtk_widget_get_visible (statusbar);
+ visible = gtk_widget_get_visible (statusbar);
- g_settings_set_boolean (window->priv->editor_settings,
- PLUMA_SETTINGS_STATUSBAR_VISIBLE, visible);
+ g_settings_set_boolean (window->priv->editor_settings,
+ PLUMA_SETTINGS_STATUSBAR_VISIBLE, visible);
- action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
- "ViewStatusbar");
+ action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
+ "ViewStatusbar");
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
}
static void
tab_width_combo_changed (PlumaStatusComboBox *combo,
- GtkMenuItem *item,
- PlumaWindow *window)
+ GtkMenuItem *item,
+ PlumaWindow *window)
{
- PlumaView *view;
- guint width_data = 0;
+ PlumaView *view;
+ guint width_data = 0;
- view = pluma_window_get_active_view (window);
+ view = pluma_window_get_active_view (window);
- if (!view)
- return;
+ if (!view)
+ return;
- width_data = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), TAB_WIDTH_DATA));
+ width_data = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), TAB_WIDTH_DATA));
- if (width_data == 0)
- return;
+ if (width_data == 0)
+ return;
- g_signal_handler_block (view, window->priv->tab_width_id);
- gtk_source_view_set_tab_width (GTK_SOURCE_VIEW (view), width_data);
- g_signal_handler_unblock (view, window->priv->tab_width_id);
+ g_signal_handler_block (view, window->priv->tab_width_id);
+ gtk_source_view_set_tab_width (GTK_SOURCE_VIEW (view), width_data);
+ g_signal_handler_unblock (view, window->priv->tab_width_id);
}
static void
use_spaces_toggled (GtkCheckMenuItem *item,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- PlumaView *view;
+ PlumaView *view;
- view = pluma_window_get_active_view (window);
+ view = pluma_window_get_active_view (window);
- g_signal_handler_block (view, window->priv->spaces_instead_of_tabs_id);
- gtk_source_view_set_insert_spaces_instead_of_tabs (
- GTK_SOURCE_VIEW (view),
- gtk_check_menu_item_get_active (item));
- g_signal_handler_unblock (view, window->priv->spaces_instead_of_tabs_id);
+ g_signal_handler_block (view, window->priv->spaces_instead_of_tabs_id);
+ gtk_source_view_set_insert_spaces_instead_of_tabs (GTK_SOURCE_VIEW (view),
+ gtk_check_menu_item_get_active (item));
+ g_signal_handler_unblock (view, window->priv->spaces_instead_of_tabs_id);
}
static void
language_combo_changed (PlumaStatusComboBox *combo,
- GtkMenuItem *item,
- PlumaWindow *window)
+ GtkMenuItem *item,
+ PlumaWindow *window)
{
- PlumaDocument *doc;
- GtkSourceLanguage *language;
+ PlumaDocument *doc;
+ GtkSourceLanguage *language;
- doc = pluma_window_get_active_document (window);
+ doc = pluma_window_get_active_document (window);
- if (!doc)
- return;
+ if (!doc)
+ return;
- language = GTK_SOURCE_LANGUAGE (g_object_get_data (G_OBJECT (item), LANGUAGE_DATA));
+ language = GTK_SOURCE_LANGUAGE (g_object_get_data (G_OBJECT (item), LANGUAGE_DATA));
- g_signal_handler_block (doc, window->priv->language_changed_id);
- pluma_document_set_language (doc, language);
- g_signal_handler_unblock (doc, window->priv->language_changed_id);
+ g_signal_handler_block (doc, window->priv->language_changed_id);
+ pluma_document_set_language (doc, language);
+ g_signal_handler_unblock (doc, window->priv->language_changed_id);
}
typedef struct
{
- const gchar *label;
- guint width;
+ const gchar *label;
+ guint width;
} TabWidthDefinition;
static void
fill_tab_width_combo (PlumaWindow *window)
{
- static TabWidthDefinition defs[] = {
- {"2", 2},
- {"4", 4},
- {"8", 8},
- {"", 0}, /* custom size */
- {NULL, 0}
- };
+ static TabWidthDefinition defs[] = {
+ {"2", 2},
+ {"4", 4},
+ {"8", 8},
+ {"", 0}, /* custom size */
+ {NULL, 0}
+ };
- PlumaStatusComboBox *combo = PLUMA_STATUS_COMBO_BOX (window->priv->tab_width_combo);
- guint i = 0;
- GtkWidget *item;
+ PlumaStatusComboBox *combo = PLUMA_STATUS_COMBO_BOX (window->priv->tab_width_combo);
+ guint i = 0;
+ GtkWidget *item;
- while (defs[i].label != NULL)
- {
- item = gtk_menu_item_new_with_label (defs[i].label);
- g_object_set_data (G_OBJECT (item), TAB_WIDTH_DATA, GINT_TO_POINTER (defs[i].width));
+ while (defs[i].label != NULL)
+ {
+ item = gtk_menu_item_new_with_label (defs[i].label);
+ g_object_set_data (G_OBJECT (item), TAB_WIDTH_DATA, GINT_TO_POINTER (defs[i].width));
- pluma_status_combo_box_add_item (combo,
- GTK_MENU_ITEM (item),
- defs[i].label);
+ pluma_status_combo_box_add_item (combo,
+ GTK_MENU_ITEM (item),
+ defs[i].label);
- if (defs[i].width != 0)
- gtk_widget_show (item);
+ if (defs[i].width != 0)
+ gtk_widget_show (item);
- ++i;
- }
+ ++i;
+ }
- item = gtk_separator_menu_item_new ();
- pluma_status_combo_box_add_item (combo, GTK_MENU_ITEM (item), NULL);
- gtk_widget_show (item);
+ item = gtk_separator_menu_item_new ();
+ pluma_status_combo_box_add_item (combo, GTK_MENU_ITEM (item), NULL);
+ gtk_widget_show (item);
- item = gtk_check_menu_item_new_with_label (_("Use Spaces"));
- pluma_status_combo_box_add_item (combo, GTK_MENU_ITEM (item), NULL);
- gtk_widget_show (item);
+ item = gtk_check_menu_item_new_with_label (_("Use Spaces"));
+ pluma_status_combo_box_add_item (combo, GTK_MENU_ITEM (item), NULL);
+ gtk_widget_show (item);
- g_signal_connect (item,
- "toggled",
- G_CALLBACK (use_spaces_toggled),
- window);
+ g_signal_connect (item,
+ "toggled",
+ G_CALLBACK (use_spaces_toggled),
+ window);
}
static void
fill_language_combo (PlumaWindow *window)
{
- GtkSourceLanguageManager *manager;
- GSList *languages;
- GSList *item;
- GtkWidget *menu_item;
- const gchar *name;
+ GtkSourceLanguageManager *manager;
+ GSList *languages;
+ GSList *item;
+ GtkWidget *menu_item;
+ const gchar *name;
- manager = pluma_get_language_manager ();
- languages = pluma_language_manager_list_languages_sorted (manager, FALSE);
+ manager = pluma_get_language_manager ();
+ languages = pluma_language_manager_list_languages_sorted (manager, FALSE);
- name = _("Plain Text");
- menu_item = gtk_menu_item_new_with_label (name);
- gtk_widget_show (menu_item);
+ name = _("Plain Text");
+ menu_item = gtk_menu_item_new_with_label (name);
+ gtk_widget_show (menu_item);
- g_object_set_data (G_OBJECT (menu_item), LANGUAGE_DATA, NULL);
- pluma_status_combo_box_add_item (PLUMA_STATUS_COMBO_BOX (window->priv->language_combo),
- GTK_MENU_ITEM (menu_item),
- name);
+ g_object_set_data (G_OBJECT (menu_item), LANGUAGE_DATA, NULL);
+ pluma_status_combo_box_add_item (PLUMA_STATUS_COMBO_BOX (window->priv->language_combo),
+ GTK_MENU_ITEM (menu_item),
+ name);
- for (item = languages; item; item = item->next)
- {
- GtkSourceLanguage *lang = GTK_SOURCE_LANGUAGE (item->data);
+ for (item = languages; item; item = item->next)
+ {
+ GtkSourceLanguage *lang = GTK_SOURCE_LANGUAGE (item->data);
- name = gtk_source_language_get_name (lang);
- menu_item = gtk_menu_item_new_with_label (name);
- gtk_widget_show (menu_item);
+ name = gtk_source_language_get_name (lang);
+ menu_item = gtk_menu_item_new_with_label (name);
+ gtk_widget_show (menu_item);
- g_object_set_data_full (G_OBJECT (menu_item),
- LANGUAGE_DATA,
- g_object_ref (lang),
- (GDestroyNotify)g_object_unref);
+ g_object_set_data_full (G_OBJECT (menu_item),
+ LANGUAGE_DATA,
+ g_object_ref (lang),
+ (GDestroyNotify)g_object_unref);
- pluma_status_combo_box_add_item (PLUMA_STATUS_COMBO_BOX (window->priv->language_combo),
- GTK_MENU_ITEM (menu_item),
- name);
- }
+ pluma_status_combo_box_add_item (PLUMA_STATUS_COMBO_BOX (window->priv->language_combo),
+ GTK_MENU_ITEM (menu_item),
+ name);
+ }
- g_slist_free (languages);
+ g_slist_free (languages);
}
static void
create_statusbar (PlumaWindow *window,
- GtkWidget *main_box)
+ GtkWidget *main_box)
{
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- window->priv->statusbar = pluma_statusbar_new ();
+ window->priv->statusbar = pluma_statusbar_new ();
- window->priv->generic_message_cid = gtk_statusbar_get_context_id
- (GTK_STATUSBAR (window->priv->statusbar), "generic_message");
- window->priv->tip_message_cid = gtk_statusbar_get_context_id
- (GTK_STATUSBAR (window->priv->statusbar), "tip_message");
+ window->priv->generic_message_cid = gtk_statusbar_get_context_id
+ (GTK_STATUSBAR (window->priv->statusbar), "generic_message");
+ window->priv->tip_message_cid = gtk_statusbar_get_context_id
+ (GTK_STATUSBAR (window->priv->statusbar), "tip_message");
- gtk_box_pack_end (GTK_BOX (main_box),
- window->priv->statusbar,
- FALSE,
- TRUE,
- 0);
+ gtk_box_pack_end (GTK_BOX (main_box),
+ window->priv->statusbar,
+ FALSE,
+ TRUE,
+ 0);
- window->priv->tab_width_combo = pluma_status_combo_box_new (_("Tab Width"));
- gtk_widget_show (window->priv->tab_width_combo);
- gtk_box_pack_end (GTK_BOX (window->priv->statusbar),
- window->priv->tab_width_combo,
- FALSE,
- TRUE,
- 0);
+ window->priv->tab_width_combo = pluma_status_combo_box_new (_("Tab Width"));
+ gtk_widget_show (window->priv->tab_width_combo);
+ gtk_box_pack_end (GTK_BOX (window->priv->statusbar),
+ window->priv->tab_width_combo,
+ FALSE,
+ TRUE,
+ 0);
- fill_tab_width_combo (window);
+ fill_tab_width_combo (window);
- g_signal_connect (G_OBJECT (window->priv->tab_width_combo),
- "changed",
- G_CALLBACK (tab_width_combo_changed),
- window);
+ g_signal_connect (G_OBJECT (window->priv->tab_width_combo),
+ "changed",
+ G_CALLBACK (tab_width_combo_changed),
+ window);
- window->priv->language_combo = pluma_status_combo_box_new (NULL);
- gtk_widget_show (window->priv->language_combo);
- gtk_box_pack_end (GTK_BOX (window->priv->statusbar),
- window->priv->language_combo,
- FALSE,
- TRUE,
- 0);
+ window->priv->language_combo = pluma_status_combo_box_new (NULL);
+ gtk_widget_show (window->priv->language_combo);
+ gtk_box_pack_end (GTK_BOX (window->priv->statusbar),
+ window->priv->language_combo,
+ FALSE,
+ TRUE,
+ 0);
- fill_language_combo (window);
+ fill_language_combo (window);
- g_signal_connect (G_OBJECT (window->priv->language_combo),
- "changed",
- G_CALLBACK (language_combo_changed),
- window);
+ g_signal_connect (G_OBJECT (window->priv->language_combo),
+ "changed",
+ G_CALLBACK (language_combo_changed),
+ window);
- g_signal_connect_after (G_OBJECT (window->priv->statusbar),
- "show",
- G_CALLBACK (statusbar_visibility_changed),
- window);
- g_signal_connect_after (G_OBJECT (window->priv->statusbar),
- "hide",
- G_CALLBACK (statusbar_visibility_changed),
- window);
+ g_signal_connect_after (G_OBJECT (window->priv->statusbar),
+ "show",
+ G_CALLBACK (statusbar_visibility_changed),
+ window);
+ g_signal_connect_after (G_OBJECT (window->priv->statusbar),
+ "hide",
+ G_CALLBACK (statusbar_visibility_changed),
+ window);
- set_statusbar_style (window, NULL);
+ set_statusbar_style (window, NULL);
}
static PlumaWindow *
clone_window (PlumaWindow *origin)
{
- PlumaWindow *window;
- GdkScreen *screen;
- PlumaApp *app;
- gint panel_page;
+ PlumaWindow *window;
+ GdkScreen *screen;
+ PlumaApp *app;
+ gint panel_page;
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- app = pluma_app_get_default ();
+ app = pluma_app_get_default ();
- screen = gtk_window_get_screen (GTK_WINDOW (origin));
- window = pluma_app_create_window (app, screen);
+ screen = gtk_window_get_screen (GTK_WINDOW (origin));
+ window = pluma_app_create_window (app, screen);
- if ((origin->priv->window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
- {
- gint w, h;
+ if ((origin->priv->window_state & GDK_WINDOW_STATE_MAXIMIZED) != 0)
+ {
+ gint w, h;
- _pluma_window_get_default_size (&w, &h);
- gtk_window_set_default_size (GTK_WINDOW (window), w, h);
- gtk_window_maximize (GTK_WINDOW (window));
- }
- else
- {
- gtk_window_set_default_size (GTK_WINDOW (window),
- origin->priv->width,
- origin->priv->height);
+ _pluma_window_get_default_size (&w, &h);
+ gtk_window_set_default_size (GTK_WINDOW (window), w, h);
+ gtk_window_maximize (GTK_WINDOW (window));
+ }
+ else
+ {
+ gtk_window_set_default_size (GTK_WINDOW (window),
+ origin->priv->width,
+ origin->priv->height);
- gtk_window_unmaximize (GTK_WINDOW (window));
- }
+ gtk_window_unmaximize (GTK_WINDOW (window));
+ }
- if ((origin->priv->window_state & GDK_WINDOW_STATE_STICKY ) != 0)
- gtk_window_stick (GTK_WINDOW (window));
- else
- gtk_window_unstick (GTK_WINDOW (window));
+ if ((origin->priv->window_state & GDK_WINDOW_STATE_STICKY ) != 0)
+ gtk_window_stick (GTK_WINDOW (window));
+ else
+ gtk_window_unstick (GTK_WINDOW (window));
- /* set the panes size, the paned position will be set when
- * they are mapped */
- window->priv->side_panel_size = origin->priv->side_panel_size;
- window->priv->bottom_panel_size = origin->priv->bottom_panel_size;
+ /* set the panes size, the paned position will be set when
+ * they are mapped */
+ window->priv->side_panel_size = origin->priv->side_panel_size;
+ window->priv->bottom_panel_size = origin->priv->bottom_panel_size;
- panel_page = _pluma_panel_get_active_item_id (PLUMA_PANEL (origin->priv->side_panel));
- _pluma_panel_set_active_item_by_id (PLUMA_PANEL (window->priv->side_panel),
- panel_page);
+ panel_page = _pluma_panel_get_active_item_id (PLUMA_PANEL (origin->priv->side_panel));
+ _pluma_panel_set_active_item_by_id (PLUMA_PANEL (window->priv->side_panel), panel_page);
- panel_page = _pluma_panel_get_active_item_id (PLUMA_PANEL (origin->priv->bottom_panel));
- _pluma_panel_set_active_item_by_id (PLUMA_PANEL (window->priv->bottom_panel),
- panel_page);
+ panel_page = _pluma_panel_get_active_item_id (PLUMA_PANEL (origin->priv->bottom_panel));
+ _pluma_panel_set_active_item_by_id (PLUMA_PANEL (window->priv->bottom_panel), panel_page);
- if (gtk_widget_get_visible (origin->priv->side_panel))
- gtk_widget_show (window->priv->side_panel);
- else
- gtk_widget_hide (window->priv->side_panel);
+ if (gtk_widget_get_visible (origin->priv->side_panel))
+ gtk_widget_show (window->priv->side_panel);
+ else
+ gtk_widget_hide (window->priv->side_panel);
- if (gtk_widget_get_visible (origin->priv->bottom_panel))
- gtk_widget_show (window->priv->bottom_panel);
- else
- gtk_widget_hide (window->priv->bottom_panel);
+ if (gtk_widget_get_visible (origin->priv->bottom_panel))
+ gtk_widget_show (window->priv->bottom_panel);
+ else
+ gtk_widget_hide (window->priv->bottom_panel);
- set_statusbar_style (window, origin);
- set_toolbar_style (window, origin);
+ set_statusbar_style (window, origin);
+ set_toolbar_style (window, origin);
- return window;
+ return window;
}
static void
update_cursor_position_statusbar (GtkTextBuffer *buffer,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- gint row, col;
- GtkTextIter iter;
- PlumaView *view;
+ gint row, col;
+ GtkTextIter iter;
+ PlumaView *view;
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- if (buffer != GTK_TEXT_BUFFER (pluma_window_get_active_document (window)))
- return;
+ if (buffer != GTK_TEXT_BUFFER (pluma_window_get_active_document (window)))
+ return;
- view = pluma_window_get_active_view (window);
+ view = pluma_window_get_active_view (window);
- gtk_text_buffer_get_iter_at_mark (buffer,
- &iter,
- gtk_text_buffer_get_insert (buffer));
+ gtk_text_buffer_get_iter_at_mark (buffer,
+ &iter,
+ gtk_text_buffer_get_insert (buffer));
- row = gtk_text_iter_get_line (&iter);
+ row = gtk_text_iter_get_line (&iter);
- col = gtk_source_view_get_visual_column (GTK_SOURCE_VIEW(view), &iter);
+ col = gtk_source_view_get_visual_column (GTK_SOURCE_VIEW(view), &iter);
- pluma_statusbar_set_cursor_position (
- PLUMA_STATUSBAR (window->priv->statusbar),
- row + 1,
- col + 1);
+ pluma_statusbar_set_cursor_position (PLUMA_STATUSBAR (window->priv->statusbar),
+ row + 1,
+ col + 1);
}
static void
update_overwrite_mode_statusbar (GtkTextView *view,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- if (view != GTK_TEXT_VIEW (pluma_window_get_active_view (window)))
- return;
+ if (view != GTK_TEXT_VIEW (pluma_window_get_active_view (window)))
+ return;
- /* Note that we have to use !gtk_text_view_get_overwrite since we
- are in the in the signal handler of "toggle overwrite" that is
- G_SIGNAL_RUN_LAST
- */
- pluma_statusbar_set_overwrite (
- PLUMA_STATUSBAR (window->priv->statusbar),
- !gtk_text_view_get_overwrite (view));
+ /* Note that we have to use !gtk_text_view_get_overwrite since we
+ are in the in the signal handler of "toggle overwrite" that is
+ G_SIGNAL_RUN_LAST
+ */
+ pluma_statusbar_set_overwrite (PLUMA_STATUSBAR (window->priv->statusbar),
+ !gtk_text_view_get_overwrite (view));
}
#define MAX_TITLE_LENGTH 100
@@ -2183,1012 +2170,999 @@ update_overwrite_mode_statusbar (GtkTextView *view,
static void
set_title (PlumaWindow *window)
{
- PlumaDocument *doc = NULL;
- gchar *name;
- gchar *dirname = NULL;
- gchar *title = NULL;
- gint len;
- GtkAction *action;
-
- if (window->priv->active_tab == NULL)
- {
- gtk_window_set_title (GTK_WINDOW (window), "Pluma");
- return;
- }
-
- doc = pluma_tab_get_document (window->priv->active_tab);
- g_return_if_fail (doc != NULL);
-
- name = pluma_document_get_short_name_for_display (doc);
-
- len = g_utf8_strlen (name, -1);
-
- /* if the name is awfully long, truncate it and be done with it,
- * otherwise also show the directory (ellipsized if needed)
- */
- if (len > MAX_TITLE_LENGTH)
- {
- gchar *tmp;
-
- tmp = pluma_utils_str_middle_truncate (name,
- MAX_TITLE_LENGTH);
- g_free (name);
- name = tmp;
- }
- else
- {
- GFile *file;
-
- file = pluma_document_get_location (doc);
- if (file != NULL)
- {
- gchar *str;
-
- str = pluma_utils_location_get_dirname_for_display (file);
- g_object_unref (file);
-
- /* use the remaining space for the dir, but use a min of 20 chars
- * so that we do not end up with a dirname like "(a...b)".
- * This means that in the worst case when the filename is long 99
- * we have a title long 99 + 20, but I think it's a rare enough
- * case to be acceptable. It's justa darn title afterall :)
- */
- dirname = pluma_utils_str_middle_truncate (str,
- MAX (20, MAX_TITLE_LENGTH - len));
- g_free (str);
- }
- }
-
- if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)))
- {
- gchar *tmp_name;
-
- tmp_name = g_strdup_printf ("*%s", name);
- g_free (name);
-
- name = tmp_name;
- cansave = TRUE;
- }
- else
- cansave = FALSE;
-
- if (pluma_document_get_readonly (doc))
- {
- if (dirname != NULL)
- title = g_strdup_printf ("%s [%s] (%s) - Pluma",
- name,
- _("Read-Only"),
- dirname);
- else
- title = g_strdup_printf ("%s [%s] - Pluma",
- name,
- _("Read-Only"));
- }
- else
- {
- if (dirname != NULL)
- title = g_strdup_printf ("%s (%s) - Pluma",
- name,
- dirname);
- else
- title = g_strdup_printf ("%s - Pluma",
- name);
- }
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "FileSave");
- gtk_action_set_sensitive (action, cansave);
-
- gtk_window_set_title (GTK_WINDOW (window), title);
-
- g_free (dirname);
- g_free (name);
- g_free (title);
+ PlumaDocument *doc = NULL;
+ gchar *name;
+ gchar *dirname = NULL;
+ gchar *title = NULL;
+ gint len;
+ GtkAction *action;
+
+ if (window->priv->active_tab == NULL)
+ {
+ gtk_window_set_title (GTK_WINDOW (window), "Pluma");
+ return;
+ }
+
+ doc = pluma_tab_get_document (window->priv->active_tab);
+ g_return_if_fail (doc != NULL);
+
+ name = pluma_document_get_short_name_for_display (doc);
+
+ len = g_utf8_strlen (name, -1);
+
+ /* if the name is awfully long, truncate it and be done with it,
+ * otherwise also show the directory (ellipsized if needed)
+ */
+ if (len > MAX_TITLE_LENGTH)
+ {
+ gchar *tmp;
+
+ tmp = pluma_utils_str_middle_truncate (name, MAX_TITLE_LENGTH);
+ g_free (name);
+ name = tmp;
+ }
+ else
+ {
+ GFile *file;
+
+ file = pluma_document_get_location (doc);
+ if (file != NULL)
+ {
+ gchar *str;
+
+ str = pluma_utils_location_get_dirname_for_display (file);
+ g_object_unref (file);
+
+ /* use the remaining space for the dir, but use a min of 20 chars
+ * so that we do not end up with a dirname like "(a...b)".
+ * This means that in the worst case when the filename is long 99
+ * we have a title long 99 + 20, but I think it's a rare enough
+ * case to be acceptable. It's justa darn title afterall :)
+ */
+ dirname = pluma_utils_str_middle_truncate (str, MAX (20, MAX_TITLE_LENGTH - len));
+ g_free (str);
+ }
+ }
+
+ if (gtk_text_buffer_get_modified (GTK_TEXT_BUFFER (doc)))
+ {
+ gchar *tmp_name;
+
+ tmp_name = g_strdup_printf ("*%s", name);
+ g_free (name);
+
+ name = tmp_name;
+ cansave = TRUE;
+ }
+ else
+ cansave = FALSE;
+
+ if (pluma_document_get_readonly (doc))
+ {
+ if (dirname != NULL)
+ title = g_strdup_printf ("%s [%s] (%s) - Pluma",
+ name,
+ _("Read-Only"),
+ dirname);
+ else
+ title = g_strdup_printf ("%s [%s] - Pluma",
+ name,
+ _("Read-Only"));
+ }
+ else
+ {
+ if (dirname != NULL)
+ title = g_strdup_printf ("%s (%s) - Pluma",
+ name,
+ dirname);
+ else
+ title = g_strdup_printf ("%s - Pluma",
+ name);
+ }
+
+ action = gtk_action_group_get_action (window->priv->action_group, "FileSave");
+ gtk_action_set_sensitive (action, cansave);
+
+ gtk_window_set_title (GTK_WINDOW (window), title);
+
+ g_free (dirname);
+ g_free (name);
+ g_free (title);
}
#undef MAX_TITLE_LENGTH
static void
set_tab_width_item_blocked (PlumaWindow *window,
- GtkMenuItem *item)
+ GtkMenuItem *item)
{
- g_signal_handlers_block_by_func (window->priv->tab_width_combo,
- tab_width_combo_changed,
- window);
+ g_signal_handlers_block_by_func (window->priv->tab_width_combo,
+ tab_width_combo_changed,
+ window);
- pluma_status_combo_box_set_item (PLUMA_STATUS_COMBO_BOX (window->priv->tab_width_combo),
- item);
+ pluma_status_combo_box_set_item (PLUMA_STATUS_COMBO_BOX (window->priv->tab_width_combo),
+ item);
- g_signal_handlers_unblock_by_func (window->priv->tab_width_combo,
- tab_width_combo_changed,
- window);
+ g_signal_handlers_unblock_by_func (window->priv->tab_width_combo,
+ tab_width_combo_changed,
+ window);
}
static void
spaces_instead_of_tabs_changed (GObject *object,
- GParamSpec *pspec,
- PlumaWindow *window)
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- PlumaView *view = PLUMA_VIEW (object);
- gboolean active = gtk_source_view_get_insert_spaces_instead_of_tabs (
- GTK_SOURCE_VIEW (view));
- GList *children = pluma_status_combo_box_get_items (
- PLUMA_STATUS_COMBO_BOX (window->priv->tab_width_combo));
- GtkCheckMenuItem *item;
+ PlumaView *view = PLUMA_VIEW (object);
+ gboolean active = gtk_source_view_get_insert_spaces_instead_of_tabs (GTK_SOURCE_VIEW (view));
+ GList *children = pluma_status_combo_box_get_items (PLUMA_STATUS_COMBO_BOX (window->priv->tab_width_combo));
+ GtkCheckMenuItem *item;
- item = GTK_CHECK_MENU_ITEM (g_list_last (children)->data);
+ item = GTK_CHECK_MENU_ITEM (g_list_last (children)->data);
- gtk_check_menu_item_set_active (item, active);
+ gtk_check_menu_item_set_active (item, active);
- g_list_free (children);
+ g_list_free (children);
}
static void
tab_width_changed (GObject *object,
- GParamSpec *pspec,
- PlumaWindow *window)
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- GList *items;
- GList *item;
- PlumaStatusComboBox *combo = PLUMA_STATUS_COMBO_BOX (window->priv->tab_width_combo);
- guint new_tab_width;
- gboolean found = FALSE;
+ GList *items;
+ GList *item;
+ PlumaStatusComboBox *combo = PLUMA_STATUS_COMBO_BOX (window->priv->tab_width_combo);
+ guint new_tab_width;
+ gboolean found = FALSE;
- items = pluma_status_combo_box_get_items (combo);
+ items = pluma_status_combo_box_get_items (combo);
- new_tab_width = gtk_source_view_get_tab_width (GTK_SOURCE_VIEW (object));
+ new_tab_width = gtk_source_view_get_tab_width (GTK_SOURCE_VIEW (object));
- for (item = items; item; item = item->next)
- {
- guint tab_width = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item->data), TAB_WIDTH_DATA));
+ for (item = items; item; item = item->next)
+ {
+ guint tab_width = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item->data), TAB_WIDTH_DATA));
- if (tab_width == new_tab_width)
- {
- set_tab_width_item_blocked (window, GTK_MENU_ITEM (item->data));
- found = TRUE;
- }
+ if (tab_width == new_tab_width)
+ {
+ set_tab_width_item_blocked (window, GTK_MENU_ITEM (item->data));
+ found = TRUE;
+ }
- if (GTK_IS_SEPARATOR_MENU_ITEM (item->next->data))
- {
- if (!found)
- {
- /* Set for the last item the custom thing */
- gchar *text;
+ if (GTK_IS_SEPARATOR_MENU_ITEM (item->next->data))
+ {
+ if (!found)
+ {
+ /* Set for the last item the custom thing */
+ gchar *text;
- text = g_strdup_printf ("%u", new_tab_width);
- pluma_status_combo_box_set_item_text (combo,
- GTK_MENU_ITEM (item->data),
- text);
+ text = g_strdup_printf ("%u", new_tab_width);
+ pluma_status_combo_box_set_item_text (combo,
+ GTK_MENU_ITEM (item->data),
+ text);
- gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (item->data))),
- text);
+ gtk_label_set_text (GTK_LABEL (gtk_bin_get_child (GTK_BIN (item->data))),
+ text);
- set_tab_width_item_blocked (window, GTK_MENU_ITEM (item->data));
- gtk_widget_show (GTK_WIDGET (item->data));
- }
- else
- {
- gtk_widget_hide (GTK_WIDGET (item->data));
- }
+ set_tab_width_item_blocked (window, GTK_MENU_ITEM (item->data));
+ gtk_widget_show (GTK_WIDGET (item->data));
+ }
+ else
+ {
+ gtk_widget_hide (GTK_WIDGET (item->data));
+ }
- break;
- }
- }
+ break;
+ }
+ }
- g_list_free (items);
+ g_list_free (items);
}
static void
language_changed (GObject *object,
- GParamSpec *pspec,
- PlumaWindow *window)
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- GList *items;
- GList *item;
- PlumaStatusComboBox *combo = PLUMA_STATUS_COMBO_BOX (window->priv->language_combo);
- GtkSourceLanguage *new_language;
- const gchar *new_id;
+ GList *items;
+ GList *item;
+ PlumaStatusComboBox *combo = PLUMA_STATUS_COMBO_BOX (window->priv->language_combo);
+ GtkSourceLanguage *new_language;
+ const gchar *new_id;
- items = pluma_status_combo_box_get_items (combo);
+ items = pluma_status_combo_box_get_items (combo);
- new_language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (object));
+ new_language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (object));
- if (new_language)
- new_id = gtk_source_language_get_id (new_language);
- else
- new_id = NULL;
+ if (new_language)
+ new_id = gtk_source_language_get_id (new_language);
+ else
+ new_id = NULL;
- for (item = items; item; item = item->next)
- {
- GtkSourceLanguage *lang = g_object_get_data (G_OBJECT (item->data), LANGUAGE_DATA);
+ for (item = items; item; item = item->next)
+ {
+ GtkSourceLanguage *lang = g_object_get_data (G_OBJECT (item->data), LANGUAGE_DATA);
- if ((new_id == NULL && lang == NULL) ||
- (new_id != NULL && lang != NULL && strcmp (gtk_source_language_get_id (lang),
- new_id) == 0))
- {
- g_signal_handlers_block_by_func (window->priv->language_combo,
- language_combo_changed,
- window);
+ if ((new_id == NULL && lang == NULL) ||
+ (new_id != NULL && lang != NULL && strcmp (gtk_source_language_get_id (lang), new_id) == 0))
+ {
+ g_signal_handlers_block_by_func (window->priv->language_combo,
+ language_combo_changed,
+ window);
- pluma_status_combo_box_set_item (PLUMA_STATUS_COMBO_BOX (window->priv->language_combo),
- GTK_MENU_ITEM (item->data));
+ pluma_status_combo_box_set_item (PLUMA_STATUS_COMBO_BOX (window->priv->language_combo),
+ GTK_MENU_ITEM (item->data));
- g_signal_handlers_unblock_by_func (window->priv->language_combo,
- language_combo_changed,
- window);
- }
- }
+ g_signal_handlers_unblock_by_func (window->priv->language_combo,
+ language_combo_changed,
+ window);
+ }
+ }
- g_list_free (items);
+ g_list_free (items);
}
static void
notebook_switch_page (GtkNotebook *book,
- GtkWidget *pg,
- gint page_num,
- PlumaWindow *window)
-{
- PlumaView *view;
- PlumaTab *tab;
- GtkAction *action;
- gchar *action_name;
-
- /* CHECK: I don't know why but it seems notebook_switch_page is called
- two times every time the user change the active tab */
-
- tab = PLUMA_TAB (gtk_notebook_get_nth_page (book, page_num));
- if (tab == window->priv->active_tab)
- return;
-
- if (window->priv->active_tab)
- {
- if (window->priv->tab_width_id)
- {
- g_signal_handler_disconnect (pluma_tab_get_view (window->priv->active_tab),
- window->priv->tab_width_id);
-
- window->priv->tab_width_id = 0;
- }
-
- if (window->priv->spaces_instead_of_tabs_id)
- {
- g_signal_handler_disconnect (pluma_tab_get_view (window->priv->active_tab),
- window->priv->spaces_instead_of_tabs_id);
-
- window->priv->spaces_instead_of_tabs_id = 0;
- }
- }
-
- /* set the active tab */
- window->priv->active_tab = tab;
-
- set_title (window);
- set_sensitivity_according_to_tab (window, tab);
-
- /* activate the right item in the documents menu */
- action_name = g_strdup_printf ("Tab_%d", page_num);
- action = gtk_action_group_get_action (window->priv->documents_list_action_group,
- action_name);
-
- /* sometimes the action doesn't exist yet, and the proper action
- * is set active during the documents list menu creation
- * CHECK: would it be nicer if active_tab was a property and we monitored the notify signal?
- */
- if (action != NULL)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
-
- g_free (action_name);
-
- /* update the syntax menu */
- update_languages_menu (window);
-
- view = pluma_tab_get_view (tab);
-
- /* sync the statusbar */
- update_cursor_position_statusbar (GTK_TEXT_BUFFER (pluma_tab_get_document (tab)),
- window);
- pluma_statusbar_set_overwrite (PLUMA_STATUSBAR (window->priv->statusbar),
- gtk_text_view_get_overwrite (GTK_TEXT_VIEW (view)));
-
- gtk_widget_show (window->priv->tab_width_combo);
- gtk_widget_show (window->priv->language_combo);
-
- window->priv->tab_width_id = g_signal_connect (view,
- "notify::tab-width",
- G_CALLBACK (tab_width_changed),
- window);
- window->priv->spaces_instead_of_tabs_id = g_signal_connect (view,
- "notify::insert-spaces-instead-of-tabs",
- G_CALLBACK (spaces_instead_of_tabs_changed),
- window);
-
- window->priv->language_changed_id = g_signal_connect (pluma_tab_get_document (tab),
- "notify::language",
- G_CALLBACK (language_changed),
- window);
-
- /* call it for the first time */
- tab_width_changed (G_OBJECT (view), NULL, window);
- spaces_instead_of_tabs_changed (G_OBJECT (view), NULL, window);
- language_changed (G_OBJECT (pluma_tab_get_document (tab)), NULL, window);
-
- g_signal_emit (G_OBJECT (window),
- signals[ACTIVE_TAB_CHANGED],
- 0,
- window->priv->active_tab);
+ GtkWidget *pg,
+ gint page_num,
+ PlumaWindow *window)
+{
+ PlumaView *view;
+ PlumaTab *tab;
+ GtkAction *action;
+ gchar *action_name;
+
+ /* CHECK: I don't know why but it seems notebook_switch_page is called
+ two times every time the user change the active tab */
+
+ tab = PLUMA_TAB (gtk_notebook_get_nth_page (book, page_num));
+ if (tab == window->priv->active_tab)
+ return;
+
+ if (window->priv->active_tab)
+ {
+ if (window->priv->tab_width_id)
+ {
+ g_signal_handler_disconnect (pluma_tab_get_view (window->priv->active_tab),
+ window->priv->tab_width_id);
+
+ window->priv->tab_width_id = 0;
+ }
+
+ if (window->priv->spaces_instead_of_tabs_id)
+ {
+ g_signal_handler_disconnect (pluma_tab_get_view (window->priv->active_tab),
+ window->priv->spaces_instead_of_tabs_id);
+
+ window->priv->spaces_instead_of_tabs_id = 0;
+ }
+ }
+
+ /* set the active tab */
+ window->priv->active_tab = tab;
+
+ set_title (window);
+ set_sensitivity_according_to_tab (window, tab);
+
+ /* activate the right item in the documents menu */
+ action_name = g_strdup_printf ("Tab_%d", page_num);
+ action = gtk_action_group_get_action (window->priv->documents_list_action_group,
+ action_name);
+
+ /* sometimes the action doesn't exist yet, and the proper action
+ * is set active during the documents list menu creation
+ * CHECK: would it be nicer if active_tab was a property and we monitored the notify signal?
+ */
+ if (action != NULL)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), TRUE);
+
+ g_free (action_name);
+
+ /* update the syntax menu */
+ update_languages_menu (window);
+
+ view = pluma_tab_get_view (tab);
+
+ /* sync the statusbar */
+ update_cursor_position_statusbar (GTK_TEXT_BUFFER (pluma_tab_get_document (tab)),
+ window);
+ pluma_statusbar_set_overwrite (PLUMA_STATUSBAR (window->priv->statusbar),
+ gtk_text_view_get_overwrite (GTK_TEXT_VIEW (view)));
+
+ gtk_widget_show (window->priv->tab_width_combo);
+ gtk_widget_show (window->priv->language_combo);
+
+ window->priv->tab_width_id = g_signal_connect (view,
+ "notify::tab-width",
+ G_CALLBACK (tab_width_changed),
+ window);
+ window->priv->spaces_instead_of_tabs_id = g_signal_connect (view,
+ "notify::insert-spaces-instead-of-tabs",
+ G_CALLBACK (spaces_instead_of_tabs_changed),
+ window);
+
+ window->priv->language_changed_id = g_signal_connect (pluma_tab_get_document (tab),
+ "notify::language",
+ G_CALLBACK (language_changed),
+ window);
+
+ /* call it for the first time */
+ tab_width_changed (G_OBJECT (view), NULL, window);
+ spaces_instead_of_tabs_changed (G_OBJECT (view), NULL, window);
+ language_changed (G_OBJECT (pluma_tab_get_document (tab)), NULL, window);
+
+ g_signal_emit (G_OBJECT (window),
+ signals[ACTIVE_TAB_CHANGED],
+ 0,
+ window->priv->active_tab);
}
static void
set_sensitivity_according_to_window_state (PlumaWindow *window)
{
- GtkAction *action;
- PlumaLockdownMask lockdown;
-
- lockdown = pluma_app_get_lockdown (pluma_app_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
- the same time (may be we can remove this limitation in the future) */
- /* We disable File->Quit/CloseAll if state is saving since saving cannot be
- cancelled (may be we can remove this limitation in the future) */
- gtk_action_group_set_sensitive (window->priv->quit_action_group,
- !(window->priv->state & PLUMA_WINDOW_STATE_SAVING) &&
- !(window->priv->state & PLUMA_WINDOW_STATE_PRINTING));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "FileCloseAll");
- gtk_action_set_sensitive (action,
- !(window->priv->state & PLUMA_WINDOW_STATE_SAVING) &&
- !(window->priv->state & PLUMA_WINDOW_STATE_PRINTING));
-
- action = gtk_action_group_get_action (window->priv->action_group,
- "FileSaveAll");
- gtk_action_set_sensitive (action,
- !(window->priv->state & PLUMA_WINDOW_STATE_PRINTING) &&
- !(lockdown & PLUMA_LOCKDOWN_SAVE_TO_DISK));
-
- action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
- "FileNew");
- gtk_action_set_sensitive (action,
- !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
-
- action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
- "FileOpen");
- gtk_action_set_sensitive (action,
- !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
-
- gtk_action_group_set_sensitive (window->priv->recents_action_group,
- !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
-
- pluma_notebook_set_close_buttons_sensitive (PLUMA_NOTEBOOK (window->priv->notebook),
- !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
-
- pluma_notebook_set_tab_drag_and_drop_enabled (PLUMA_NOTEBOOK (window->priv->notebook),
- !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
-
- if ((window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION) != 0)
- {
- /* TODO: If we really care, Find could be active
- * when in SAVING_SESSION state */
-
- if (gtk_action_group_get_sensitive (window->priv->action_group))
- gtk_action_group_set_sensitive (window->priv->action_group,
- FALSE);
- if (gtk_action_group_get_sensitive (window->priv->quit_action_group))
- gtk_action_group_set_sensitive (window->priv->quit_action_group,
- FALSE);
- if (gtk_action_group_get_sensitive (window->priv->close_action_group))
- gtk_action_group_set_sensitive (window->priv->close_action_group,
- FALSE);
- }
- else
- {
- if (!gtk_action_group_get_sensitive (window->priv->action_group))
- gtk_action_group_set_sensitive (window->priv->action_group,
- window->priv->num_tabs > 0);
- if (!gtk_action_group_get_sensitive (window->priv->quit_action_group))
- gtk_action_group_set_sensitive (window->priv->quit_action_group,
- window->priv->num_tabs > 0);
- if (!gtk_action_group_get_sensitive (window->priv->close_action_group))
- {
- gtk_action_group_set_sensitive (window->priv->close_action_group,
- window->priv->num_tabs > 0);
- }
- }
+ GtkAction *action;
+ PlumaLockdownMask lockdown;
+
+ lockdown = pluma_app_get_lockdown (pluma_app_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
+ the same time (may be we can remove this limitation in the future) */
+ /* We disable File->Quit/CloseAll if state is saving since saving cannot be
+ cancelled (may be we can remove this limitation in the future) */
+ gtk_action_group_set_sensitive (window->priv->quit_action_group,
+ !(window->priv->state & PLUMA_WINDOW_STATE_SAVING) &&
+ !(window->priv->state & PLUMA_WINDOW_STATE_PRINTING));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FileCloseAll");
+ gtk_action_set_sensitive (action,
+ !(window->priv->state & PLUMA_WINDOW_STATE_SAVING) &&
+ !(window->priv->state & PLUMA_WINDOW_STATE_PRINTING));
+
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FileSaveAll");
+ gtk_action_set_sensitive (action,
+ !(window->priv->state & PLUMA_WINDOW_STATE_PRINTING) &&
+ !(lockdown & PLUMA_LOCKDOWN_SAVE_TO_DISK));
+
+ action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
+ "FileNew");
+ gtk_action_set_sensitive (action,
+ !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
+
+ action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
+ "FileOpen");
+ gtk_action_set_sensitive (action,
+ !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
+
+ gtk_action_group_set_sensitive (window->priv->recents_action_group,
+ !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
+
+ pluma_notebook_set_close_buttons_sensitive (PLUMA_NOTEBOOK (window->priv->notebook),
+ !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
+
+ pluma_notebook_set_tab_drag_and_drop_enabled (PLUMA_NOTEBOOK (window->priv->notebook),
+ !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
+
+ if ((window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION) != 0)
+ {
+ /* TODO: If we really care, Find could be active
+ * when in SAVING_SESSION state */
+
+ if (gtk_action_group_get_sensitive (window->priv->action_group))
+ gtk_action_group_set_sensitive (window->priv->action_group, FALSE);
+
+ if (gtk_action_group_get_sensitive (window->priv->quit_action_group))
+ gtk_action_group_set_sensitive (window->priv->quit_action_group, FALSE);
+
+ if (gtk_action_group_get_sensitive (window->priv->close_action_group))
+ gtk_action_group_set_sensitive (window->priv->close_action_group, FALSE);
+ }
+ else
+ {
+ if (!gtk_action_group_get_sensitive (window->priv->action_group))
+ gtk_action_group_set_sensitive (window->priv->action_group, window->priv->num_tabs > 0);
+
+ if (!gtk_action_group_get_sensitive (window->priv->quit_action_group))
+ gtk_action_group_set_sensitive (window->priv->quit_action_group, window->priv->num_tabs > 0);
+
+ if (!gtk_action_group_get_sensitive (window->priv->close_action_group))
+ gtk_action_group_set_sensitive (window->priv->close_action_group, window->priv->num_tabs > 0);
+ }
}
static void
update_tab_autosave (GtkWidget *widget,
- gpointer data)
+ gpointer data)
{
- PlumaTab *tab = PLUMA_TAB (widget);
- gboolean *enabled = (gboolean *) data;
+ PlumaTab *tab = PLUMA_TAB (widget);
+ gboolean *enabled = (gboolean *) data;
- pluma_tab_set_auto_save_enabled (tab, *enabled);
+ pluma_tab_set_auto_save_enabled (tab, *enabled);
}
void
_pluma_window_set_lockdown (PlumaWindow *window,
- PlumaLockdownMask lockdown)
+ PlumaLockdownMask lockdown)
{
- PlumaTab *tab;
- GtkAction *action;
- gboolean autosave;
+ PlumaTab *tab;
+ GtkAction *action;
+ gboolean autosave;
- /* start/stop autosave in each existing tab */
- autosave = g_settings_get_boolean (window->priv->editor_settings,
- PLUMA_SETTINGS_AUTO_SAVE);
- gtk_container_foreach (GTK_CONTAINER (window->priv->notebook),
- update_tab_autosave,
- &autosave);
+ /* start/stop autosave in each existing tab */
+ autosave = g_settings_get_boolean (window->priv->editor_settings, PLUMA_SETTINGS_AUTO_SAVE);
+ gtk_container_foreach (GTK_CONTAINER (window->priv->notebook),
+ update_tab_autosave,
+ &autosave);
- /* update menues wrt the current active tab */
- tab = pluma_window_get_active_tab (window);
+ /* update menues wrt the current active tab */
+ tab = pluma_window_get_active_tab (window);
- set_sensitivity_according_to_tab (window, tab);
+ set_sensitivity_according_to_tab (window, tab);
- action = gtk_action_group_get_action (window->priv->action_group,
- "FileSaveAll");
- gtk_action_set_sensitive (action,
- !(window->priv->state & PLUMA_WINDOW_STATE_PRINTING) &&
- !(lockdown & PLUMA_LOCKDOWN_SAVE_TO_DISK));
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FileSaveAll");
+ gtk_action_set_sensitive (action,
+ !(window->priv->state & PLUMA_WINDOW_STATE_PRINTING) &&
+ !(lockdown & PLUMA_LOCKDOWN_SAVE_TO_DISK));
}
static void
analyze_tab_state (PlumaTab *tab,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- PlumaTabState ts;
+ PlumaTabState ts;
- ts = pluma_tab_get_state (tab);
+ ts = pluma_tab_get_state (tab);
- switch (ts)
- {
- case PLUMA_TAB_STATE_LOADING:
- case PLUMA_TAB_STATE_REVERTING:
- window->priv->state |= PLUMA_WINDOW_STATE_LOADING;
- break;
+ switch (ts)
+ {
+ case PLUMA_TAB_STATE_LOADING:
+ case PLUMA_TAB_STATE_REVERTING:
+ window->priv->state |= PLUMA_WINDOW_STATE_LOADING;
+ break;
- case PLUMA_TAB_STATE_SAVING:
- window->priv->state |= PLUMA_WINDOW_STATE_SAVING;
- break;
+ case PLUMA_TAB_STATE_SAVING:
+ window->priv->state |= PLUMA_WINDOW_STATE_SAVING;
+ break;
- case PLUMA_TAB_STATE_PRINTING:
- case PLUMA_TAB_STATE_PRINT_PREVIEWING:
- window->priv->state |= PLUMA_WINDOW_STATE_PRINTING;
- break;
+ case PLUMA_TAB_STATE_PRINTING:
+ case PLUMA_TAB_STATE_PRINT_PREVIEWING:
+ window->priv->state |= PLUMA_WINDOW_STATE_PRINTING;
+ break;
- case PLUMA_TAB_STATE_LOADING_ERROR:
- case PLUMA_TAB_STATE_REVERTING_ERROR:
- case PLUMA_TAB_STATE_SAVING_ERROR:
- case PLUMA_TAB_STATE_GENERIC_ERROR:
- window->priv->state |= PLUMA_WINDOW_STATE_ERROR;
- ++window->priv->num_tabs_with_error;
- default:
- /* NOP */
- break;
- }
+ case PLUMA_TAB_STATE_LOADING_ERROR:
+ case PLUMA_TAB_STATE_REVERTING_ERROR:
+ case PLUMA_TAB_STATE_SAVING_ERROR:
+ case PLUMA_TAB_STATE_GENERIC_ERROR:
+ window->priv->state |= PLUMA_WINDOW_STATE_ERROR;
+ ++window->priv->num_tabs_with_error;
+ default:
+ /* NOP */
+ break;
+ }
}
static void
update_window_state (PlumaWindow *window)
{
- PlumaWindowState old_ws;
- gint old_num_of_errors;
+ PlumaWindowState old_ws;
+ gint old_num_of_errors;
- pluma_debug_message (DEBUG_WINDOW, "Old state: %x", window->priv->state);
+ pluma_debug_message (DEBUG_WINDOW, "Old state: %x", window->priv->state);
- old_ws = window->priv->state;
- old_num_of_errors = window->priv->num_tabs_with_error;
+ old_ws = window->priv->state;
+ old_num_of_errors = window->priv->num_tabs_with_error;
- window->priv->state = old_ws & PLUMA_WINDOW_STATE_SAVING_SESSION;
+ window->priv->state = old_ws & PLUMA_WINDOW_STATE_SAVING_SESSION;
- window->priv->num_tabs_with_error = 0;
+ window->priv->num_tabs_with_error = 0;
- gtk_container_foreach (GTK_CONTAINER (window->priv->notebook),
- (GtkCallback)analyze_tab_state,
- window);
+ gtk_container_foreach (GTK_CONTAINER (window->priv->notebook),
+ (GtkCallback)analyze_tab_state,
+ window);
- pluma_debug_message (DEBUG_WINDOW, "New state: %x", window->priv->state);
+ pluma_debug_message (DEBUG_WINDOW, "New state: %x", window->priv->state);
- if (old_ws != window->priv->state)
- {
- set_sensitivity_according_to_window_state (window);
+ if (old_ws != window->priv->state)
+ {
+ set_sensitivity_according_to_window_state (window);
- pluma_statusbar_set_window_state (PLUMA_STATUSBAR (window->priv->statusbar),
- window->priv->state,
- window->priv->num_tabs_with_error);
+ pluma_statusbar_set_window_state (PLUMA_STATUSBAR (window->priv->statusbar),
+ window->priv->state,
+ window->priv->num_tabs_with_error);
- g_object_notify (G_OBJECT (window), "state");
- }
- else if (old_num_of_errors != window->priv->num_tabs_with_error)
- {
- pluma_statusbar_set_window_state (PLUMA_STATUSBAR (window->priv->statusbar),
- window->priv->state,
- window->priv->num_tabs_with_error);
- }
+ g_object_notify (G_OBJECT (window), "state");
+ }
+ else if (old_num_of_errors != window->priv->num_tabs_with_error)
+ {
+ pluma_statusbar_set_window_state (PLUMA_STATUSBAR (window->priv->statusbar),
+ window->priv->state,
+ window->priv->num_tabs_with_error);
+ }
}
static void
sync_state (PlumaTab *tab,
- GParamSpec *pspec,
- PlumaWindow *window)
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- update_window_state (window);
+ update_window_state (window);
- if (tab != window->priv->active_tab)
- return;
+ if (tab != window->priv->active_tab)
+ return;
- set_sensitivity_according_to_tab (window, tab);
+ set_sensitivity_according_to_tab (window, tab);
- g_signal_emit (G_OBJECT (window), signals[ACTIVE_TAB_STATE_CHANGED], 0);
+ g_signal_emit (G_OBJECT (window), signals[ACTIVE_TAB_STATE_CHANGED], 0);
}
static void
sync_name (PlumaTab *tab,
- GParamSpec *pspec,
- PlumaWindow *window)
-{
- GtkAction *action;
- gchar *action_name;
- gchar *tab_name;
- gchar *escaped_name;
- gchar *tip;
- gint n;
- PlumaDocument *doc;
-
- if (tab == window->priv->active_tab)
- {
- set_title (window);
-
- doc = pluma_tab_get_document (tab);
- action = gtk_action_group_get_action (window->priv->action_group,
- "FileRevert");
- gtk_action_set_sensitive (action,
- !pluma_document_is_untitled (doc));
- }
-
- /* sync the item in the documents list menu */
- n = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
- GTK_WIDGET (tab));
- action_name = g_strdup_printf ("Tab_%d", n);
- action = gtk_action_group_get_action (window->priv->documents_list_action_group,
- action_name);
- g_free (action_name);
- g_return_if_fail (action != NULL);
-
- tab_name = _pluma_tab_get_name (tab);
- escaped_name = pluma_utils_escape_underscores (tab_name, -1);
- tip = get_menu_tip_for_tab (tab);
-
- g_object_set (action, "label", escaped_name, NULL);
- g_object_set (action, "tooltip", tip, NULL);
-
- g_free (tab_name);
- g_free (escaped_name);
- g_free (tip);
-
- peas_extension_set_call (window->priv->extensions, "update_state");
+ GParamSpec *pspec,
+ PlumaWindow *window)
+{
+ GtkAction *action;
+ gchar *action_name;
+ gchar *tab_name;
+ gchar *escaped_name;
+ gchar *tip;
+ gint n;
+ PlumaDocument *doc;
+
+ if (tab == window->priv->active_tab)
+ {
+ set_title (window);
+
+ doc = pluma_tab_get_document (tab);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "FileRevert");
+ gtk_action_set_sensitive (action, !pluma_document_is_untitled (doc));
+ }
+
+ /* sync the item in the documents list menu */
+ n = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (tab));
+
+ action_name = g_strdup_printf ("Tab_%d", n);
+ action = gtk_action_group_get_action (window->priv->documents_list_action_group,
+ action_name);
+ g_free (action_name);
+ g_return_if_fail (action != NULL);
+
+ tab_name = _pluma_tab_get_name (tab);
+ escaped_name = pluma_utils_escape_underscores (tab_name, -1);
+ tip = get_menu_tip_for_tab (tab);
+
+ g_object_set (action, "label", escaped_name, NULL);
+ g_object_set (action, "tooltip", tip, NULL);
+
+ g_free (tab_name);
+ g_free (escaped_name);
+ g_free (tip);
+
+ peas_extension_set_call (window->priv->extensions, "update_state");
}
static PlumaWindow *
get_drop_window (GtkWidget *widget)
{
- GtkWidget *target_window;
+ GtkWidget *target_window;
- target_window = gtk_widget_get_toplevel (widget);
- g_return_val_if_fail (PLUMA_IS_WINDOW (target_window), NULL);
+ target_window = gtk_widget_get_toplevel (widget);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (target_window), NULL);
- if ((PLUMA_WINDOW(target_window)->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION) != 0)
- return NULL;
+ if ((PLUMA_WINDOW(target_window)->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION) != 0)
+ return NULL;
- return PLUMA_WINDOW (target_window);
+ return PLUMA_WINDOW (target_window);
}
static void
load_uris_from_drop (PlumaWindow *window,
- gchar **uri_list)
+ gchar **uri_list)
{
- GSList *uris = NULL;
- gint i;
+ GSList *uris = NULL;
+ gint i;
- if (uri_list == NULL)
- return;
+ if (uri_list == NULL)
+ return;
- for (i = 0; uri_list[i] != NULL; ++i)
- {
- uris = g_slist_prepend (uris, uri_list[i]);
- }
+ for (i = 0; uri_list[i] != NULL; ++i)
+ {
+ uris = g_slist_prepend (uris, uri_list[i]);
+ }
- uris = g_slist_reverse (uris);
- pluma_commands_load_uris (window,
- uris,
- NULL,
- 0);
+ uris = g_slist_reverse (uris);
+ pluma_commands_load_uris (window,
+ uris,
+ NULL,
+ 0);
- g_slist_free (uris);
+ g_slist_free (uris);
}
/* Handle drops on the PlumaWindow */
static void
-drag_data_received_cb (GtkWidget *widget,
- GdkDragContext *context,
- gint x,
- gint y,
- GtkSelectionData *selection_data,
- guint info,
- guint timestamp,
- gpointer data)
+drag_data_received_cb (GtkWidget *widget,
+ GdkDragContext *context,
+ gint x,
+ gint y,
+ GtkSelectionData *selection_data,
+ guint info,
+ guint timestamp,
+ gpointer data)
{
- PlumaWindow *window;
- gchar **uri_list;
+ PlumaWindow *window;
+ gchar **uri_list;
- window = get_drop_window (widget);
+ window = get_drop_window (widget);
- if (window == NULL)
- return;
+ if (window == NULL)
+ return;
- if (info == TARGET_URI_LIST)
- {
- uri_list = pluma_utils_drop_get_uris(selection_data);
- load_uris_from_drop (window, uri_list);
- g_strfreev (uri_list);
- }
+ if (info == TARGET_URI_LIST)
+ {
+ uri_list = pluma_utils_drop_get_uris(selection_data);
+ load_uris_from_drop (window, uri_list);
+ g_strfreev (uri_list);
+ }
}
/* Handle drops on the PlumaView */
static void
drop_uris_cb (GtkWidget *widget,
- gchar **uri_list)
+ gchar **uri_list)
{
- PlumaWindow *window;
+ PlumaWindow *window;
- window = get_drop_window (widget);
+ window = get_drop_window (widget);
- if (window == NULL)
- return;
+ if (window == NULL)
+ return;
- load_uris_from_drop (window, uri_list);
+ load_uris_from_drop (window, uri_list);
}
static void
fullscreen_controls_show (PlumaWindow *window)
{
- GdkScreen *screen;
- GdkDisplay *display;
- GdkRectangle fs_rect;
- gint w, h;
+ GdkScreen *screen;
+ GdkDisplay *display;
+ GdkRectangle fs_rect;
+ gint w, h;
- screen = gtk_window_get_screen (GTK_WINDOW (window));
- display = gdk_screen_get_display (screen);
+ screen = gtk_window_get_screen (GTK_WINDOW (window));
+ display = gdk_screen_get_display (screen);
- gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
- gtk_widget_get_window (GTK_WIDGET (window))),
- &fs_rect);
+ gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
+ gtk_widget_get_window (GTK_WIDGET (window))),
+ &fs_rect);
- gtk_window_get_size (GTK_WINDOW (window->priv->fullscreen_controls), &w, &h);
+ gtk_window_get_size (GTK_WINDOW (window->priv->fullscreen_controls), &w, &h);
- gtk_window_resize (GTK_WINDOW (window->priv->fullscreen_controls),
- fs_rect.width, h);
+ gtk_window_resize (GTK_WINDOW (window->priv->fullscreen_controls),
+ fs_rect.width, h);
- gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
- fs_rect.x, fs_rect.y - h + 1);
+ gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
+ fs_rect.x, fs_rect.y - h + 1);
- gtk_widget_show_all (window->priv->fullscreen_controls);
+ gtk_widget_show_all (window->priv->fullscreen_controls);
}
static gboolean
run_fullscreen_animation (gpointer data)
{
- PlumaWindow *window = PLUMA_WINDOW (data);
- GdkScreen *screen;
- GdkDisplay *display;
- GdkRectangle fs_rect;
- gint x, y;
-
- screen = gtk_window_get_screen (GTK_WINDOW (window));
- display = gdk_screen_get_display (screen);
-
- gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
- gtk_widget_get_window (GTK_WIDGET (window))),
- &fs_rect);
-
- gtk_window_get_position (GTK_WINDOW (window->priv->fullscreen_controls),
- &x, &y);
-
- if (window->priv->fullscreen_animation_enter)
- {
- if (y == fs_rect.y)
- {
- window->priv->fullscreen_animation_timeout_id = 0;
- return FALSE;
- }
- else
- {
- gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
- x, y + 1);
- return TRUE;
- }
- }
- else
- {
- gint w, h;
-
- gtk_window_get_size (GTK_WINDOW (window->priv->fullscreen_controls),
- &w, &h);
-
- if (y == fs_rect.y - h + 1)
- {
- window->priv->fullscreen_animation_timeout_id = 0;
- return FALSE;
- }
- else
- {
- gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
- x, y - 1);
- return TRUE;
- }
- }
+ PlumaWindow *window = PLUMA_WINDOW (data);
+ GdkScreen *screen;
+ GdkDisplay *display;
+ GdkRectangle fs_rect;
+ gint x, y;
+
+ screen = gtk_window_get_screen (GTK_WINDOW (window));
+ display = gdk_screen_get_display (screen);
+
+ gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
+ gtk_widget_get_window (GTK_WIDGET (window))),
+ &fs_rect);
+
+ gtk_window_get_position (GTK_WINDOW (window->priv->fullscreen_controls),
+ &x,
+ &y);
+
+ if (window->priv->fullscreen_animation_enter)
+ {
+ if (y == fs_rect.y)
+ {
+ window->priv->fullscreen_animation_timeout_id = 0;
+ return FALSE;
+ }
+ else
+ {
+ gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
+ x, y + 1);
+ return TRUE;
+ }
+ }
+ else
+ {
+ gint w, h;
+
+ gtk_window_get_size (GTK_WINDOW (window->priv->fullscreen_controls),
+ &w, &h);
+
+ if (y == fs_rect.y - h + 1)
+ {
+ window->priv->fullscreen_animation_timeout_id = 0;
+ return FALSE;
+ }
+ else
+ {
+ gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
+ x, y - 1);
+ return TRUE;
+ }
+ }
}
static void
show_hide_fullscreen_toolbar (PlumaWindow *window,
- gboolean show,
- gint height)
-{
- GtkSettings *settings;
- gboolean enable_animations;
-
- settings = gtk_widget_get_settings (GTK_WIDGET (window));
- g_object_get (G_OBJECT (settings),
- "gtk-enable-animations",
- &enable_animations,
- NULL);
-
- if (enable_animations)
- {
- window->priv->fullscreen_animation_enter = show;
-
- if (window->priv->fullscreen_animation_timeout_id == 0)
- {
- window->priv->fullscreen_animation_timeout_id =
- g_timeout_add (FULLSCREEN_ANIMATION_SPEED,
- (GSourceFunc) run_fullscreen_animation,
- window);
- }
- }
- else
- {
- GdkRectangle fs_rect;
- GdkScreen *screen;
- GdkDisplay *display;
-
- screen = gtk_window_get_screen (GTK_WINDOW (window));
- display = gdk_screen_get_display (screen);
-
- gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
- gtk_widget_get_window (GTK_WIDGET (window))),
- &fs_rect);
-
- if (show)
- gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
- fs_rect.x, fs_rect.y);
- else
- gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
- fs_rect.x, fs_rect.y - height + 1);
- }
+ gboolean show,
+ gint height)
+{
+ GtkSettings *settings;
+ gboolean enable_animations;
+
+ settings = gtk_widget_get_settings (GTK_WIDGET (window));
+ g_object_get (G_OBJECT (settings),
+ "gtk-enable-animations",
+ &enable_animations,
+ NULL);
+
+ if (enable_animations)
+ {
+ window->priv->fullscreen_animation_enter = show;
+
+ if (window->priv->fullscreen_animation_timeout_id == 0)
+ {
+ window->priv->fullscreen_animation_timeout_id =
+ g_timeout_add (FULLSCREEN_ANIMATION_SPEED,
+ (GSourceFunc) run_fullscreen_animation,
+ window);
+ }
+ }
+ else
+ {
+ GdkRectangle fs_rect;
+ GdkScreen *screen;
+ GdkDisplay *display;
+
+ screen = gtk_window_get_screen (GTK_WINDOW (window));
+ display = gdk_screen_get_display (screen);
+
+ gdk_monitor_get_geometry (gdk_display_get_monitor_at_window (display,
+ gtk_widget_get_window (GTK_WIDGET (window))),
+ &fs_rect);
+
+ if (show)
+ gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
+ fs_rect.x, fs_rect.y);
+ else
+ gtk_window_move (GTK_WINDOW (window->priv->fullscreen_controls),
+ fs_rect.x, fs_rect.y - height + 1);
+ }
}
static gboolean
-on_fullscreen_controls_enter_notify_event (GtkWidget *widget,
- GdkEventCrossing *event,
- PlumaWindow *window)
+on_fullscreen_controls_enter_notify_event (GtkWidget *widget,
+ GdkEventCrossing *event,
+ PlumaWindow *window)
{
- show_hide_fullscreen_toolbar (window, TRUE, 0);
+ show_hide_fullscreen_toolbar (window, TRUE, 0);
- return FALSE;
+ return FALSE;
}
static gboolean
-on_fullscreen_controls_leave_notify_event (GtkWidget *widget,
- GdkEventCrossing *event,
- PlumaWindow *window)
+on_fullscreen_controls_leave_notify_event (GtkWidget *widget,
+ GdkEventCrossing *event,
+ PlumaWindow *window)
{
- GdkDevice *device;
- gint w, h;
- gint x, y;
+ GdkDevice *device;
+ gint w, h;
+ gint x, y;
- device = gdk_event_get_device ((GdkEvent *)event);
+ device = gdk_event_get_device ((GdkEvent *)event);
- gtk_window_get_size (GTK_WINDOW (window->priv->fullscreen_controls), &w, &h);
- gdk_device_get_position (device, NULL, &x, &y);
+ gtk_window_get_size (GTK_WINDOW (window->priv->fullscreen_controls), &w, &h);
+ gdk_device_get_position (device, NULL, &x, &y);
- /* gtk seems to emit leave notify when clicking on tool items,
- * work around it by checking the coordinates
- */
- if (y >= h)
- {
- show_hide_fullscreen_toolbar (window, FALSE, h);
- }
+ /* gtk seems to emit leave notify when clicking on tool items,
+ * work around it by checking the coordinates
+ */
+ if (y >= h)
+ {
+ show_hide_fullscreen_toolbar (window, FALSE, h);
+ }
- return FALSE;
+ return FALSE;
}
static void
fullscreen_controls_build (PlumaWindow *window)
{
- PlumaWindowPrivate *priv = window->priv;
- GtkWidget *toolbar;
- GtkAction *action;
+ PlumaWindowPrivate *priv = window->priv;
+ GtkWidget *toolbar;
+ GtkAction *action;
- if (priv->fullscreen_controls != NULL)
- return;
+ if (priv->fullscreen_controls != NULL)
+ return;
- priv->fullscreen_controls = gtk_window_new (GTK_WINDOW_POPUP);
+ priv->fullscreen_controls = gtk_window_new (GTK_WINDOW_POPUP);
- gtk_window_set_transient_for (GTK_WINDOW (priv->fullscreen_controls),
- &window->window);
+ gtk_window_set_transient_for (GTK_WINDOW (priv->fullscreen_controls),
+ &window->window);
- /* popup toolbar */
- toolbar = gtk_ui_manager_get_widget (priv->manager, "/FullscreenToolBar");
- gtk_container_add (GTK_CONTAINER (priv->fullscreen_controls),
- toolbar);
+ /* popup toolbar */
+ toolbar = gtk_ui_manager_get_widget (priv->manager, "/FullscreenToolBar");
+ gtk_container_add (GTK_CONTAINER (priv->fullscreen_controls), toolbar);
- action = gtk_action_group_get_action (priv->always_sensitive_action_group,
- "LeaveFullscreen");
- g_object_set (action, "is-important", TRUE, NULL);
+ action = gtk_action_group_get_action (priv->always_sensitive_action_group,
+ "LeaveFullscreen");
+ g_object_set (action, "is-important", TRUE, NULL);
- setup_toolbar_open_button (window, toolbar);
+ setup_toolbar_open_button (window, toolbar);
- gtk_container_foreach (GTK_CONTAINER (toolbar),
- (GtkCallback)set_non_homogeneus,
- NULL);
+ gtk_container_foreach (GTK_CONTAINER (toolbar),
+ (GtkCallback)set_non_homogeneus,
+ NULL);
- /* Set the toolbar style */
- gtk_toolbar_set_style (GTK_TOOLBAR (toolbar),
- GTK_TOOLBAR_BOTH_HORIZ);
+ /* Set the toolbar style */
+ gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_BOTH_HORIZ);
- g_signal_connect (priv->fullscreen_controls, "enter-notify-event",
- G_CALLBACK (on_fullscreen_controls_enter_notify_event),
- window);
- g_signal_connect (priv->fullscreen_controls, "leave-notify-event",
- G_CALLBACK (on_fullscreen_controls_leave_notify_event),
- window);
+ g_signal_connect (priv->fullscreen_controls, "enter-notify-event",
+ G_CALLBACK (on_fullscreen_controls_enter_notify_event),
+ window);
+ g_signal_connect (priv->fullscreen_controls, "leave-notify-event",
+ G_CALLBACK (on_fullscreen_controls_leave_notify_event),
+ window);
}
static void
can_search_again (PlumaDocument *doc,
- GParamSpec *pspec,
- PlumaWindow *window)
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- gboolean sensitive;
- GtkAction *action;
+ gboolean sensitive;
+ GtkAction *action;
- if (doc != pluma_window_get_active_document (window))
- return;
+ if (doc != pluma_window_get_active_document (window))
+ return;
- sensitive = pluma_document_get_can_search_again (doc);
+ sensitive = pluma_document_get_can_search_again (doc);
- action = gtk_action_group_get_action (window->priv->action_group,
- "SearchFindNext");
- gtk_action_set_sensitive (action, sensitive);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "SearchFindNext");
+ gtk_action_set_sensitive (action, sensitive);
- action = gtk_action_group_get_action (window->priv->action_group,
- "SearchFindPrevious");
- gtk_action_set_sensitive (action, sensitive);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "SearchFindPrevious");
+ gtk_action_set_sensitive (action, sensitive);
- action = gtk_action_group_get_action (window->priv->action_group,
- "SearchClearHighlight");
- gtk_action_set_sensitive (action, sensitive);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "SearchClearHighlight");
+ gtk_action_set_sensitive (action, sensitive);
}
static void
can_undo (PlumaDocument *doc,
- GParamSpec *pspec,
- PlumaWindow *window)
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- GtkAction *action;
- gboolean sensitive;
+ GtkAction *action;
+ gboolean sensitive;
- sensitive = gtk_source_buffer_can_undo (GTK_SOURCE_BUFFER (doc));
+ sensitive = gtk_source_buffer_can_undo (GTK_SOURCE_BUFFER (doc));
- if (doc != pluma_window_get_active_document (window))
- return;
+ if (doc != pluma_window_get_active_document (window))
+ return;
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditUndo");
- gtk_action_set_sensitive (action, sensitive);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditUndo");
+ gtk_action_set_sensitive (action, sensitive);
}
static void
can_redo (PlumaDocument *doc,
- GParamSpec *pspec,
- PlumaWindow *window)
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- GtkAction *action;
- gboolean sensitive;
+ GtkAction *action;
+ gboolean sensitive;
- sensitive = gtk_source_buffer_can_redo (GTK_SOURCE_BUFFER (doc));
+ sensitive = gtk_source_buffer_can_redo (GTK_SOURCE_BUFFER (doc));
- if (doc != pluma_window_get_active_document (window))
- return;
+ if (doc != pluma_window_get_active_document (window))
+ return;
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditRedo");
- gtk_action_set_sensitive (action, sensitive);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditRedo");
+ gtk_action_set_sensitive (action, sensitive);
}
static void
selection_changed (PlumaDocument *doc,
- GParamSpec *pspec,
- PlumaWindow *window)
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- PlumaTab *tab;
- PlumaView *view;
- GtkAction *action;
- PlumaTabState state;
- gboolean state_normal;
- gboolean editable;
+ PlumaTab *tab;
+ PlumaView *view;
+ GtkAction *action;
+ PlumaTabState state;
+ gboolean state_normal;
+ gboolean editable;
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- if (doc != pluma_window_get_active_document (window))
- return;
+ if (doc != pluma_window_get_active_document (window))
+ return;
- tab = pluma_tab_get_from_document (doc);
- state = pluma_tab_get_state (tab);
- state_normal = (state == PLUMA_TAB_STATE_NORMAL);
+ tab = pluma_tab_get_from_document (doc);
+ state = pluma_tab_get_state (tab);
+ state_normal = (state == PLUMA_TAB_STATE_NORMAL);
- view = pluma_tab_get_view (tab);
- editable = gtk_text_view_get_editable (GTK_TEXT_VIEW (view));
+ view = pluma_tab_get_view (tab);
+ editable = gtk_text_view_get_editable (GTK_TEXT_VIEW (view));
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditCut");
- gtk_action_set_sensitive (action,
- state_normal &&
- editable &&
- gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditCut");
+ gtk_action_set_sensitive (action,
+ state_normal &&
+ editable &&
+ gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditCopy");
- gtk_action_set_sensitive (action,
- (state_normal ||
- state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) &&
- gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditCopy");
+ gtk_action_set_sensitive (action,
+ (state_normal ||
+ state == PLUMA_TAB_STATE_EXTERNALLY_MODIFIED_NOTIFICATION) &&
+ gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
- action = gtk_action_group_get_action (window->priv->action_group,
- "EditDelete");
- gtk_action_set_sensitive (action,
- state_normal &&
- editable &&
- gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "EditDelete");
+ gtk_action_set_sensitive (action,
+ state_normal &&
+ editable &&
+ gtk_text_buffer_get_has_selection (GTK_TEXT_BUFFER (doc)));
- peas_extension_set_call (window->priv->extensions, "update_state");
+ peas_extension_set_call (window->priv->extensions, "update_state");
}
static void
sync_languages_menu (PlumaDocument *doc,
- GParamSpec *pspec,
- PlumaWindow *window)
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- update_languages_menu (window);
- peas_extension_set_call (window->priv->extensions, "update_state");
+ update_languages_menu (window);
+ peas_extension_set_call (window->priv->extensions, "update_state");
}
static void
readonly_changed (PlumaDocument *doc,
- GParamSpec *pspec,
- PlumaWindow *window)
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- set_sensitivity_according_to_tab (window, window->priv->active_tab);
+ set_sensitivity_according_to_tab (window, window->priv->active_tab);
- sync_name (window->priv->active_tab, NULL, window);
+ sync_name (window->priv->active_tab, NULL, window);
- peas_extension_set_call (window->priv->extensions, "update_state");
+ peas_extension_set_call (window->priv->extensions, "update_state");
}
static void
@@ -3196,327 +3170,323 @@ editable_changed (PlumaView *view,
GParamSpec *arg1,
PlumaWindow *window)
{
- peas_extension_set_call (window->priv->extensions, "update_state");
+ peas_extension_set_call (window->priv->extensions, "update_state");
}
static void
update_sensitivity_according_to_open_tabs (PlumaWindow *window)
{
- GtkAction *action;
+ GtkAction *action;
- /* Set sensitivity */
- gtk_action_group_set_sensitive (window->priv->action_group,
- window->priv->num_tabs != 0);
+ /* Set sensitivity */
+ gtk_action_group_set_sensitive (window->priv->action_group,
+ window->priv->num_tabs != 0);
- action = gtk_action_group_get_action (window->priv->action_group,
- "DocumentsMoveToNewWindow");
- gtk_action_set_sensitive (action,
- window->priv->num_tabs > 1);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "DocumentsMoveToNewWindow");
+ gtk_action_set_sensitive (action, window->priv->num_tabs > 1);
- gtk_action_group_set_sensitive (window->priv->close_action_group,
- window->priv->num_tabs != 0);
+ gtk_action_group_set_sensitive (window->priv->close_action_group,
+ window->priv->num_tabs != 0);
}
static void
notebook_tab_added (PlumaNotebook *notebook,
- PlumaTab *tab,
- PlumaWindow *window)
-{
- PlumaView *view;
- PlumaDocument *doc;
-
- pluma_debug (DEBUG_WINDOW);
-
- g_return_if_fail ((window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION) == 0);
-
- ++window->priv->num_tabs;
-
- update_sensitivity_according_to_open_tabs (window);
-
- view = pluma_tab_get_view (tab);
- doc = pluma_tab_get_document (tab);
-
- /* IMPORTANT: remember to disconnect the signal in notebook_tab_removed
- * if a new signal is connected here */
-
- g_signal_connect (tab,
- "notify::name",
- G_CALLBACK (sync_name),
- window);
- g_signal_connect (tab,
- "notify::state",
- G_CALLBACK (sync_state),
- window);
-
- g_signal_connect (doc,
- "cursor-moved",
- G_CALLBACK (update_cursor_position_statusbar),
- window);
- g_signal_connect (doc,
- "notify::can-search-again",
- G_CALLBACK (can_search_again),
- window);
- g_signal_connect (doc,
- "notify::can-undo",
- G_CALLBACK (can_undo),
- window);
- g_signal_connect (doc,
- "notify::can-redo",
- G_CALLBACK (can_redo),
- window);
- g_signal_connect (doc,
- "notify::has-selection",
- G_CALLBACK (selection_changed),
- window);
- g_signal_connect (doc,
- "notify::language",
- G_CALLBACK (sync_languages_menu),
- window);
- g_signal_connect (doc,
- "notify::read-only",
- G_CALLBACK (readonly_changed),
- window);
- g_signal_connect (view,
- "toggle_overwrite",
- G_CALLBACK (update_overwrite_mode_statusbar),
- window);
- g_signal_connect (view,
- "notify::editable",
- G_CALLBACK (editable_changed),
- window);
-
- update_documents_list_menu (window);
-
- g_signal_connect (view,
- "drop_uris",
- G_CALLBACK (drop_uris_cb),
- NULL);
-
- update_window_state (window);
-
- g_signal_emit (G_OBJECT (window), signals[TAB_ADDED], 0, tab);
+ PlumaTab *tab,
+ PlumaWindow *window)
+{
+ PlumaView *view;
+ PlumaDocument *doc;
+
+ pluma_debug (DEBUG_WINDOW);
+
+ g_return_if_fail ((window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION) == 0);
+
+ ++window->priv->num_tabs;
+
+ update_sensitivity_according_to_open_tabs (window);
+
+ view = pluma_tab_get_view (tab);
+ doc = pluma_tab_get_document (tab);
+
+ /* IMPORTANT: remember to disconnect the signal in notebook_tab_removed
+ * if a new signal is connected here */
+
+ g_signal_connect (tab,
+ "notify::name",
+ G_CALLBACK (sync_name),
+ window);
+ g_signal_connect (tab,
+ "notify::state",
+ G_CALLBACK (sync_state),
+ window);
+
+ g_signal_connect (doc,
+ "cursor-moved",
+ G_CALLBACK (update_cursor_position_statusbar),
+ window);
+ g_signal_connect (doc,
+ "notify::can-search-again",
+ G_CALLBACK (can_search_again),
+ window);
+ g_signal_connect (doc,
+ "notify::can-undo",
+ G_CALLBACK (can_undo),
+ window);
+ g_signal_connect (doc,
+ "notify::can-redo",
+ G_CALLBACK (can_redo),
+ window);
+ g_signal_connect (doc,
+ "notify::has-selection",
+ G_CALLBACK (selection_changed),
+ window);
+ g_signal_connect (doc,
+ "notify::language",
+ G_CALLBACK (sync_languages_menu),
+ window);
+ g_signal_connect (doc,
+ "notify::read-only",
+ G_CALLBACK (readonly_changed),
+ window);
+ g_signal_connect (view,
+ "toggle_overwrite",
+ G_CALLBACK (update_overwrite_mode_statusbar),
+ window);
+ g_signal_connect (view,
+ "notify::editable",
+ G_CALLBACK (editable_changed),
+ window);
+
+ update_documents_list_menu (window);
+
+ g_signal_connect (view,
+ "drop_uris",
+ G_CALLBACK (drop_uris_cb),
+ NULL);
+
+ update_window_state (window);
+
+ g_signal_emit (G_OBJECT (window), signals[TAB_ADDED], 0, tab);
}
static void
notebook_tab_removed (PlumaNotebook *notebook,
- PlumaTab *tab,
- PlumaWindow *window)
-{
- PlumaView *view;
- PlumaDocument *doc;
-
- pluma_debug (DEBUG_WINDOW);
-
- g_return_if_fail ((window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION) == 0);
-
- --window->priv->num_tabs;
-
- view = pluma_tab_get_view (tab);
- doc = pluma_tab_get_document (tab);
-
- g_signal_handlers_disconnect_by_func (tab,
- G_CALLBACK (sync_name),
- window);
- g_signal_handlers_disconnect_by_func (tab,
- G_CALLBACK (sync_state),
- window);
- g_signal_handlers_disconnect_by_func (doc,
- G_CALLBACK (update_cursor_position_statusbar),
- window);
- g_signal_handlers_disconnect_by_func (doc,
- G_CALLBACK (can_search_again),
- window);
- g_signal_handlers_disconnect_by_func (doc,
- G_CALLBACK (can_undo),
- window);
- g_signal_handlers_disconnect_by_func (doc,
- G_CALLBACK (can_redo),
- window);
- g_signal_handlers_disconnect_by_func (doc,
- G_CALLBACK (selection_changed),
- window);
- g_signal_handlers_disconnect_by_func (doc,
- G_CALLBACK (sync_languages_menu),
- window);
- g_signal_handlers_disconnect_by_func (doc,
- G_CALLBACK (readonly_changed),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (update_overwrite_mode_statusbar),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (editable_changed),
- window);
- g_signal_handlers_disconnect_by_func (view,
- G_CALLBACK (drop_uris_cb),
- NULL);
-
- if (window->priv->tab_width_id && tab == pluma_window_get_active_tab (window))
- {
- g_signal_handler_disconnect (view, window->priv->tab_width_id);
- window->priv->tab_width_id = 0;
- }
-
- if (window->priv->spaces_instead_of_tabs_id && tab == pluma_window_get_active_tab (window))
- {
- g_signal_handler_disconnect (view, window->priv->spaces_instead_of_tabs_id);
- window->priv->spaces_instead_of_tabs_id = 0;
- }
-
- if (window->priv->language_changed_id && tab == pluma_window_get_active_tab (window))
- {
- g_signal_handler_disconnect (doc, window->priv->language_changed_id);
- window->priv->language_changed_id = 0;
- }
-
- g_return_if_fail (window->priv->num_tabs >= 0);
- if (window->priv->num_tabs == 0)
- {
- window->priv->active_tab = NULL;
-
- set_title (window);
-
- /* Remove line and col info */
- pluma_statusbar_set_cursor_position (
- PLUMA_STATUSBAR (window->priv->statusbar),
- -1,
- -1);
-
- pluma_statusbar_clear_overwrite (
- PLUMA_STATUSBAR (window->priv->statusbar));
-
- /* hide the combos */
- gtk_widget_hide (window->priv->tab_width_combo);
- gtk_widget_hide (window->priv->language_combo);
- }
-
- if (!window->priv->removing_tabs)
- {
- update_documents_list_menu (window);
- update_next_prev_doc_sensitivity_per_window (window);
- }
- else
- {
- if (window->priv->num_tabs == 0)
- {
- update_documents_list_menu (window);
- update_next_prev_doc_sensitivity_per_window (window);
- }
- }
-
- update_sensitivity_according_to_open_tabs (window);
-
- if (window->priv->num_tabs == 0)
- {
- peas_extension_set_call (window->priv->extensions, "update_state");
- }
-
- update_window_state (window);
-
- g_signal_emit (G_OBJECT (window), signals[TAB_REMOVED], 0, tab);
+ PlumaTab *tab,
+ PlumaWindow *window)
+{
+ PlumaView *view;
+ PlumaDocument *doc;
+
+ pluma_debug (DEBUG_WINDOW);
+
+ g_return_if_fail ((window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION) == 0);
+
+ --window->priv->num_tabs;
+
+ view = pluma_tab_get_view (tab);
+ doc = pluma_tab_get_document (tab);
+
+ g_signal_handlers_disconnect_by_func (tab,
+ G_CALLBACK (sync_name),
+ window);
+ g_signal_handlers_disconnect_by_func (tab,
+ G_CALLBACK (sync_state),
+ window);
+ g_signal_handlers_disconnect_by_func (doc,
+ G_CALLBACK (update_cursor_position_statusbar),
+ window);
+ g_signal_handlers_disconnect_by_func (doc,
+ G_CALLBACK (can_search_again),
+ window);
+ g_signal_handlers_disconnect_by_func (doc,
+ G_CALLBACK (can_undo),
+ window);
+ g_signal_handlers_disconnect_by_func (doc,
+ G_CALLBACK (can_redo),
+ window);
+ g_signal_handlers_disconnect_by_func (doc,
+ G_CALLBACK (selection_changed),
+ window);
+ g_signal_handlers_disconnect_by_func (doc,
+ G_CALLBACK (sync_languages_menu),
+ window);
+ g_signal_handlers_disconnect_by_func (doc,
+ G_CALLBACK (readonly_changed),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (update_overwrite_mode_statusbar),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (editable_changed),
+ window);
+ g_signal_handlers_disconnect_by_func (view,
+ G_CALLBACK (drop_uris_cb),
+ NULL);
+
+ if (window->priv->tab_width_id && tab == pluma_window_get_active_tab (window))
+ {
+ g_signal_handler_disconnect (view, window->priv->tab_width_id);
+ window->priv->tab_width_id = 0;
+ }
+
+ if (window->priv->spaces_instead_of_tabs_id && tab == pluma_window_get_active_tab (window))
+ {
+ g_signal_handler_disconnect (view, window->priv->spaces_instead_of_tabs_id);
+ window->priv->spaces_instead_of_tabs_id = 0;
+ }
+
+ if (window->priv->language_changed_id && tab == pluma_window_get_active_tab (window))
+ {
+ g_signal_handler_disconnect (doc, window->priv->language_changed_id);
+ window->priv->language_changed_id = 0;
+ }
+
+ g_return_if_fail (window->priv->num_tabs >= 0);
+ if (window->priv->num_tabs == 0)
+ {
+ window->priv->active_tab = NULL;
+
+ set_title (window);
+
+ /* Remove line and col info */
+ pluma_statusbar_set_cursor_position (PLUMA_STATUSBAR (window->priv->statusbar),
+ -1,
+ -1);
+
+ pluma_statusbar_clear_overwrite (PLUMA_STATUSBAR (window->priv->statusbar));
+
+ /* hide the combos */
+ gtk_widget_hide (window->priv->tab_width_combo);
+ gtk_widget_hide (window->priv->language_combo);
+ }
+
+ if (!window->priv->removing_tabs)
+ {
+ update_documents_list_menu (window);
+ update_next_prev_doc_sensitivity_per_window (window);
+ }
+ else
+ {
+ if (window->priv->num_tabs == 0)
+ {
+ update_documents_list_menu (window);
+ update_next_prev_doc_sensitivity_per_window (window);
+ }
+ }
+
+ update_sensitivity_according_to_open_tabs (window);
+
+ if (window->priv->num_tabs == 0)
+ {
+ peas_extension_set_call (window->priv->extensions, "update_state");
+ }
+
+ update_window_state (window);
+
+ g_signal_emit (G_OBJECT (window), signals[TAB_REMOVED], 0, tab);
}
static void
notebook_tabs_reordered (PlumaNotebook *notebook,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- update_documents_list_menu (window);
- update_next_prev_doc_sensitivity_per_window (window);
+ update_documents_list_menu (window);
+ update_next_prev_doc_sensitivity_per_window (window);
- g_signal_emit (G_OBJECT (window), signals[TABS_REORDERED], 0);
+ g_signal_emit (G_OBJECT (window), signals[TABS_REORDERED], 0);
}
static void
notebook_tab_detached (PlumaNotebook *notebook,
- PlumaTab *tab,
- PlumaWindow *window)
+ PlumaTab *tab,
+ PlumaWindow *window)
{
- PlumaWindow *new_window;
+ PlumaWindow *new_window;
- new_window = clone_window (window);
+ new_window = clone_window (window);
- pluma_notebook_move_tab (notebook,
- PLUMA_NOTEBOOK (_pluma_window_get_notebook (new_window)),
- tab, 0);
+ pluma_notebook_move_tab (notebook,
+ PLUMA_NOTEBOOK (_pluma_window_get_notebook (new_window)),
+ tab, 0);
- gtk_window_set_position (GTK_WINDOW (new_window),
- GTK_WIN_POS_MOUSE);
+ gtk_window_set_position (GTK_WINDOW (new_window), GTK_WIN_POS_MOUSE);
- gtk_widget_show (GTK_WIDGET (new_window));
+ gtk_widget_show (GTK_WIDGET (new_window));
}
static void
notebook_tab_close_request (PlumaNotebook *notebook,
- PlumaTab *tab,
- GtkWindow *window)
+ PlumaTab *tab,
+ GtkWindow *window)
{
- /* Note: we are destroying the tab before the default handler
- * seems to be ok, but we need to keep an eye on this. */
- _pluma_cmd_file_close_tab (tab, PLUMA_WINDOW (window));
+ /* Note: we are destroying the tab before the default handler
+ * seems to be ok, but we need to keep an eye on this. */
+ _pluma_cmd_file_close_tab (tab, PLUMA_WINDOW (window));
}
static gboolean
show_notebook_popup_menu (GtkNotebook *notebook,
- PlumaWindow *window,
- GdkEventButton *event)
+ PlumaWindow *window,
+ GdkEventButton *event)
{
- GtkWidget *menu;
-// GtkAction *action;
+ GtkWidget *menu;
+// GtkAction *action;
- menu = gtk_ui_manager_get_widget (window->priv->manager, "/NotebookPopup");
- g_return_val_if_fail (menu != NULL, FALSE);
+ menu = gtk_ui_manager_get_widget (window->priv->manager, "/NotebookPopup");
+ g_return_val_if_fail (menu != NULL, FALSE);
// CHECK do we need this?
#if 0
- /* allow extensions to sync when showing the popup */
- action = gtk_action_group_get_action (window->priv->action_group,
- "NotebookPopupAction");
- g_return_val_if_fail (action != NULL, FALSE);
- gtk_action_activate (action);
+ /* allow extensions to sync when showing the popup */
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "NotebookPopupAction");
+ g_return_val_if_fail (action != NULL, FALSE);
+ gtk_action_activate (action);
#endif
- GtkWidget *tab;
- GtkWidget *tab_label;
+ GtkWidget *tab;
+ GtkWidget *tab_label;
- tab = GTK_WIDGET (pluma_window_get_active_tab (window));
- g_return_val_if_fail (tab != NULL, FALSE);
+ tab = GTK_WIDGET (pluma_window_get_active_tab (window));
+ g_return_val_if_fail (tab != NULL, FALSE);
- tab_label = gtk_notebook_get_tab_label (notebook, tab);
+ tab_label = gtk_notebook_get_tab_label (notebook, tab);
- gtk_menu_popup_at_widget (GTK_MENU (menu),
- tab_label,
- GDK_GRAVITY_SOUTH_WEST,
- GDK_GRAVITY_NORTH_WEST,
- (const GdkEvent*) event);
+ gtk_menu_popup_at_widget (GTK_MENU (menu),
+ tab_label,
+ GDK_GRAVITY_SOUTH_WEST,
+ GDK_GRAVITY_NORTH_WEST,
+ (const GdkEvent*) event);
- gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
+ gtk_menu_shell_select_first (GTK_MENU_SHELL (menu), FALSE);
- return TRUE;
+ return TRUE;
}
static gboolean
notebook_button_press_event (GtkNotebook *notebook,
- GdkEventButton *event,
- PlumaWindow *window)
+ GdkEventButton *event,
+ PlumaWindow *window)
{
- if (event->type == GDK_BUTTON_PRESS)
- {
- if (event->button == 3)
- return show_notebook_popup_menu (notebook, window, event);
+ if (event->type == GDK_BUTTON_PRESS)
+ {
+ if (event->button == 3)
+ return show_notebook_popup_menu (notebook, window, event);
- else if (event->button == 2)
- {
- PlumaTab *tab;
- tab = pluma_window_get_active_tab (window);
- notebook_tab_close_request (PLUMA_NOTEBOOK (notebook), tab, GTK_WINDOW (window));
- }
- }
- else if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
- {
- pluma_window_create_tab (window, TRUE);
- }
+ else if (event->button == 2)
+ {
+ PlumaTab *tab;
+ tab = pluma_window_get_active_tab (window);
+ notebook_tab_close_request (PLUMA_NOTEBOOK (notebook), tab, GTK_WINDOW (window));
+ }
+ }
+ else if ((event->type == GDK_2BUTTON_PRESS) && (event->button == 1))
+ {
+ pluma_window_create_tab (window, TRUE);
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
@@ -3524,601 +3494,593 @@ notebook_scroll_event (GtkNotebook *notebook,
GdkEventScroll *event,
PlumaWindow *window)
{
- if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT)
- {
- gtk_notebook_prev_page (notebook);
- }
- else if (event->direction == GDK_SCROLL_DOWN || event->direction == GDK_SCROLL_RIGHT)
- {
- gtk_notebook_next_page (notebook);
- }
+ if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT)
+ {
+ gtk_notebook_prev_page (notebook);
+ }
+ else if (event->direction == GDK_SCROLL_DOWN || event->direction == GDK_SCROLL_RIGHT)
+ {
+ gtk_notebook_next_page (notebook);
+ }
- return FALSE;
+ return FALSE;
}
static gboolean
notebook_popup_menu (GtkNotebook *notebook,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- /* Only respond if the notebook is the actual focus */
- if (PLUMA_IS_NOTEBOOK (gtk_window_get_focus (GTK_WINDOW (window))))
- {
- return show_notebook_popup_menu (notebook, window, NULL);
- }
+ /* Only respond if the notebook is the actual focus */
+ if (PLUMA_IS_NOTEBOOK (gtk_window_get_focus (GTK_WINDOW (window))))
+ {
+ return show_notebook_popup_menu (notebook, window, NULL);
+ }
- return FALSE;
+ return FALSE;
}
static void
side_panel_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation,
- PlumaWindow *window)
+ GtkAllocation *allocation,
+ PlumaWindow *window)
{
- window->priv->side_panel_size = allocation->width;
+ window->priv->side_panel_size = allocation->width;
}
static void
bottom_panel_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation,
- PlumaWindow *window)
+ GtkAllocation *allocation,
+ PlumaWindow *window)
{
- window->priv->bottom_panel_size = allocation->height;
+ window->priv->bottom_panel_size = allocation->height;
}
static void
hpaned_restore_position (GtkWidget *widget,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- gint pos;
+ gint pos;
- pluma_debug_message (DEBUG_WINDOW,
- "Restoring hpaned position: side panel size %d",
- window->priv->side_panel_size);
+ pluma_debug_message (DEBUG_WINDOW,
+ "Restoring hpaned position: side panel size %d",
+ window->priv->side_panel_size);
- pos = MAX (100, window->priv->side_panel_size);
- gtk_paned_set_position (GTK_PANED (window->priv->hpaned), pos);
+ pos = MAX (100, window->priv->side_panel_size);
+ gtk_paned_set_position (GTK_PANED (window->priv->hpaned), pos);
- /* start monitoring the size */
- g_signal_connect (window->priv->side_panel,
- "size-allocate",
- G_CALLBACK (side_panel_size_allocate),
- window);
+ /* start monitoring the size */
+ g_signal_connect (window->priv->side_panel,
+ "size-allocate",
+ G_CALLBACK (side_panel_size_allocate),
+ window);
- /* run this only once */
- g_signal_handlers_disconnect_by_func (widget, hpaned_restore_position, window);
+ /* run this only once */
+ g_signal_handlers_disconnect_by_func (widget, hpaned_restore_position, window);
}
static void
vpaned_restore_position (GtkWidget *widget,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- GtkAllocation allocation;
- gint pos;
+ GtkAllocation allocation;
+ gint pos;
- gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_allocation (widget, &allocation);
- pluma_debug_message (DEBUG_WINDOW,
- "Restoring vpaned position: bottom panel size %d",
- window->priv->bottom_panel_size);
+ pluma_debug_message (DEBUG_WINDOW,
+ "Restoring vpaned position: bottom panel size %d",
+ window->priv->bottom_panel_size);
- pos = allocation.height -
- MAX (50, window->priv->bottom_panel_size);
- gtk_paned_set_position (GTK_PANED (window->priv->vpaned), pos);
+ pos = allocation.height - MAX (50, window->priv->bottom_panel_size);
+ gtk_paned_set_position (GTK_PANED (window->priv->vpaned), pos);
- /* start monitoring the size */
- g_signal_connect (window->priv->bottom_panel,
- "size-allocate",
- G_CALLBACK (bottom_panel_size_allocate),
- window);
+ /* start monitoring the size */
+ g_signal_connect (window->priv->bottom_panel,
+ "size-allocate",
+ G_CALLBACK (bottom_panel_size_allocate),
+ window);
- /* run this only once */
- g_signal_handlers_disconnect_by_func (widget, vpaned_restore_position, window);
+ /* run this only once */
+ g_signal_handlers_disconnect_by_func (widget, vpaned_restore_position, window);
}
static void
side_panel_visibility_changed (GtkWidget *side_panel,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- gboolean visible;
- GtkAction *action;
+ gboolean visible;
+ GtkAction *action;
- visible = gtk_widget_get_visible (side_panel);
+ visible = gtk_widget_get_visible (side_panel);
- if (!g_settings_get_boolean (window->priv->editor_settings, "show-tabs-with-side-pane"))
- {
- if (visible)
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), FALSE);
- else
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook),
- g_settings_get_boolean (window->priv->editor_settings, "show-single-tab") ||
- (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1));
- }
- else
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook),
- g_settings_get_boolean (window->priv->editor_settings, "show-single-tab") ||
- (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1));
+ if (!g_settings_get_boolean (window->priv->editor_settings, "show-tabs-with-side-pane"))
+ {
+ if (visible)
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), FALSE);
+ else
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook),
+ g_settings_get_boolean (window->priv->editor_settings, "show-single-tab") ||
+ (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1));
+ }
+ else
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook),
+ g_settings_get_boolean (window->priv->editor_settings, "show-single-tab") ||
+ (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1));
- g_settings_set_boolean (window->priv->editor_settings,
- PLUMA_SETTINGS_SIDE_PANE_VISIBLE,
- visible);
+ g_settings_set_boolean (window->priv->editor_settings,
+ PLUMA_SETTINGS_SIDE_PANE_VISIBLE,
+ visible);
- action = gtk_action_group_get_action (window->priv->panes_action_group,
- "ViewSidePane");
+ action = gtk_action_group_get_action (window->priv->panes_action_group,
+ "ViewSidePane");
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
- /* focus the document */
- if (!visible && window->priv->active_tab != NULL)
- gtk_widget_grab_focus (GTK_WIDGET (
- pluma_tab_get_view (PLUMA_TAB (window->priv->active_tab))));
+ /* focus the document */
+ if (!visible && window->priv->active_tab != NULL)
+ gtk_widget_grab_focus (GTK_WIDGET (pluma_tab_get_view (PLUMA_TAB (window->priv->active_tab))));
}
static void
create_side_panel (PlumaWindow *window)
{
- GtkWidget *documents_panel;
+ GtkWidget *documents_panel;
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- window->priv->side_panel = pluma_panel_new (GTK_ORIENTATION_VERTICAL);
+ window->priv->side_panel = pluma_panel_new (GTK_ORIENTATION_VERTICAL);
- gtk_paned_pack1 (GTK_PANED (window->priv->hpaned),
- window->priv->side_panel,
- FALSE,
- FALSE);
+ gtk_paned_pack1 (GTK_PANED (window->priv->hpaned),
+ window->priv->side_panel,
+ FALSE,
+ FALSE);
- g_signal_connect_after (window->priv->side_panel,
- "show",
- G_CALLBACK (side_panel_visibility_changed),
- window);
- g_signal_connect_after (window->priv->side_panel,
- "hide",
- G_CALLBACK (side_panel_visibility_changed),
- window);
+ g_signal_connect_after (window->priv->side_panel,
+ "show",
+ G_CALLBACK (side_panel_visibility_changed),
+ window);
+ g_signal_connect_after (window->priv->side_panel,
+ "hide",
+ G_CALLBACK (side_panel_visibility_changed),
+ window);
- documents_panel = pluma_documents_panel_new (window);
- pluma_panel_add_item_with_icon (PLUMA_PANEL (window->priv->side_panel),
- documents_panel,
- _("Documents"),
- "text-x-generic");
+ documents_panel = pluma_documents_panel_new (window);
+ pluma_panel_add_item_with_icon (PLUMA_PANEL (window->priv->side_panel),
+ documents_panel,
+ _("Documents"),
+ "text-x-generic");
}
static void
bottom_panel_visibility_changed (PlumaPanel *bottom_panel,
- PlumaWindow *window)
+ PlumaWindow *window)
{
- gboolean visible;
- GtkAction *action;
+ gboolean visible;
+ GtkAction *action;
- visible = gtk_widget_get_visible (GTK_WIDGET (bottom_panel));
+ visible = gtk_widget_get_visible (GTK_WIDGET (bottom_panel));
- g_settings_set_boolean (window->priv->editor_settings,
- PLUMA_SETTINGS_BOTTOM_PANE_VISIBLE,
- visible);
+ g_settings_set_boolean (window->priv->editor_settings,
+ PLUMA_SETTINGS_BOTTOM_PANE_VISIBLE,
+ visible);
- action = gtk_action_group_get_action (window->priv->panes_action_group,
- "ViewBottomPane");
+ action = gtk_action_group_get_action (window->priv->panes_action_group,
+ "ViewBottomPane");
- if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
+ if (gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)) != visible)
+ gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), visible);
- /* focus the document */
- if (!visible && window->priv->active_tab != NULL)
- gtk_widget_grab_focus (GTK_WIDGET (
- pluma_tab_get_view (PLUMA_TAB (window->priv->active_tab))));
+ /* focus the document */
+ if (!visible && window->priv->active_tab != NULL)
+ gtk_widget_grab_focus (GTK_WIDGET (pluma_tab_get_view (PLUMA_TAB (window->priv->active_tab))));
}
static void
bottom_panel_item_removed (PlumaPanel *panel,
- GtkWidget *item,
- PlumaWindow *window)
+ GtkWidget *item,
+ PlumaWindow *window)
{
- if (pluma_panel_get_n_items (panel) == 0)
- {
- GtkAction *action;
+ if (pluma_panel_get_n_items (panel) == 0)
+ {
+ GtkAction *action;
- gtk_widget_hide (GTK_WIDGET (panel));
+ gtk_widget_hide (GTK_WIDGET (panel));
- action = gtk_action_group_get_action (window->priv->panes_action_group,
- "ViewBottomPane");
- gtk_action_set_sensitive (action, FALSE);
- }
+ action = gtk_action_group_get_action (window->priv->panes_action_group,
+ "ViewBottomPane");
+ gtk_action_set_sensitive (action, FALSE);
+ }
}
static void
bottom_panel_item_added (PlumaPanel *panel,
- GtkWidget *item,
- PlumaWindow *window)
+ GtkWidget *item,
+ PlumaWindow *window)
{
- /* if it's the first item added, set the menu item
- * sensitive and if needed show the panel */
- if (pluma_panel_get_n_items (panel) == 1)
- {
- GtkAction *action;
- gboolean show;
+ /* if it's the first item added, set the menu item
+ * sensitive and if needed show the panel */
+ if (pluma_panel_get_n_items (panel) == 1)
+ {
+ GtkAction *action;
+ gboolean show;
- action = gtk_action_group_get_action (window->priv->panes_action_group,
- "ViewBottomPane");
- gtk_action_set_sensitive (action, TRUE);
+ action = gtk_action_group_get_action (window->priv->panes_action_group,
+ "ViewBottomPane");
+ gtk_action_set_sensitive (action, TRUE);
- show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- if (show)
- gtk_widget_show (GTK_WIDGET (panel));
- }
+ show = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ if (show)
+ gtk_widget_show (GTK_WIDGET (panel));
+ }
}
static void
create_bottom_panel (PlumaWindow *window)
{
- pluma_debug (DEBUG_WINDOW);
+ pluma_debug (DEBUG_WINDOW);
- window->priv->bottom_panel = pluma_panel_new (GTK_ORIENTATION_HORIZONTAL);
+ window->priv->bottom_panel = pluma_panel_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_paned_pack2 (GTK_PANED (window->priv->vpaned),
- window->priv->bottom_panel,
- FALSE,
- FALSE);
+ gtk_paned_pack2 (GTK_PANED (window->priv->vpaned),
+ window->priv->bottom_panel,
+ FALSE,
+ FALSE);
- g_signal_connect_after (window->priv->bottom_panel,
- "show",
- G_CALLBACK (bottom_panel_visibility_changed),
- window);
- g_signal_connect_after (window->priv->bottom_panel,
- "hide",
- G_CALLBACK (bottom_panel_visibility_changed),
- window);
+ g_signal_connect_after (window->priv->bottom_panel,
+ "show",
+ G_CALLBACK (bottom_panel_visibility_changed),
+ window);
+ g_signal_connect_after (window->priv->bottom_panel,
+ "hide",
+ G_CALLBACK (bottom_panel_visibility_changed),
+ window);
}
static void
init_panels_visibility (PlumaWindow *window)
{
- gint active_page;
- gboolean side_pane_visible;
- gboolean bottom_pane_visible;
-
- pluma_debug (DEBUG_WINDOW);
-
- /* side pane */
- active_page = g_settings_get_int (window->priv->editor_settings,
- PLUMA_SETTINGS_SIDE_PANEL_ACTIVE_PAGE);
- _pluma_panel_set_active_item_by_id (PLUMA_PANEL (window->priv->side_panel),
- active_page);
-
- side_pane_visible = g_settings_get_boolean (window->priv->editor_settings,
- PLUMA_SETTINGS_SIDE_PANE_VISIBLE);
- bottom_pane_visible = g_settings_get_boolean (window->priv->editor_settings,
- PLUMA_SETTINGS_BOTTOM_PANE_VISIBLE);
-
- if (side_pane_visible)
-
- {
- gtk_widget_show (window->priv->side_panel);
- }
-
- /* bottom pane, it can be empty */
- if (pluma_panel_get_n_items (PLUMA_PANEL (window->priv->bottom_panel)) > 0)
- {
- active_page = g_settings_get_int (window->priv->editor_settings,
- PLUMA_SETTINGS_BOTTOM_PANEL_ACTIVE_PAGE);
- _pluma_panel_set_active_item_by_id (PLUMA_PANEL (window->priv->bottom_panel),
- active_page);
-
- if (bottom_pane_visible)
- {
- gtk_widget_show (window->priv->bottom_panel);
- }
- }
- else
- {
- GtkAction *action;
- action = gtk_action_group_get_action (window->priv->panes_action_group,
- "ViewBottomPane");
- gtk_action_set_sensitive (action, FALSE);
- }
-
- /* start track sensitivity after the initial state is set */
- window->priv->bottom_panel_item_removed_handler_id =
- g_signal_connect (window->priv->bottom_panel,
- "item_removed",
- G_CALLBACK (bottom_panel_item_removed),
- window);
-
- g_signal_connect (window->priv->bottom_panel,
- "item_added",
- G_CALLBACK (bottom_panel_item_added),
- window);
+ gint active_page;
+ gboolean side_pane_visible;
+ gboolean bottom_pane_visible;
+
+ pluma_debug (DEBUG_WINDOW);
+
+ /* side pane */
+ active_page = g_settings_get_int (window->priv->editor_settings,
+ PLUMA_SETTINGS_SIDE_PANEL_ACTIVE_PAGE);
+ _pluma_panel_set_active_item_by_id (PLUMA_PANEL (window->priv->side_panel),
+ active_page);
+
+ side_pane_visible = g_settings_get_boolean (window->priv->editor_settings,
+ PLUMA_SETTINGS_SIDE_PANE_VISIBLE);
+ bottom_pane_visible = g_settings_get_boolean (window->priv->editor_settings,
+ PLUMA_SETTINGS_BOTTOM_PANE_VISIBLE);
+
+ if (side_pane_visible)
+
+ {
+ gtk_widget_show (window->priv->side_panel);
+ }
+
+ /* bottom pane, it can be empty */
+ if (pluma_panel_get_n_items (PLUMA_PANEL (window->priv->bottom_panel)) > 0)
+ {
+ active_page = g_settings_get_int (window->priv->editor_settings,
+ PLUMA_SETTINGS_BOTTOM_PANEL_ACTIVE_PAGE);
+ _pluma_panel_set_active_item_by_id (PLUMA_PANEL (window->priv->bottom_panel),
+ active_page);
+
+ if (bottom_pane_visible)
+ {
+ gtk_widget_show (window->priv->bottom_panel);
+ }
+ }
+ else
+ {
+ GtkAction *action;
+ action = gtk_action_group_get_action (window->priv->panes_action_group,
+ "ViewBottomPane");
+ gtk_action_set_sensitive (action, FALSE);
+ }
+
+ /* start track sensitivity after the initial state is set */
+ window->priv->bottom_panel_item_removed_handler_id =
+ g_signal_connect (window->priv->bottom_panel,
+ "item_removed",
+ G_CALLBACK (bottom_panel_item_removed),
+ window);
+
+ g_signal_connect (window->priv->bottom_panel,
+ "item_added",
+ G_CALLBACK (bottom_panel_item_added),
+ window);
}
static void
-clipboard_owner_change (GtkClipboard *clipboard,
- GdkEventOwnerChange *event,
- PlumaWindow *window)
+clipboard_owner_change (GtkClipboard *clipboard,
+ GdkEventOwnerChange *event,
+ PlumaWindow *window)
{
- set_paste_sensitivity_according_to_clipboard (window,
- clipboard);
+ set_paste_sensitivity_according_to_clipboard (window, clipboard);
}
static void
window_realized (GtkWidget *window,
- gpointer *data)
+ gpointer *data)
{
- GtkClipboard *clipboard;
+ GtkClipboard *clipboard;
- clipboard = gtk_widget_get_clipboard (window,
- GDK_SELECTION_CLIPBOARD);
+ clipboard = gtk_widget_get_clipboard (window, GDK_SELECTION_CLIPBOARD);
- g_signal_connect (clipboard,
- "owner_change",
- G_CALLBACK (clipboard_owner_change),
- window);
+ g_signal_connect (clipboard,
+ "owner_change",
+ G_CALLBACK (clipboard_owner_change),
+ window);
}
static void
window_unrealized (GtkWidget *window,
- gpointer *data)
+ gpointer *data)
{
- GtkClipboard *clipboard;
+ GtkClipboard *clipboard;
- clipboard = gtk_widget_get_clipboard (window,
- GDK_SELECTION_CLIPBOARD);
+ clipboard = gtk_widget_get_clipboard (window, GDK_SELECTION_CLIPBOARD);
- g_signal_handlers_disconnect_by_func (clipboard,
- G_CALLBACK (clipboard_owner_change),
- window);
+ g_signal_handlers_disconnect_by_func (clipboard,
+ G_CALLBACK (clipboard_owner_change),
+ window);
}
static void
check_window_is_active (PlumaWindow *window,
- GParamSpec *property,
- gpointer useless)
-{
- if (window->priv->window_state & GDK_WINDOW_STATE_FULLSCREEN)
- {
- if (gtk_window_is_active (GTK_WINDOW (window)))
- {
- gtk_widget_show (window->priv->fullscreen_controls);
- }
- else
- {
- gtk_widget_hide (window->priv->fullscreen_controls);
- }
- }
+ GParamSpec *property,
+ gpointer useless)
+{
+ if (window->priv->window_state & GDK_WINDOW_STATE_FULLSCREEN)
+ {
+ if (gtk_window_is_active (GTK_WINDOW (window)))
+ {
+ gtk_widget_show (window->priv->fullscreen_controls);
+ }
+ else
+ {
+ gtk_widget_hide (window->priv->fullscreen_controls);
+ }
+ }
}
static void
connect_notebook_signals (PlumaWindow *window,
- GtkWidget *notebook)
-{
- g_signal_connect (notebook,
- "switch-page",
- G_CALLBACK (notebook_switch_page),
- window);
- g_signal_connect (notebook,
- "tab-added",
- G_CALLBACK (notebook_tab_added),
- window);
- g_signal_connect (notebook,
- "tab-removed",
- G_CALLBACK (notebook_tab_removed),
- window);
- g_signal_connect (notebook,
- "tabs-reordered",
- G_CALLBACK (notebook_tabs_reordered),
- window);
- g_signal_connect (notebook,
- "tab-detached",
- G_CALLBACK (notebook_tab_detached),
- window);
- g_signal_connect (notebook,
- "tab-close-request",
- G_CALLBACK (notebook_tab_close_request),
- window);
- g_signal_connect (notebook,
- "button-press-event",
- G_CALLBACK (notebook_button_press_event),
- window);
- g_signal_connect (notebook,
- "popup-menu",
- G_CALLBACK (notebook_popup_menu),
- window);
- g_signal_connect (notebook,
- "scroll-event",
- G_CALLBACK (notebook_scroll_event),
- window);
+ GtkWidget *notebook)
+{
+ g_signal_connect (notebook,
+ "switch-page",
+ G_CALLBACK (notebook_switch_page),
+ window);
+ g_signal_connect (notebook,
+ "tab-added",
+ G_CALLBACK (notebook_tab_added),
+ window);
+ g_signal_connect (notebook,
+ "tab-removed",
+ G_CALLBACK (notebook_tab_removed),
+ window);
+ g_signal_connect (notebook,
+ "tabs-reordered",
+ G_CALLBACK (notebook_tabs_reordered),
+ window);
+ g_signal_connect (notebook,
+ "tab-detached",
+ G_CALLBACK (notebook_tab_detached),
+ window);
+ g_signal_connect (notebook,
+ "tab-close-request",
+ G_CALLBACK (notebook_tab_close_request),
+ window);
+ g_signal_connect (notebook,
+ "button-press-event",
+ G_CALLBACK (notebook_button_press_event),
+ window);
+ g_signal_connect (notebook,
+ "popup-menu",
+ G_CALLBACK (notebook_popup_menu),
+ window);
+ g_signal_connect (notebook,
+ "scroll-event",
+ G_CALLBACK (notebook_scroll_event),
+ window);
}
static void
add_notebook (PlumaWindow *window,
- GtkWidget *notebook)
+ GtkWidget *notebook)
{
- gtk_paned_pack1 (GTK_PANED (window->priv->vpaned),
- notebook,
- TRUE,
- TRUE);
+ gtk_paned_pack1 (GTK_PANED (window->priv->vpaned),
+ notebook,
+ TRUE,
+ TRUE);
- gtk_widget_show (notebook);
+ gtk_widget_show (notebook);
- gtk_widget_add_events (notebook, GDK_SCROLL_MASK);
- connect_notebook_signals (window, notebook);
+ gtk_widget_add_events (notebook, GDK_SCROLL_MASK);
+ connect_notebook_signals (window, notebook);
}
static void
on_extension_added (PeasExtensionSet *extensions,
- PeasPluginInfo *info,
- PeasExtension *exten,
- PlumaWindow *window)
+ PeasPluginInfo *info,
+ PeasExtension *exten,
+ PlumaWindow *window)
{
- peas_extension_call (exten, "activate", window);
+ peas_extension_call (exten, "activate", window);
}
static void
on_extension_removed (PeasExtensionSet *extensions,
- PeasPluginInfo *info,
- PeasExtension *exten,
- PlumaWindow *window)
+ PeasPluginInfo *info,
+ PeasExtension *exten,
+ PlumaWindow *window)
{
- peas_extension_call (exten, "deactivate", window);
+ peas_extension_call (exten, "deactivate", window);
- /* Ensure update of ui manager, because we suspect it does something
- * with expected static strings in the type module (when unloaded the
- * strings don't exist anymore, and ui manager updates in an idle
- * func) */
- gtk_ui_manager_ensure_update (window->priv->manager);
+ /* Ensure update of ui manager, because we suspect it does something
+ * with expected static strings in the type module (when unloaded the
+ * strings don't exist anymore, and ui manager updates in an idle
+ * func) */
+ gtk_ui_manager_ensure_update (window->priv->manager);
}
static void
pluma_window_init (PlumaWindow *window)
{
- GtkWidget *main_box;
- GtkTargetList *tl;
-
- pluma_debug (DEBUG_WINDOW);
-
- window->priv = pluma_window_get_instance_private (window);
- window->priv->active_tab = NULL;
- window->priv->num_tabs = 0;
- window->priv->removing_tabs = FALSE;
- window->priv->state = PLUMA_WINDOW_STATE_NORMAL;
- window->priv->dispose_has_run = FALSE;
- window->priv->fullscreen_controls = NULL;
- window->priv->fullscreen_animation_timeout_id = 0;
- window->priv->editor_settings = g_settings_new (PLUMA_SCHEMA_ID);
-
- window->priv->message_bus = pluma_message_bus_new ();
-
- window->priv->window_group = gtk_window_group_new ();
- gtk_window_group_add_window (window->priv->window_group, GTK_WINDOW (window));
-
- GtkStyleContext *context;
-
- context = gtk_widget_get_style_context (GTK_WIDGET (window));
- gtk_style_context_add_class (context, "pluma-window");
-
- main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (window), main_box);
- gtk_widget_show (main_box);
-
- /* Add menu bar and toolbar bar */
- create_menu_bar_and_toolbar (window, main_box);
-
- /* Add status bar */
- create_statusbar (window, main_box);
-
- /* Add the main area */
- pluma_debug_message (DEBUG_WINDOW, "Add main area");
- window->priv->hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
- gtk_box_pack_start (GTK_BOX (main_box),
- window->priv->hpaned,
- TRUE,
- TRUE,
- 0);
-
- window->priv->vpaned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
- gtk_paned_pack2 (GTK_PANED (window->priv->hpaned),
- window->priv->vpaned,
- TRUE,
- FALSE);
-
- pluma_debug_message (DEBUG_WINDOW, "Create pluma notebook");
- window->priv->notebook = pluma_notebook_new ();
- add_notebook (window, window->priv->notebook);
-
- /* side and bottom panels */
- create_side_panel (window);
- create_bottom_panel (window);
-
- /* panes' state must be restored after panels have been mapped,
- * since the bottom pane position depends on the size of the vpaned. */
- window->priv->side_panel_size = g_settings_get_int (window->priv->editor_settings,
- PLUMA_SETTINGS_SIDE_PANEL_SIZE);
- window->priv->bottom_panel_size = g_settings_get_int (window->priv->editor_settings,
- PLUMA_SETTINGS_BOTTOM_PANEL_SIZE);
-
- g_signal_connect_after (window->priv->hpaned,
- "map",
- G_CALLBACK (hpaned_restore_position),
- window);
- g_signal_connect_after (window->priv->vpaned,
- "map",
- G_CALLBACK (vpaned_restore_position),
- window);
-
- gtk_widget_show (window->priv->hpaned);
- gtk_widget_show (window->priv->vpaned);
-
- /* Drag and drop support, set targets to NULL because we add the
- default uri_targets below */
- gtk_drag_dest_set (GTK_WIDGET (window),
- GTK_DEST_DEFAULT_MOTION |
- GTK_DEST_DEFAULT_HIGHLIGHT |
- GTK_DEST_DEFAULT_DROP,
- NULL,
- 0,
- GDK_ACTION_COPY);
-
- /* Add uri targets */
- tl = gtk_drag_dest_get_target_list (GTK_WIDGET (window));
-
- if (tl == NULL)
- {
- tl = gtk_target_list_new (NULL, 0);
- gtk_drag_dest_set_target_list (GTK_WIDGET (window), tl);
- gtk_target_list_unref (tl);
- }
-
- gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
-
- /* connect instead of override, so that we can
- * share the cb code with the view */
- g_signal_connect (window,
- "drag_data_received",
- G_CALLBACK (drag_data_received_cb),
- NULL);
-
- /* we can get the clipboard only after the widget
- * is realized */
- g_signal_connect (window,
- "realize",
- G_CALLBACK (window_realized),
- NULL);
- g_signal_connect (window,
- "unrealize",
- G_CALLBACK (window_unrealized),
- NULL);
-
- /* Check if the window is active for fullscreen */
- g_signal_connect (window,
- "notify::is-active",
- G_CALLBACK (check_window_is_active),
- NULL);
-
- pluma_debug_message (DEBUG_WINDOW, "Update plugins ui");
-
- window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (pluma_plugins_engine_get_default ()),
+ GtkWidget *main_box;
+ GtkTargetList *tl;
+
+ pluma_debug (DEBUG_WINDOW);
+
+ window->priv = pluma_window_get_instance_private (window);
+ window->priv->active_tab = NULL;
+ window->priv->num_tabs = 0;
+ window->priv->removing_tabs = FALSE;
+ window->priv->state = PLUMA_WINDOW_STATE_NORMAL;
+ window->priv->dispose_has_run = FALSE;
+ window->priv->fullscreen_controls = NULL;
+ window->priv->fullscreen_animation_timeout_id = 0;
+ window->priv->editor_settings = g_settings_new (PLUMA_SCHEMA_ID);
+
+ window->priv->message_bus = pluma_message_bus_new ();
+
+ window->priv->window_group = gtk_window_group_new ();
+ gtk_window_group_add_window (window->priv->window_group, GTK_WINDOW (window));
+
+ GtkStyleContext *context;
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (window));
+ gtk_style_context_add_class (context, "pluma-window");
+
+ main_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_container_add (GTK_CONTAINER (window), main_box);
+ gtk_widget_show (main_box);
+
+ /* Add menu bar and toolbar bar */
+ create_menu_bar_and_toolbar (window, main_box);
+
+ /* Add status bar */
+ create_statusbar (window, main_box);
+
+ /* Add the main area */
+ pluma_debug_message (DEBUG_WINDOW, "Add main area");
+ window->priv->hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL);
+ gtk_box_pack_start (GTK_BOX (main_box),
+ window->priv->hpaned,
+ TRUE,
+ TRUE,
+ 0);
+
+ window->priv->vpaned = gtk_paned_new (GTK_ORIENTATION_VERTICAL);
+ gtk_paned_pack2 (GTK_PANED (window->priv->hpaned),
+ window->priv->vpaned,
+ TRUE,
+ FALSE);
+
+ pluma_debug_message (DEBUG_WINDOW, "Create pluma notebook");
+ window->priv->notebook = pluma_notebook_new ();
+ add_notebook (window, window->priv->notebook);
+
+ /* side and bottom panels */
+ create_side_panel (window);
+ create_bottom_panel (window);
+
+ /* panes' state must be restored after panels have been mapped,
+ * since the bottom pane position depends on the size of the vpaned. */
+ window->priv->side_panel_size = g_settings_get_int (window->priv->editor_settings,
+ PLUMA_SETTINGS_SIDE_PANEL_SIZE);
+ window->priv->bottom_panel_size = g_settings_get_int (window->priv->editor_settings,
+ PLUMA_SETTINGS_BOTTOM_PANEL_SIZE);
+
+ g_signal_connect_after (window->priv->hpaned,
+ "map",
+ G_CALLBACK (hpaned_restore_position),
+ window);
+ g_signal_connect_after (window->priv->vpaned,
+ "map",
+ G_CALLBACK (vpaned_restore_position),
+ window);
+
+ gtk_widget_show (window->priv->hpaned);
+ gtk_widget_show (window->priv->vpaned);
+
+ /* Drag and drop support, set targets to NULL because we add the
+ default uri_targets below */
+ gtk_drag_dest_set (GTK_WIDGET (window),
+ GTK_DEST_DEFAULT_MOTION |
+ GTK_DEST_DEFAULT_HIGHLIGHT |
+ GTK_DEST_DEFAULT_DROP,
+ NULL,
+ 0,
+ GDK_ACTION_COPY);
+
+ /* Add uri targets */
+ tl = gtk_drag_dest_get_target_list (GTK_WIDGET (window));
+
+ if (tl == NULL)
+ {
+ tl = gtk_target_list_new (NULL, 0);
+ gtk_drag_dest_set_target_list (GTK_WIDGET (window), tl);
+ gtk_target_list_unref (tl);
+ }
+
+ gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
+
+ /* connect instead of override, so that we can
+ * share the cb code with the view */
+ g_signal_connect (window,
+ "drag_data_received",
+ G_CALLBACK (drag_data_received_cb),
+ NULL);
+
+ /* we can get the clipboard only after the widget
+ * is realized */
+ g_signal_connect (window,
+ "realize",
+ G_CALLBACK (window_realized),
+ NULL);
+ g_signal_connect (window,
+ "unrealize",
+ G_CALLBACK (window_unrealized),
+ NULL);
+
+ /* Check if the window is active for fullscreen */
+ g_signal_connect (window,
+ "notify::is-active",
+ G_CALLBACK (check_window_is_active),
+ NULL);
+
+ pluma_debug_message (DEBUG_WINDOW, "Update plugins ui");
+
+ window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (pluma_plugins_engine_get_default ()),
PLUMA_TYPE_WINDOW_ACTIVATABLE,
"window",
window,
NULL);
- g_signal_connect (window->priv->extensions,
- "extension-added",
- G_CALLBACK (on_extension_added),
- window);
- g_signal_connect (window->priv->extensions,
- "extension-removed",
- G_CALLBACK (on_extension_removed),
- window);
+ g_signal_connect (window->priv->extensions, "extension-added",
+ G_CALLBACK (on_extension_added),
+ window);
+ g_signal_connect (window->priv->extensions, "extension-removed",
+ G_CALLBACK (on_extension_removed),
+ window);
- peas_extension_set_call (window->priv->extensions, "activate");
+ peas_extension_set_call (window->priv->extensions, "activate");
- /* set visibility of panes.
- This needs to be done after plugins activatation */
- init_panels_visibility (window);
+ /* set visibility of panes.
+ * This needs to be done after plugins activatation */
+ init_panels_visibility (window);
- update_sensitivity_according_to_open_tabs (window);
+ update_sensitivity_according_to_open_tabs (window);
- pluma_debug_message (DEBUG_WINDOW, "END");
+ pluma_debug_message (DEBUG_WINDOW, "END");
}
/**
@@ -4132,16 +4094,16 @@ pluma_window_init (PlumaWindow *window)
PlumaView *
pluma_window_get_active_view (PlumaWindow *window)
{
- PlumaView *view;
+ PlumaView *view;
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- if (window->priv->active_tab == NULL)
- return NULL;
+ if (window->priv->active_tab == NULL)
+ return NULL;
- view = pluma_tab_get_view (PLUMA_TAB (window->priv->active_tab));
+ view = pluma_tab_get_view (PLUMA_TAB (window->priv->active_tab));
- return view;
+ return view;
}
/**
@@ -4155,23 +4117,23 @@ pluma_window_get_active_view (PlumaWindow *window)
PlumaDocument *
pluma_window_get_active_document (PlumaWindow *window)
{
- PlumaView *view;
+ PlumaView *view;
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- view = pluma_window_get_active_view (window);
- if (view == NULL)
- return NULL;
+ view = pluma_window_get_active_view (window);
+ if (view == NULL)
+ return NULL;
- return PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+ return PLUMA_DOCUMENT (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
}
GtkWidget *
_pluma_window_get_notebook (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- return window->priv->notebook;
+ return window->priv->notebook;
}
/**
@@ -4186,26 +4148,26 @@ _pluma_window_get_notebook (PlumaWindow *window)
*/
PlumaTab *
pluma_window_create_tab (PlumaWindow *window,
- gboolean jump_to)
+ gboolean jump_to)
{
- PlumaTab *tab;
+ PlumaTab *tab;
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- tab = PLUMA_TAB (_pluma_tab_new ());
- gtk_widget_show (GTK_WIDGET (tab));
+ tab = PLUMA_TAB (_pluma_tab_new ());
+ gtk_widget_show (GTK_WIDGET (tab));
- pluma_notebook_add_tab (PLUMA_NOTEBOOK (window->priv->notebook),
- tab,
- -1,
- jump_to);
+ pluma_notebook_add_tab (PLUMA_NOTEBOOK (window->priv->notebook),
+ tab,
+ -1,
+ jump_to);
- if (!gtk_widget_get_visible (GTK_WIDGET (window)))
- {
- gtk_window_present (GTK_WINDOW (window));
- }
+ if (!gtk_widget_get_visible (GTK_WIDGET (window)))
+ {
+ gtk_window_present (GTK_WINDOW (window));
+ }
- return tab;
+ return tab;
}
/**
@@ -4226,38 +4188,37 @@ pluma_window_create_tab (PlumaWindow *window,
*/
PlumaTab *
pluma_window_create_tab_from_uri (PlumaWindow *window,
- const gchar *uri,
- const PlumaEncoding *encoding,
- gint line_pos,
- gboolean create,
- gboolean jump_to)
+ const gchar *uri,
+ const PlumaEncoding *encoding,
+ gint line_pos,
+ gboolean create,
+ gboolean jump_to)
{
- GtkWidget *tab;
-
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- g_return_val_if_fail (uri != NULL, NULL);
+ GtkWidget *tab;
- tab = _pluma_tab_new_from_uri (uri,
- encoding,
- line_pos,
- create);
- if (tab == NULL)
- return NULL;
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (uri != NULL, NULL);
- gtk_widget_show (tab);
+ tab = _pluma_tab_new_from_uri (uri,
+ encoding,
+ line_pos,
+ create);
+ if (tab == NULL)
+ return NULL;
- pluma_notebook_add_tab (PLUMA_NOTEBOOK (window->priv->notebook),
- PLUMA_TAB (tab),
- -1,
- jump_to);
+ gtk_widget_show (tab);
+ pluma_notebook_add_tab (PLUMA_NOTEBOOK (window->priv->notebook),
+ PLUMA_TAB (tab),
+ -1,
+ jump_to);
- if (!gtk_widget_get_visible (GTK_WIDGET (window)))
- {
- gtk_window_present (GTK_WINDOW (window));
- }
+ if (!gtk_widget_get_visible (GTK_WIDGET (window)))
+ {
+ gtk_window_present (GTK_WINDOW (window));
+ }
- return PLUMA_TAB (tab);
+ return PLUMA_TAB (tab);
}
/**
@@ -4271,20 +4232,20 @@ pluma_window_create_tab_from_uri (PlumaWindow *window,
PlumaTab *
pluma_window_get_active_tab (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- return (window->priv->active_tab == NULL) ?
- NULL : PLUMA_TAB (window->priv->active_tab);
+ return (window->priv->active_tab == NULL) ?
+ NULL : PLUMA_TAB (window->priv->active_tab);
}
static void
add_document (PlumaTab *tab, GList **res)
{
- PlumaDocument *doc;
+ PlumaDocument *doc;
- doc = pluma_tab_get_document (tab);
+ doc = pluma_tab_get_document (tab);
- *res = g_list_prepend (*res, doc);
+ *res = g_list_prepend (*res, doc);
}
/**
@@ -4300,27 +4261,27 @@ add_document (PlumaTab *tab, GList **res)
GList *
pluma_window_get_documents (PlumaWindow *window)
{
- GList *res = NULL;
+ GList *res = NULL;
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- gtk_container_foreach (GTK_CONTAINER (window->priv->notebook),
- (GtkCallback)add_document,
- &res);
+ gtk_container_foreach (GTK_CONTAINER (window->priv->notebook),
+ (GtkCallback)add_document,
+ &res);
- res = g_list_reverse (res);
+ res = g_list_reverse (res);
- return res;
+ return res;
}
static void
add_view (PlumaTab *tab, GList **res)
{
- PlumaView *view;
+ PlumaView *view;
- view = pluma_tab_get_view (tab);
+ view = pluma_tab_get_view (tab);
- *res = g_list_prepend (*res, view);
+ *res = g_list_prepend (*res, view);
}
/**
@@ -4335,17 +4296,17 @@ add_view (PlumaTab *tab, GList **res)
GList *
pluma_window_get_views (PlumaWindow *window)
{
- GList *res = NULL;
+ GList *res = NULL;
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- gtk_container_foreach (GTK_CONTAINER (window->priv->notebook),
- (GtkCallback)add_view,
- &res);
+ gtk_container_foreach (GTK_CONTAINER (window->priv->notebook),
+ (GtkCallback)add_view,
+ &res);
- res = g_list_reverse (res);
+ res = g_list_reverse (res);
- return res;
+ return res;
}
/**
@@ -4357,15 +4318,14 @@ pluma_window_get_views (PlumaWindow *window)
*/
void
pluma_window_close_tab (PlumaWindow *window,
- PlumaTab *tab)
+ PlumaTab *tab)
{
- g_return_if_fail (PLUMA_IS_WINDOW (window));
- g_return_if_fail (PLUMA_IS_TAB (tab));
- g_return_if_fail ((pluma_tab_get_state (tab) != PLUMA_TAB_STATE_SAVING) &&
- (pluma_tab_get_state (tab) != PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW));
+ g_return_if_fail (PLUMA_IS_WINDOW (window));
+ g_return_if_fail (PLUMA_IS_TAB (tab));
+ g_return_if_fail ((pluma_tab_get_state (tab) != PLUMA_TAB_STATE_SAVING) &&
+ (pluma_tab_get_state (tab) != PLUMA_TAB_STATE_SHOWING_PRINT_PREVIEW));
- pluma_notebook_remove_tab (PLUMA_NOTEBOOK (window->priv->notebook),
- tab);
+ pluma_notebook_remove_tab (PLUMA_NOTEBOOK (window->priv->notebook), tab);
}
/**
@@ -4377,15 +4337,15 @@ pluma_window_close_tab (PlumaWindow *window,
void
pluma_window_close_all_tabs (PlumaWindow *window)
{
- g_return_if_fail (PLUMA_IS_WINDOW (window));
- g_return_if_fail (!(window->priv->state & PLUMA_WINDOW_STATE_SAVING) &&
- !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
+ g_return_if_fail (PLUMA_IS_WINDOW (window));
+ g_return_if_fail (!(window->priv->state & PLUMA_WINDOW_STATE_SAVING) &&
+ !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
- window->priv->removing_tabs = TRUE;
+ window->priv->removing_tabs = TRUE;
- pluma_notebook_remove_all_tabs (PLUMA_NOTEBOOK (window->priv->notebook));
+ pluma_notebook_remove_all_tabs (PLUMA_NOTEBOOK (window->priv->notebook));
- window->priv->removing_tabs = FALSE;
+ window->priv->removing_tabs = FALSE;
}
/**
@@ -4397,53 +4357,52 @@ pluma_window_close_all_tabs (PlumaWindow *window)
*/
void
pluma_window_close_tabs (PlumaWindow *window,
- const GList *tabs)
+ const GList *tabs)
{
- g_return_if_fail (PLUMA_IS_WINDOW (window));
- g_return_if_fail (!(window->priv->state & PLUMA_WINDOW_STATE_SAVING) &&
- !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
+ g_return_if_fail (PLUMA_IS_WINDOW (window));
+ g_return_if_fail (!(window->priv->state & PLUMA_WINDOW_STATE_SAVING) &&
+ !(window->priv->state & PLUMA_WINDOW_STATE_SAVING_SESSION));
- if (tabs == NULL)
- return;
+ if (tabs == NULL)
+ return;
- window->priv->removing_tabs = TRUE;
+ window->priv->removing_tabs = TRUE;
- while (tabs != NULL)
- {
- if (tabs->next == NULL)
- window->priv->removing_tabs = FALSE;
+ while (tabs != NULL)
+ {
+ if (tabs->next == NULL)
+ window->priv->removing_tabs = FALSE;
- pluma_notebook_remove_tab (PLUMA_NOTEBOOK (window->priv->notebook),
- PLUMA_TAB (tabs->data));
+ pluma_notebook_remove_tab (PLUMA_NOTEBOOK (window->priv->notebook),
+ PLUMA_TAB (tabs->data));
- tabs = g_list_next (tabs);
- }
+ tabs = g_list_next (tabs);
+ }
- g_return_if_fail (window->priv->removing_tabs == FALSE);
+ g_return_if_fail (window->priv->removing_tabs == FALSE);
}
PlumaWindow *
_pluma_window_move_tab_to_new_window (PlumaWindow *window,
- PlumaTab *tab)
+ PlumaTab *tab)
{
- PlumaWindow *new_window;
+ PlumaWindow *new_window;
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- g_return_val_if_fail (PLUMA_IS_TAB (tab), NULL);
- g_return_val_if_fail (gtk_notebook_get_n_pages (
- GTK_NOTEBOOK (window->priv->notebook)) > 1,
- NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_TAB (tab), NULL);
+ g_return_val_if_fail (gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->priv->notebook)) > 1,
+ NULL);
- new_window = clone_window (window);
+ new_window = clone_window (window);
- pluma_notebook_move_tab (PLUMA_NOTEBOOK (window->priv->notebook),
- PLUMA_NOTEBOOK (new_window->priv->notebook),
- tab,
- -1);
+ pluma_notebook_move_tab (PLUMA_NOTEBOOK (window->priv->notebook),
+ PLUMA_NOTEBOOK (new_window->priv->notebook),
+ tab,
+ -1);
- gtk_widget_show (GTK_WIDGET (new_window));
+ gtk_widget_show (GTK_WIDGET (new_window));
- return new_window;
+ return new_window;
}
/**
@@ -4455,19 +4414,19 @@ _pluma_window_move_tab_to_new_window (PlumaWindow *window,
*/
void
pluma_window_set_active_tab (PlumaWindow *window,
- PlumaTab *tab)
+ PlumaTab *tab)
{
- gint page_num;
+ gint page_num;
- g_return_if_fail (PLUMA_IS_WINDOW (window));
- g_return_if_fail (PLUMA_IS_TAB (tab));
+ g_return_if_fail (PLUMA_IS_WINDOW (window));
+ g_return_if_fail (PLUMA_IS_TAB (tab));
- page_num = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
- GTK_WIDGET (tab));
- g_return_if_fail (page_num != -1);
+ page_num = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
+ GTK_WIDGET (tab));
+ g_return_if_fail (page_num != -1);
- gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook),
- page_num);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook),
+ page_num);
}
/**
@@ -4481,17 +4440,17 @@ pluma_window_set_active_tab (PlumaWindow *window,
GtkWindowGroup *
pluma_window_get_group (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- return window->priv->window_group;
+ return window->priv->window_group;
}
gboolean
_pluma_window_is_removing_tabs (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), FALSE);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), FALSE);
- return window->priv->removing_tabs;
+ return window->priv->removing_tabs;
}
/**
@@ -4505,9 +4464,9 @@ _pluma_window_is_removing_tabs (PlumaWindow *window)
GtkUIManager *
pluma_window_get_ui_manager (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- return window->priv->manager;
+ return window->priv->manager;
}
/**
@@ -4521,9 +4480,9 @@ pluma_window_get_ui_manager (PlumaWindow *window)
PlumaPanel *
pluma_window_get_side_panel (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- return PLUMA_PANEL (window->priv->side_panel);
+ return PLUMA_PANEL (window->priv->side_panel);
}
/**
@@ -4537,9 +4496,9 @@ pluma_window_get_side_panel (PlumaWindow *window)
PlumaPanel *
pluma_window_get_bottom_panel (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- return PLUMA_PANEL (window->priv->bottom_panel);
+ return PLUMA_PANEL (window->priv->bottom_panel);
}
/**
@@ -4553,9 +4512,9 @@ pluma_window_get_bottom_panel (PlumaWindow *window)
GtkWidget *
pluma_window_get_statusbar (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), 0);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), 0);
- return window->priv->statusbar;
+ return window->priv->statusbar;
}
/**
@@ -4569,36 +4528,36 @@ pluma_window_get_statusbar (PlumaWindow *window)
PlumaWindowState
pluma_window_get_state (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), PLUMA_WINDOW_STATE_NORMAL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), PLUMA_WINDOW_STATE_NORMAL);
- return window->priv->state;
+ return window->priv->state;
}
GFile *
_pluma_window_get_default_location (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- return window->priv->default_location != NULL ?
- g_object_ref (window->priv->default_location) : NULL;
+ return window->priv->default_location != NULL ?
+ g_object_ref (window->priv->default_location) : NULL;
}
void
_pluma_window_set_default_location (PlumaWindow *window,
- GFile *location)
+ GFile *location)
{
- GFile *dir;
+ GFile *dir;
- g_return_if_fail (PLUMA_IS_WINDOW (window));
- g_return_if_fail (G_IS_FILE (location));
+ g_return_if_fail (PLUMA_IS_WINDOW (window));
+ g_return_if_fail (G_IS_FILE (location));
- dir = g_file_get_parent (location);
- g_return_if_fail (dir != NULL);
+ dir = g_file_get_parent (location);
+ g_return_if_fail (dir != NULL);
- if (window->priv->default_location != NULL)
- g_object_unref (window->priv->default_location);
+ if (window->priv->default_location != NULL)
+ g_object_unref (window->priv->default_location);
- window->priv->default_location = dir;
+ window->priv->default_location = dir;
}
/**
@@ -4613,144 +4572,144 @@ _pluma_window_set_default_location (PlumaWindow *window,
GList *
pluma_window_get_unsaved_documents (PlumaWindow *window)
{
- GList *unsaved_docs = NULL;
- GList *tabs;
- GList *l;
+ GList *unsaved_docs = NULL;
+ GList *tabs;
+ GList *l;
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- tabs = gtk_container_get_children (GTK_CONTAINER (window->priv->notebook));
+ tabs = gtk_container_get_children (GTK_CONTAINER (window->priv->notebook));
- l = tabs;
- while (l != NULL)
- {
- PlumaTab *tab;
+ l = tabs;
+ while (l != NULL)
+ {
+ PlumaTab *tab;
- tab = PLUMA_TAB (l->data);
+ tab = PLUMA_TAB (l->data);
- if (!_pluma_tab_can_close (tab))
- {
- PlumaDocument *doc;
+ if (!_pluma_tab_can_close (tab))
+ {
+ PlumaDocument *doc;
- doc = pluma_tab_get_document (tab);
- unsaved_docs = g_list_prepend (unsaved_docs, doc);
- }
+ doc = pluma_tab_get_document (tab);
+ unsaved_docs = g_list_prepend (unsaved_docs, doc);
+ }
- l = g_list_next (l);
- }
+ l = g_list_next (l);
+ }
- g_list_free (tabs);
+ g_list_free (tabs);
- return g_list_reverse (unsaved_docs);
+ return g_list_reverse (unsaved_docs);
}
void
_pluma_window_set_saving_session_state (PlumaWindow *window,
- gboolean saving_session)
+ gboolean saving_session)
{
- PlumaWindowState old_state;
+ PlumaWindowState old_state;
- g_return_if_fail (PLUMA_IS_WINDOW (window));
+ g_return_if_fail (PLUMA_IS_WINDOW (window));
- old_state = window->priv->state;
+ old_state = window->priv->state;
- if (saving_session)
- window->priv->state |= PLUMA_WINDOW_STATE_SAVING_SESSION;
- else
- window->priv->state &= ~PLUMA_WINDOW_STATE_SAVING_SESSION;
+ if (saving_session)
+ window->priv->state |= PLUMA_WINDOW_STATE_SAVING_SESSION;
+ else
+ window->priv->state &= ~PLUMA_WINDOW_STATE_SAVING_SESSION;
- if (old_state != window->priv->state)
- {
- set_sensitivity_according_to_window_state (window);
+ if (old_state != window->priv->state)
+ {
+ set_sensitivity_according_to_window_state (window);
- g_object_notify (G_OBJECT (window), "state");
- }
+ g_object_notify (G_OBJECT (window), "state");
+ }
}
static void
-hide_notebook_tabs_on_fullscreen (GtkNotebook *notebook,
- GParamSpec *pspec,
- PlumaWindow *window)
+hide_notebook_tabs_on_fullscreen (GtkNotebook *notebook,
+ GParamSpec *pspec,
+ PlumaWindow *window)
{
- gtk_notebook_set_show_tabs (notebook, FALSE);
+ gtk_notebook_set_show_tabs (notebook, FALSE);
}
void
_pluma_window_fullscreen (PlumaWindow *window)
{
- g_return_if_fail (PLUMA_IS_WINDOW (window));
+ g_return_if_fail (PLUMA_IS_WINDOW (window));
- if (_pluma_window_is_fullscreen (window))
- return;
+ if (_pluma_window_is_fullscreen (window))
+ return;
- /* Go to fullscreen mode and hide bars */
- gtk_window_fullscreen (&window->window);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), FALSE);
- g_signal_connect (window->priv->notebook, "notify::show-tabs",
- G_CALLBACK (hide_notebook_tabs_on_fullscreen), window);
+ /* Go to fullscreen mode and hide bars */
+ gtk_window_fullscreen (&window->window);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), FALSE);
+ g_signal_connect (window->priv->notebook, "notify::show-tabs",
+ G_CALLBACK (hide_notebook_tabs_on_fullscreen), window);
- gtk_widget_hide (window->priv->menubar);
+ gtk_widget_hide (window->priv->menubar);
- g_signal_handlers_block_by_func (window->priv->toolbar,
- toolbar_visibility_changed,
- window);
- gtk_widget_hide (window->priv->toolbar);
+ g_signal_handlers_block_by_func (window->priv->toolbar,
+ toolbar_visibility_changed,
+ window);
+ gtk_widget_hide (window->priv->toolbar);
- g_signal_handlers_block_by_func (window->priv->statusbar,
- statusbar_visibility_changed,
- window);
- gtk_widget_hide (window->priv->statusbar);
+ g_signal_handlers_block_by_func (window->priv->statusbar,
+ statusbar_visibility_changed,
+ window);
+ gtk_widget_hide (window->priv->statusbar);
- fullscreen_controls_build (window);
- fullscreen_controls_show (window);
+ fullscreen_controls_build (window);
+ fullscreen_controls_show (window);
}
void
_pluma_window_unfullscreen (PlumaWindow *window)
{
- gboolean visible;
- GtkAction *action;
+ gboolean visible;
+ GtkAction *action;
- g_return_if_fail (PLUMA_IS_WINDOW (window));
+ g_return_if_fail (PLUMA_IS_WINDOW (window));
- if (!_pluma_window_is_fullscreen (window))
- return;
+ if (!_pluma_window_is_fullscreen (window))
+ return;
- /* Unfullscreen and show bars */
- gtk_window_unfullscreen (&window->window);
- g_signal_handlers_disconnect_by_func (window->priv->notebook,
- hide_notebook_tabs_on_fullscreen,
- window);
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), TRUE);
- gtk_widget_show (window->priv->menubar);
+ /* Unfullscreen and show bars */
+ gtk_window_unfullscreen (&window->window);
+ g_signal_handlers_disconnect_by_func (window->priv->notebook,
+ hide_notebook_tabs_on_fullscreen,
+ window);
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->priv->notebook), TRUE);
+ gtk_widget_show (window->priv->menubar);
- action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
- "ViewToolbar");
- visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- if (visible)
- gtk_widget_show (window->priv->toolbar);
- g_signal_handlers_unblock_by_func (window->priv->toolbar,
- toolbar_visibility_changed,
- window);
+ action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
+ "ViewToolbar");
+ visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ if (visible)
+ gtk_widget_show (window->priv->toolbar);
+ g_signal_handlers_unblock_by_func (window->priv->toolbar,
+ toolbar_visibility_changed,
+ window);
- action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
- "ViewStatusbar");
- visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- if (visible)
- gtk_widget_show (window->priv->statusbar);
- g_signal_handlers_unblock_by_func (window->priv->statusbar,
- statusbar_visibility_changed,
- window);
+ action = gtk_action_group_get_action (window->priv->always_sensitive_action_group,
+ "ViewStatusbar");
+ visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
+ if (visible)
+ gtk_widget_show (window->priv->statusbar);
+ g_signal_handlers_unblock_by_func (window->priv->statusbar,
+ statusbar_visibility_changed,
+ window);
- gtk_widget_hide (window->priv->fullscreen_controls);
+ gtk_widget_hide (window->priv->fullscreen_controls);
}
gboolean
_pluma_window_is_fullscreen (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), FALSE);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), FALSE);
- return window->priv->window_state & GDK_WINDOW_STATE_FULLSCREEN;
+ return window->priv->window_state & GDK_WINDOW_STATE_FULLSCREEN;
}
/**
@@ -4764,45 +4723,45 @@ _pluma_window_is_fullscreen (PlumaWindow *window)
*/
PlumaTab *
pluma_window_get_tab_from_location (PlumaWindow *window,
- GFile *location)
+ GFile *location)
{
- GList *tabs;
- GList *l;
- PlumaTab *ret = NULL;
+ GList *tabs;
+ GList *l;
+ PlumaTab *ret = NULL;
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- g_return_val_if_fail (G_IS_FILE (location), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (G_IS_FILE (location), NULL);
- tabs = gtk_container_get_children (GTK_CONTAINER (window->priv->notebook));
+ tabs = gtk_container_get_children (GTK_CONTAINER (window->priv->notebook));
- for (l = tabs; l != NULL; l = g_list_next (l))
- {
- PlumaDocument *d;
- PlumaTab *t;
- GFile *f;
+ for (l = tabs; l != NULL; l = g_list_next (l))
+ {
+ PlumaDocument *d;
+ PlumaTab *t;
+ GFile *f;
- t = PLUMA_TAB (l->data);
- d = pluma_tab_get_document (t);
+ t = PLUMA_TAB (l->data);
+ d = pluma_tab_get_document (t);
- f = pluma_document_get_location (d);
+ f = pluma_document_get_location (d);
- if ((f != NULL))
- {
- gboolean found = g_file_equal (location, f);
+ if ((f != NULL))
+ {
+ gboolean found = g_file_equal (location, f);
- g_object_unref (f);
+ g_object_unref (f);
- if (found)
- {
- ret = t;
- break;
- }
- }
- }
+ if (found)
+ {
+ ret = t;
+ break;
+ }
+ }
+ }
- g_list_free (tabs);
+ g_list_free (tabs);
- return ret;
+ return ret;
}
/**
@@ -4814,20 +4773,20 @@ pluma_window_get_tab_from_location (PlumaWindow *window,
*
* Return value: (transfer none): the #PlumaMessageBus associated with @window
*/
-PlumaMessageBus *
+PlumaMessageBus *
pluma_window_get_message_bus (PlumaWindow *window)
{
- g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
+ g_return_val_if_fail (PLUMA_IS_WINDOW (window), NULL);
- return window->priv->message_bus;
+ return window->priv->message_bus;
}
void
_pluma_window_get_default_size (gint *width, gint *height)
{
- g_return_if_fail (width != NULL && height != NULL);
+ g_return_if_fail (width != NULL && height != NULL);
- *width = PLUMA_WINDOW_DEFAULT_WIDTH;
- *height = PLUMA_WINDOW_DEFAULT_HEIGHT;
+ *width = PLUMA_WINDOW_DEFAULT_WIDTH;
+ *height = PLUMA_WINDOW_DEFAULT_HEIGHT;
}