Skip to content

Commit

Permalink
port plugins to use the window-construct property.
Browse files Browse the repository at this point in the history
pluma-file-browser-plugin.c: rename "data" to "priv".
  • Loading branch information
mbkma authored and raveit65 committed Mar 4, 2021
1 parent 0d91cd7 commit f4ed769
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 331 deletions.
30 changes: 15 additions & 15 deletions plugins/docinfo/pluma-docinfo-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@
#include <glib/gi18n-lib.h>
#include <pango/pango-break.h>
#include <gmodule.h>
#include <libpeas/peas-activatable.h>

#include <pluma/pluma-window-activatable.h>
#include <pluma/pluma-window.h>
#include <pluma/pluma-debug.h>
#include <pluma/pluma-utils.h>

#define MENU_PATH "/MenuBar/ToolsMenu/ToolsOps_2"

static void peas_activatable_iface_init (PeasActivatableInterface *iface);
static void pluma_window_activatable_iface_init (PlumaWindowActivatableInterface *iface);

typedef struct
{
Expand All @@ -60,7 +60,7 @@ typedef struct

struct _PlumaDocInfoPluginPrivate
{
GtkWidget *window;
PlumaWindow *window;

GtkActionGroup *ui_action_group;
guint ui_id;
Expand All @@ -73,12 +73,12 @@ G_DEFINE_DYNAMIC_TYPE_EXTENDED (PlumaDocInfoPlugin,
PEAS_TYPE_EXTENSION_BASE,
0,
G_ADD_PRIVATE_DYNAMIC (PlumaDocInfoPlugin)
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
peas_activatable_iface_init))
G_IMPLEMENT_INTERFACE_DYNAMIC (PLUMA_TYPE_WINDOW_ACTIVATABLE,
pluma_window_activatable_iface_init))

enum {
PROP_0,
PROP_OBJECT
PROP_WINDOW
};

static void docinfo_dialog_response_cb (GtkDialog *widget,
Expand Down Expand Up @@ -505,8 +505,8 @@ pluma_docinfo_plugin_set_property (GObject *object,

switch (prop_id)
{
case PROP_OBJECT:
plugin->priv->window = GTK_WIDGET (g_value_dup_object (value));
case PROP_WINDOW:
plugin->priv->window = PLUMA_WINDOW (g_value_dup_object (value));
break;

default:
Expand All @@ -525,7 +525,7 @@ pluma_docinfo_plugin_get_property (GObject *object,

switch (prop_id)
{
case PROP_OBJECT:
case PROP_WINDOW:
g_value_set_object (value, plugin->priv->window);
break;

Expand All @@ -536,7 +536,7 @@ pluma_docinfo_plugin_get_property (GObject *object,
}

static void
pluma_docinfo_plugin_activate (PeasActivatable *activatable)
pluma_docinfo_plugin_activate (PlumaWindowActivatable *activatable)
{
PlumaDocInfoPlugin *plugin;
PlumaDocInfoPluginPrivate *data;
Expand Down Expand Up @@ -578,7 +578,7 @@ pluma_docinfo_plugin_activate (PeasActivatable *activatable)
}

static void
pluma_docinfo_plugin_deactivate (PeasActivatable *activatable)
pluma_docinfo_plugin_deactivate (PlumaWindowActivatable *activatable)
{
PlumaDocInfoPluginPrivate *data;
PlumaWindow *window;
Expand All @@ -598,7 +598,7 @@ pluma_docinfo_plugin_deactivate (PeasActivatable *activatable)
}

static void
pluma_docinfo_plugin_update_state (PeasActivatable *activatable)
pluma_docinfo_plugin_update_state (PlumaWindowActivatable *activatable)
{
pluma_debug (DEBUG_PLUGINS);

Expand All @@ -614,7 +614,7 @@ pluma_docinfo_plugin_class_init (PlumaDocInfoPluginClass *klass)
object_class->set_property = pluma_docinfo_plugin_set_property;
object_class->get_property = pluma_docinfo_plugin_get_property;

g_object_class_override_property (object_class, PROP_OBJECT, "object");
g_object_class_override_property (object_class, PROP_WINDOW, "window");
}

static void
Expand All @@ -624,7 +624,7 @@ pluma_docinfo_plugin_class_finalize (PlumaDocInfoPluginClass *klass)
}

static void
peas_activatable_iface_init (PeasActivatableInterface *iface)
pluma_window_activatable_iface_init (PlumaWindowActivatableInterface *iface)
{
iface->activate = pluma_docinfo_plugin_activate;
iface->deactivate = pluma_docinfo_plugin_deactivate;
Expand All @@ -637,6 +637,6 @@ peas_register_types (PeasObjectModule *module)
pluma_docinfo_plugin_register_type (G_TYPE_MODULE (module));

peas_object_module_register_extension_type (module,
PEAS_TYPE_ACTIVATABLE,
PLUMA_TYPE_WINDOW_ACTIVATABLE,
PLUMA_TYPE_DOCINFO_PLUGIN);
}
24 changes: 10 additions & 14 deletions plugins/externaltools/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,10 @@ def filter(self, document):
action.set_visible(states[action._tool_item.applicability] and
self.filter_language(language, action._tool_item))

class ExternalToolsPlugin(GObject.Object, Peas.Activatable):
class ExternalToolsPlugin(GObject.Object, Pluma.WindowActivatable):
__gtype_name__ = "ExternalToolsPlugin"

object = GObject.Property(type=GObject.Object)
window = GObject.Property(type=Pluma.Window)

def __init__(self):
GObject.Object.__init__(self)
Expand All @@ -164,8 +164,7 @@ def do_activate(self):
self._library = ToolLibrary()
self._library.set_locations(os.path.join(self.plugin_info.get_data_dir(), 'tools'))

window = self.object
manager = window.get_ui_manager()
manager = self.window.get_ui_manager()

self._action_group = Gtk.ActionGroup('ExternalToolsPluginActions')
self._action_group.set_translation_domain('pluma')
Expand Down Expand Up @@ -204,34 +203,31 @@ def do_activate(self):
self._merge_id = manager.add_ui_from_string(ui_string)

# Create output console
self._output_buffer = OutputPanel(self.plugin_info.get_data_dir(), window)
self._output_buffer = OutputPanel(self.plugin_info.get_data_dir(), self.window)

self.menu = ToolMenu(self._library, window, self._output_buffer, self,
self.menu = ToolMenu(self._library, self.window, self._output_buffer, self,
"/MenuBar/ToolsMenu/ToolsOps_4/ExternalToolsMenu/ExternalToolPlaceholder")
manager.ensure_update()

bottom = window.get_bottom_panel()
bottom = self.window.get_bottom_panel()
bottom.add_item_with_icon(self._output_buffer.panel,
_("Shell Output"),
"system-run")

def do_deactivate(self):
window = self.object
manager = window.get_ui_manager()
manager = self.window.get_ui_manager()

self.menu.deactivate()
manager.remove_ui(self._merge_id)
manager.remove_action_group(self._action_group)
manager.ensure_update()

bottom = window.get_bottom_panel()
bottom = self.window.get_bottom_panel()
bottom.remove_item(self._output_buffer.panel)

def do_update_state(self):
window = self.object

self.menu.filter(window.get_active_document())
window.get_ui_manager().ensure_update()
self.menu.filter(self.window.get_active_document())
self.window.get_ui_manager().ensure_update()

def open_dialog(self):
if not self._manager:
Expand Down
Loading

0 comments on commit f4ed769

Please sign in to comment.