[gitg/vala] Check if there is a selection or show empty file
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/vala] Check if there is a selection or show empty file
- Date: Tue, 17 Jul 2012 15:04:41 +0000 (UTC)
commit aaf07ed67e43aff16876fdd925d4d85c01360e9f
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date: Tue Jul 17 17:04:36 2012 +0200
Check if there is a selection or show empty file
plugins/files/gitg-files.vala | 42 +++++++++++++++++++++++-----------------
1 files changed, 24 insertions(+), 18 deletions(-)
---
diff --git a/plugins/files/gitg-files.vala b/plugins/files/gitg-files.vala
index 15e9c9a..c159fcf 100644
--- a/plugins/files/gitg-files.vala
+++ b/plugins/files/gitg-files.vala
@@ -197,18 +197,35 @@ namespace GitgFiles
}
}
+ private void set_viewer(Gtk.Widget? wid)
+ {
+ var child = d_scrolled.get_child();
+
+ if (child != wid)
+ {
+ if (child != null)
+ {
+ d_scrolled.remove(d_scrolled.get_child());
+ }
+
+ if (wid != null)
+ {
+ d_scrolled.add(wid);
+ }
+ }
+ }
+
private void selection_changed(Gtk.TreeSelection selection)
{
Gtk.TreeModel mod;
Gtk.TreeIter iter;
- selection.get_selected(out mod, out iter);
-
var buf = d_source.get_buffer() as GtkSource.Buffer;
buf.set_text("");
- if (d_model.get_isdir(iter))
+ if (!selection.get_selected(out mod, out iter) || d_model.get_isdir(iter))
{
+ set_viewer(d_source);
return;
}
@@ -218,8 +235,10 @@ namespace GitgFiles
try
{
blob = application.repository.lookup(id, typeof(Ggit.Blob)) as Ggit.Blob;
- } catch
+ }
+ catch
{
+ set_viewer(d_source);
return;
}
@@ -256,20 +275,7 @@ namespace GitgFiles
wid = d_source;
}
- var child = d_scrolled.get_child();
-
- if (child != wid)
- {
- if (child != null)
- {
- d_scrolled.remove(d_scrolled.get_child());
- }
-
- if (wid != null)
- {
- d_scrolled.add(wid);
- }
- }
+ set_viewer(wid);
}
public bool is_enabled()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]