[shotwell] Add more details to Mass storage cameras
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] Add more details to Mass storage cameras
- Date: Thu, 24 Aug 2017 20:35:37 +0000 (UTC)
commit 11c2c85696b032edd8a47b4384e89b7e784900a9
Author: Jens Georg <mail jensge org>
Date: Thu Aug 24 22:21:54 2017 +0200
Add more details to Mass storage cameras
Get icon and description from associated GVolume for mass storage
cameras. This should make it easier to find the correct camera when
having connected more than one devices.
src/camera/CameraTable.vala | 12 +++++++++++-
src/sidebar/Tree.vala | 28 ++++++++++++++++++++++------
2 files changed, 33 insertions(+), 7 deletions(-)
---
diff --git a/src/camera/CameraTable.vala b/src/camera/CameraTable.vala
index 7eb7ae2..1636816 100644
--- a/src/camera/CameraTable.vala
+++ b/src/camera/CameraTable.vala
@@ -342,11 +342,21 @@ public class CameraTable {
display_name = device.get_property("ID_MODEL");
}
}
+
+ if (port.has_prefix("disk:")) {
+ try {
+ var mount = File.new_for_path (port.substring(5)).find_enclosing_mount();
+ var volume = mount.get_volume();
+ // Translators: First %s is the name of camera as gotten from GPhoto, second is the
GVolume name, e.g. Mass storage camera (510MB volume)
+ display_name = _("%s (%s)").printf (name, volume.get_name ());
+ icon = volume.get_icon().to_string();
+
+ } catch (Error e) { }
+ }
if (null == display_name) {
// Default to GPhoto detected name.
display_name = name;
}
-
int index = port_info_list.lookup_path(port);
if (index < 0)
do_op((GPhoto.Result) index, "lookup port %s".printf(port));
diff --git a/src/sidebar/Tree.vala b/src/sidebar/Tree.vala
index cfe937e..c707c63 100644
--- a/src/sidebar/Tree.vala
+++ b/src/sidebar/Tree.vala
@@ -56,7 +56,7 @@ public class Sidebar.Tree : Gtk.TreeView {
typeof (string), // NAME
typeof (string?), // TOOLTIP
typeof (EntryWrapper), // WRAPPER
- typeof (string?) // ICON
+ typeof (Icon?) // ICON
);
private Gtk.Builder builder = new Gtk.Builder ();
@@ -98,8 +98,8 @@ public class Sidebar.Tree : Gtk.TreeView {
text_column.set_expand(true);
Gtk.CellRendererPixbuf icon_renderer = new Gtk.CellRendererPixbuf();
icon_renderer.follow_state = true;
- text_column.pack_start(icon_renderer, false);
- text_column.add_attribute(icon_renderer, "icon_name", Columns.ICON);
+ text_column.pack_start (icon_renderer, false);
+ text_column.add_attribute(icon_renderer, "gicon", Columns.ICON);
text_column.set_cell_data_func(icon_renderer, icon_renderer_function);
text_renderer = new Gtk.CellRendererText();
text_renderer.ellipsize = Pango.EllipsizeMode.END;
@@ -735,10 +735,17 @@ public class Sidebar.Tree : Gtk.TreeView {
store.set(wrapper.get_iter(), Columns.TOOLTIP, guarded_markup_escape_text(tooltip));
}
- private void on_sidebar_icon_changed(Sidebar.Entry entry, string? icon) {
+ private void on_sidebar_icon_changed(Sidebar.Entry entry, string? icon_name) {
EntryWrapper? wrapper = get_wrapper(entry);
assert(wrapper != null);
-
+ Icon? icon = null;
+
+ try {
+ if (icon_name != null) {
+ icon = Icon.new_for_string (icon_name);
+ }
+ } catch (Error e) { }
+
store.set(wrapper.get_iter(), Columns.ICON, icon);
}
@@ -767,9 +774,18 @@ public class Sidebar.Tree : Gtk.TreeView {
private void load_entry_icons(Gtk.TreeIter iter) {
EntryWrapper? wrapper = get_wrapper_at_iter(iter);
+ Icon? icon = null;
if (wrapper == null)
return;
- string? icon = wrapper.entry.get_sidebar_icon();
+
+ try {
+ string? name = wrapper.entry.get_sidebar_icon();
+ if (name != null) {
+ icon = Icon.new_for_string (name);
+ }
+ } catch (Error e) { }
+
+
store.set(iter, Columns.ICON, icon);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]