[blam/gtk-builder: 54/56] Merge remote-tracking branch 'origin/master' into gtk-builder
- From: Carlos Martín Nieto <cmartin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [blam/gtk-builder: 54/56] Merge remote-tracking branch 'origin/master' into gtk-builder
- Date: Sun, 6 Oct 2013 17:37:28 +0000 (UTC)
commit a9daa1b117eb209104c9b90a8cfd20ec48b2eaf3
Merge: c30ee04 7b63577
Author: Carlos Martín Nieto <cmn dwim me>
Date: Sun Oct 6 17:00:48 2013 +0200
Merge remote-tracking branch 'origin/master' into gtk-builder
Conflicts:
blam.csproj
src/ChannelCollection.cs
src/ChannelList.cs
Makefile.am | 6 +-
NEWS | 39 +--
autogen.sh | 76 ++++--
blam.csproj | 9 +-
blam.desktop.in.in | 4 +-
configure.in => configure.ac | 10 +-
gtk-gui/generated.cs | 6 +-
po/el.po | 508 +++++++++++++++++++------------------
po/lv.po | 93 ++++----
src/AddChannelDialog.cs | 8 +-
src/Application.cs | 119 +++------
src/Channel.cs | 240 ++++++++++--------
src/ChannelCollection.cs | 249 ++++++++++---------
src/ChannelDialog.cs | 1 -
src/ChannelGroup.cs | 39 ++--
src/ChannelList.cs | 220 ++++++++++-------
src/Defines.cs.in | 4 +-
src/FeedUpdater.cs | 68 -----
src/Filter.cs | 27 --
src/GLibSynchronizationContext.cs | 71 +++++
src/Item.cs | 41 ++--
src/ItemList.cs | 154 +++++++-----
src/ItemStore.cs | 96 +++-----
src/ItemView.cs | 66 +++--
src/MainloopEmitter.cs | 45 ----
src/Makefile.am | 28 +-
src/Opml.cs | 5 +-
src/TrayIcon.cs | 29 ++-
src/TreeSelectionExtensions.cs | 33 +++
29 files changed, 1190 insertions(+), 1104 deletions(-)
---
diff --cc blam.csproj
index 475cde5,0e01d9f..da31d49
--- a/blam.csproj
+++ b/blam.csproj
@@@ -7,10 -7,11 +7,11 @@@
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{4E407663-2362-4FCD-BC45-A772920BB32F}</ProjectGuid>
<OutputType>WinExe</OutputType>
- <RootNamespace>Imendio.Blam</RootNamespace>
+ <RootNamespace>Blam</RootNamespace>
<AssemblyName>blam</AssemblyName>
<ReleaseVersion>1.9.10</ReleaseVersion>
- <StartupObject>Imendio.Blam.Application</StartupObject>
+ <StartupObject>Blam.Blam</StartupObject>
+ <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>True</DebugSymbols>
@@@ -72,9 -73,11 +73,10 @@@
<Private>False</Private>
<Package>gtk-sharp-2.0</Package>
</Reference>
- <Reference Include="gconf-sharp, Version=2.24.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
- <Private>False</Private>
++ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="gconf-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f">
<Package>gconf-sharp-2.0</Package>
</Reference>
- <Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup>
<Compile Include="src\Application.cs" />
@@@ -108,8 -108,8 +107,10 @@@
<Compile Include="gtk-gui\generated.cs" />
<Compile Include="gtk-gui\Imendio.Blam.AddChannelDialog.cs" />
<Compile Include="src\AddChannelDialog.cs" />
+ <Compile Include="src\Blam.cs" />
+ <Compile Include="src\BuilderExtensions.cs" />
+ <Compile Include="src\GLibSynchronizationContext.cs" />
+ <Compile Include="src\TreeSelectionExtensions.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
@@@ -117,10 -117,7 +118,10 @@@
<None Include="src\Makefile" />
<None Include="src\Makefile.am" />
<None Include="src\Makefile.in" />
- <None Include="configure.in" />
+ <None Include="configure.ac" />
+ <None Include="src\blam.exe.config">
+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+ </None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="src\blam.glade">
diff --cc gtk-gui/generated.cs
index 9636f6f,9636f6f..9ef3363
--- a/gtk-gui/generated.cs
+++ b/gtk-gui/generated.cs
@@@ -5,7 -5,7 +5,7 @@@ namespace Steti
internal class Gui
{
private static bool initialized;
--
++
internal static void Initialize (Gtk.Widget iconRenderer)
{
if ((Stetic.Gui.initialized == false)) {
@@@ -13,14 -13,14 +13,14 @@@
}
}
}
--
++
internal class ActionGroups
{
public static Gtk.ActionGroup GetActionGroup (System.Type type)
{
return Stetic.ActionGroups.GetActionGroup (type.FullName);
}
--
++
public static Gtk.ActionGroup GetActionGroup (string name)
{
return null;
diff --cc src/ChannelCollection.cs
index d7fb0f9,1bcd581..2fdf072
--- a/src/ChannelCollection.cs
+++ b/src/ChannelCollection.cs
@@@ -7,7 -7,7 +7,8 @@@
using System;
using System.Collections;
+using System.Collections.Generic;
+ using System.Collections.Specialized;
using System.Linq;
using System.IO;
using System.Reflection;
@@@ -168,99 -187,96 +189,97 @@@ namespace Imendio.Blam
Console.Error.WriteLine ("File replace error: " + e.Message);
return;
}
-
- MarkAsDirty (false);
- }
+ }
}
- public void Add (IChannel channel)
+ public async Task Add (IChannel channel, bool update = false)
{
// If we already have this feed, simply return
- if (mChannels.Cast<Channel>().Any(channel.Url.Equals))
+ if (mChannels.Cast<Channel>().Any(channel.Url.Equals))
return;
- if(channel.Name == null){
- channel.Name = channel.Url;
- }
+ if(channel.Name == null){
+ channel.Name = channel.Url;
+ }
- mChannels.Add (channel as Channel);
- channel.RefreshAsync(updated => {
- MarkAsDirty(true);
- if (ChannelAdded != null)
- ChannelAdded (channel);
- });
- }
- mChannels.Add (channel);
++ mChannels.Add (channel as Channel);
+ if (update) {
- bool res = await channel.RefreshAsync();
- if (res)
++ var updated = await channel.RefreshAsync();
++ if (updated)
+ MarkAsDirty();
+ }
- public void Add(ChannelGroup group, IChannel channel)
+ NotifyAdd(channel);
++
+ }
+
+ public async void Add(ChannelGroup group, IChannel channel)
{
group.Add(channel);
- channel.RefreshAsync(updated => {
- channel.Updated += Updated;
-
- if(ChannelGroupAdded != null){
- ChannelGroupAdded(group, channel);
- }
+ channel.PropertyChanged += ChannelChanged;
- MarkAsDirty(true);
- });
- }
+ NotifyAdd(new { Group = group, Channel = channel });
- public void Updated (IChannel channel)
- {
- MarkAsDirty (true);
+ MarkAsDirty();
+ }
- if (ChannelUpdated != null) {
- ChannelUpdated (channel);
- }
- }
+ void ChannelChanged(object sender, PropertyChangedEventArgs args)
+ {
+ IChannel channel = (IChannel)sender;
+ MarkAsDirty();
- public void Remove (IChannel channel)
- {
- /* Try to find out from which list we need to remove. */
- if(mChannels.Contains(channel)){
- mChannels.Remove (channel as Channel);
- } else if(Groups.Contains(channel)){
- Groups.Remove(channel as ChannelGroup);
- } else {
- /* It's not a first-level channel or group. Dig deeper. */
- foreach(ChannelGroup group in Groups){
- if(group.Channels.Contains(channel)){
- group.Channels.Remove(channel);
- break;
- }
- }
- }
+ if (PropertyChanged != null)
+ PropertyChanged(this, args);
+ }
- if (ChannelRemoved != null) {
- ChannelRemoved (channel);
- }
+ void DoRemove(IChannel channel)
+ {
+ /* Try to find out from which list we need to remove. */
+ if(mChannels.Contains(channel)){
- mChannels.Remove (channel);
++ mChannels.Remove(channel as Channel);
+ } else if(Groups.Contains(channel)){
- Groups.Remove(channel);
++ Groups.Remove(channel as ChannelGroup);
+ } else {
+ /* It's not a first-level channel or group. Dig deeper. */
+ foreach(ChannelGroup group in Groups){
+ if(group.Channels.Contains(channel)){
+ group.Channels.Remove(channel);
+ break;
+ }
+ }
+ }
+
+ NotifyRemove(channel);
+ }
- MarkAsDirty(true);
- }
+ public void Remove (IChannel channel)
+ {
+ DoRemove(channel);
+ channel.RemoveItems();
+ MarkAsDirty();
+ }
- delegate void RefreshAllDelegate();
+ public void Move(IChannel src, IChannel dst)
+ {
+ DoRemove(src);
+ if (dst == null)
+ Add(src);
+ else
+ Add((ChannelGroup)dst, src);
- public void RefreshAllAsync()
- {
- var fun = new RefreshAllDelegate(RefreshAll);
- fun.BeginInvoke(fun.EndInvoke, null);
- }
+ MarkAsDirty();
+ }
- public void RefreshAll ()
- {
- var all = mChannels.Cast<Channel>();
- foreach(ChannelGroup group in Groups){
- all.Union(group.Channels.Cast<Channel>());
- }
+ public async void RefreshAll()
+ {
+ var all = mChannels.Cast<IChannel>().Union(Groups.Cast<IChannel>());
- Parallel.ForEach(mChannels.Cast<Channel>(), c => {
- bool updated = c.Refresh();
- if (updated) {
- MarkAsDirty (true);
- }
- new MainloopEmitter (this.ChannelRefreshFinished, c).Emit ();
- });
- }
+ foreach (var chan in all) {
+ EmitChannelRefreshStarted(chan);
+ await chan.RefreshAsync();
+ EmitChannelRefreshFinished(chan);
+ }
+ }
private void EmitChannelRefreshStarted (IChannel channel)
{
diff --cc src/ChannelList.cs
index 1a76dc0,139f2e5..574b2f6
--- a/src/ChannelList.cs
+++ b/src/ChannelList.cs
@@@ -10,80 -10,11 +10,82 @@@ using Gtk
using GtkSharp;
using System;
using System.Collections;
+using System.Collections.Generic;
+ using System.Collections.Specialized;
using System.Runtime.InteropServices;
+ using System.ComponentModel;
using Mono.Unix;
+namespace Blam
+{
+ using Channel = Imendio.Blam.Channel;
+ using IChannel = Imendio.Blam.IChannel;
+ using ChannelGroup = Imendio.Blam.ChannelGroup;
+
+ public class FeedList : Gtk.TreeView
+ {
+ TreeViewColumn name_col;
+
+ public FeedList(IEnumerable<Channel> channels, IEnumerable<ChannelGroup> groups)
+ {
+ name_col = new TreeViewColumn();
+ var renderer = new CellRendererText();
+ name_col.PackStart(renderer, true);
+ name_col.Sizing = TreeViewColumnSizing.GrowOnly;
+ name_col.Expand = true;
+ name_col.SetCellDataFunc(renderer, NamesCellDataFunc);
+ AppendColumn(name_col);
+
+ var items_col = new TreeViewColumn();
+ renderer = new CellRendererText();
+ items_col.PackStart(renderer, true);
+ items_col.SetCellDataFunc(renderer, ItemsCellDataFunc);
+ AppendColumn(items_col);
+
+ RulesHint = true;
+ Model = new TreeStore (typeof(IChannel));
+ HeadersVisible = false;
+
+ var model = Model as TreeStore;
+
+ foreach (IChannel chan in channels)
+ chan.Iter = model.AppendValues(chan);
+
+ foreach (ChannelGroup group in groups) {
+ var iter = model.AppendValues(group);
+ group.Iter = iter;
+ //SetDragDestRow(Model.GetPath(iter), TreeViewDropPosition.IntoOrAfter);
+
+ foreach(IChannel chan in group.Channels)
+ chan.Iter = model.AppendValues(group.Iter, chan);
+ }
+ }
+
+ void NamesCellDataFunc(TreeViewColumn col, CellRenderer _cell, TreeModel model, TreeIter iter)
+ {
+ IChannel channel = model.GetValue(iter, 0) as IChannel;
+ var cell = _cell as CellRendererText;
+ var weight = channel.NrOfUnreadItems > 0 ? Pango.Weight.Bold : Pango.Weight.Normal;
+
+ cell.Text = channel.Name;
+ cell.Ellipsize = Pango.EllipsizeMode.End;
+ cell.Weight = (int)weight;
+ }
+
+ private void ItemsCellDataFunc(TreeViewColumn col, CellRenderer _cell, TreeModel model,
TreeIter iter)
+ {
+ IChannel channel = model.GetValue(iter, 0) as IChannel;
+ var cell = _cell as CellRendererText;
+ var weight = channel.NrOfUnreadItems > 0 ? Pango.Weight.Bold : Pango.Weight.Normal;
+
+ cell.Text = String.Format("{0}/{1}", channel.NrOfUnreadItems, channel.NrOfItems);
+ cell.Xalign = 1.0f;
+ cell.Weight = (int)weight;
+ }
+
+ }
+}
+
namespace Imendio.Blam {
public class ChannelList : Gtk.TreeView {
@@@ -107,62 -38,97 +109,99 @@@
new TargetEntry("channel", TargetFlags.Widget, (uint)TargetType.Channel)
};
+ ChannelCollection Collection;
+
- public ChannelList(ChannelCollection collection)
- {
- Collection = collection;
- Collection.CollectionChanged += CollectionChanged;
- Collection.PropertyChanged += CollectionPropertyChanged;
+ public ChannelList(IEnumerable<Channel> channels, IEnumerable<ChannelGroup> groups)
+ {
+ TreeViewColumn col;
+ CellRenderer cell;
- /* Channel name column */
- nameColumn = new TreeViewColumn();
- cell = new CellRendererText();
- TreeViewColumn col;
- CellRenderer cell;
++ Collection = new ChannelCollection();
+
+ /* Channel name column */
+ nameColumn = new TreeViewColumn();
+ cell = new CellRendererText();
- nameColumn.PackStart(cell, true);
- nameColumn.Sizing = TreeViewColumnSizing.GrowOnly;
- nameColumn.Expand = true;
- nameColumn.SetCellDataFunc(cell, new TreeCellDataFunc(NamesCellDataFunc));
+ nameColumn.PackStart(cell, true);
+ nameColumn.Sizing = TreeViewColumnSizing.GrowOnly;
+ nameColumn.Expand = true;
+ nameColumn.SetCellDataFunc(cell, new TreeCellDataFunc(NamesCellDataFunc));
- AppendColumn(nameColumn);
+ AppendColumn(nameColumn);
- /* Items column */
- col = new TreeViewColumn();
- cell = new CellRendererText();
+ /* Items column */
+ col = new TreeViewColumn();
+ cell = new CellRendererText();
- col.PackStart(cell, true);
- col.SetCellDataFunc(cell,
- new TreeCellDataFunc(ItemsCellDataFunc));
+ col.PackStart(cell, true);
+ col.SetCellDataFunc(cell,
+ new TreeCellDataFunc(ItemsCellDataFunc));
- AppendColumn(col);
+ AppendColumn(col);
- this.RulesHint = true;
+ this.RulesHint = true;
- selectionChangedHandler = new EventHandler(SelectionChanged);
- this.Selection.Changed += selectionChangedHandler;
+ selectionChangedHandler = new EventHandler(SelectionChanged);
+ this.Selection.Changed += selectionChangedHandler;
- this.Model = new TreeStore (typeof(Channel));
- this.HeadersVisible = false;
+ this.Model = new TreeStore (typeof(Channel));
+ this.HeadersVisible = false;
- // Sort the list
- (Model as TreeStore).DefaultSortFunc = ChannelSort;
- (this.Model as TreeStore).SetSortColumnId (-1, SortType.Ascending);
+ // Sort the list
+ (Model as TreeStore).DefaultSortFunc = ChannelSort;
+ (this.Model as TreeStore).SetSortColumnId (-1, SortType.Ascending);
- // Right click popup
- this.popupMenu = new ChannelMenu();
- this.popupMenu.EditSelected += EditChannelCb;
- this.popupMenu.MarkAsReadSelected += MarkAsReadCb;
- this.popupMenu.RemoveSelected += RemoveChannelCb;
- this.popupMenu.RefreshSelected += RefreshChannelCb;
+ // Right click popup
+ this.popupMenu = new ChannelMenu();
+ this.popupMenu.EditSelected += EditChannelCb;
+ this.popupMenu.MarkAsReadSelected += MarkAsReadCb;
+ this.popupMenu.RemoveSelected += RemoveChannelCb;
+ this.popupMenu.RefreshSelected += RefreshChannelCb;
EnableModelDragSource(ModifierType.Button1Mask, DragEntries, DragAction.Copy);
DragDataGet += DragDataGetHandler;
EnableModelDragDest(DragEntries, DragAction.Copy);
DragDataReceived += DragDataReceivedHandler;
- foreach (IChannel channel in channels)
+ // Add the groups and chanels to the view
- foreach (IChannel channel in Collection.Channels)
++ foreach (IChannel channel in channels) {
++ Collection.Add(channel, false).Wait();
Add (channel);
++ }
- foreach (IChannel group in groups)
- foreach (IChannel group in Collection.Groups)
++ foreach (IChannel group in groups) {
++ Collection.Add(group, false).Wait();
AddGroup(group);
- }
++ }
+ }
+
+ void CollectionPropertyChanged(object sender, PropertyChangedEventArgs args)
+ {
+ Application.Context.Post(state => Application.TheApp.UpdateTotalNumberOfUnread(),
null);
+ }
+
+ void CollectionChanged(object sender, NotifyCollectionChangedEventArgs args)
+ {
+ switch (args.Action) {
+ case NotifyCollectionChangedAction.Add:
+ foreach (var channel in args.NewItems) {
+ if (channel is Channel) {
+ Add((IChannel)channel);
+ } else if (channel is ChannelGroup) {
+ AddGroup((IChannel)channel);
+ } else {
+ dynamic obj = channel;
+ AddToGroup(obj.Group, obj.Channel);
+ }
+ }
+ break;
+ case NotifyCollectionChangedAction.Remove:
+ foreach (IChannel channel in args.OldItems) {
+ Remove(channel);
+ }
+ break;
+ }
+ }
private void ForceResort()
{
diff --cc src/ItemList.cs
index 0b18b2f,347bf3a..bb867ba
--- a/src/ItemList.cs
+++ b/src/ItemList.cs
@@@ -12,85 -12,17 +12,87 @@@ using GLib
using GtkSharp;
using System;
using System.Collections;
+ using System.Threading;
+ using System.Threading.Tasks;
using System.ServiceModel.Syndication;
+ using System.ComponentModel;
+ using System.Runtime.CompilerServices;
+namespace Blam
+{
+ using Channel = Imendio.Blam.Channel;
+ using IChannel = Imendio.Blam.IChannel;
+ using ItemView = Imendio.Blam.ItemView;
+ using Item = Imendio.Blam.Item;
+ using ItemStore = Imendio.Blam.ItemStore;
+
+ public delegate void OnChange(Item item);
+
+ public class ItemList : Gtk.TreeView
+ {
+ public IChannel Channel {
+ get {
+ return current;
+ }
+ set {
+ current = value;
+ UpdateList();
+ }
+ }
+
+ IChannel current;
+ TreeViewColumn column;
+
+ public event OnChange OnChangeEvent;
+
+ public ItemList()
+ {
+ column = new TreeViewColumn();
+ var renderer = new CellRendererText();
+ column.PackStart(renderer, true);
+ column.SetCellDataFunc(renderer, CellDataFunc);
+ AppendColumn(column);
+
+ this.Model = new ListStore (typeof(Imendio.Blam.Item));
+ this.HeadersVisible = false;
+
+ }
+
+ void CellDataFunc (TreeViewColumn col, CellRenderer _cell, TreeModel model, TreeIter iter)
+ {
+ Item item = model.GetValue(iter, 0) as Item;
+
+ CellRendererText cell = _cell as CellRendererText;
+ var weight = item.Unread ? Pango.Weight.Bold : Pango.Weight.Normal;
+ var text = (item.Title as TextSyndicationContent).Text.Trim();
+
+ cell.Text = Imendio.Blam.HtmlUtils.Unescape(text);
+ cell.Weight = (int)weight;
+ cell.Ellipsize = Pango.EllipsizeMode.End;
+ }
+
+ void UpdateList()
+ {
+ var list = Model as ListStore;
- var store = ItemStore.GetInstance();
+
+ list.Clear();
+ foreach(string id in current.ItemList){
+ if (id == null)
+ continue;
+
- list.AppendValues(store.Get(id));
++ list.AppendValues(ItemStore.Get(id));
+ }
+ }
+
+
+ }
+}
+
namespace Imendio.Blam {
- public class ItemList : Gtk.TreeView {
+ public class ItemList : Gtk.TreeView, INotifyPropertyChanged {
- public delegate void ItemSelectedHandler(Imendio.Blam.Item item);
- public event ItemSelectedHandler ItemSelected;
+ public event PropertyChangedEventHandler PropertyChanged;
private ItemView itemView;
diff --cc src/ItemView.cs
index d57d268,a19fc32..f16182b
--- a/src/ItemView.cs
+++ b/src/ItemView.cs
@@@ -18,39 -18,9 +18,40 @@@ using System.Reflection
using System.IO;
using System.Net;
using System.Text;
+ using System.ComponentModel;
using System.ServiceModel.Syndication;
+namespace Blam
+{
+ using Item = Imendio.Blam.Item;
+ using Defines = Imendio.Blam.Defines;
+ public class ItemView : WebKit.WebView
+ {
+ Item current;
+
+ public Item Item {
+ get {
+ return current;
+ }
+ set {
+ current = value;
+ UpdateView();
+ }
+ }
+
+ public ItemView() : base()
+ {
+ }
+
+ void UpdateView()
+ {
+ string text = current.Summary != null ? current.Summary.Text
+ : current.Content != null ? (current.Content as TextSyndicationContent).Text
: null;
+ LoadString(text, null, null, Defines.APP_DATADIR);
+ }
+ }
+}
+
namespace Imendio.Blam {
public class ItemView : Gtk.EventBox {
private WebView webView;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]