Add new (App/Window/View)Activatable interfaces for plugins
Currently only the modelines and filebrowser plugins are updated to these new interfaces
This commit is contained in:
@@ -70,6 +70,7 @@ NOINST_H_FILES = \
|
||||
|
||||
INST_H_FILES = \
|
||||
xed-app.h \
|
||||
xed-app-activatable.h \
|
||||
xed-commands.h \
|
||||
xed-debug.h \
|
||||
xed-document.h \
|
||||
@@ -91,7 +92,9 @@ INST_H_FILES = \
|
||||
xed-tab.h \
|
||||
xed-utils.h \
|
||||
xed-view.h \
|
||||
xed-window.h
|
||||
xed-view-activatable.h \
|
||||
xed-window.h \
|
||||
xed-window-activatable.h
|
||||
|
||||
if !ENABLE_GVFS_METADATA
|
||||
INST_H_FILES += xed-metadata-manager.h
|
||||
@@ -105,6 +108,7 @@ header_DATA = \
|
||||
|
||||
libxed_c_files = \
|
||||
xed-app.c \
|
||||
xed-app-activatable.c \
|
||||
xed-close-button.c \
|
||||
xed-commands-documents.c \
|
||||
xed-commands-edit.c \
|
||||
@@ -152,7 +156,9 @@ libxed_c_files = \
|
||||
xed-tab-label.c \
|
||||
xed-utils.c \
|
||||
xed-view.c \
|
||||
xed-view-activatable.c \
|
||||
xed-window.c \
|
||||
xed-window-activatable.c \
|
||||
xedtextregion.c
|
||||
|
||||
libxed_la_SOURCES = \
|
||||
|
108
xed/xed-app-activatable.c
Normal file
108
xed/xed-app-activatable.c
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* xed-app-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* 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 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 Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xed-app-activatable.h"
|
||||
#include "xed-app.h"
|
||||
|
||||
/**
|
||||
* SECTION:xed-app-activatable
|
||||
* @short_description: Interface for activatable extensions on apps
|
||||
* @see_also: #PeasExtensionSet
|
||||
*
|
||||
* #XedAppActivatable is an interface which should be implemented by
|
||||
* extensions that should be activated on a xed application.
|
||||
**/
|
||||
|
||||
G_DEFINE_INTERFACE(XedAppActivatable, xed_app_activatable, G_TYPE_OBJECT)
|
||||
|
||||
void
|
||||
xed_app_activatable_default_init (XedAppActivatableInterface *iface)
|
||||
{
|
||||
static gboolean initialized = FALSE;
|
||||
|
||||
if (!initialized)
|
||||
{
|
||||
/**
|
||||
* XedAppActivatable:app:
|
||||
*
|
||||
* The app property contains the xed app for this
|
||||
* #XedAppActivatable instance.
|
||||
*/
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_object ("app",
|
||||
"App",
|
||||
"The xed app",
|
||||
XED_TYPE_APP,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
initialized = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_app_activatable_activate:
|
||||
* @activatable: A #XedAppActivatable.
|
||||
*
|
||||
* Activates the extension on the application.
|
||||
*/
|
||||
void
|
||||
xed_app_activatable_activate (XedAppActivatable *activatable)
|
||||
{
|
||||
XedAppActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_APP_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_APP_ACTIVATABLE_GET_IFACE (activatable);
|
||||
|
||||
if (iface->activate != NULL)
|
||||
{
|
||||
iface->activate (activatable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_app_activatable_deactivate:
|
||||
* @activatable: A #XedAppActivatable.
|
||||
*
|
||||
* Deactivates the extension from the application.
|
||||
*
|
||||
*/
|
||||
void
|
||||
xed_app_activatable_deactivate (XedAppActivatable *activatable)
|
||||
{
|
||||
XedAppActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_APP_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_APP_ACTIVATABLE_GET_IFACE (activatable);
|
||||
|
||||
if (iface->deactivate != NULL)
|
||||
{
|
||||
iface->deactivate (activatable);
|
||||
}
|
||||
}
|
61
xed/xed-app-activatable.h
Normal file
61
xed/xed-app-activatable.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* xed-app-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* 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 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 Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XED_APP_ACTIVATABLE_H__
|
||||
#define __XED_APP_ACTIVATABLE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XED_TYPE_APP_ACTIVATABLE (xed_app_activatable_get_type ())
|
||||
#define XED_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_APP_ACTIVATABLE, XedAppActivatable))
|
||||
#define XED_APP_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XED_TYPE_APP_ACTIVATABLE, XedAppActivatableInterface))
|
||||
#define XED_IS_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_APP_ACTIVATABLE))
|
||||
#define XED_APP_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XED_TYPE_APP_ACTIVATABLE, XedAppActivatableInterface))
|
||||
|
||||
typedef struct _XedAppActivatable XedAppActivatable; /* dummy typedef */
|
||||
typedef struct _XedAppActivatableInterface XedAppActivatableInterface;
|
||||
|
||||
struct _XedAppActivatableInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Virtual public methods */
|
||||
void (*activate) (XedAppActivatable *activatable);
|
||||
void (*deactivate) (XedAppActivatable *activatable);
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xed_app_activatable_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void xed_app_activatable_activate (XedAppActivatable *activatable);
|
||||
void xed_app_activatable_deactivate (XedAppActivatable *activatable);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_APP_ACTIVATABLE_H__ */
|
@@ -36,6 +36,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include <glib/gi18n.h>
|
||||
#include <libpeas/peas-extension-set.h>
|
||||
|
||||
#include "xed-app.h"
|
||||
#include "xed-prefs-manager-app.h"
|
||||
@@ -45,6 +46,8 @@
|
||||
#include "xed-utils.h"
|
||||
#include "xed-enum-types.h"
|
||||
#include "xed-dirs.h"
|
||||
#include "xed-app-activatable.h"
|
||||
#include "xed-plugins-engine.h"
|
||||
|
||||
#define XED_PAGE_SETUP_FILE "xed-page-setup"
|
||||
#define XED_PRINT_SETTINGS_FILE "xed-print-settings"
|
||||
@@ -61,8 +64,11 @@ struct _XedAppPrivate
|
||||
{
|
||||
GList *windows;
|
||||
XedWindow *active_window;
|
||||
|
||||
GtkPageSetup *page_setup;
|
||||
GtkPrintSettings *print_settings;
|
||||
|
||||
PeasExtensionSet *extensions;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(XedApp, xed_app, G_TYPE_OBJECT)
|
||||
@@ -87,6 +93,16 @@ xed_app_finalize (GObject *object)
|
||||
G_OBJECT_CLASS (xed_app_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_app_dispose (GObject *object)
|
||||
{
|
||||
XedApp *app = XED_APP (object);
|
||||
|
||||
g_clear_object (&app->priv->extensions);
|
||||
|
||||
G_OBJECT_CLASS (xed_app_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_app_get_property (GObject *object,
|
||||
guint prop_id,
|
||||
@@ -107,9 +123,10 @@ xed_app_class_init (XedAppClass *klass)
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->finalize = xed_app_finalize;
|
||||
object_class->dispose = xed_app_dispose;
|
||||
object_class->get_property = xed_app_get_property;
|
||||
|
||||
g_type_class_add_private (object_class, sizeof(XedAppPrivate));
|
||||
g_type_class_add_private (object_class, sizeof (XedAppPrivate));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -308,19 +325,40 @@ save_print_settings (XedApp *app)
|
||||
g_free (filename);
|
||||
}
|
||||
|
||||
static void
|
||||
extension_added (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedApp *app)
|
||||
{
|
||||
peas_extension_call (exten, "activate");
|
||||
}
|
||||
|
||||
static void
|
||||
extension_removed (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedApp *app)
|
||||
{
|
||||
peas_extension_call (exten, "deactivate");
|
||||
}
|
||||
|
||||
static void
|
||||
xed_app_init (XedApp *app)
|
||||
{
|
||||
app->priv = XED_APP_GET_PRIVATE (app);
|
||||
|
||||
load_accels ();
|
||||
}
|
||||
|
||||
static void
|
||||
app_weak_notify (gpointer data,
|
||||
GObject *where_the_app_was)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
app->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
||||
XED_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-removed",
|
||||
G_CALLBACK (extension_removed), app);
|
||||
|
||||
peas_extension_set_call (app->priv->extensions, "activate");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -342,7 +380,6 @@ xed_app_get_default (void)
|
||||
app = XED_APP (g_object_new (XED_TYPE_APP, NULL));
|
||||
|
||||
g_object_add_weak_pointer (G_OBJECT (app), (gpointer) &app);
|
||||
g_object_weak_ref (G_OBJECT (app), app_weak_notify, NULL);
|
||||
|
||||
return app;
|
||||
}
|
||||
@@ -421,7 +458,7 @@ window_destroy (XedWindow *window,
|
||||
save_page_setup (app);
|
||||
save_print_settings (app);
|
||||
|
||||
g_object_unref (app);
|
||||
gtk_main_quit ();
|
||||
}
|
||||
}
|
||||
|
||||
|
96
xed/xed-view-activatable.c
Normal file
96
xed/xed-view-activatable.c
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* xed-view-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* 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 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 Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xed-view-activatable.h"
|
||||
#include "xed-view.h"
|
||||
|
||||
/**
|
||||
* SECTION:xed-view-activatable
|
||||
* @short_description: Interface for activatable extensions on views
|
||||
* @see_also: #PeasExtensionSet
|
||||
*
|
||||
* #XedViewActivatable is an interface which should be implemented by
|
||||
* extensions that should be activated on a xed view.
|
||||
**/
|
||||
G_DEFINE_INTERFACE(XedViewActivatable, xed_view_activatable, G_TYPE_OBJECT)
|
||||
|
||||
void
|
||||
xed_view_activatable_default_init (XedViewActivatableInterface *iface)
|
||||
{
|
||||
/**
|
||||
* XedViewActivatable:view:
|
||||
*
|
||||
* The window property contains the xed window for this
|
||||
* #XedViewActivatable instance.
|
||||
*/
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_object ("view",
|
||||
"view",
|
||||
"A xed view",
|
||||
XED_TYPE_VIEW,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_view_activatable_activate:
|
||||
* @activatable: A #XedViewActivatable.
|
||||
*
|
||||
* Activates the extension on the window property.
|
||||
*/
|
||||
void
|
||||
xed_view_activatable_activate (XedViewActivatable *activatable)
|
||||
{
|
||||
XedViewActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_VIEW_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_VIEW_ACTIVATABLE_GET_IFACE (activatable);
|
||||
if (iface->activate != NULL)
|
||||
{
|
||||
iface->activate (activatable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_view_activatable_deactivate:
|
||||
* @activatable: A #XedViewActivatable.
|
||||
*
|
||||
* Deactivates the extension on the window property.
|
||||
*/
|
||||
void
|
||||
xed_view_activatable_deactivate (XedViewActivatable *activatable)
|
||||
{
|
||||
XedViewActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_VIEW_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_VIEW_ACTIVATABLE_GET_IFACE (activatable);
|
||||
if (iface->deactivate != NULL)
|
||||
{
|
||||
iface->deactivate (activatable);
|
||||
}
|
||||
}
|
60
xed/xed-view-activatable.h
Normal file
60
xed/xed-view-activatable.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* xed-view-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* 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 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 Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XED_VIEW_ACTIVATABLE_H__
|
||||
#define __XED_VIEW_ACTIVATABLE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XED_TYPE_VIEW_ACTIVATABLE (xed_view_activatable_get_type ())
|
||||
#define XED_VIEW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_VIEW_ACTIVATABLE, XedViewActivatable))
|
||||
#define XED_VIEW_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XED_TYPE_VIEW_ACTIVATABLE, XedViewActivatableInterface))
|
||||
#define XED_IS_VIEW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_VIEW_ACTIVATABLE))
|
||||
#define XED_VIEW_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XED_TYPE_VIEW_ACTIVATABLE, XedViewActivatableInterface))
|
||||
|
||||
typedef struct _XedViewActivatable XedViewActivatable; /* dummy typedef */
|
||||
typedef struct _XedViewActivatableInterface XedViewActivatableInterface;
|
||||
|
||||
struct _XedViewActivatableInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Virtual public methods */
|
||||
void (*activate) (XedViewActivatable *activatable);
|
||||
void (*deactivate) (XedViewActivatable *activatable);
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xed_view_activatable_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void xed_view_activatable_activate (XedViewActivatable *activatable);
|
||||
void xed_view_activatable_deactivate (XedViewActivatable *activatable);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_VIEW_ACTIVATABLE_H__ */
|
@@ -6,9 +6,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <libpeas/peas-extension-set.h>
|
||||
#include <glib/gi18n.h>
|
||||
|
||||
#include "xed-view.h"
|
||||
#include "xed-view-activatable.h"
|
||||
#include "xed-plugins-engine.h"
|
||||
#include "xed-debug.h"
|
||||
#include "xed-prefs-manager.h"
|
||||
#include "xed-prefs-manager-app.h"
|
||||
@@ -34,10 +37,13 @@ struct _XedViewPrivate
|
||||
guint search_entry_changed_id;
|
||||
gboolean disable_popdown;
|
||||
GtkTextBuffer *current_buffer;
|
||||
PeasExtensionSet *extensions;
|
||||
guint view_realized : 1;
|
||||
};
|
||||
|
||||
static void xed_view_dispose (GObject *object);
|
||||
static void xed_view_finalize (GObject *object);
|
||||
static void xed_view_realize (GtkWidget *widget);
|
||||
static gint xed_view_focus_out (GtkWidget *widget, GdkEventFocus *event);
|
||||
static gboolean xed_view_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint timestamp);
|
||||
static void xed_view_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y,
|
||||
@@ -107,6 +113,7 @@ xed_view_class_init (XedViewClass *klass)
|
||||
widget_class->drag_data_received = xed_view_drag_data_received;
|
||||
widget_class->drag_drop = xed_view_drag_drop;
|
||||
widget_class->button_press_event = xed_view_button_press_event;
|
||||
widget_class->realize = xed_view_realize;
|
||||
klass->start_interactive_goto_line = start_interactive_goto_line;
|
||||
|
||||
text_view_class->delete_from_cursor = xed_view_delete_from_cursor;
|
||||
@@ -152,6 +159,24 @@ current_buffer_removed (XedView *view)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
extension_added (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedView *view)
|
||||
{
|
||||
peas_extension_call (exten, "activate");
|
||||
}
|
||||
|
||||
static void
|
||||
extension_removed (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedView *view)
|
||||
{
|
||||
peas_extension_call (exten, "deactivate");
|
||||
}
|
||||
|
||||
static void
|
||||
on_notify_buffer_cb (XedView *view,
|
||||
GParamSpec *arg1,
|
||||
@@ -223,6 +248,14 @@ xed_view_init (XedView *view)
|
||||
gtk_target_list_add_uri_targets (tl, TARGET_URI_LIST);
|
||||
}
|
||||
|
||||
view->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
||||
XED_TYPE_VIEW_ACTIVATABLE, "view", view, NULL);
|
||||
|
||||
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);
|
||||
|
||||
/* Act on buffer change */
|
||||
g_signal_connect(view, "notify::buffer", G_CALLBACK (on_notify_buffer_cb), NULL);
|
||||
}
|
||||
@@ -234,6 +267,12 @@ xed_view_dispose (GObject *object)
|
||||
|
||||
view = XED_VIEW(object);
|
||||
|
||||
if (view->priv->extensions != NULL)
|
||||
{
|
||||
g_object_unref (view->priv->extensions);
|
||||
view->priv->extensions = NULL;
|
||||
}
|
||||
|
||||
if (view->priv->search_window != NULL)
|
||||
{
|
||||
gtk_widget_destroy (view->priv->search_window);
|
||||
@@ -261,7 +300,8 @@ xed_view_finalize (GObject *object)
|
||||
XedView *view;
|
||||
view = XED_VIEW(object);
|
||||
current_buffer_removed (view);
|
||||
(* G_OBJECT_CLASS (xed_view_parent_class)->finalize) (object);
|
||||
|
||||
G_OBJECT_CLASS (xed_view_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gint
|
||||
@@ -1141,6 +1181,20 @@ xed_view_button_press_event (GtkWidget *widget,
|
||||
return GTK_WIDGET_CLASS (xed_view_parent_class)->button_press_event (widget, event);
|
||||
}
|
||||
|
||||
static void
|
||||
xed_view_realize (GtkWidget *widget)
|
||||
{
|
||||
XedView *view = XED_VIEW (widget);
|
||||
|
||||
if (!view->priv->view_realized)
|
||||
{
|
||||
peas_extension_set_call (view->priv->extensions, "activate");
|
||||
view->priv->view_realized = TRUE;
|
||||
}
|
||||
|
||||
GTK_WIDGET_CLASS (xed_view_parent_class)->realize (widget);
|
||||
}
|
||||
|
||||
static void
|
||||
search_highlight_updated_cb (XedDocument *doc,
|
||||
GtkTextIter *start,
|
||||
|
117
xed/xed-window-activatable.c
Normal file
117
xed/xed-window-activatable.c
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* xed-window-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* 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 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 Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include "xed-window-activatable.h"
|
||||
#include "xed-window.h"
|
||||
|
||||
/**
|
||||
* SECTION:xed-window-activatable
|
||||
* @short_description: Interface for activatable extensions on windows
|
||||
* @see_also: #PeasExtensionSet
|
||||
*
|
||||
* #XedWindowActivatable is an interface which should be implemented by
|
||||
* extensions that should be activated on a xed main window.
|
||||
**/
|
||||
G_DEFINE_INTERFACE(XedWindowActivatable, xed_window_activatable, G_TYPE_OBJECT)
|
||||
|
||||
void
|
||||
xed_window_activatable_default_init (XedWindowActivatableInterface *iface)
|
||||
{
|
||||
/**
|
||||
* XedWindowActivatable:window:
|
||||
*
|
||||
* The window property contains the xed window for this
|
||||
* #XedWindowActivatable instance.
|
||||
*/
|
||||
g_object_interface_install_property (iface,
|
||||
g_param_spec_object ("window",
|
||||
"Window",
|
||||
"The xed window",
|
||||
XED_TYPE_WINDOW,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_window_activatable_activate:
|
||||
* @activatable: A #XedWindowActivatable.
|
||||
*
|
||||
* Activates the extension on the window property.
|
||||
*/
|
||||
void
|
||||
xed_window_activatable_activate (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedWindowActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
|
||||
if (iface->activate != NULL)
|
||||
{
|
||||
iface->activate (activatable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_window_activatable_deactivate:
|
||||
* @activatable: A #XedWindowActivatable.
|
||||
*
|
||||
* Deactivates the extension on the window property.
|
||||
*/
|
||||
void
|
||||
xed_window_activatable_deactivate (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedWindowActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
|
||||
if (iface->deactivate != NULL)
|
||||
{
|
||||
iface->deactivate (activatable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* xed_window_activatable_update_state:
|
||||
* @activatable: A #XedWindowActivatable.
|
||||
*
|
||||
* Triggers an update of the extension insternal state to take into account
|
||||
* state changes in the window state, due to some event or user action.
|
||||
*/
|
||||
void
|
||||
xed_window_activatable_update_state (XedWindowActivatable *activatable)
|
||||
{
|
||||
XedWindowActivatableInterface *iface;
|
||||
|
||||
g_return_if_fail (XED_IS_WINDOW_ACTIVATABLE (activatable));
|
||||
|
||||
iface = XED_WINDOW_ACTIVATABLE_GET_IFACE (activatable);
|
||||
if (iface->update_state != NULL)
|
||||
{
|
||||
iface->update_state (activatable);
|
||||
}
|
||||
}
|
62
xed/xed-window-activatable.h
Normal file
62
xed/xed-window-activatable.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* xed-window-activatable.h
|
||||
* This file is part of xed
|
||||
*
|
||||
* 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 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 Library General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __XED_WINDOW_ACTIVATABLE_H__
|
||||
#define __XED_WINDOW_ACTIVATABLE_H__
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/*
|
||||
* Type checking and casting macros
|
||||
*/
|
||||
#define XED_TYPE_WINDOW_ACTIVATABLE (xed_window_activatable_get_type ())
|
||||
#define XED_WINDOW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), XED_TYPE_WINDOW_ACTIVATABLE, XedWindowActivatable))
|
||||
#define XED_WINDOW_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), XED_TYPE_WINDOW_ACTIVATABLE, XedWindowActivatableInterface))
|
||||
#define XED_IS_WINDOW_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), XED_TYPE_WINDOW_ACTIVATABLE))
|
||||
#define XED_WINDOW_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), XED_TYPE_WINDOW_ACTIVATABLE, XedWindowActivatableInterface))
|
||||
|
||||
typedef struct _XedWindowActivatable XedWindowActivatable; /* dummy typedef */
|
||||
typedef struct _XedWindowActivatableInterface XedWindowActivatableInterface;
|
||||
|
||||
struct _XedWindowActivatableInterface
|
||||
{
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Virtual public methods */
|
||||
void (*activate) (XedWindowActivatable *activatable);
|
||||
void (*deactivate) (XedWindowActivatable *activatable);
|
||||
void (*update_state) (XedWindowActivatable *activatable);
|
||||
};
|
||||
|
||||
/*
|
||||
* Public methods
|
||||
*/
|
||||
GType xed_window_activatable_get_type (void) G_GNUC_CONST;
|
||||
|
||||
void xed_window_activatable_activate (XedWindowActivatable *activatable);
|
||||
void xed_window_activatable_deactivate (XedWindowActivatable *activatable);
|
||||
void xed_window_activatable_update_state (XedWindowActivatable *activatable);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __XED_WINDOW_ACTIVATABLE_H__ */
|
@@ -9,7 +9,6 @@
|
||||
#include <gio/gio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtksourceview/gtksource.h>
|
||||
#include <libpeas/peas-activatable.h>
|
||||
#include <libpeas/peas-extension-set.h>
|
||||
|
||||
#include "xed-ui.h"
|
||||
@@ -27,6 +26,7 @@
|
||||
#include "xed-panel.h"
|
||||
#include "xed-documents-panel.h"
|
||||
#include "xed-plugins-engine.h"
|
||||
#include "xed-window-activatable.h"
|
||||
#include "xed-enum-types.h"
|
||||
#include "xed-dirs.h"
|
||||
#include "xed-status-combo-box.h"
|
||||
@@ -142,7 +142,7 @@ xed_window_dispose (GObject *object)
|
||||
|
||||
xed_debug (DEBUG_WINDOW);
|
||||
|
||||
window = XED_WINDOW(object);
|
||||
window = XED_WINDOW (object);
|
||||
|
||||
/* Stop tracking removal of panes otherwise we always
|
||||
* end up with thinking we had no pane active, since they
|
||||
@@ -163,11 +163,13 @@ xed_window_dispose (GObject *object)
|
||||
if (!window->priv->dispose_has_run)
|
||||
{
|
||||
save_panes_state (window);
|
||||
|
||||
/* Note that unreffing the extension will automatically remove
|
||||
all extensions which in turn will deactivate the extension */
|
||||
g_object_unref (window->priv->extensions);
|
||||
|
||||
peas_engine_garbage_collect (PEAS_ENGINE (xed_plugins_engine_get_default ()));
|
||||
|
||||
window->priv->dispose_has_run = TRUE;
|
||||
}
|
||||
|
||||
@@ -191,23 +193,10 @@ xed_window_dispose (GObject *object)
|
||||
window->priv->recents_handler_id = 0;
|
||||
}
|
||||
|
||||
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->window_group != NULL)
|
||||
{
|
||||
g_object_unref (window->priv->window_group);
|
||||
window->priv->window_group = NULL;
|
||||
}
|
||||
g_clear_object (&window->priv->manager);
|
||||
g_clear_object (&window->priv->message_bus);
|
||||
g_clear_object (&window->priv->window_group);
|
||||
g_clear_object (&window->priv->default_location);
|
||||
|
||||
/* Now that there have broken some reference loops, force collection again. */
|
||||
peas_engine_garbage_collect (PEAS_ENGINE (xed_plugins_engine_get_default ()));
|
||||
@@ -218,13 +207,8 @@ xed_window_dispose (GObject *object)
|
||||
static void
|
||||
xed_window_finalize (GObject *object)
|
||||
{
|
||||
XedWindow *window;
|
||||
xed_debug (DEBUG_WINDOW);
|
||||
window = XED_WINDOW(object);
|
||||
if (window->priv->default_location != NULL)
|
||||
{
|
||||
g_object_unref (window->priv->default_location);
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (xed_window_parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
@@ -646,7 +630,7 @@ set_sensitivity_according_to_tab (XedWindow *window,
|
||||
|
||||
update_next_prev_doc_sensitivity (window, tab);
|
||||
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2376,7 +2360,7 @@ sync_name (XedTab *tab,
|
||||
g_free (escaped_name);
|
||||
g_free (tip);
|
||||
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static XedWindow *
|
||||
@@ -2789,7 +2773,7 @@ selection_changed (XedDocument *doc,
|
||||
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", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2798,7 +2782,7 @@ sync_languages_menu (XedDocument *doc,
|
||||
XedWindow *window)
|
||||
{
|
||||
update_languages_menu (window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2808,7 +2792,7 @@ readonly_changed (XedDocument *doc,
|
||||
{
|
||||
set_sensitivity_according_to_tab (window, window->priv->active_tab);
|
||||
sync_name (window->priv->active_tab, NULL, window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2816,7 +2800,7 @@ editable_changed (XedView *view,
|
||||
GParamSpec *arg1,
|
||||
XedWindow *window)
|
||||
{
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2964,7 +2948,7 @@ notebook_tab_removed (XedNotebook *notebook,
|
||||
|
||||
if (window->priv->num_tabs == 0)
|
||||
{
|
||||
peas_extension_set_call (window->priv->extensions, "update_state", window);
|
||||
peas_extension_set_call (window->priv->extensions, "update_state");
|
||||
}
|
||||
|
||||
update_window_state (window);
|
||||
@@ -3374,21 +3358,21 @@ add_notebook (XedWindow *window,
|
||||
}
|
||||
|
||||
static void
|
||||
on_extension_added (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedWindow *window)
|
||||
extension_added (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedWindow *window)
|
||||
{
|
||||
peas_extension_call (exten, "activate", window);
|
||||
peas_extension_call (exten, "activate");
|
||||
}
|
||||
|
||||
static void
|
||||
on_extension_removed (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedWindow *window)
|
||||
extension_removed (PeasExtensionSet *extensions,
|
||||
PeasPluginInfo *info,
|
||||
PeasExtension *exten,
|
||||
XedWindow *window)
|
||||
{
|
||||
peas_extension_call (exten, "deactivate", window);
|
||||
peas_extension_call (exten, "deactivate");
|
||||
|
||||
/* Ensure update of the 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 the ui manager update in a idle func) */
|
||||
@@ -3501,13 +3485,13 @@ xed_window_init (XedWindow *window)
|
||||
xed_debug_message (DEBUG_WINDOW, "Update plugins ui");
|
||||
|
||||
window->priv->extensions = peas_extension_set_new (PEAS_ENGINE (xed_plugins_engine_get_default ()),
|
||||
PEAS_TYPE_ACTIVATABLE, "object", window, NULL);
|
||||
XED_TYPE_WINDOW_ACTIVATABLE, "window", window, NULL);
|
||||
|
||||
g_signal_connect (window->priv->extensions, "extension-added", G_CALLBACK (extension_added), window);
|
||||
g_signal_connect (window->priv->extensions, "extension-removed", G_CALLBACK (extension_removed), window);
|
||||
|
||||
peas_extension_set_call (window->priv->extensions, "activate");
|
||||
|
||||
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);
|
||||
|
||||
/* set visibility of panes.
|
||||
* This needs to be done after plugins activatation */
|
||||
init_panels_visibility (window);
|
||||
|
Reference in New Issue
Block a user