commit 6014922f3b2f1564a9d32a33af37676c71ef7fa8
Author: phantomjinx <[email protected]>
Date: Sat Jun 19 01:21:10 2010 +0100
Experimental simple browser for finding coverart using webkit
* Entire plugin compiling should be conditional on webkit dependency
TODO | 6 +-
configure.in | 27 ++++
plugins/Makefile.am | 3 +-
plugins/coverweb/Makefile.am | 138 +++++++++++++++++++++
plugins/coverweb/coverweb.c | 197 ++++++++++++++++++++++++++++++
plugins/coverweb/coverweb.glade | 133 ++++++++++++++++++++
plugins/coverweb/coverweb.h | 68 ++++++++++
plugins/coverweb/coverweb.plugin | 4 +
plugins/coverweb/coverweb.ui | 7 +
plugins/coverweb/coverweb_preferences.c | 182 +++++++++++++++++++++++++++
plugins/coverweb/coverweb_preferences.h | 34 +++++
plugins/coverweb/icons/Makefile.am | 4 +
plugins/coverweb/icons/internet-icon.png | Bin 0 -> 16261 bytes
plugins/coverweb/plugin.c | 167 +++++++++++++++++++++++++
plugins/coverweb/plugin.h | 65 ++++++++++
15 files changed, 1031 insertions(+), 4 deletions(-)
---
diff --git a/TODO b/TODO
index daf7cf6..bcd7c98 100644
--- a/TODO
+++ b/TODO
@@ -53,13 +53,13 @@ Help Menu
# Help Contents
# About box
-Playlists Plugin
+#Playlists Plugin
# popup menu
-Tracks Plugin
+#Tracks Plugin
# popup menu
-Sorttab Menu
+#Sorttab Menu
# popup menu
# Save on exit
diff --git a/configure.in b/configure.in
index 6e28697..cfc69c7 100644
--- a/configure.in
+++ b/configure.in
@@ -245,6 +245,31 @@ AC_CHECK_HEADERS(linux/cdrom.h scsi/sg.h scsi/scsi.h
scsi/scsi_ioctl.h)
libgpod_version=`$PKG_CONFIG libgpod-1.0 --modversion`
AC_DEFINE_UNQUOTED(LIBGPOD_VERSION, "${libgpod_version}", [Set this to the
libgpod version])
+dnl Check for webkit
+dnl -------------------------------------------------------------
+
+AC_ARG_ENABLE(plugin-coverweb,
+ AC_HELP_STRING([--disable-plugin-coverweb],[Disable browser plugin for
finding coverart in gtkpod]),
+ [ if test "$enableval" = "no"; then
+ user_disabled_coverweb=1
+ fi ],
+ [ user_disabled_coverweb=0 ])
+
+AC_MSG_CHECKING(if coverweb plugin is disabled)
+if test "$user_disabled_coverweb" = 1; then
+ AC_MSG_RESULT(yes)
+ coverweb="no"
+else
+ AC_MSG_RESULT(no)
+
+ PKG_CHECK_MODULES(PLUGIN_COVERWEB,
+ [webkit-1.0 >= 1.1],
+ [coverweb="yes"],
+ [coverweb="no"])
+fi
+
+AM_CONDITIONAL(HAVE_PLUGIN_COVERWEB, [test x$coverweb = xyes])
+
dnl Setup Plugin directories
dnl ------------------------
gtkpod_plugin_dir='$(libdir)/$(PACKAGE)'
@@ -348,6 +373,8 @@ plugins/core_preferences/icons/hicolor/48x48/places/Makefile
plugins/info_display/Makefile
plugins/cover_display/Makefile
plugins/cover_display/icons/Makefile
+plugins/coverweb/Makefile
+plugins/coverweb/icons/Makefile
])
echo "
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 6e7ebdc..067a9ae 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -9,6 +9,7 @@ SUBDIRS = . \
details_editor \
core_preferences \
info_display \
- cover_display
+ cover_display \
+ coverweb
# indent
diff --git a/plugins/coverweb/Makefile.am b/plugins/coverweb/Makefile.am
new file mode 100644
index 0000000..8e70b89
--- /dev/null
+++ b/plugins/coverweb/Makefile.am
@@ -0,0 +1,138 @@
+if HAVE_PLUGIN_COVERWEB
+
+plugin_name = coverweb
+plugin_lib = lib$(plugin_name).so
+plugin_file = $(plugin_name).plugin
+
+# Plugin description file
+plugin_in_files = $(plugin_file)
+
+# Plugin UI file
+coverweb_uidir = $(gtkpod_ui_dir)
+coverweb_ui_DATA = $(plugin_name).ui
+
+# Plugin Glade file
+coverweb_gladedir = $(gtkpod_glade_dir)
+coverweb_glade_DATA = $(plugin_name).glade
+
+# Plugin Icon file
+coverweb_pixmapsdir = $(gtkpod_image_dir)
+coverweb_pixmaps_DATA =
+
+# Where to install the plugin
+plugindir = $(gtkpod_plugin_dir)
+coverweb_plugindir = $(gtkpod_plugin_dir)
+coverweb_plugin_DATA = $(plugin_file)
+
+SUBDIRS = icons
+
+# Even though this is located in the plugin directory, it will be
+# included from plugin sub-directories.
+include ../../data/directories.mk
+
+# The plugin
+plugin_LTLIBRARIES = libcoverweb.la
+
+AM_CPPFLAGS = \
+ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+ -DGTKPOD_DATA_DIR=\"$(gtkpod_data_dir)\" \
+ -DGTKPOD_PLUGIN_DIR=\"$(gtkpod_plugin_dir)\" \
+ -DGTKPOD_IMAGE_DIR=\"$(gtkpod_image_dir)\" \
+ -DGTKPOD_GLADE_DIR=\"$(gtkpod_glade_dir)\" \
+ -DGTKPOD_UI_DIR=\"$(gtkpod_ui_dir)\" \
+ -DPACKAGE_DATA_DIR=\"$(datadir)\" \
+ -DPACKAGE_SRC_DIR=\"$(srcdir)\" \
+ $(GTKPOD_CFLAGS) \
+ $(PLUGIN_COVERWEB_CFLAGS)
+
+# Plugin sources
+libcoverweb_la_SOURCES = plugin.c plugin.h \
+ coverweb.c coverweb.h \
+ coverweb_preferences.c
coverweb_preferences.h
+
+libcoverweb_la_LDFLAGS = $(GTKPOD_PLUGIN_LDFLAGS)
+
+# Plugin dependencies
+libcoverweb_la_LIBADD = \
+ $(LIBGTKPOD_LIBS) \
+ $(LIBANJUTA_LIBS) \
+ $(PLUGIN_COVERWEB_LIBS)
+
+all-local: create-plugin-links create-ui-link create-glade-link copy-icons-dir
+
+# Creating symbolic links in plugin root directory
+create-plugin-links:
+ echo "Creating plugin links"
+ if test ! -e ../$(plugin_lib); then \
+ ln -s `pwd`/.libs/$(plugin_lib) ../$(plugin_lib); \
+ fi; \
+ if test ! -e ../$(plugin_file); then \
+ ln -s `pwd`/$(plugin_file) ../$(plugin_file); \
+ fi;
+
+# Creating symbolic link to ui file in installed ui directory
+create-ui-link: create-ui-dir
+ if test -e $(gtkpod_ui_dir)/$(plugin_name).ui; then \
+ # File already exists. Replacing ..." \
+ sudo rm -f $(gtkpod_ui_dir)/$(plugin_name).ui; \
+ fi; \
+ # Creating link for $(plugin_name).ui" \
+ sudo ln -s `pwd`/$(plugin_name).ui $(gtkpod_ui_dir)/$(plugin_name).ui;
+
+create-glade-link: create-glade-dir
+ if test -e `pwd`/$(plugin_name).glade; then \
+ if test -e $(gtkpod_glade_dir)/$(plugin_name).glade; then \
+ # File already exists. Replacing ..." \
+ sudo rm -f $(gtkpod_glade_dir)/$(plugin_name).glade; \
+ fi; \
+ # Creating link for $(plugin_name).glade" \
+ sudo ln -s `pwd`/$(plugin_name).glade
$(gtkpod_glade_dir)/$(plugin_name).glade; \
+ fi; \
+ if test -e `pwd`/$(plugin_name).xml; then \
+ if test -e $(gtkpod_glade_dir)/$(plugin_name).xml; then \
+ # File already exists. Replacing ..." \
+ sudo rm -f $(gtkpod_glade_dir)/$(plugin_name).xml; \
+ fi; \
+ # Creating link for $(plugin_name).xml" \
+ sudo ln -s `pwd`/$(plugin_name).xml
$(gtkpod_glade_dir)/$(plugin_name).xml; \
+ fi;
+
+# Copy icons
+copy-icons-dir: create-icons-dir
+ if test -e `pwd`/icons; then \
+ sudo cp -rf `pwd`/icons/* $(gtkpod_image_dir)/; \
+ sudo chmod -R 755 $(gtkpod_image_dir)/*; \
+ sudo find $(gtkpod_image_dir) -name 'Makefile*' -delete; \
+ fi;
+
+# Clean up the links and files created purely for dev testing
+clean-local: clean-plugin-files clean-ui-dir clean-glade-dir clean-image-dir
+
+clean-plugin-files:
+ rm -f ../$(plugin_lib) ../$(plugin_file)
+
+clean-ui-dir:
+ if test -h $(gtkpod_ui_dir)/$(plugin_name).ui; then \
+ # Symbolic link exists. Removing ..." \
+ sudo rm -f $(gtkpod_ui_dir)/$(plugin_name).ui; \
+ fi;
+
+clean-glade-dir:
+ if test -h $(gtkpod_glade_dir)/$(plugin_name).glade; then \
+ # Symbolic link exists. Removing ..." \
+ sudo rm -f $(gtkpod_glade_dir)/$(plugin_name).glade; \
+ fi;
+
+clean-image-dir:
+ if test -d $(gtkpod_image_dir); then \
+ sudo find $(gtkpod_image_dir) -name '$(plugin_name)*' -delete; \
+ fi;
+
+endif
+
+EXTRA_DIST = \
+ $(plugin_in_files) \
+ $(coverweb_plugin_DATA) \
+ $(coverweb_ui_DATA) \
+ $(coverweb_glade_DATA) \
+ $(coverweb_pixmaps_DATA)
diff --git a/plugins/coverweb/coverweb.c b/plugins/coverweb/coverweb.c
new file mode 100644
index 0000000..5c302da
--- /dev/null
+++ b/plugins/coverweb/coverweb.c
@@ -0,0 +1,197 @@
+/*
+ | Copyright (C) 2002-2010 Jorg Schuler <jcsjcs at users sourceforge net>
+ | Paul Richardson <phantom_sf at
users.sourceforge.net>
+ | Part of the gtkpod project.
+ |
+ | URL: http://www.gtkpod.org/
+ | URL: http://gtkpod.sourceforge.net/
+ |
+ | 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
+ |
+ | iTunes and iPod are trademarks of Apple
+ |
+ | This product is not supported/written/published by Apple!
+ |
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <webkit/webkit.h>
+#include "libgtkpod/prefs.h"
+#include "coverweb.h"
+
+static WebBrowser *browser;
+
+static void activate_uri_entry_cb(GtkWidget* entry, gpointer data) {
+ const gchar* uri = gtk_entry_get_text(GTK_ENTRY (entry));
+ g_assert (uri);
+ webkit_web_view_open(WEBKIT_WEB_VIEW(browser->webview), uri);
+}
+
+static void link_hover_cb(WebKitWebView* page, const gchar* title, const
gchar* link, gpointer data) {
+ /* underflow is allowed */
+ gtk_statusbar_pop(browser->statusbar, browser->status_context_id);
+ if (link)
+ gtk_statusbar_push(browser->statusbar, browser->status_context_id,
link);
+}
+
+static void progress_change_cb(WebKitWebView* page, gint progress, gpointer
data) {
+ browser->load_progress = progress;
+}
+
+static void load_commit_cb(WebKitWebView* page, WebKitWebFrame* frame,
gpointer data) {
+ const gchar* uri = webkit_web_frame_get_uri(frame);
+ if (uri)
+ gtk_entry_set_text(GTK_ENTRY (browser->uri_entry), uri);
+}
+
+static void go_back_cb(GtkWidget* widget, gpointer data) {
+ webkit_web_view_go_back(WEBKIT_WEB_VIEW(browser->webview));
+}
+
+static void go_forward_cb(GtkWidget* widget, gpointer data) {
+ webkit_web_view_go_forward(WEBKIT_WEB_VIEW(browser->webview));
+}
+
+static void bookmark_menu_item_cb(GtkMenuItem* mi, gpointer data) {
+ webkit_web_view_open(WEBKIT_WEB_VIEW(browser->webview),
gtk_menu_item_get_label(mi));
+}
+
+static void create_browser() {
+ browser->browser_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
(browser->browser_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+ browser->webview = webkit_web_view_new();
+ gtk_container_add(GTK_CONTAINER(browser->browser_window),
browser->webview);
+
+ g_signal_connect (G_OBJECT (browser->webview), "load-progress-changed",
G_CALLBACK (progress_change_cb), browser);
+ g_signal_connect (G_OBJECT (browser->webview), "load-committed",
G_CALLBACK (load_commit_cb), browser);
+ g_signal_connect (G_OBJECT (browser->webview), "hovering-over-link",
G_CALLBACK (link_hover_cb), browser);
+
+ WebKitWebSettings* settings = webkit_web_settings_new();
+ g_object_set(G_OBJECT(settings), "enable-private-browsing", FALSE, NULL);
+ g_object_set(G_OBJECT(settings), "enable-plugins", FALSE, NULL);
+ webkit_web_view_set_settings(WEBKIT_WEB_VIEW(browser->webview), settings);
+
+ webkit_web_view_open(WEBKIT_WEB_VIEW(browser->webview),
"http://images.google.com");
+}
+
+static void create_statusbar() {
+ browser->statusbar = GTK_STATUSBAR (gtk_statusbar_new ());
+ browser->status_context_id =
gtk_statusbar_get_context_id(browser->statusbar, "Link Hover");
+}
+
+void update_bookmark_menu() {
+ GList *bookmarks;
+ gint i;
+
+ if (browser->bookmark_menu) {
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(browser->bookmark_menu_item),
NULL);
+ browser->bookmark_menu = NULL;
+ }
+
+ browser->bookmark_menu = gtk_menu_new();
+ bookmarks = prefs_get_list("coverweb_bookmark_");
+ for (i = 0; i < g_list_length(bookmarks); ++i) {
+ gchar *bookmark = g_list_nth_data(bookmarks, i);
+ GtkWidget *bookitem = gtk_menu_item_new_with_label(bookmark);
+ gtk_menu_append(GTK_MENU(browser->bookmark_menu), bookitem);
+ g_signal_connect (G_OBJECT (bookitem), "activate",
G_CALLBACK(bookmark_menu_item_cb), (gpointer) browser);
+ gtk_widget_show(bookitem);
+ }
+
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM (browser->bookmark_menu_item),
browser->bookmark_menu);
+}
+
+static void create_menubar() {
+ browser->menubar = gtk_menu_bar_new();
+ browser->bookmark_menu_item =
gtk_image_menu_item_new_from_stock(GTK_STOCK_CDROM, NULL);
+ gtk_menu_item_set_label(GTK_MENU_ITEM(browser->bookmark_menu_item),
"Bookmarks");
+ update_bookmark_menu();
+ gtk_menu_shell_append(GTK_MENU_SHELL(browser->menubar),
browser->bookmark_menu_item);
+}
+
+static void create_toolbar() {
+ browser->toolbar = gtk_toolbar_new();
+ gtk_toolbar_set_orientation(GTK_TOOLBAR (browser->toolbar),
GTK_ORIENTATION_HORIZONTAL);
+ gtk_toolbar_set_style(GTK_TOOLBAR (browser->toolbar),
GTK_TOOLBAR_BOTH_HORIZ);
+
+ GtkToolItem* item;
+ /* the back button */
+ item = gtk_tool_button_new_from_stock(GTK_STOCK_GO_BACK);
+ g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (go_back_cb),
(gpointer) browser);
+ gtk_toolbar_insert(GTK_TOOLBAR (browser->toolbar), item, -1);
+
+ /* The forward button */
+ item = gtk_tool_button_new_from_stock(GTK_STOCK_GO_FORWARD);
+ g_signal_connect (G_OBJECT (item), "clicked", G_CALLBACK (go_forward_cb),
(gpointer) browser);
+ gtk_toolbar_insert(GTK_TOOLBAR (browser->toolbar), item, -1);
+
+ /* The URL entry */
+ item = gtk_tool_item_new();
+ gtk_tool_item_set_expand(item, TRUE);
+
+ browser->uri_entry = gtk_entry_new();
+ gtk_container_add(GTK_CONTAINER (item), browser->uri_entry);
+ g_signal_connect (G_OBJECT (browser->uri_entry), "activate", G_CALLBACK
(activate_uri_entry_cb), (gpointer)browser);
+ gtk_toolbar_insert(GTK_TOOLBAR (browser->toolbar), item, -1);
+
+ /* The go button */
+ item = gtk_tool_button_new_from_stock(GTK_STOCK_OK);
+ g_signal_connect_swapped (G_OBJECT (item), "clicked", G_CALLBACK
(activate_uri_entry_cb), (gpointer)browser->uri_entry);
+ gtk_toolbar_insert(GTK_TOOLBAR (browser->toolbar), item, -1);
+}
+
+/**
+ *
+ * init_web_browser
+ *
+ * Initialise the webkit browser
+ *
+ * @parent: Widget to house the browser
+ */
+WebBrowser *init_web_browser(GtkWidget *parent) {
+ browser = g_new0(WebBrowser, 1);
+
+ create_menubar();
+ create_toolbar();
+ create_browser();
+ create_statusbar();
+
+ GtkWidget* vbox = gtk_vbox_new(FALSE, 0);
+ gtk_box_pack_start(GTK_BOX (vbox), browser->menubar, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX (vbox), browser->toolbar, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX (vbox), browser->browser_window, TRUE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX (vbox), GTK_WIDGET(browser->statusbar), FALSE,
FALSE, 0);
+
+ if (GTK_IS_SCROLLED_WINDOW(parent))
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(parent),
vbox);
+ else
+ gtk_container_add(GTK_CONTAINER (parent), vbox);
+
+ return browser;
+}
+
+/**
+ *
+ * destroy_cover_web
+ *
+ * destroy the web browser and all associated items.
+ */
+void destroy_cover_web() {
+
+}
diff --git a/plugins/coverweb/coverweb.glade b/plugins/coverweb/coverweb.glade
new file mode 100644
index 0000000..d784846
--- /dev/null
+++ b/plugins/coverweb/coverweb.glade
@@ -0,0 +1,133 @@
+<?xml version="1.0"?>
+<glade-interface>
+ <!-- interface-requires gtk+ 2.6 -->
+ <!-- interface-naming-policy toplevel-contextual -->
+ <widget class="GtkWindow" id="prefs_window">
+ <child>
+ <widget class="GtkNotebook" id="coverweb_settings_notebook">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <widget class="GtkVBox" id="vbox5">
+ <property name="visible">True</property>
+ <property name="border_width">12</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">18</property>
+ <child>
+ <widget class="GtkFrame" id="frame4">
+ <property name="visible">True</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <widget class="GtkAlignment" id="alignment14">
+ <property name="visible">True</property>
+ <property name="xalign">0.43999999761581421</property>
+ <property name="top_padding">6</property>
+ <property name="left_padding">12</property>
+ <child>
+ <widget class="GtkHBox" id="hbox3">
+ <property name="height_request">140</property>
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkScrolledWindow"
id="scrolledwindow1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property
name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <widget class="GtkTreeView" id="bookmarks_view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK |
GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property
name="headers_visible">False</property>
+ <property name="rules_hint">True</property>
+ </widget>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkVButtonBox" id="vbuttonbox2">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <property name="layout_style">spread</property>
+ <child>
+ <widget class="GtkButton" id="bookmark_add">
+ <property name="label">gtk-add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked"
handler="on_bookmark_add_clicked"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="bookmark_remove">
+ <property name="label">gtk-remove</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked"
handler="on_bookmark_remove_clicked"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="xalign">0.43999999761581421</property>
+ <property name="label"
translatable="yes"><b>Bookmarks</b></property>
+ <property name="use_markup">True</property>
+ </widget>
+ <packing>
+ <property name="type">label_item</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkLabel" id="display_page_label">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Cover Browser</property>
+ </widget>
+ <packing>
+ <property name="tab_fill">False</property>
+ <property name="type">tab</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
+</glade-interface>
diff --git a/plugins/coverweb/coverweb.h b/plugins/coverweb/coverweb.h
new file mode 100644
index 0000000..eaa7a6d
--- /dev/null
+++ b/plugins/coverweb/coverweb.h
@@ -0,0 +1,68 @@
+/*
+ | Copyright (C) 2002-2010 Jorg Schuler <jcsjcs at users sourceforge net>
+ | Paul Richardson <phantom_sf at
users.sourceforge.net>
+ | Part of the gtkpod project.
+ |
+ | URL: http://www.gtkpod.org/
+ | URL: http://gtkpod.sourceforge.net/
+ |
+ | 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
+ |
+ | iTunes and iPod are trademarks of Apple
+ |
+ | This product is not supported/written/published by Apple!
+ |
+ */
+
+#ifndef COVERWEB_H_
+#define COVERWEB_H_
+
+typedef struct {
+ GtkWidget *window;
+ GtkWidget *menubar;
+ GtkWidget *bookmark_menu_item;
+ GtkWidget *bookmark_menu;
+ GtkWidget *toolbar;
+ GtkWidget *browser_window;
+ GtkWidget *webview;
+
+ GtkStatusbar *statusbar;
+ guint status_context_id;
+ gint load_progress;
+ GtkWidget* uri_entry;
+
+} WebBrowser;
+
+/**
+ *
+ * init_web_browser
+ *
+ * Initialise the webkit browser
+ *
+ * @parent: Widget to house the browser
+ */
+WebBrowser *init_web_browser(GtkWidget *parent);
+
+/**
+ *
+ * destroy_cover_web
+ *
+ * destroy the web browser and all associated items.
+ */
+void destroy_cover_web();
+
+void update_bookmark_menu();
+
+#endif /* COVERWEB_H_ */
diff --git a/plugins/coverweb/coverweb.plugin b/plugins/coverweb/coverweb.plugin
new file mode 100644
index 0000000..f68b703
--- /dev/null
+++ b/plugins/coverweb/coverweb.plugin
@@ -0,0 +1,4 @@
+[Anjuta Plugin]
+Location=coverweb:CoverWebPlugin
+Name=Cover Web Plugin
+Description=Web Browser for downloading Cover Artwork
diff --git a/plugins/coverweb/coverweb.ui b/plugins/coverweb/coverweb.ui
new file mode 100644
index 0000000..b141558
--- /dev/null
+++ b/plugins/coverweb/coverweb.ui
@@ -0,0 +1,7 @@
+<!--*- xml -*-->
+<ui>
+ <menubar name="MenuMain">
+ </menubar>
+ <toolbar name="ToolbarMain">
+ </toolbar>
+</ui>
diff --git a/plugins/coverweb/coverweb_preferences.c
b/plugins/coverweb/coverweb_preferences.c
new file mode 100644
index 0000000..367d8f0
--- /dev/null
+++ b/plugins/coverweb/coverweb_preferences.c
@@ -0,0 +1,182 @@
+/*
+ | Copyright (C) 2002-2010 Jorg Schuler <jcsjcs at users sourceforge net>
+ | Paul Richardson <phantom_sf at
users.sourceforge.net>
+ | Part of the gtkpod project.
+ |
+ | URL: http://www.gtkpod.org/
+ | URL: http://gtkpod.sourceforge.net/
+ |
+ | 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
+ |
+ | iTunes and iPod are trademarks of Apple
+ |
+ | This product is not supported/written/published by Apple!
+ |
+ */
+
+#include <gtk/gtk.h>
+#include <glade/glade.h>
+#include "libgtkpod/misc.h"
+#include "libgtkpod/prefs.h"
+#include "libgtkpod/gtkpod_app_iface.h"
+#include "plugin.h"
+#include "coverweb.h"
+#include "coverweb_preferences.h"
+
+static GtkWidget *bookmarks_view = NULL;
+
+static void setup_bookmarks_tree (GtkTreeView *treeview, gboolean list_visible)
+{
+ GtkListStore *store;
+ GtkTreeIter iter;
+ GtkTreeViewColumn *column;
+ GtkCellRenderer *renderer;
+ gint i;
+
+ /* Delete any existing columns first */
+ GList *columns = gtk_tree_view_get_columns(treeview);
+ for (i = 0; i < g_list_length(columns); ++i) {
+ column = gtk_tree_view_get_column (treeview, 0);
+ gtk_tree_view_remove_column (treeview, column);
+ }
+ g_list_free(columns);
+
+ store = gtk_list_store_new (1, G_TYPE_STRING);
+ column = gtk_tree_view_column_new ();
+ renderer = gtk_cell_renderer_text_new ();
+
+ gtk_tree_view_column_pack_start (column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes (column, renderer, "text", 0, NULL);
+ gtk_tree_view_append_column (treeview, column);
+ gtk_tree_view_set_model (treeview, GTK_TREE_MODEL (store));
+ g_object_unref (G_OBJECT (store));
+
+ GList *bookmarks = prefs_get_list("coverweb_bookmark_");
+ for (i = 0; i < g_list_length(bookmarks); i++) {
+ gchar *bmark = g_list_nth_data(bookmarks, i);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, bmark, -1);
+ }
+}
+
+static gboolean tree_get_current_iter (GtkTreeView *view, GtkTreeIter *iter)
+{
+ GtkTreeModel *model = gtk_tree_view_get_model (view);
+ GtkTreePath *path;
+
+ gtk_tree_view_get_cursor (view, &path, NULL);
+
+ if (!path)
+ return FALSE;
+
+ gtk_tree_model_get_iter (model, iter, path);
+ gtk_tree_path_free (path);
+
+ return TRUE;
+}
+
+static void save_bookmarks_preferences() {
+ g_return_if_fail(bookmarks_view);
+ GtkTreeModel *model;
+ GtkListStore *store;
+ GtkTreeIter iter;
+ gint row = 0;
+ gboolean valid;
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW(bookmarks_view));
+ store = GTK_LIST_STORE(model);
+
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+ while (valid) {
+ /* Walk through the list, reading each row */
+ gchar *bmark;
+
+ gtk_tree_model_get (model, &iter,
+ 0, &bmark,
+ -1);
+
+ prefs_set_string_index("coverweb_bookmark_", row, bmark);
+ g_free (bmark);
+ row++;
+ valid = gtk_tree_model_iter_next (model, &iter);
+ }
+ prefs_set_string_index("coverweb_bookmark_", row, LIST_END_MARKER);
+
+ update_bookmark_menu();
+}
+
+/*
+ glade callback
+*/
+G_MODULE_EXPORT void on_bookmark_add_clicked (GtkButton *sender, gpointer e)
+{
+ g_return_if_fail(bookmarks_view);
+
+ gchar *bookmark;
+ GtkTreeView *view = GTK_TREE_VIEW (bookmarks_view);
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ bookmark
+ = get_user_string(_("Bookmark Url"), _("Please enter the full
url of the bookmark"), NULL, NULL, NULL, GTK_STOCK_ADD);
+
+ if (!bookmark)
+ return;
+
+ model = gtk_tree_view_get_model (view);
+ gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+ gtk_list_store_set(GTK_LIST_STORE (model), &iter,
+ 0, bookmark, -1);
+
+ save_bookmarks_preferences();
+}
+
+/*
+ glade callback
+*/
+G_MODULE_EXPORT void on_bookmark_remove_clicked (GtkButton *sender, gpointer e)
+{
+ g_return_if_fail(bookmarks_view);
+
+ gchar *bmark;
+ GtkTreeView *view = GTK_TREE_VIEW (bookmarks_view);
+ GtkTreeModel *model = gtk_tree_view_get_model (view);
+ GtkTreeIter iter;
+
+ if(!tree_get_current_iter (view, &iter) || !gtk_list_store_iter_is_valid
(GTK_LIST_STORE (model), &iter))
+ return;
+
+ gtk_tree_model_get (model, &iter, 0, &bmark, -1);
+ gtk_list_store_remove (GTK_LIST_STORE (model), &iter);
+
+ save_bookmarks_preferences();
+}
+
+GtkWidget *init_coverweb_preferences() {
+ GtkWidget *notebook;
+ GladeXML *pref_xml;
+
+ pref_xml = gtkpod_xml_new(GLADE_FILE, "coverweb_settings_notebook");
+ notebook = gtkpod_xml_get_widget(pref_xml, "coverweb_settings_notebook");
+ bookmarks_view = gtkpod_xml_get_widget(pref_xml, "bookmarks_view");
+
+ gtk_widget_ref(notebook);
+
+ setup_bookmarks_tree (GTK_TREE_VIEW(bookmarks_view), TRUE);
+
+ glade_xml_signal_autoconnect(pref_xml);
+ return notebook;
+}
diff --git a/plugins/coverweb/coverweb_preferences.h
b/plugins/coverweb/coverweb_preferences.h
new file mode 100644
index 0000000..2b1d05e
--- /dev/null
+++ b/plugins/coverweb/coverweb_preferences.h
@@ -0,0 +1,34 @@
+/*
+ | Copyright (C) 2002-2010 Jorg Schuler <jcsjcs at users sourceforge net>
+ | Paul Richardson <phantom_sf at
users.sourceforge.net>
+ | Part of the gtkpod project.
+ |
+ | URL: http://www.gtkpod.org/
+ | URL: http://gtkpod.sourceforge.net/
+ |
+ | 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
+ |
+ | iTunes and iPod are trademarks of Apple
+ |
+ | This product is not supported/written/published by Apple!
+ |
+ */
+
+#ifndef COVER_WEB_PREFERENCES_H_
+#define COVER_WEB_PREFERENCES_H_
+
+GtkWidget *init_coverweb_preferences();
+
+#endif /* COVER_WEB_PREFERENCES_H_ */
diff --git a/plugins/coverweb/icons/Makefile.am
b/plugins/coverweb/icons/Makefile.am
new file mode 100644
index 0000000..60bfa77
--- /dev/null
+++ b/plugins/coverweb/icons/Makefile.am
@@ -0,0 +1,4 @@
+coverweb_icondir = $(pkgdatadir)/icons
+coverweb_icon_DATA = internet-icon.png
+
+EXTRA_DIST = $(cover_display_icon_DATA)
\ No newline at end of file
diff --git a/plugins/coverweb/icons/internet-icon.png
b/plugins/coverweb/icons/internet-icon.png
new file mode 100644
index 0000000..f9ce002
Binary files /dev/null and b/plugins/coverweb/icons/internet-icon.png differ
diff --git a/plugins/coverweb/plugin.c b/plugins/coverweb/plugin.c
new file mode 100644
index 0000000..629b367
--- /dev/null
+++ b/plugins/coverweb/plugin.c
@@ -0,0 +1,167 @@
+/*
+ | Copyright (C) 2002-2010 Jorg Schuler <jcsjcs at users sourceforge net>
+ | Paul Richardson <phantom_sf at
users.sourceforge.net>
+ | Part of the gtkpod project.
+ |
+ | URL: http://www.gtkpod.org/
+ | URL: http://gtkpod.sourceforge.net/
+ |
+ | 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
+ |
+ | iTunes and iPod are trademarks of Apple
+ |
+ | This product is not supported/written/published by Apple!
+ |
+ | $Id$
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <glib.h>
+#include <libanjuta/anjuta-utils.h>
+#include <libanjuta/interfaces/ianjuta-preferences.h>
+#include "libgtkpod/gtkpod_app_iface.h"
+#include "libgtkpod/prefs.h"
+#include "plugin.h"
+#include "coverweb.h"
+#include "coverweb_preferences.h"
+
+#define TAB_NAME "Cover Web"
+
+/* Parent class. Part of standard class definition */
+static gpointer parent_class;
+
+static GtkActionEntry cover_actions[] =
+ {
+ };
+
+static void set_default_preferences() {
+ if (!prefs_get_string_value_index("coverweb_bookmark_", 0, NULL))
+ {
+ prefs_set_string_index("coverweb_bookmark_", 0,
"http://images.google.com");
+ prefs_set_string_index("coverweb_bookmark_", 1,
"http://www.allcdcovers.com");
+ prefs_set_string_index("coverweb_bookmark_", 2, LIST_END_MARKER);
+ }
+}
+
+static gboolean activate_plugin(AnjutaPlugin *plugin) {
+ AnjutaUI *ui;
+ CoverWebPlugin *cover_web_plugin;
+ GtkActionGroup* action_group;
+
+ cover_web_plugin = (CoverWebPlugin*) plugin;
+ ui = anjuta_shell_get_ui(plugin->shell, NULL);
+
+ /* Add our cover_actions */
+ action_group
+ = anjuta_ui_add_action_group_entries(ui, "ActionGroupCoverWeb",
_("Cover Display"), cover_actions, G_N_ELEMENTS (cover_actions),
GETTEXT_PACKAGE, TRUE, plugin);
+ cover_web_plugin->action_group = action_group;
+
+ /* Merge UI */
+ cover_web_plugin->uiid = anjuta_ui_merge(ui, UI_FILE);
+
+ /* Set preferences */
+ set_default_preferences();
+
+ /* Add widget in Shell. Any number of widgets can be added */
+ cover_web_plugin->coverweb_window = gtk_scrolled_window_new(NULL, NULL);
+ gtk_widget_ref(cover_web_plugin->coverweb_window);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW
(cover_web_plugin->coverweb_window), GTK_POLICY_NEVER, GTK_POLICY_NEVER);
+ gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW
(cover_web_plugin->coverweb_window), GTK_SHADOW_IN);
+
+ init_web_browser(cover_web_plugin->coverweb_window);
+ gtk_widget_show_all(cover_web_plugin->coverweb_window);
+ anjuta_shell_add_widget(plugin->shell, cover_web_plugin->coverweb_window,
"CoverWebPlugin", "Cover Browser", NULL, ANJUTA_SHELL_PLACEMENT_CENTER, NULL);
+
+ return TRUE; /* FALSE if activation failed */
+}
+
+static gboolean deactivate_plugin(AnjutaPlugin *plugin) {
+ AnjutaUI *ui;
+ CoverWebPlugin *cover_web_plugin;
+
+ cover_web_plugin = (CoverWebPlugin*) plugin;
+ ui = anjuta_shell_get_ui(plugin->shell, NULL);
+
+ /* Remove widgets from Shell */
+ anjuta_shell_remove_widget(plugin->shell,
cover_web_plugin->coverweb_window, NULL);
+
+ /* Destroy the browser */
+ destroy_cover_web();
+
+ /* Unmerge UI */
+ anjuta_ui_unmerge(ui, cover_web_plugin->uiid);
+
+ /* Remove Action groups */
+ anjuta_ui_remove_action_group(ui, cover_web_plugin->action_group);
+
+ /* FALSE if plugin doesn't want to deactivate */
+ return TRUE;
+}
+
+static void cover_web_plugin_instance_init(GObject *obj) {
+ CoverWebPlugin *plugin = (CoverWebPlugin*) obj;
+ plugin->uiid = 0;
+ plugin->coverweb_window = NULL;
+ plugin->action_group = NULL;
+}
+
+static void cover_web_plugin_class_init(GObjectClass *klass) {
+ AnjutaPluginClass *plugin_class = ANJUTA_PLUGIN_CLASS (klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+
+ plugin_class->activate = activate_plugin;
+ plugin_class->deactivate = deactivate_plugin;
+}
+
+static void ipreferences_merge(IAnjutaPreferences* ipref, AnjutaPreferences*
prefs, GError** e) {
+ gchar *file;
+ GdkPixbuf *pixbuf;
+ GdkPixbuf *scaled;
+
+ CoverWebPlugin* plugin = COVER_WEB_PLUGIN(ipref);
+ plugin->prefs = init_coverweb_preferences();
+ if (plugin->prefs == NULL)
+ return;
+
+ file = g_build_filename(GTKPOD_IMAGE_DIR, "internet-icon.png", NULL);
+ pixbuf = gdk_pixbuf_new_from_file(file, NULL);
+ scaled = gdk_pixbuf_scale_simple(pixbuf, 48, 48, GDK_INTERP_BILINEAR);
+ anjuta_preferences_dialog_add_page(ANJUTA_PREFERENCES_DIALOG
(anjuta_preferences_get_dialog (prefs)), "gtkpod-coverweb-settings",
_(TAB_NAME), scaled, plugin->prefs);
+ g_free(file);
+ g_object_unref(pixbuf);
+ g_object_unref(scaled);
+}
+
+static void ipreferences_unmerge(IAnjutaPreferences* ipref, AnjutaPreferences*
prefs, GError** e) {
+ anjuta_preferences_remove_page(prefs, _(TAB_NAME));
+ CoverWebPlugin* plugin = COVER_WEB_PLUGIN(ipref);
+ gtk_widget_destroy(plugin->prefs);
+}
+
+static void
+ipreferences_iface_init(IAnjutaPreferencesIface* iface)
+{
+ iface->merge = ipreferences_merge;
+ iface->unmerge = ipreferences_unmerge;
+}
+
+ANJUTA_PLUGIN_BEGIN (CoverWebPlugin, cover_web_plugin);
+ANJUTA_PLUGIN_ADD_INTERFACE(ipreferences, IANJUTA_TYPE_PREFERENCES);
+ANJUTA_PLUGIN_END;
+
+ANJUTA_SIMPLE_PLUGIN (CoverWebPlugin, cover_web_plugin);
diff --git a/plugins/coverweb/plugin.h b/plugins/coverweb/plugin.h
new file mode 100644
index 0000000..936eef7
--- /dev/null
+++ b/plugins/coverweb/plugin.h
@@ -0,0 +1,65 @@
+/*
+| Copyright (C) 2002-2010 Jorg Schuler <jcsjcs at users sourceforge net>
+| Paul Richardson <phantom_sf at
users.sourceforge.net>
+| Part of the gtkpod project.
+|
+| URL: http://www.gtkpod.org/
+| URL: http://gtkpod.sourceforge.net/
+|
+| 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
+|
+| iTunes and iPod are trademarks of Apple
+|
+| This product is not supported/written/published by Apple!
+|
+| $Id$
+*/
+
+#ifndef PLUGIN_H_
+#define PLUGIN_H_
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <libanjuta/anjuta-plugin.h>
+
+#define UI_FILE GTKPOD_UI_DIR"/coverweb.ui"
+#define GLADE_FILE GTKPOD_GLADE_DIR"/coverweb.glade"
+
+extern GType cover_web_plugin_get_type (GTypeModule *module);
+#define COVER_WEB_TYPE_PLUGIN (cover_web_plugin_get_type (NULL))
+#define COVER_WEB_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o),
COVER_WEB_TYPE_PLUGIN, CoverWebPlugin))
+#define COVER_WEB_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k),
COVER_WEB_TYPE_PLUGIN, CoverWebPluginClass))
+#define COVER_WEB_IS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o),
COVER_WEB_TYPE_PLUGIN))
+#define COVER_WEB_IS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k),
COVER_WEB_TYPE_PLUGIN))
+#define COVER_WEB_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o),
COVER_WEB_TYPE_PLUGIN, CoverWebPluginClass))
+
+typedef struct _CoverWebPlugin CoverWebPlugin;
+typedef struct _CoverWebPluginClass CoverWebPluginClass;
+
+struct _CoverWebPlugin {
+ AnjutaPlugin parent;
+ GtkWidget *coverweb_window;
+ gint uiid;
+ GtkActionGroup *action_group;
+ GtkWidget *prefs;
+};
+
+struct _CoverWebPluginClass {
+ AnjutaPluginClass parent_class;
+};
+
+#endif /* PLUGIN_H_ */
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2