From 0818b9ad4bc1ffc36ded4dded069029aab29362d Mon Sep 17 00:00:00 2001 From: Jim Nelson Date: Mon, 10 Sep 2012 18:46:39 -0700 Subject: [PATCH] Improved icons: Further closes #5722 Fixes some icon issues associated with this ticket. Custom toolbar icons now shown at full size. --- icons/16x16/tags.svg | 225 ++++++++++++++++++++ icons/24x24/mail-move.svg | 316 ++++++++++++++++++++++------- src/client/models/folder-list.vala | 5 +- src/client/ui/folder-menu.vala | 4 +- src/client/ui/icon-factory.vala | 33 ++- src/client/ui/main-toolbar.vala | 6 +- src/client/util/util-menu.vala | 8 +- 7 files changed, 508 insertions(+), 89 deletions(-) create mode 100644 icons/16x16/tags.svg diff --git a/icons/16x16/tags.svg b/icons/16x16/tags.svg new file mode 100644 index 00000000..be9a0b13 --- /dev/null +++ b/icons/16x16/tags.svg @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/icons/24x24/mail-move.svg b/icons/24x24/mail-move.svg index c3e2b292..9a055ea1 100644 --- a/icons/24x24/mail-move.svg +++ b/icons/24x24/mail-move.svg @@ -2,66 +2,202 @@ + id="svg4532"> + id="defs4534"> + gradientTransform="matrix(0.42307923,0,0,0.39244743,3.8461899,12.352884)" + spreadMethod="reflect" /> + id="linearGradient3866-6"> + - + x1="23.99999" + y1="6.6759877" + x2="23.99999" + y2="41.184601" + id="linearGradient4333" + xlink:href="#linearGradient4366" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(0.45945946,0,0,0.29729728,2.9729738,16.864867)" /> + + + - + gradientTransform="matrix(0.39078075,0,0,0.4337445,4.6029954,15.522359)" /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + style="opacity:0.4;fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:0.99236642;stroke-dasharray:3, 1;stroke-dashoffset:0" /> + + + + + + + + height="13.000001" + rx="1" + ry="1" + x="4.5" + y="17.499998" + id="rect2396-9-3" + style="opacity:0.3;fill:none;stroke:#000000;stroke-width:1;stroke-opacity:1;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> - - - - - + d="m 5.2155719,18.774502 8.7845191,7.314042 8.917279,-7.363225" + id="path3341-2-2" + style="fill:none;stroke:url(#linearGradient4313);stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate" /> diff --git a/src/client/models/folder-list.vala b/src/client/models/folder-list.vala index 58bceb9b..c331567a 100644 --- a/src/client/models/folder-list.vala +++ b/src/client/models/folder-list.vala @@ -37,7 +37,7 @@ public class FolderList : Sidebar.Tree { public Icon? get_sidebar_icon() { switch (folder.get_special_folder_type()) { case Geary.SpecialFolderType.NONE: - return IconFactory.instance.label_icon; + return IconFactory.instance.get_custom_icon("tag", IconFactory.ICON_SIDEBAR); case Geary.SpecialFolderType.INBOX: return new ThemedIcon("mail-inbox"); @@ -132,7 +132,8 @@ public class FolderList : Sidebar.Tree { } private void reset_user_folder_group() { - user_folder_group = new Sidebar.Grouping("", IconFactory.instance.label_folder_icon); + user_folder_group = new Sidebar.Grouping("", + IconFactory.instance.get_custom_icon("tags", IconFactory.ICON_SIDEBAR)); user_folder_branch = new Sidebar.Branch(user_folder_group, Sidebar.Branch.Options.STARTUP_OPEN_GROUPING, user_folder_comparator); } diff --git a/src/client/ui/folder-menu.vala b/src/client/ui/folder-menu.vala index 74cfc912..f5ffbbee 100644 --- a/src/client/ui/folder-menu.vala +++ b/src/client/ui/folder-menu.vala @@ -12,7 +12,7 @@ public class FolderMenu { public signal void folder_selected(Geary.Folder folder); - public FolderMenu(Gtk.ToggleToolButton button, string? icon_name, string? label) { + public FolderMenu(Gtk.ToggleToolButton button, Icon? icon, string? label) { this.button = button; // TODO Add fancy filter option. @@ -28,7 +28,7 @@ public class FolderMenu { add_proxy_menu(button, label, proxy_menu); // only use label for proxy, not the toolbar - make_menu_dropdown_button(button, icon_name, null); + make_menu_dropdown_button(button, icon, null); } public void add_folder(Geary.Folder folder) { diff --git a/src/client/ui/icon-factory.vala b/src/client/ui/icon-factory.vala index 75742a23..0712e73f 100644 --- a/src/client/ui/icon-factory.vala +++ b/src/client/ui/icon-factory.vala @@ -6,6 +6,9 @@ // Singleton class to hold icons. public class IconFactory { + public const Gtk.IconSize ICON_TOOLBAR = Gtk.IconSize.LARGE_TOOLBAR; + public const Gtk.IconSize ICON_SIDEBAR = Gtk.IconSize.MENU; + private static IconFactory? _instance = null; public static IconFactory instance { get { @@ -23,19 +26,19 @@ public class IconFactory { public const int UNREAD_ICON_SIZE = 16; public Gdk.Pixbuf unread { get; private set; } - + public const int STAR_ICON_SIZE = 16; public Gdk.Pixbuf starred { get; private set; } public Gdk.Pixbuf unstarred { get; private set; } - - public ThemedIcon label_icon { get; private set; default = new ThemedIcon("tag"); } - public ThemedIcon label_folder_icon { get; private set; default = new ThemedIcon("tag"); } private Gtk.IconTheme icon_theme { get; private set; } + private File icons_dir; + // Creates the icon factory. private IconFactory() { icon_theme = Gtk.IconTheme.get_default(); + icons_dir = GearyApplication.instance.get_resource_directory().get_child("icons"); append_icons_search_path(null); append_icons_search_path("128x128"); @@ -50,13 +53,27 @@ public class IconFactory { unstarred = load("non-starred-grey", STAR_ICON_SIZE); } - private void append_icons_search_path(string? name) { - File basedir = GearyApplication.instance.get_resource_directory().get_child("icons"); + public Icon get_custom_icon(string name, Gtk.IconSize size) { + int pixels; + switch (size) { + case ICON_SIDEBAR: + pixels = 16; + break; + + case ICON_TOOLBAR: + default: + pixels = 24; + break; + } + return new FileIcon(icons_dir.get_child("%dx%d".printf(pixels, pixels)).get_child("%s.svg".printf(name))); + } + + private void append_icons_search_path(string? name) { if (Geary.String.is_empty(name)) - icon_theme.append_search_path(basedir.get_path()); + icon_theme.append_search_path(icons_dir.get_path()); else - icon_theme.append_search_path(basedir.get_child(name).get_path()); + icon_theme.append_search_path(icons_dir.get_child(name).get_path()); } private Gdk.Pixbuf? load(string icon_name, int size, Gtk.IconLookupFlags flags = 0) { diff --git a/src/client/ui/main-toolbar.vala b/src/client/ui/main-toolbar.vala index 2abdcc11..0d7841a9 100644 --- a/src/client/ui/main-toolbar.vala +++ b/src/client/ui/main-toolbar.vala @@ -26,11 +26,13 @@ public class MainToolbar : Gtk.Box { // Setup the folder menus (move/copy). Gtk.ToggleToolButton copy_menu_button = set_toolbutton_action(builder, GearyController.ACTION_COPY_MENU) as Gtk.ToggleToolButton; - copy_folder_menu = new FolderMenu(copy_menu_button, "tag-new", _("Label as")); + copy_folder_menu = new FolderMenu(copy_menu_button, + IconFactory.instance.get_custom_icon("tag-new", IconFactory.ICON_TOOLBAR), _("Label as")); Gtk.ToggleToolButton move_menu_button = set_toolbutton_action(builder, GearyController.ACTION_MOVE_MENU) as Gtk.ToggleToolButton; - move_folder_menu = new FolderMenu(move_menu_button, "mail-move", _("Move to")); + move_folder_menu = new FolderMenu(move_menu_button, + IconFactory.instance.get_custom_icon("mail-move", IconFactory.ICON_TOOLBAR), _("Move to")); // Assemble mark menu button. GearyApplication.instance.load_ui_file("toolbar_mark_menu.ui"); diff --git a/src/client/util/util-menu.vala b/src/client/util/util-menu.vala index 5c1ce5b8..9c9c9ccc 100644 --- a/src/client/util/util-menu.vala +++ b/src/client/util/util-menu.vala @@ -25,7 +25,7 @@ public void menu_popup_relative(Gtk.Menu menu, out int x, out int y, out bool pu } // This method must be called AFTER the button is added to the toolbar. -public void make_menu_dropdown_button(Gtk.ToggleToolButton toggle_tool_button, string? icon_name, string? label) { +public void make_menu_dropdown_button(Gtk.ToggleToolButton toggle_tool_button, Icon? icon, string? label) { Gtk.ToggleButton? toggle_button = toggle_tool_button.get_child() as Gtk.ToggleButton; if (toggle_button == null) { debug("Problem making dropdown button: ToggleToolButton's child is not a ToggleButton"); @@ -39,13 +39,13 @@ public void make_menu_dropdown_button(Gtk.ToggleToolButton toggle_tool_button, s Gtk.Box box = new Gtk.Box(Gtk.Orientation.HORIZONTAL, 0); box.set_homogeneous(false); - if (icon_name != null) - box.pack_start(new Gtk.Image.from_icon_name(icon_name, Gtk.IconSize.SMALL_TOOLBAR)); + if (icon != null) + box.pack_start(new Gtk.Image.from_gicon(icon, Gtk.IconSize.LARGE_TOOLBAR)); if (label != null) box.pack_start(new Gtk.Label(label)); - box.pack_end(new Gtk.Image.from_icon_name("menu-down", Gtk.IconSize.SMALL_TOOLBAR)); + box.pack_end(new Gtk.Image.from_icon_name("menu-down", Gtk.IconSize.LARGE_TOOLBAR)); toggle_button.add(box); }