-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added LifereaNodeSourceActivatable interface to allow plugins impleme…
…nting new node source types. (for Github #18)
- Loading branch information
Showing
11 changed files
with
186 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ To be released | |
* Fixes Github #133: Subscribe into TheOldReader categories | ||
* Improves Google Reader API error handling | ||
* Now using HTTPS only when accessing TheOldReader | ||
* Added LifereaNodeSourceActivatable interface to allow plugins | ||
implementing new node source types. | ||
|
||
|
||
2015-01-06 Lars Windolf <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/** | ||
* @file node_source.c generic node source provider implementation | ||
* | ||
* Copyright (C) 2005-2014 Lars Windolf <[email protected]> | ||
* Copyright (C) 2005-2015 Lars Windolf <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -33,6 +33,7 @@ | |
#include "item_state.h" | ||
#include "node.h" | ||
#include "node_type.h" | ||
#include "plugins_engine.h" | ||
#include "ui/icons.h" | ||
#include "ui/liferea_dialog.h" | ||
#include "ui/ui_common.h" | ||
|
@@ -46,8 +47,10 @@ | |
#include "fl_sources/reedah_source.h" | ||
#include "fl_sources/theoldreader_source.h" | ||
#include "fl_sources/ttrss_source.h" | ||
#include "fl_sources/node_source_activatable.h" | ||
|
||
static GSList *nodeSourceTypes = NULL; | ||
static GSList *nodeSourceTypes = NULL; | ||
static PeasExtensionSet *extensions = NULL; | ||
|
||
nodePtr | ||
node_source_root_from_node (nodePtr node) | ||
|
@@ -75,7 +78,7 @@ node_source_type_find (const gchar *typeStr, guint capabilities) | |
return NULL; | ||
} | ||
|
||
static gboolean | ||
gboolean | ||
node_source_type_register (nodeSourceTypePtr type) | ||
{ | ||
debug1 (DEBUG_PARSING, "Registering node source type %s", type->name); | ||
|
@@ -124,6 +127,9 @@ node_source_setup_root (void) | |
node_source_type_register (ttrss_source_get_type ()); | ||
node_source_type_register (theoldreader_source_get_type ()); | ||
|
||
extensions = peas_extension_set_new (PEAS_ENGINE (liferea_plugins_engine_get_default ()), | ||
LIFEREA_NODE_SOURCE_ACTIVATABLE_TYPE, NULL); | ||
|
||
type = node_source_type_find (NULL, NODE_SOURCE_CAPABILITY_IS_ROOT); | ||
if (!type) | ||
g_error ("No root capable node source found!"); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* @file node_type_activatable.c Node Source Plugin Type | ||
* | ||
* Copyright (C) 2015 Lars Windolf <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU 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 | ||
*/ | ||
|
||
#include "node_source_activatable.h" | ||
|
||
/** | ||
* SECTION:node_source_activatable | ||
* @short_description: Interface for activatable extensions providing a new node source type | ||
* @see_also: #PeasExtensionSet | ||
* | ||
* #LifereaNodeSourceActivatable is an interface which should be implemented by | ||
* extensions that want to a new node source type (usually online news aggregators) | ||
**/ | ||
G_DEFINE_INTERFACE (LifereaNodeSourceActivatable, liferea_node_source_activatable, G_TYPE_OBJECT) | ||
|
||
void | ||
liferea_node_source_activatable_default_init (LifereaNodeSourceActivatableInterface *iface) | ||
{ | ||
/* No properties yet */ | ||
} | ||
|
||
void | ||
liferea_node_source_activatable_activate (LifereaNodeSourceActivatable * activatable) | ||
{ | ||
LifereaNodeSourceActivatableInterface *iface; | ||
|
||
g_return_if_fail (IS_LIFEREA_NODE_SOURCE_ACTIVATABLE (activatable)); | ||
|
||
iface = LIFEREA_NODE_SOURCE_ACTIVATABLE_GET_IFACE (activatable); | ||
if (iface->activate) | ||
iface->activate (activatable); | ||
} | ||
|
||
void | ||
liferea_node_source_activatable_deactivate (LifereaNodeSourceActivatable * activatable) | ||
{ | ||
LifereaNodeSourceActivatableInterface *iface; | ||
|
||
g_return_if_fail (IS_LIFEREA_NODE_SOURCE_ACTIVATABLE (activatable)); | ||
|
||
iface = LIFEREA_NODE_SOURCE_ACTIVATABLE_GET_IFACE (activatable); | ||
if (iface->deactivate) | ||
iface->deactivate (activatable); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* @file node_source_activatable.h Node Source Plugin Type | ||
* | ||
* Copyright (C) 2015 Lars Windolf <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU 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 General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU 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 _LIFEREA_NODE_SOURCE_ACTIVATABLE_H__ | ||
#define _LIFEREA_NODE_SOURCE_ACTIVATABLE_H__ | ||
|
||
#include <glib-object.h> | ||
#include <gtk/gtk.h> | ||
|
||
G_BEGIN_DECLS | ||
|
||
#define LIFEREA_NODE_SOURCE_ACTIVATABLE_TYPE (liferea_node_source_activatable_get_type ()) | ||
#define LIFEREA_NODE_SOURCE_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LIFEREA_NODE_SOURCE_ACTIVATABLE_TYPE, LifereaNodeSourceActivatable)) | ||
#define LIFEREA_NODE_SOURCE_ACTIVATABLE_IFACE(obj) (G_TYPE_CHECK_CLASS_CAST ((obj), LIFEREA_NODE_SOURCE_ACTIVATABLE_TYPE, LifereaNodeSourceActivatableInterface)) | ||
#define IS_LIFEREA_NODE_SOURCE_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LIFEREA_NODE_SOURCE_ACTIVATABLE_TYPE)) | ||
#define LIFEREA_NODE_SOURCE_ACTIVATABLE_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), LIFEREA_NODE_SOURCE_ACTIVATABLE_TYPE, LifereaNodeSourceActivatableInterface)) | ||
|
||
typedef struct _LifereaNodeSourceActivatable LifereaNodeSourceActivatable; | ||
typedef struct _LifereaNodeSourceActivatableInterface LifereaNodeSourceActivatableInterface; | ||
|
||
struct _LifereaNodeSourceActivatableInterface | ||
{ | ||
GTypeInterface g_iface; | ||
|
||
void (*activate) (LifereaNodeSourceActivatable * activatable); | ||
void (*deactivate) (LifereaNodeSourceActivatable * activatable); | ||
}; | ||
|
||
GType liferea_node_source_activatable_get_type (void) G_GNUC_CONST; | ||
|
||
void liferea_node_source_activatable_activate (LifereaNodeSourceActivatable *activatable); | ||
|
||
void liferea_node_source_activatable_deactivate (LifereaNodeSourceActivatable *activatable); | ||
|
||
G_END_DECLS | ||
|
||
#endif /* __LIFEREA_NODE_SOURCE_ACTIVATABLE_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* | ||
* Copyright (C) 2002-2005 Paolo Maggi | ||
* Copyright (C) 2010 Steve Frécinaux | ||
* Copyright (C) 2012 Lars Windolf <[email protected]> | ||
* Copyright (C) 2012-2015 Lars Windolf <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -102,6 +102,36 @@ liferea_plugins_engine_init (LifereaPluginsEngine * engine) | |
engine, "loaded-plugins", G_SETTINGS_BIND_DEFAULT); | ||
} | ||
|
||
/* Provide default signal handlers */ | ||
|
||
static void | ||
on_extension_added (PeasExtensionSet *extensions, | ||
PeasPluginInfo *info, | ||
PeasExtension *exten, | ||
gpointer user_data) | ||
{ | ||
peas_extension_call (exten, "activate"); | ||
} | ||
|
||
static void | ||
on_extension_removed (PeasExtensionSet *extensions, | ||
PeasPluginInfo *info, | ||
PeasExtension *exten, | ||
gpointer user_data) | ||
{ | ||
peas_extension_call (exten, "deactivate"); | ||
} | ||
|
||
void | ||
liferea_plugins_engine_set_default_signals (PeasExtensionSet *extensions, | ||
gpointer user_data) | ||
{ | ||
g_signal_connect (extensions, "extension-added", G_CALLBACK (on_extension_added), user_data); | ||
g_signal_connect (extensions, "extension-removed", G_CALLBACK (on_extension_removed), user_data); | ||
|
||
peas_extension_set_call (extensions, "activate"); | ||
} | ||
|
||
static void | ||
liferea_plugins_engine_dispose (GObject * object) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* plugins_engine.h: Liferea Plugins using libpeas | ||
* | ||
* Copyright (C) 2012 Lars Windolf <[email protected]> | ||
* Copyright (C) 2012-2015 Lars Windolf <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -22,8 +22,8 @@ | |
#ifndef _PLUGINS_ENGINE | ||
#define _PLUGINS_ENGINE | ||
|
||
#include <glib.h> | ||
#include <libpeas/peas-engine.h> | ||
#include <libpeas/peas-extension-set.h> | ||
|
||
G_BEGIN_DECLS | ||
|
||
|
@@ -51,6 +51,16 @@ GType liferea_plugins_engine_get_type (void) G_GNUC_CONST; | |
|
||
LifereaPluginsEngine *liferea_plugins_engine_get_default (void); | ||
|
||
/** | ||
* liferea_plugins_set_default_signals: | ||
* | ||
* Set up default "activate" and "deactivate" signals. | ||
* | ||
* @extensions: the extensions set | ||
* @user_data: some user data (or NULL) | ||
*/ | ||
void liferea_plugins_set_default_signals (PeasExtensionSet *extensions, gpointer user_data); | ||
|
||
G_END_DECLS | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* @file liferea_media_player.c media player helpers | ||
* | ||
* Copyright (C) 2012 Lars Windolf <[email protected]> | ||
* Copyright (C) 2012-2015 Lars Windolf <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -23,31 +23,9 @@ | |
#include "plugins_engine.h" | ||
|
||
#include <libpeas/peas-activatable.h> | ||
#include <libpeas/peas-extension-set.h> | ||
|
||
// FIXME: This should be a member of some object! | ||
static PeasExtensionSet *extensions = NULL; /**< Plugin management */ | ||
static gint count = 0; /**< Number of active auth plugins */ | ||
|
||
static void | ||
on_extension_added (PeasExtensionSet *extensions, | ||
PeasPluginInfo *info, | ||
PeasExtension *exten, | ||
gpointer user_data) | ||
{ | ||
peas_extension_call (exten, "activate"); | ||
count++; | ||
} | ||
|
||
static void | ||
on_extension_removed (PeasExtensionSet *extensions, | ||
PeasPluginInfo *info, | ||
PeasExtension *exten, | ||
gpointer user_data) | ||
{ | ||
peas_extension_call (exten, "deactivate"); | ||
count--; | ||
} | ||
static PeasExtensionSet *extensions = NULL; | ||
|
||
static PeasExtensionSet * | ||
liferea_media_player_get_extension_set (void) | ||
|
@@ -56,10 +34,7 @@ liferea_media_player_get_extension_set (void) | |
extensions = peas_extension_set_new (PEAS_ENGINE (liferea_plugins_engine_get_default ()), | ||
LIFEREA_MEDIA_PLAYER_ACTIVATABLE_TYPE, NULL); | ||
|
||
g_signal_connect (extensions, "extension-added", G_CALLBACK (on_extension_added), NULL); | ||
g_signal_connect (extensions, "extension-removed", G_CALLBACK (on_extension_removed), NULL); | ||
|
||
peas_extension_set_foreach (extensions, on_extension_added, NULL); | ||
liferea_plugins_engine_set_default_signals (extensions, NULL); | ||
} | ||
|
||
return extensions; | ||
|