static void tab_added_cb (PlumaWindow *window, PlumaTab *tab, PlumaSpellPlugin *plugin) { PlumaDocument *doc; gchar *uri; doc = pluma_tab_get_document (tab); g_object_get(G_OBJECT(doc), "uri", &uri, NULL); if (!uri) { set_auto_spell_from_metadata (plugin, doc, plugin->priv->action_group); g_free(uri); } g_signal_connect (doc, "loaded", G_CALLBACK (on_document_loaded), plugin); g_signal_connect (doc, "saved", G_CALLBACK (on_document_saved), plugin); }
static void on_document_loaded (GeditDocument *doc, const GError *error, GeditWindow *window) { if (error == NULL) { WindowData *data = g_object_get_data (G_OBJECT (window), WINDOW_DATA_KEY); set_auto_spell_from_metadata (window, doc, data->action_group); } }
static void on_document_loaded (GeditDocument *doc, GeditSpellPlugin *plugin) { GeditSpellChecker *spell; GeditView *view; spell = GEDIT_SPELL_CHECKER (g_object_get_qdata (G_OBJECT (doc), spell_checker_id)); if (spell != NULL) { set_language_from_metadata (spell, doc); } view = GEDIT_VIEW (g_object_get_data (G_OBJECT (doc), GEDIT_AUTOMATIC_SPELL_VIEW)); set_auto_spell_from_metadata (plugin, view); }
static void on_document_loaded (PlumaDocument *doc, const GError *error, PlumaSpellPlugin *plugin) { if (error == NULL) { PlumaSpellChecker *spell; spell = PLUMA_SPELL_CHECKER (g_object_get_qdata (G_OBJECT (doc), spell_checker_id)); if (spell != NULL) { set_language_from_metadata (spell, doc); } set_auto_spell_from_metadata (plugin, doc, plugin->priv->action_group); } }
static void gedit_spell_plugin_activate (GeditWindowActivatable *activatable) { GeditSpellPlugin *plugin; GeditSpellPluginPrivate *priv; GList *views, *l; gedit_debug (DEBUG_PLUGINS); plugin = GEDIT_SPELL_PLUGIN (activatable); priv = plugin->priv; g_action_map_add_action_entries (G_ACTION_MAP (priv->window), action_entries, G_N_ELEMENTS (action_entries), activatable); priv->message_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (gedit_window_get_statusbar (priv->window)), "spell_plugin_message"); update_ui (plugin); views = gedit_window_get_views (priv->window); for (l = views; l != NULL; l = g_list_next (l)) { GeditView *view = GEDIT_VIEW (l->data); set_auto_spell_from_metadata (plugin, view); } priv->tab_added_id = g_signal_connect (priv->window, "tab-added", G_CALLBACK (tab_added_cb), activatable); priv->tab_removed_id = g_signal_connect (priv->window, "tab-removed", G_CALLBACK (tab_removed_cb), activatable); }
static void impl_activate (GeditPlugin *plugin, GeditWindow *window) { GtkUIManager *manager; WindowData *data; ActionData *action_data; GList *docs, *l; gedit_debug (DEBUG_PLUGINS); data = g_slice_new (WindowData); action_data = g_slice_new (ActionData); action_data->plugin = plugin; action_data->window = window; manager = gedit_window_get_ui_manager (window); data->action_group = gtk_action_group_new ("GeditSpellPluginActions"); gtk_action_group_set_translation_domain (data->action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions_full (data->action_group, action_entries, G_N_ELEMENTS (action_entries), action_data, (GDestroyNotify) free_action_data); gtk_action_group_add_toggle_actions (data->action_group, toggle_action_entries, G_N_ELEMENTS (toggle_action_entries), window); gtk_ui_manager_insert_action_group (manager, data->action_group, -1); data->ui_id = gtk_ui_manager_new_merge_id (manager); data->message_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (gedit_window_get_statusbar (window)), "spell_plugin_message"); g_object_set_data_full (G_OBJECT (window), WINDOW_DATA_KEY, data, (GDestroyNotify) free_window_data); gtk_ui_manager_add_ui (manager, data->ui_id, MENU_PATH, "CheckSpell", "CheckSpell", GTK_UI_MANAGER_MENUITEM, FALSE); gtk_ui_manager_add_ui (manager, data->ui_id, MENU_PATH, "AutoSpell", "AutoSpell", GTK_UI_MANAGER_MENUITEM, FALSE); gtk_ui_manager_add_ui (manager, data->ui_id, MENU_PATH, "ConfigSpell", "ConfigSpell", GTK_UI_MANAGER_MENUITEM, FALSE); update_ui_real (window, data); docs = gedit_window_get_documents (window); for (l = docs; l != NULL; l = g_list_next (l)) { set_auto_spell_from_metadata (window, GEDIT_DOCUMENT (l->data), data->action_group); } data->tab_added_id = g_signal_connect (window, "tab-added", G_CALLBACK (tab_added_cb), NULL); data->tab_removed_id = g_signal_connect (window, "tab-removed", G_CALLBACK (tab_removed_cb), NULL); }
static void pluma_spell_plugin_activate (PeasActivatable *activatable) { PlumaSpellPlugin *plugin; PlumaSpellPluginPrivate *data; PlumaWindow *window; GtkUIManager *manager; GList *docs, *l; pluma_debug (DEBUG_PLUGINS); plugin = PLUMA_SPELL_PLUGIN (activatable); data = plugin->priv; window = PLUMA_WINDOW (data->window); manager = pluma_window_get_ui_manager (window); data->action_group = gtk_action_group_new ("PlumaSpellPluginActions"); gtk_action_group_set_translation_domain (data->action_group, GETTEXT_PACKAGE); gtk_action_group_add_actions (data->action_group, action_entries, G_N_ELEMENTS (action_entries), plugin); gtk_action_group_add_toggle_actions (data->action_group, toggle_action_entries, G_N_ELEMENTS (toggle_action_entries), plugin); gtk_ui_manager_insert_action_group (manager, data->action_group, -1); data->ui_id = gtk_ui_manager_new_merge_id (manager); data->message_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (pluma_window_get_statusbar (window)), "spell_plugin_message"); gtk_ui_manager_add_ui (manager, data->ui_id, MENU_PATH, "CheckSpell", "CheckSpell", GTK_UI_MANAGER_MENUITEM, FALSE); gtk_ui_manager_add_ui (manager, data->ui_id, MENU_PATH, "AutoSpell", "AutoSpell", GTK_UI_MANAGER_MENUITEM, FALSE); gtk_ui_manager_add_ui (manager, data->ui_id, MENU_PATH, "ConfigSpell", "ConfigSpell", GTK_UI_MANAGER_MENUITEM, FALSE); update_ui (plugin); docs = pluma_window_get_documents (window); for (l = docs; l != NULL; l = g_list_next (l)) { PlumaDocument *doc = PLUMA_DOCUMENT (l->data); set_auto_spell_from_metadata (plugin, doc, data->action_group); g_signal_handlers_disconnect_by_func (doc, on_document_loaded, plugin); g_signal_handlers_disconnect_by_func (doc, on_document_saved, plugin); } data->tab_added_id = g_signal_connect (window, "tab-added", G_CALLBACK (tab_added_cb), plugin); data->tab_removed_id = g_signal_connect (window, "tab-removed", G_CALLBACK (tab_removed_cb), plugin); }