void
pluma_plugins_engine_deactivate_plugins (PlumaPluginsEngine *engine,
					  PlumaWindow        *window)
{
	GList *pl;

	pluma_debug (DEBUG_PLUGINS);

	g_return_if_fail (PLUMA_IS_PLUGINS_ENGINE (engine));
	g_return_if_fail (PLUMA_IS_WINDOW (window));

	for (pl = engine->priv->plugin_list; pl; pl = pl->next)
	{
		PlumaPluginInfo *info = (PlumaPluginInfo*)pl->data;

		/* check if the plugin is actually active */
		if (!pluma_plugin_info_is_active (info))
			continue;

		/* call deactivate for the plugin for this window */
		pluma_plugin_deactivate (info->plugin, window);
	}

	pluma_debug_message (DEBUG_PLUGINS, "End");
}
static void
pluma_plugins_engine_finalize (GObject *object)
{
	PlumaPluginsEngine *engine = PLUMA_PLUGINS_ENGINE (object);
	GList *item;

	pluma_debug (DEBUG_PLUGINS);

	/* Firs deactivate all plugins */
	for (item = engine->priv->plugin_list; item; item = item->next)
	{
		PlumaPluginInfo *info = PLUMA_PLUGIN_INFO (item->data);

		if (pluma_plugin_info_is_active (info))
			pluma_plugins_engine_deactivate_plugin_real (engine, info);
	}

	/* unref the loaders */
	g_hash_table_destroy (engine->priv->loaders);

	/* and finally free the infos */
	for (item = engine->priv->plugin_list; item; item = item->next)
	{
		PlumaPluginInfo *info = PLUMA_PLUGIN_INFO (item->data);

		_pluma_plugin_info_unref (info);
	}

	g_list_free (engine->priv->plugin_list);

	G_OBJECT_CLASS (pluma_plugins_engine_parent_class)->finalize (object);
}
const GList *
pluma_plugins_engine_get_plugin_list (PlumaPluginsEngine *engine)
{
	pluma_debug (DEBUG_PLUGINS);

	return engine->priv->plugin_list;
}
static void
impl_activate (PlumaPlugin *plugin,
	       PlumaWindow *window)
{
	SoupMessage *msg;
	WindowData *data;

	pluma_debug (DEBUG_PLUGINS);

	data = g_slice_new (WindowData);
	data->plugin = PLUMA_CHECK_UPDATE_PLUGIN (plugin);
	data->url = NULL;
	data->version = NULL;

	g_object_set_data_full (G_OBJECT (window),
				WINDOW_DATA_KEY,
				data,
				free_window_data);

	msg = soup_message_new ("GET", PLUMA_URL);

	soup_session_queue_message (PLUMA_CHECK_UPDATE_PLUGIN (plugin)->priv->session, msg,
				    (SoupSessionCallback)parse_page_version,
				    window);
}
static void
pluma_plugins_engine_init (PlumaPluginsEngine *engine)
{
	pluma_debug (DEBUG_PLUGINS);

	if (!g_module_supported ())
	{
		g_warning ("pluma is not able to initialize the plugins engine.");
		return;
	}

	engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine,
						    PLUMA_TYPE_PLUGINS_ENGINE,
						    PlumaPluginsEnginePrivate);

	load_all_plugins (engine);

	/* make sure that the first reactivation will read active plugins
	   from the prefs */
	engine->priv->activate_from_prefs = TRUE;

	/* mapping from loadername -> loader object */
	engine->priv->loaders = g_hash_table_new_full (hash_lowercase,
						       equal_lowercase,
						       (GDestroyNotify)g_free,
						       (GDestroyNotify)loader_destroy);
}
static void
impl_activate (PlumaPlugin *plugin,
	       PlumaWindow *window)
{
	WindowData *data;
	GList *views;
	GList *item;

	pluma_debug (DEBUG_PLUGINS);

	data = g_slice_new (WindowData);
	g_object_set_data_full (G_OBJECT (window),
				WINDOW_DATA_KEY,
				data,
				(GDestroyNotify) free_window_data);

	views = pluma_window_get_views (window);
	for (item = views; item != NULL; item = item->next)
	{
		enable_bookmarks (PLUMA_VIEW (item->data), plugin);
		load_bookmark_metadata (PLUMA_VIEW (item->data));
	}

	g_list_free (views);

	g_signal_connect (window, "tab-added",
			  G_CALLBACK (on_tab_added), plugin);

	g_signal_connect (window, "tab-removed",
			  G_CALLBACK (on_tab_removed), plugin);

	install_menu (window);
	install_messages (window);
}
static void
impl_deactivate	(PlumaPlugin *plugin,
		 PlumaWindow *window)
{
	WindowData *data;
	GList *views;
	GList *item;

	pluma_debug (DEBUG_PLUGINS);

	uninstall_menu (window);
	uninstall_messages (window);

	views = pluma_window_get_views (window);

	for (item = views; item != NULL; item = item->next)
	{
		disable_bookmarks (PLUMA_VIEW (item->data));
	}

	g_list_free (views);

	data = BOOKMARKS_DATA (window);
	g_return_if_fail (data != NULL);

	g_signal_handlers_disconnect_by_func (window, on_tab_added, plugin);
	g_signal_handlers_disconnect_by_func (window, on_tab_removed, plugin);

	g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
}
Ejemplo n.º 8
0
static gboolean
goto_next_word (PlumaDocument *doc)
{
	CheckRange *range;
	GtkTextIter current_iter;
	GtkTextIter old_current_iter;
	GtkTextIter end_iter;

	pluma_debug (DEBUG_PLUGINS);

	g_return_val_if_fail (doc != NULL, FALSE);

	range = get_check_range (doc);
	g_return_val_if_fail (range != NULL, FALSE);

	gtk_text_buffer_get_iter_at_mark (GTK_TEXT_BUFFER (doc), 
					  &current_iter,
					  range->current_mark);
	gtk_text_buffer_get_end_iter (GTK_TEXT_BUFFER (doc), &end_iter);

	old_current_iter = current_iter;

	gtk_text_iter_forward_word_ends (&current_iter, 2);
	gtk_text_iter_backward_word_start (&current_iter);

	if (pluma_spell_utils_skip_no_spell_check (&current_iter, &end_iter) &&
	    (gtk_text_iter_compare (&old_current_iter, &current_iter) < 0) &&
	    (gtk_text_iter_compare (&current_iter, &end_iter) < 0))
	{
		update_current (doc, gtk_text_iter_get_offset (&current_iter));
		return TRUE;
	}

	return FALSE;
}
Ejemplo n.º 9
0
static void
ignore_cb (PlumaSpellCheckerDialog *dlg,
	   const gchar             *w,
	   PlumaView               *view)
{
	gchar *word = NULL;

	pluma_debug (DEBUG_PLUGINS);

	g_return_if_fail (w != NULL);
	g_return_if_fail (view != NULL);

	word = get_next_misspelled_word (view);
	if (word == NULL)
	{
		pluma_spell_checker_dialog_set_completed (dlg);
		
		return;
	}

	pluma_spell_checker_dialog_set_misspelled_word (PLUMA_SPELL_CHECKER_DIALOG (dlg),
							word,
							-1);

	g_free (word);
}
Ejemplo n.º 10
0
static void
pluma_spell_plugin_update_state (PeasActivatable *activatable)
{
	pluma_debug (DEBUG_PLUGINS);

	update_ui (PLUMA_SPELL_PLUGIN (activatable));
}
Ejemplo n.º 11
0
static void
auto_spell_cb (GtkAction   *action,
	       PlumaSpellPlugin *plugin)
{
	PlumaWindow *window;
	PlumaDocument *doc;
	gboolean active;

	pluma_debug (DEBUG_PLUGINS);

	window = PLUMA_WINDOW (plugin->priv->window);

	active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));

	pluma_debug_message (DEBUG_PLUGINS, active ? "Auto Spell activated" : "Auto Spell deactivated");

	doc = pluma_window_get_active_document (window);
	if (doc == NULL)
		return;

	if (get_autocheck_type (plugin) == AUTOCHECK_DOCUMENT)
	{
		pluma_document_set_metadata (doc,
				     PLUMA_METADATA_ATTRIBUTE_SPELL_ENABLED,
				     active ? "1" : NULL, NULL);
	}

	set_auto_spell (window, doc, active);
}
static void
docinfo_real (PlumaDocument *doc,
	      DocInfoDialog *dialog)
{
	GtkTextIter start, end;
	gint words = 0;
	gint chars = 0;
	gint white_chars = 0;
	gint lines = 0;
	gint bytes = 0;
	gchar *tmp_str;
	gchar *doc_name;

	pluma_debug (DEBUG_PLUGINS);

	gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (doc),
				    &start,
				    &end);

	lines = gtk_text_buffer_get_line_count (GTK_TEXT_BUFFER (doc));

	calculate_info (doc,
			&start, &end,
			&chars, &words, &white_chars, &bytes);

	if (chars == 0)
		lines = 0;

	pluma_debug_message (DEBUG_PLUGINS, "Chars: %d", chars);
	pluma_debug_message (DEBUG_PLUGINS, "Lines: %d", lines);
	pluma_debug_message (DEBUG_PLUGINS, "Words: %d", words);
	pluma_debug_message (DEBUG_PLUGINS, "Chars non-space: %d", chars - white_chars);
	pluma_debug_message (DEBUG_PLUGINS, "Bytes: %d", bytes);

	doc_name = pluma_document_get_short_name_for_display (doc);
	tmp_str = g_strdup_printf ("<span weight=\"bold\">%s</span>", doc_name);
	gtk_label_set_markup (GTK_LABEL (dialog->file_name_label), tmp_str);
	g_free (doc_name);
	g_free (tmp_str);

	tmp_str = g_strdup_printf("%d", lines);
	gtk_label_set_text (GTK_LABEL (dialog->lines_label), tmp_str);
	g_free (tmp_str);

	tmp_str = g_strdup_printf("%d", words);
	gtk_label_set_text (GTK_LABEL (dialog->words_label), tmp_str);
	g_free (tmp_str);

	tmp_str = g_strdup_printf("%d", chars);
	gtk_label_set_text (GTK_LABEL (dialog->chars_label), tmp_str);
	g_free (tmp_str);

	tmp_str = g_strdup_printf("%d", chars - white_chars);
	gtk_label_set_text (GTK_LABEL (dialog->chars_ns_label), tmp_str);
	g_free (tmp_str);

	tmp_str = g_strdup_printf("%d", bytes);
	gtk_label_set_text (GTK_LABEL (dialog->bytes_label), tmp_str);
	g_free (tmp_str);
}
void
pluma_plugins_engine_configure_plugin (PlumaPluginsEngine *engine,
				       PlumaPluginInfo    *info,
				       GtkWindow          *parent)
{
	GtkWidget *conf_dlg;

	GtkWindowGroup *wg;

	pluma_debug (DEBUG_PLUGINS);

	g_return_if_fail (info != NULL);

	conf_dlg = pluma_plugin_create_configure_dialog (info->plugin);
	g_return_if_fail (conf_dlg != NULL);
	gtk_window_set_transient_for (GTK_WINDOW (conf_dlg),
				      parent);

	wg = gtk_window_get_group (parent);
	if (wg == NULL)
	{
		wg = gtk_window_group_new ();
		gtk_window_group_add_window (wg, parent);
	}

	gtk_window_group_add_window (wg,
				     GTK_WINDOW (conf_dlg));

	gtk_window_set_modal (GTK_WINDOW (conf_dlg), TRUE);
	gtk_widget_show (conf_dlg);
}
void
pluma_plugins_engine_active_plugins_changed (PlumaPluginsEngine *engine)
{
	gboolean to_activate;
	GSList *active_plugins;
	GList *pl;

	pluma_debug (DEBUG_PLUGINS);

	active_plugins = pluma_prefs_manager_get_active_plugins ();

	for (pl = engine->priv->plugin_list; pl; pl = pl->next)
	{
		PlumaPluginInfo *info = (PlumaPluginInfo*)pl->data;

		if (!pluma_plugin_info_is_available (info))
			continue;

		to_activate = (g_slist_find_custom (active_plugins,
						    pluma_plugin_info_get_module_name (info),
						    (GCompareFunc)strcmp) != NULL);

		if (!pluma_plugin_info_is_active (info) && to_activate)
			g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
		else if (pluma_plugin_info_is_active (info) && !to_activate)
			g_signal_emit (engine, signals[DEACTIVATE_PLUGIN], 0, info);
	}

	g_slist_foreach (active_plugins, (GFunc) g_free, NULL);
	g_slist_free (active_plugins);
}
void
pluma_document_saver_save (PlumaDocumentSaver     *saver,
			   GTimeVal               *old_mtime)
{
	pluma_debug (DEBUG_SAVER);

	g_return_if_fail (PLUMA_IS_DOCUMENT_SAVER (saver));
	g_return_if_fail (saver->uri != NULL && strlen (saver->uri) > 0);

	g_return_if_fail (saver->used == FALSE);
	saver->used = TRUE;

	// CHECK:
	// - sanity check a max len for the uri?
	// report async (in an idle handler) or sync (bool ret)
	// async is extra work here, sync is special casing in the caller

	/* never keep backup of autosaves */
	if ((saver->flags & PLUMA_DOCUMENT_SAVE_PRESERVE_BACKUP) != 0)
		saver->keep_backup = FALSE;
	else
		saver->keep_backup = pluma_prefs_manager_get_create_backup_copy ();

	PLUMA_DOCUMENT_SAVER_GET_CLASS (saver)->save (saver, old_mtime);
}
static void
impl_deactivate	(PlumaPlugin *plugin,
		 PlumaWindow *window)
{
	PlumaDrawspacesPlugin *ds_plugin = PLUMA_DRAWSPACES_PLUGIN (plugin);
	GtkUIManager *manager;
	WindowData *data;

	pluma_debug (DEBUG_PLUGINS);

	data = (WindowData *) g_object_get_data (G_OBJECT (window),
						 WINDOW_DATA_KEY);
	g_return_if_fail (data != NULL);

	manager = pluma_window_get_ui_manager (window);

	data->enable = FALSE;
	draw_spaces_in_window (window, ds_plugin);

	g_signal_handlers_disconnect_by_func (window, tab_added_cb, ds_plugin);

	gtk_ui_manager_remove_ui (manager, data->ui_id);
	gtk_ui_manager_remove_action_group (manager, data->action_group);

	g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL);
}
Ejemplo n.º 17
0
static void
pluma_prefs_manager_bracket_matching_changed (GSettings *settings,
        gchar       *key,
        gpointer     user_data)
{
    pluma_debug (DEBUG_PREFS);

    if (strcmp (key, GPM_BRACKET_MATCHING) == 0)
    {
        gboolean enable;
        GList *docs;
        GList *l;

        enable = g_settings_get_boolean (settings, key);

        docs = pluma_app_get_documents (pluma_app_get_default ());
        l = docs;

        while (l != NULL)
        {
            gtk_source_buffer_set_highlight_matching_brackets (GTK_SOURCE_BUFFER (l->data),
                    enable);

            l = l->next;
        }

        g_list_free (docs);
    }
}
Ejemplo n.º 18
0
static void
pluma_prefs_manager_line_numbers_changed (GSettings *settings,
        gchar       *key,
        gpointer     user_data)
{
    pluma_debug (DEBUG_PREFS);

    if (strcmp (key, GPM_DISPLAY_LINE_NUMBERS) == 0)
    {
        gboolean dln;
        GList *views;
        GList *l;

        dln = g_settings_get_boolean (settings, key);

        views = pluma_app_get_views (pluma_app_get_default ());
        l = views;

        while (l != NULL)
        {
            gtk_source_view_set_show_line_numbers (GTK_SOURCE_VIEW (l->data),
                                                   dln);

            l = l->next;
        }

        g_list_free (views);
    }
}
Ejemplo n.º 19
0
static void
pluma_prefs_manager_hl_current_line_changed (GSettings *settings,
        gchar       *key,
        gpointer     user_data)
{
    pluma_debug (DEBUG_PREFS);

    if (strcmp (key, GPM_HIGHLIGHT_CURRENT_LINE) == 0)
    {
        gboolean hl;
        GList *views;
        GList *l;

        hl = g_settings_get_boolean (settings, key);

        views = pluma_app_get_views (pluma_app_get_default ());
        l = views;

        while (l != NULL)
        {
            gtk_source_view_set_highlight_current_line (GTK_SOURCE_VIEW (l->data),
                    hl);

            l = l->next;
        }

        g_list_free (views);
    }
}
Ejemplo n.º 20
0
static void
pluma_prefs_manager_lockdown_changed (GSettings *settings,
                                      gchar       *key,
                                      gpointer     user_data)
{
    PlumaApp *app;
    gboolean locked;

    pluma_debug (DEBUG_PREFS);

    locked = g_settings_get_boolean (settings, key);

    app = pluma_app_get_default ();

    if (strcmp (key, GPM_LOCKDOWN_COMMAND_LINE) == 0)
        _pluma_app_set_lockdown_bit (app,
                                     PLUMA_LOCKDOWN_COMMAND_LINE,
                                     locked);

    else if (strcmp (key, GPM_LOCKDOWN_PRINTING) == 0)
        _pluma_app_set_lockdown_bit (app,
                                     PLUMA_LOCKDOWN_PRINTING,
                                     locked);

    else if (strcmp (key, GPM_LOCKDOWN_PRINT_SETUP) == 0)
        _pluma_app_set_lockdown_bit (app,
                                     PLUMA_LOCKDOWN_PRINT_SETUP,
                                     locked);

    else if (strcmp (key, GPM_LOCKDOWN_SAVE_TO_DISK) == 0)
        _pluma_app_set_lockdown_bit (app,
                                     PLUMA_LOCKDOWN_SAVE_TO_DISK,
                                     locked);
}
Ejemplo n.º 21
0
static void
pluma_prefs_manager_wrap_mode_changed (GSettings *settings,
                                       gchar         *key,
                                       gpointer       user_data)
{
    pluma_debug (DEBUG_PREFS);

    if (strcmp (key, GPM_WRAP_MODE) == 0)
    {
        GtkWrapMode wrap_mode;
        GList *views;
        GList *l;

        wrap_mode = get_wrap_mode_from_string (g_settings_get_string(settings, key));

        views = pluma_app_get_views (pluma_app_get_default ());
        l = views;

        while (l != NULL)
        {
            gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (l->data),
                                         wrap_mode);

            l = l->next;
        }

        g_list_free (views);
    }
}
Ejemplo n.º 22
0
static void
pluma_prefs_manager_search_hl_enable_changed (GSettings *settings,
        gchar       *key,
        gpointer     user_data)
{
    pluma_debug (DEBUG_PREFS);

    if (strcmp (key, GPM_SEARCH_HIGHLIGHTING_ENABLE) == 0)
    {
        gboolean enable;
        GList *docs;
        GList *l;

        enable = g_settings_get_boolean (settings, key);

        docs = pluma_app_get_documents (pluma_app_get_default ());
        l = docs;

        while (l != NULL)
        {
            g_return_if_fail (PLUMA_IS_DOCUMENT (l->data));

            pluma_document_set_enable_search_highlighting  (PLUMA_DOCUMENT (l->data),
                    enable);

            l = l->next;
        }

        g_list_free (docs);
    }
}
Ejemplo n.º 23
0
static void
pluma_prefs_manager_max_recents_changed (GSettings *settings,
        gchar       *key,
        gpointer     user_data)
{
    pluma_debug (DEBUG_PREFS);

    if (strcmp (key, GPM_MAX_RECENTS) == 0)
    {
        const GList *windows;
        gint max;

        max = g_settings_get_int (settings, key);

        if (max < 0) {
            max = GPM_DEFAULT_MAX_RECENTS;
        }

        windows = pluma_app_get_windows (pluma_app_get_default ());
        while (windows != NULL)
        {
            PlumaWindow *w = windows->data;

            gtk_recent_chooser_set_limit (GTK_RECENT_CHOOSER (w->priv->toolbar_recent_menu),
                                          max);

            windows = g_list_next (windows);
        }

        /* FIXME: we have no way at the moment to trigger the
         * update of the inline recents in the File menu */
    }
}
Ejemplo n.º 24
0
static void
pluma_prefs_manager_smart_home_end_changed (GSettings *settings,
        gchar       *key,
        gpointer     user_data)
{
    pluma_debug (DEBUG_PREFS);

    if (strcmp (key, GPM_SMART_HOME_END) == 0)
    {
        GtkSourceSmartHomeEndType smart_he;
        GList *views;
        GList *l;

        smart_he = get_smart_home_end_from_string (g_settings_get_string (settings, key));

        views = pluma_app_get_views (pluma_app_get_default ());
        l = views;

        while (l != NULL)
        {
            gtk_source_view_set_smart_home_end (GTK_SOURCE_VIEW (l->data),
                                                smart_he);

            l = l->next;
        }

        g_list_free (views);
    }
}
Ejemplo n.º 25
0
static void
pluma_prefs_manager_undo_changed (GSettings *settings,
                                  gchar       *key,
                                  gpointer     user_data)
{
    pluma_debug (DEBUG_PREFS);

    if (strcmp (key, GPM_UNDO_ACTIONS_LIMIT) == 0)
    {
        gint ul;
        GList *docs;
        GList *l;

        ul = g_settings_get_int (settings, key);

        ul = CLAMP (ul, -1, 250);

        docs = pluma_app_get_documents (pluma_app_get_default ());
        l = docs;

        while (l != NULL)
        {
            gtk_source_buffer_set_max_undo_levels (GTK_SOURCE_BUFFER (l->data),
                                                   ul);

            l = l->next;
        }

        g_list_free (docs);
    }
}
Ejemplo n.º 26
0
static void
pluma_prefs_manager_auto_indent_changed (GSettings *settings,
        gchar       *key,
        gpointer     user_data)
{
    pluma_debug (DEBUG_PREFS);

    if (strcmp (key, GPM_AUTO_INDENT) == 0)
    {
        gboolean enable;
        GList *views;
        GList *l;

        enable = g_settings_get_boolean (settings, key);

        views = pluma_app_get_views (pluma_app_get_default ());
        l = views;

        while (l != NULL)
        {
            gtk_source_view_set_auto_indent (GTK_SOURCE_VIEW (l->data),
                                             enable);

            l = l->next;
        }

        g_list_free (views);
    }
}
void
pluma_plugins_engine_rescan_plugins (PlumaPluginsEngine *engine)
{
	pluma_debug (DEBUG_PLUGINS);

	load_all_plugins (engine);
}
void
_pluma_cmd_search_find_prev (GtkAction   *action,
			     PlumaWindow *window)
{
	pluma_debug (DEBUG_COMMANDS);

	do_find_again (window, TRUE);
}
Ejemplo n.º 29
0
void
_pluma_cmd_edit_preferences (GtkAction   *action,
			    PlumaWindow *window)
{
	pluma_debug (DEBUG_COMMANDS);

	pluma_show_preferences_dialog (window);
}
Ejemplo n.º 30
0
gboolean 
pluma_document_loader_cancel (PlumaDocumentLoader *loader)
{
	pluma_debug (DEBUG_LOADER);

	g_return_val_if_fail (PLUMA_IS_DOCUMENT_LOADER (loader), FALSE);

	return PLUMA_DOCUMENT_LOADER_GET_CLASS (loader)->cancel (loader);
}