Source list view: update style, get color from parent window style
authorPhilipp Zabel <philipp.zabel@gmail.com>
Thu, 8 Jul 2010 19:39:15 +0000 (21:39 +0200)
committerPhilipp Zabel <philipp.zabel@gmail.com>
Wed, 14 Jul 2010 21:34:08 +0000 (23:34 +0200)
src/plugins/catalog-plugin.vala
src/source-dialog.vala
src/source-list-view.vala
src/source-list-window.vala

index 3616e34..831fb3e 100644 (file)
@@ -90,7 +90,7 @@ class CatalogPlugin : Plugin {
                        }
                }
 
-               var source_list = new SourceListView (available_sources, true);
+               var source_list = new SourceListView (available_sources, true, window);
 
                var content = (VBox) dialog.get_content_area ();
                content.pack_start (source_list, true, true, 0);
@@ -202,7 +202,7 @@ class CatalogPlugin : Plugin {
                dialog.set_transient_for (window);
                dialog.set_title (_("Select active movie lists"));
 
-               var source_list = new SourceListView (sources, false);
+               var source_list = new SourceListView (sources, false, window);
                source_list.set_hildon_ui_mode (UIMode.EDIT);
 
                var selection = source_list.get_selection ();
index 35876c7..4e4b012 100644 (file)
@@ -36,7 +36,7 @@ class SourceDialog : Gtk.Dialog {
                        }
                }
 
-               var source_list = new SourceListView (sources, true);
+               var source_list = new SourceListView (sources, true, window);
                content.pack_start (source_list, true, true, 0);
 
                source_list.source_activated.connect (on_source_activated);
index 64188be..df492e4 100644 (file)
@@ -27,7 +27,7 @@ public class SourceListView : PannableArea {
 
        public signal void source_activated (MovieSource source);
 
-       public SourceListView (List<MovieSource> list, bool _filtered) {
+       public SourceListView (List<MovieSource> list, bool _filtered, Gtk.Window window) {
                filtered = _filtered;
 
                // Source list
@@ -65,28 +65,27 @@ public class SourceListView : PannableArea {
                var vbox_renderer = new CellRendererVBox ();
 
                var renderer = new CellRendererText ();
+               renderer.yalign = 1.0f;
                vbox_renderer.append (renderer, true);
                vbox_renderer.set_data ("name", renderer);
 
                // Add description
                renderer = new CellRendererText ();
-               renderer.set ("ellipsize", Pango.EllipsizeMode.END);
+               renderer.yalign = 0;
+               renderer.ellipsize = Pango.EllipsizeMode.END;
 
                Pango.AttrList attr_list = new Pango.AttrList ();
-               var style = Gtk.rc_get_style_by_paths (this.get_settings (), "SmallSystemFont", null, typeof (void));
+               var style = Gtk.rc_get_style_by_paths (Gtk.Settings.get_default (), "SmallSystemFont", null, typeof (void));
                if (style != null) {
                        var attr_font_desc = new Pango.AttrFontDesc (style.font_desc.copy ());
                        attr_list.insert ((owned) attr_font_desc);
-               } else {
-                       Pango.Attribute attr_font_scale = Pango.attr_scale_new (Pango.Scale.SMALL);
-                       attr_list.insert ((owned) attr_font_scale);
                }
                Gdk.Color color;
-               if (!style.lookup_color ("SecondaryTextColor", out color)) {
-                       Gdk.Color.parse ("grey", out color);
+               window.ensure_style ();
+               if (window.style.lookup_color ("SecondaryTextColor", out color)) {
+                       Pango.Attribute attr_color = Pango.attr_foreground_new (color.red, color.green, color.blue);
+                       attr_list.insert ((owned) attr_color);
                }
-               Pango.Attribute attr_color = Pango.attr_foreground_new (color.red, color.green, color.blue);
-               attr_list.insert ((owned) attr_color);
                renderer.attributes = attr_list;
 
                vbox_renderer.append (renderer, true);
index 98f3df3..708ad16 100644 (file)
@@ -35,7 +35,7 @@ public class SourceListWindow : StackableWindow {
                set_main_menu (menu);
 
                var sources = new List<MovieSource> ();
-               source_list = new SourceListView (sources, true);
+               source_list = new SourceListView (sources, true, this);
 
                alignment = new Alignment (0.0f, 0.0f, 1.0f, 1.0f);
                alignment.top_padding = MARGIN_HALF;