[blam] ItemList: signal row update when toggling read status
- From: Carlos Martín Nieto <cmartin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [blam] ItemList: signal row update when toggling read status
- Date: Sat, 15 Jun 2013 13:29:16 +0000 (UTC)
commit 6902974b58bba3b79c664c5e61a78d055ba1da8e
Author: Carlos Martín Nieto <cmn dwim me>
Date: Sat Jun 15 14:06:14 2013 +0200
ItemList: signal row update when toggling read status
Gtk needs to be told that we've updated the item, so do it.
blam.csproj | 1 +
src/Application.cs | 1 +
src/ItemList.cs | 21 +++++++++++++--------
src/Makefile.am | 1 +
src/TreeSelectionExtensions.cs | 33 +++++++++++++++++++++++++++++++++
5 files changed, 49 insertions(+), 8 deletions(-)
---
diff --git a/blam.csproj b/blam.csproj
index 1f66b3d..1e0f3ab 100644
--- a/blam.csproj
+++ b/blam.csproj
@@ -110,6 +110,7 @@
<Compile Include="gtk-gui\Imendio.Blam.AddChannelDialog.cs" />
<Compile Include="src\AddChannelDialog.cs" />
<Compile Include="src\GLibSynchronizationContext.cs" />
+ <Compile Include="src\TreeSelectionExtensions.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
diff --git a/src/Application.cs b/src/Application.cs
index b4b35a2..a44e119 100644
--- a/src/Application.cs
+++ b/src/Application.cs
@@ -367,6 +367,7 @@ namespace Imendio.Blam {
// Toggle unread status
item.SetUnread (!item.Unread);
+ itemList.EmitSelectedRowChanged();
}
public void EditEntryKeywordsActivated (object obj, EventArgs args)
diff --git a/src/ItemList.cs b/src/ItemList.cs
index 3a06200..e1a5fc1 100644
--- a/src/ItemList.cs
+++ b/src/ItemList.cs
@@ -163,18 +163,23 @@ namespace Imendio.Blam {
return null;
}
- private async void SelectionChanged (object obj, EventArgs args)
+ public void EmitSelectedRowChanged()
{
- TreeSelection selection = (TreeSelection) obj;
TreeIter iter;
TreeModel model;
- Imendio.Blam.Item item;
- if (!selection.GetSelected (out model, out iter)) {
+ if (!Selected(out model, out iter))
return;
- }
- item = (Imendio.Blam.Item) model.GetValue (iter, 0);
+ model.EmitRowChanged(model.GetPath(iter), iter);
+ }
+
+ private async void SelectionChanged (object obj, EventArgs args)
+ {
+ TreeSelection selection = (TreeSelection) obj;
+ Imendio.Blam.Item item;
+
+ item = selection.Item();
if (item == null)
return;
@@ -186,7 +191,7 @@ namespace Imendio.Blam {
if (!useTimeout) {
item.SetUnread(false);
- model.EmitRowChanged(model.GetPath(iter), iter);
+ selection.EmitRowChanged();
return;
}
@@ -201,7 +206,7 @@ namespace Imendio.Blam {
MarkReadCancel = null;
item.SetUnread(false);
- model.EmitRowChanged(model.GetPath(iter), iter);
+ selection.EmitRowChanged();
}
private int CompareFunc(TreeModel model, TreeIter a, TreeIter b)
diff --git a/src/Makefile.am b/src/Makefile.am
index a60047d..89b9690 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -34,6 +34,7 @@ BLAM_CSFILES = Application.cs \
Theme.cs \
ThemeManager.cs \
TrayIcon.cs \
+ TreeSelectionExtensions.cs \
Utils.cs \
Proxy.cs \
ItemStore.cs \
diff --git a/src/TreeSelectionExtensions.cs b/src/TreeSelectionExtensions.cs
new file mode 100644
index 0000000..3d66a56
--- /dev/null
+++ b/src/TreeSelectionExtensions.cs
@@ -0,0 +1,33 @@
+using System;
+using Gtk;
+
+namespace Imendio.Blam
+{
+ public static class TreeSelectionExtensions
+ {
+ public static void EmitRowChanged(this TreeSelection selection)
+ {
+ TreeIter iter;
+ TreeModel model;
+
+ if (!selection.GetSelected (out model, out iter)) {
+ return;
+ }
+
+ model.EmitRowChanged(model.GetPath(iter), iter);
+ }
+
+ public static Item Item(this TreeSelection selection)
+ {
+ TreeIter iter;
+ TreeModel model;
+
+ if (!selection.GetSelected (out model, out iter)) {
+ return null;
+ }
+
+ return (Imendio.Blam.Item) model.GetValue (iter, 0);
+ }
+ }
+}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]