static DrawspacesConfigureDialog * get_configuration_dialog (PlumaDrawspacesPlugin *plugin) { DrawspacesConfigureDialog *dialog = NULL; gboolean ret; GtkWidget *error_widget; gchar *datadir; gchar *filename; gchar *root_objects[] = { "dialog_draw_spaces", NULL }; dialog = g_slice_new (DrawspacesConfigureDialog); datadir = pluma_plugin_get_data_dir (PLUMA_PLUGIN (plugin)); filename = g_build_filename (datadir, UI_FILE, NULL); ret = pluma_utils_get_ui_objects (filename, root_objects, &error_widget, "dialog_draw_spaces", &dialog->dialog, "check_button_draw_tabs", &dialog->draw_tabs, "check_button_draw_spaces", &dialog->draw_spaces, "check_button_draw_new_lines", &dialog->draw_newline, "check_button_draw_nbsp", &dialog->draw_nbsp, "check_button_draw_leading", &dialog->draw_leading, "check_button_draw_text", &dialog->draw_text, "check_button_draw_trailing", &dialog->draw_trailing, NULL); g_free (datadir); g_free (filename); if (!ret) { GtkWidget *dialog_error; GtkWidget *content; dialog_error = gtk_dialog_new_with_buttons (_("Error dialog"), NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); content = gtk_dialog_get_content_area (GTK_DIALOG (dialog_error)); gtk_widget_show (error_widget); gtk_box_pack_start_defaults (GTK_BOX (content), error_widget); gtk_widget_show (dialog_error); gtk_dialog_run (GTK_DIALOG (dialog_error)); gtk_widget_destroy (dialog_error); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->draw_tabs), plugin->priv->flags & GTK_SOURCE_DRAW_SPACES_TAB); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->draw_spaces), plugin->priv->flags & GTK_SOURCE_DRAW_SPACES_SPACE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->draw_newline), plugin->priv->flags & GTK_SOURCE_DRAW_SPACES_NEWLINE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->draw_nbsp), plugin->priv->flags & GTK_SOURCE_DRAW_SPACES_NBSP); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->draw_leading), plugin->priv->flags & GTK_SOURCE_DRAW_SPACES_LEADING); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->draw_text), plugin->priv->flags & GTK_SOURCE_DRAW_SPACES_TEXT); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->draw_trailing), plugin->priv->flags & GTK_SOURCE_DRAW_SPACES_TRAILING); g_signal_connect (dialog->draw_tabs, "toggled", G_CALLBACK (on_draw_tabs_toggled), plugin); g_signal_connect (dialog->draw_spaces, "toggled", G_CALLBACK (on_draw_spaces_toggled), plugin); g_signal_connect (dialog->draw_newline, "toggled", G_CALLBACK (on_draw_newline_toggled), plugin); g_signal_connect (dialog->draw_nbsp, "toggled", G_CALLBACK (on_draw_nbsp_toggled), plugin); g_signal_connect (dialog->draw_leading, "toggled", G_CALLBACK (on_draw_leading_toggled), plugin); g_signal_connect (dialog->draw_text, "toggled", G_CALLBACK (on_draw_text_toggled), plugin); g_signal_connect (dialog->draw_trailing, "toggled", G_CALLBACK (on_draw_trailing_toggled), plugin); g_signal_connect (dialog->dialog, "destroy", G_CALLBACK (dialog_destroyed), dialog); return dialog; }
static PlumaPlugin * new_plugin_from_info (PlumaPluginLoaderPython *loader, PlumaPluginInfo *info) { PythonInfo *pyinfo; PyTypeObject *pytype; PyObject *pyobject; PyGObject *pygobject; PlumaPlugin *instance; PyObject *emptyarg; pyinfo = (PythonInfo *)g_hash_table_lookup (loader->priv->loaded_plugins, info); if (pyinfo == NULL) return NULL; pytype = (PyTypeObject *)pyinfo->type; if (pytype->tp_new == NULL) return NULL; emptyarg = PyTuple_New(0); pyobject = pytype->tp_new (pytype, emptyarg, NULL); Py_DECREF (emptyarg); if (pyobject == NULL) { g_error ("Could not create instance for %s.", pluma_plugin_info_get_name (info)); return NULL; } pygobject = (PyGObject *)pyobject; if (pygobject->obj != NULL) { Py_DECREF (pyobject); g_error ("Could not create instance for %s (GObject already initialized).", pluma_plugin_info_get_name (info)); return NULL; } pygobject_construct (pygobject, "install-dir", pyinfo->path, "data-dir-name", pluma_plugin_info_get_module_name (info), NULL); if (pygobject->obj == NULL) { g_error ("Could not create instance for %s (GObject not constructed).", pluma_plugin_info_get_name (info)); Py_DECREF (pyobject); return NULL; } /* now call tp_init manually */ if (PyType_IsSubtype (pyobject->ob_type, pytype) && pyobject->ob_type->tp_init != NULL) { emptyarg = PyTuple_New(0); pyobject->ob_type->tp_init (pyobject, emptyarg, NULL); Py_DECREF (emptyarg); } instance = PLUMA_PLUGIN (pygobject->obj); pyinfo->instance = (PyObject *)pygobject; /* make sure to register the python instance for the PlumaPluginPython object to it can wrap the virtual pluma plugin funcs back to python */ _pluma_plugin_python_set_instance (PLUMA_PLUGIN_PYTHON (instance), (PyObject *)pygobject); /* we return a reference here because the other is owned by python */ return PLUMA_PLUGIN (g_object_ref (instance)); }