From 4d7936832ef3c56a6b481287f09183f978c5eefb Mon Sep 17 00:00:00 2001 From: Philipp Zabel Date: Thu, 12 Nov 2009 13:18:59 +0100 Subject: [PATCH] Add GConf option to control poster downloads --- Makefile.am | 6 +++--- configure.ac | 4 ++++ src/poster/movie-poster-factory.vala | 16 ++++++++++++++-- src/settings-dialog.vala | 12 ++++++++++++ 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/Makefile.am b/Makefile.am index 59b6ec1..054d7f2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -62,10 +62,10 @@ ${cinaest_SOURCES}: ${cinaest_VALASOURCES} ${VALAC} -C ${cinaest_VALASOURCES} ${cinaest_VALAFLAGS} cinaest_VALAFLAGS = --vapidir ./vapi --pkg config \ - --pkg dbus-glib-1 --pkg hildon-1 --pkg libosso --pkg gmodule-2.0 -cinaest_CFLAGS = ${DBUS_CFLAGS} ${HILDON_CFLAGS} ${OSSO_CFLAGS} ${GMODULE_CFLAGS} \ + --pkg dbus-glib-1 --pkg gconf-2.0 --pkg hildon-1 --pkg libosso --pkg gmodule-2.0 +cinaest_CFLAGS = ${DBUS_CFLAGS} ${GCONF_CFLAGS} ${HILDON_CFLAGS} ${OSSO_CFLAGS} ${GMODULE_CFLAGS} \ -DGETTEXT_PACKAGE=\"@GETTEXT_PACKAGE@\" -cinaest_LDADD = ${DBUS_LIBS} ${HILDON_LIBS} ${OSSO_LIBS} ${GMODULE_LIBS} +cinaest_LDADD = ${DBUS_LIBS} ${GCONF_LIBS} ${HILDON_LIBS} ${OSSO_LIBS} ${GMODULE_LIBS} libgoogle_plugin_la_SOURCES = \ src/plugins/google-plugin.c \ diff --git a/configure.ac b/configure.ac index df89570..bf969a4 100644 --- a/configure.ac +++ b/configure.ac @@ -20,6 +20,10 @@ PKG_CHECK_MODULES(GMODULE, gmodule-2.0 >= 2.20.3) AC_SUBST(GMODULE_LIBS) AC_SUBST(GMODULE_CFLAGS) +PKG_CHECK_MODULES(GCONF, gconf-2.0 >= 2.16.0) +AC_SUBST(GCONF_LIBS) +AC_SUBST(GCONF_CFLAGS) + PKG_CHECK_MODULES(HILDON, hildon-1 >= 2.2.0) AC_SUBST(HILDON_LIBS) AC_SUBST(HILDON_CFLAGS) diff --git a/src/poster/movie-poster-factory.vala b/src/poster/movie-poster-factory.vala index e3224ba..d7cff95 100644 --- a/src/poster/movie-poster-factory.vala +++ b/src/poster/movie-poster-factory.vala @@ -8,6 +8,9 @@ namespace MoviePoster { private static Factory the_factory = null; private List requests; dynamic DBus.Object server; + internal bool download_posters; + private GConf.Client gc; + private uint cxnid; construct { try { @@ -19,6 +22,15 @@ namespace MoviePoster { } catch (Error e) { warning ("Couldn't connect to Google image downloader: %s\n", e.message); } + gc = GConf.Client.get_default (); + + download_posters = gc.get_bool ("/apps/cinaest/download_posters"); + gc.add_dir ("/apps/cinaest", GConf.ClientPreloadType.ONELEVEL); + cxnid = gc.notify_add ("/apps/cinaest/download_posters", on_download_posters_changed); + } + + private static void on_download_posters_changed (GConf.Client gc, uint cxnid, GConf.Entry entry) { + the_factory.download_posters = entry.get_value ().get_bool (); } public static Factory get_instance () { @@ -34,7 +46,7 @@ namespace MoviePoster { // TODO: make this async? var pixbuf = new Gdk.Pixbuf.from_file_at_size (path, 268, 424); callback (pixbuf, movie); - } else if (server != null) { + } else if (server != null && download_posters) { var request = new Request (); request.handle = server.fetch (movie.title.down (), movie.year.to_string (), "movie"); @@ -54,7 +66,7 @@ namespace MoviePoster { // TODO: make this async? var pixbuf = new Gdk.Pixbuf.from_file_at_size (path, (int) width, (int) height); callback (pixbuf, movie); - } else if (server != null) { + } else if (server != null && download_posters) { var request = new Request (); request.handle = server.fetch_thumbnail (movie.title.down (), movie.year.to_string (), "movie"); diff --git a/src/settings-dialog.vala b/src/settings-dialog.vala index 26aebf3..ec4368c 100644 --- a/src/settings-dialog.vala +++ b/src/settings-dialog.vala @@ -22,6 +22,7 @@ using Gtk; class SettingsDialog : Gtk.Dialog { List buttons; Gtk.Window movie_list_window; + private Hildon.CheckButton download_posters; public SettingsDialog (Gtk.Window window) { movie_list_window = window; @@ -45,6 +46,10 @@ class SettingsDialog : Gtk.Dialog { vbox = (VBox) get_content_area (); } + download_posters = new Hildon.CheckButton (SizeType.FINGER_HEIGHT); + download_posters.set_label (_("Download movie posters")); + vbox.pack_start (download_posters, true, true, 0); + HBox hbox; int i = 0; buttons = new List (); @@ -66,6 +71,8 @@ class SettingsDialog : Gtk.Dialog { buttons.append (button); } + + add_button (_("Done"), ResponseType.ACCEPT); } public void on_plugin_settings (Gtk.Button button) { @@ -76,6 +83,9 @@ class SettingsDialog : Gtk.Dialog { public new int run () { int res = 0; + var gc = GConf.Client.get_default (); + + download_posters.set_active (gc.get_bool ("/apps/cinaest/download_posters")); show_all (); @@ -87,6 +97,8 @@ class SettingsDialog : Gtk.Dialog { } } while (res >= 0); + if (res == ResponseType.ACCEPT) + gc.set_bool ("/apps/cinaest/download_posters", download_posters.get_active ()); destroy (); return res; -- 1.7.9.5