Add source list window
authorPhilipp Zabel <philipp.zabel@gmail.com>
Thu, 19 Nov 2009 13:47:38 +0000 (14:47 +0100)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Thu, 19 Nov 2009 16:21:59 +0000 (17:21 +0100)
Replaces the movie list window as primary window. A configuration option
will be provided to make Cinaest switch to the movie list window on
startup.

Makefile.am
po/POTFILES.in
src/main.vala
src/source-list-view.vala
src/source-list-window.vala [new file with mode: 0644]

index 69d45c2..99d866a 100644 (file)
@@ -45,7 +45,8 @@ cinaest_SOURCES = \
        src/poster/movie-poster-factory.c \
        src/settings-dialog.c \
        src/source-dialog.c \
-       src/source-list-view.c
+       src/source-list-view.c \
+       src/source-list-window.c
 
 cinaest_VALASOURCES = \
         src/main.vala \
@@ -65,7 +66,8 @@ cinaest_VALASOURCES = \
        src/poster/movie-poster-factory.vala \
        src/settings-dialog.vala \
        src/source-dialog.vala \
-       src/source-list-view.vala
+       src/source-list-view.vala \
+       src/source-list-window.vala
 
 src/main.c: ${cinaest_VALASOURCES}
        ${VALAC} -C ${cinaest_VALASOURCES} ${cinaest_VALAFLAGS}
index b5134d7..8176160 100644 (file)
@@ -8,3 +8,4 @@ src/plugins/imdb-plugin.vala
 src/plugins/google-plugin.vala
 src/settings-dialog.vala
 src/source-dialog.vala
+src/source-list-window.vala
index a833fc3..b681fc2 100644 (file)
 using Hildon;
 
 public class CinaestProgram : Hildon.Program {
-       MovieListWindow window;
+       SourceListWindow window;
        public static List<Plugin> plugins;
 
        construct {
                Environment.set_application_name ("Cinæst");
 
-               window = new MovieListWindow ();
+               window = new SourceListWindow ();
                window.destroy.connect (Gtk.main_quit);
 
                add_window (window);
@@ -60,11 +60,8 @@ public class CinaestProgram : Hildon.Program {
        }
 
        public void run () {
-               // FIXME - always start with the first plugin's first source for now
-               if (plugins != null) {
-                       var plugin = plugins.first ().data;
-                       if (plugin != null)
-                               window.source = plugin.get_sources ().first ().data;
+               foreach (Plugin plugin in plugins) {
+                       window.add_sources (plugin.get_sources ());
                }
                Gtk.main ();
        }
index 5806dd1..6ef3974 100644 (file)
@@ -21,17 +21,14 @@ using Hildon;
 
 public class SourceListView : PannableArea {
        TreeView tree;
+       ListStore store;
 
        public signal void source_activated (MovieSource source);
 
        public SourceListView (List<MovieSource> list) {
                // Source list
-               var store = new ListStore (3, typeof (string), typeof (string), typeof (MovieSource));
-               foreach (MovieSource source in list) {
-                       TreeIter iter;
-                       store.append (out iter);
-                       store.set (iter, 0, source.get_name (), 1, source.get_description (), 2, source);
-               }
+               store = new ListStore (3, typeof (string), typeof (string), typeof (MovieSource));
+               add_sources (list);
 
                // Tree View
                tree = (TreeView) Hildon.gtk_tree_view_new_with_model (UIMode.NORMAL, store);
@@ -92,6 +89,14 @@ public class SourceListView : PannableArea {
                tree.row_activated.connect (on_row_activated);
        }
 
+       public void add_sources (List<MovieSource> list) {
+               foreach (MovieSource source in list) {
+                       TreeIter iter;
+                       store.append (out iter);
+                       store.set (iter, 0, source.get_name (), 1, source.get_description (), 2, source);
+               }
+       }
+
        private void on_row_activated (TreeView tree, TreePath path_, TreeViewColumn column) {
                TreePath path = path_.copy (); // FIXME - calling model.get_iter with path_ directly causes a C qualifier warning
                TreeModel model = tree.model;
diff --git a/src/source-list-window.vala b/src/source-list-window.vala
new file mode 100644 (file)
index 0000000..9736fb8
--- /dev/null
@@ -0,0 +1,48 @@
+/* This file is part of Cinaest.
+ *
+ * Copyright (C) 2009 Philipp Zabel
+ *
+ * Cinaest 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 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Cinaest 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 Cinaest. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+using Gtk;
+using Hildon;
+
+public class SourceListWindow : StackableWindow {
+       SourceListView source_list;
+
+       construct {
+               set_title ("Cinæst");
+
+               var sources = new List<MovieSource> ();
+               source_list = new SourceListView (sources);
+
+               var hbox = new HBox (true, 0);
+               hbox.pack_start (source_list, true, true, MARGIN_DOUBLE);
+               add (hbox);
+
+               source_list.source_activated.connect (on_source_activated);
+
+               show_all ();
+       }
+
+       public void add_sources (List<MovieSource> list) {
+               source_list.add_sources (list);
+       }
+
+       private void on_source_activated (MovieSource source) {
+               var window = new MovieListWindow ();
+               window.source = source;
+       }
+}