diff options
author | Jasper St. Pierre <jstpierre@mecheye.net> | 2014-12-31 20:48:26 -0800 |
---|---|---|
committer | Alberts Muktupāvels <alberts.muktupavels@gmail.com> | 2015-01-07 13:24:46 +0200 |
commit | d896d5be1f4f4763bb7e764fb7bc1de3f8136dba (patch) | |
tree | c92785b8f4ba8b0c360e21a6ae675f2873015984 /src | |
parent | 7ad98683faca4f6691133aee0d848516bea8a81b (diff) | |
download | metacity-d896d5be1f4f4763bb7e764fb7bc1de3f8136dba.tar.gz |
ui: Refactor the default image lookup
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/ui.c | 56 |
1 files changed, 16 insertions, 40 deletions
diff --git a/src/ui/ui.c b/src/ui/ui.c index 1c777180..5cb8e24f 100644 --- a/src/ui/ui.c +++ b/src/ui/ui.c @@ -574,6 +574,20 @@ meta_ui_pop_delay_exposes (MetaUI *ui) meta_frames_pop_delay_exposes (ui->frames); } +static GdkPixbuf * +load_default_window_icon (int size) +{ + GtkIconTheme *theme = gtk_icon_theme_get_default (); + const char *icon_name; + + if (gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME)) + icon_name = META_DEFAULT_ICON_NAME; + else + icon_name = "image-missing"; + + return gtk_icon_theme_load_icon (theme, icon_name, size, 0, NULL); +} + GdkPixbuf* meta_ui_get_default_window_icon (MetaUI *ui) { @@ -581,26 +595,7 @@ meta_ui_get_default_window_icon (MetaUI *ui) if (default_icon == NULL) { - GtkIconTheme *theme; - gboolean icon_exists; - - theme = gtk_icon_theme_get_default (); - - icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME); - - if (icon_exists) - default_icon = gtk_icon_theme_load_icon (theme, - META_DEFAULT_ICON_NAME, - META_ICON_WIDTH, - 0, - NULL); - else - default_icon = gtk_icon_theme_load_icon (theme, - "image-missing", - META_ICON_WIDTH, - 0, - NULL); - + default_icon = load_default_window_icon (META_ICON_WIDTH); g_assert (default_icon); } @@ -616,26 +611,7 @@ meta_ui_get_default_mini_icon (MetaUI *ui) if (default_icon == NULL) { - GtkIconTheme *theme; - gboolean icon_exists; - - theme = gtk_icon_theme_get_default (); - - icon_exists = gtk_icon_theme_has_icon (theme, META_DEFAULT_ICON_NAME); - - if (icon_exists) - default_icon = gtk_icon_theme_load_icon (theme, - META_DEFAULT_ICON_NAME, - META_MINI_ICON_WIDTH, - 0, - NULL); - else - default_icon = gtk_icon_theme_load_icon (theme, - "image-missing", - META_MINI_ICON_WIDTH, - 0, - NULL); - + default_icon = load_default_window_icon (META_MINI_ICON_WIDTH); g_assert (default_icon); } |