[geary] Simplify icon handling a bit.
- From: Adam Dingle <adamd src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Simplify icon handling a bit.
- Date: Thu, 28 Apr 2016 18:23:25 +0000 (UTC)
commit d33e3e7229bd4a72643b01e098356670ba168e68
Author: Michael James Gratton <mike vee net>
Date: Wed Apr 27 11:56:25 2016 +1000
Simplify icon handling a bit.
When implementing bug 765359, it appears that Geary is doing too much
work to load icons. Simplify it a bit.
* src/client/components/icon-factory.vala (IconFactory): Don't bother
loading an application icon, it's easier and works better to just use
an icon name where needed. Don't bother adding all of the icons/*x*
directories to the icon theme search path, just make the icon's
directory hierarchy follow the XDG/hicolor spec and add the base
directory. Remove now-redundant code.
* src/client/application/geary-controller.vala: Set the default icon name
for all geary windows.
(GearyController:on_about()): Set the name for the icon in the About
dialog.
* src/client/components/main-window.vala (ApplicationWindow): Don't
bother loading icons for the window, just use the new default.
* src/client/notification/libnotify.vala: Don't bother passing the
application icon through for error notifications, an icon name has
already been set.
* icons/*x*/geary.png: Move to a new directory hierarchy that follows the
hicolor spec.
* icons/CMakeLists.txt: Updated to use new paths to the icons.
icons/CMakeLists.txt | 14 +++---
icons/{16x16 => hicolor/16x16/apps}/geary.png | Bin 742 -> 742 bytes
icons/{24x24 => hicolor/24x24/apps}/geary.png | Bin 1295 -> 1295 bytes
icons/{256x256 => hicolor/256x256/apps}/geary.png | Bin 24639 -> 24639 bytes
icons/{32x32 => hicolor/32x32/apps}/geary.png | Bin 1666 -> 1666 bytes
icons/{48x48 => hicolor/48x48/apps}/geary.png | Bin 2672 -> 2672 bytes
icons/{512x512 => hicolor/512x512/apps}/geary.png | Bin 62570 -> 62570 bytes
.../{ => hicolor/symbolic/apps}/geary-symbolic.svg | 0
src/client/application/geary-controller.vala | 13 ++++--
src/client/components/icon-factory.vala | 46 ++-----------------
src/client/components/main-window.vala | 9 +---
src/client/notification/libnotify.vala | 7 +--
12 files changed, 25 insertions(+), 64 deletions(-)
---
diff --git a/icons/CMakeLists.txt b/icons/CMakeLists.txt
index 080319e..b14903d 100644
--- a/icons/CMakeLists.txt
+++ b/icons/CMakeLists.txt
@@ -27,13 +27,13 @@ set(ICON_FILES
install(FILES ${ICON_FILES} DESTINATION ${ICONS_DEST})
# Application icon goes in theme directory
-install(FILES "16x16/geary.png" DESTINATION share/icons/hicolor/16x16/apps)
-install(FILES "24x24/geary.png" DESTINATION share/icons/hicolor/24x24/apps)
-install(FILES "32x32/geary.png" DESTINATION share/icons/hicolor/32x32/apps)
-install(FILES "48x48/geary.png" DESTINATION share/icons/hicolor/48x48/apps)
-install(FILES "256x256/geary.png" DESTINATION share/icons/hicolor/256x256/apps)
-install(FILES "512x512/geary.png" DESTINATION share/icons/hicolor/512x512/apps)
-install(FILES "geary-symbolic.svg" DESTINATION share/icons/hicolor/symbolic/apps)
+install(FILES "hicolor/16x16/apps/geary.png" DESTINATION share/icons/hicolor/16x16/apps)
+install(FILES "hicolor/24x24/apps/geary.png" DESTINATION share/icons/hicolor/24x24/apps)
+install(FILES "hicolor/32x32/apps/geary.png" DESTINATION share/icons/hicolor/32x32/apps)
+install(FILES "hicolor/48x48/apps/geary.png" DESTINATION share/icons/hicolor/48x48/apps)
+install(FILES "hicolor/256x256/apps/geary.png" DESTINATION share/icons/hicolor/256x256/apps)
+install(FILES "hicolor/512x512/apps/geary.png" DESTINATION share/icons/hicolor/512x512/apps)
+install(FILES "hicolor/symbolic/apps/geary-symbolic.svg" DESTINATION share/icons/hicolor/symbolic/apps)
# Optional: update icon cache at install time.
if (ICON_UPDATE)
diff --git a/icons/geary-symbolic.svg b/icons/hicolor/symbolic/apps/geary-symbolic.svg
similarity index 100%
rename from icons/geary-symbolic.svg
rename to icons/hicolor/symbolic/apps/geary-symbolic.svg
diff --git a/src/client/application/geary-controller.vala b/src/client/application/geary-controller.vala
index cb19248..be94860 100644
--- a/src/client/application/geary-controller.vala
+++ b/src/client/application/geary-controller.vala
@@ -174,10 +174,14 @@ public class GearyController : Geary.BaseObject {
* Starts the controller and brings up Geary.
*/
public async void open_async() {
- // This initializes the IconFactory, important to do before the actions are created (as they
- // refer to some of Geary's custom icons)
+ // This initializes the IconFactory, important to do before
+ // the actions are created (as they refer to some of Geary's
+ // custom icons)
IconFactory.instance.init();
-
+
+ // Ensure all geary windows have an icon
+ Gtk.Window.set_default_icon_name("geary");
+
// Setup actions.
setup_actions();
GearyApplication.instance.load_ui_resource("accelerators.ui");
@@ -1709,6 +1713,7 @@ public class GearyController : Geary.BaseObject {
"authors", GearyApplication.AUTHORS,
"copyright", GearyApplication.COPYRIGHT,
"license-type", Gtk.License.LGPL_2_1,
+ "logo-icon-name", "geary",
"version", GearyApplication.VERSION,
"website", GearyApplication.WEBSITE,
"website-label", GearyApplication.WEBSITE_LABEL,
@@ -1718,7 +1723,7 @@ public class GearyController : Geary.BaseObject {
"translator-credits", _("translator-credits")
);
}
-
+
private void on_donate() {
try {
Gtk.show_uri(null, GearyApplication.DONATE, Gdk.CURRENT_TIME);
diff --git a/src/client/components/icon-factory.vala b/src/client/components/icon-factory.vala
index 1dd53d4..9505e57 100644
--- a/src/client/components/icon-factory.vala
+++ b/src/client/components/icon-factory.vala
@@ -20,10 +20,7 @@ public class IconFactory {
private set { _instance = value; }
}
-
- public const int APPLICATION_ICON_SIZE = 128;
- public Gdk.Pixbuf application_icon { get; private set; }
-
+
public const int UNREAD_ICON_SIZE = 16;
public const int STAR_ICON_SIZE = 16;
@@ -33,19 +30,11 @@ public class IconFactory {
// 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");
- append_icons_search_path("48x48");
- append_icons_search_path("24x24");
- append_icons_search_path("16x16");
-
- // Load icons here.
- application_icon = load("geary", APPLICATION_ICON_SIZE);
+ icon_theme = Gtk.IconTheme.get_default();
+ icon_theme.append_search_path(icons_dir.get_path());
}
-
+
public void init() {
// perform any additional initialization here; at this time, everything is done in the
// constructor
@@ -79,32 +68,7 @@ public class IconFactory {
return new FileIcon(icon_file);
}
-
- private void append_icons_search_path(string? name) {
- if (Geary.String.is_empty(name))
- icon_theme.append_search_path(icons_dir.get_path());
- else
- 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) {
- // Try looking up IconInfo (to report path in case of error) then load image
- Gtk.IconInfo? icon_info = icon_theme.lookup_icon(icon_name, size, flags);
- if (icon_info != null) {
- try {
- return icon_info.load_icon();
- } catch (Error err) {
- warning("Couldn't load icon %s at %s, falling back to image-missing: %s", icon_name,
- icon_info.get_filename(), err.message);
- }
- } else {
- debug("Unable to lookup icon %s, falling back to image-missing...", icon_name);
- }
-
- // Default: missing image icon.
- return get_missing_icon(size, flags);
- }
-
+
// Attempts to load and return the missing image icon.
private Gdk.Pixbuf? get_missing_icon(int size, Gtk.IconLookupFlags flags = 0) {
try {
diff --git a/src/client/components/main-window.vala b/src/client/components/main-window.vala
index 3fb763a..d92bc27 100644
--- a/src/client/components/main-window.vala
+++ b/src/client/components/main-window.vala
@@ -63,14 +63,7 @@ public class MainWindow : Gtk.ApplicationWindow {
spinner.set_progress_monitor(progress_monitor);
progress_monitor.add(conversation_list_store.preview_monitor);
-
- GLib.List<Gdk.Pixbuf> pixbuf_list = new GLib.List<Gdk.Pixbuf>();
- pixbuf_list.append(IconFactory.instance.application_icon);
- // Use copy() because set_default_icon_list() actually accepts an owned reference
- // If we didn't hold the pixbufs in memory, would need to use copy_deep()
- // See https://mail.gnome.org/archives/vala-list/2014-August/msg00022.html
- set_default_icon_list(pixbuf_list.copy());
-
+
delete_event.connect(on_delete_event);
key_press_event.connect(on_key_press_event);
key_release_event.connect(on_key_release_event);
diff --git a/src/client/notification/libnotify.vala b/src/client/notification/libnotify.vala
index 212fb94..97fb517 100644
--- a/src/client/notification/libnotify.vala
+++ b/src/client/notification/libnotify.vala
@@ -196,11 +196,10 @@ public class Libnotify : Geary.BaseObject {
// but it means in the future, a more robust system will be needed.)
if (error_notification != null)
return;
-
- error_notification = issue_notification("email", summary, body,
- IconFactory.instance.application_icon, null);
+
+ error_notification = issue_notification("email", summary, body, null, null);
}
-
+
public void clear_error_notification() {
if (error_notification != null) {
try {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]