All of lore.kernel.org
 help / color / mirror / Atom feed
From: Programmingkid <programmingkidx@gmail.com>
To: Akihiko Odaki <akihiko.odaki@gmail.com>
Cc: Peter Maydell <peter.maydell@linaro.org>,
	Jason Wang <jasowang@redhat.com>,
	QEMU devel list <qemu-devel@nongnu.org>,
	Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [PATCH 3/4] ui/icons: Use bundle mechanism
Date: Fri, 9 Jul 2021 22:48:12 -0400	[thread overview]
Message-ID: <202D0876-4A6E-4159-8A42-572DE1FA87AF@gmail.com> (raw)
In-Reply-To: <CAMVc7JUSc6qe59TKqyLYRR=s3T3Hf+JVr=UsDNdfsT0DBL8drQ@mail.gmail.com>



> On Jul 8, 2021, at 8:31 PM, Akihiko Odaki <akihiko.odaki@gmail.com> wrote:
> 
> Hi,
> 
> Reverting commit e31746ecf8dd2f25f687c94ac14016a3ba5debfc solves the
> problem only for cocoa and introduces another problem. (For others:
> see https://lore.kernel.org/qemu-devel/797ADA26-0366-447F-85F0-5E27DC534479@gmail.com/
> for the context.)

What is the other problem that reverting the commit causes? 

> The fix for cocoa basically comes for free if you
> fix the problem for other displays, and that's what this patch does.

That may be true but it also introduces the problem of having to keep track of a picture file. With the original code there is no external picture file needed.

> 
> On Fri, Jul 9, 2021 at 3:52 AM Programmingkid <programmingkidx@gmail.com> wrote:
>> 
>> 
>>> On Jul 8, 2021, at 1:25 PM, Akihiko Odaki <akihiko.odaki@gmail.com> wrote:
>>> 
>>> Signed-off-by: Akihiko Odaki <akihiko.odaki@gmail.com>
>>> ---
>>> configure   | 10 ++++++++++
>>> meson.build |  3 +--
>>> ui/cocoa.m  | 20 +++++++++++---------
>>> ui/gtk.c    |  8 +++++---
>>> ui/sdl2.c   | 18 +++++++++++-------
>>> 5 files changed, 38 insertions(+), 21 deletions(-)
>>> 
>>> diff --git a/configure b/configure
>>> index cff5a8ac280..a9f746849ec 100755
>>> --- a/configure
>>> +++ b/configure
>>> @@ -5058,6 +5058,16 @@ for f in $UNLINK ; do
>>>    fi
>>> done
>>> 
>>> +for icon_extension in bmp png ; do
>>> +  for icon_file in $source_path/ui/icons/qemu_*.$icon_extension ; do
>>> +    icon_basename=${icon_file%.$icon_extension}
>>> +    icon_name=${icon_basename#$source_path/ui/icons/qemu_}
>>> +    icon_dir=qemu-bundle/share/icons/hicolor/$icon_name/apps
>>> +    symlink $icon_file $icon_dir/qemu.$icon_extension
>>> +  done
>>> +done
>>> +
>>> +symlink $source_path/ui/icons/qemu.svg qemu-bundle/share/icons/hicolor/scalable/apps/qemu.svg
>>> symlink ../../pc-bios qemu-bundle/share/qemu
>>> 
>>> (for i in $cross_cc_vars; do
>>> diff --git a/meson.build b/meson.build
>>> index 44adc660e23..6d90fe92bf1 100644
>>> --- a/meson.build
>>> +++ b/meson.build
>>> @@ -1200,8 +1200,7 @@ config_host_data.set_quoted('CONFIG_QEMU_CONFDIR', get_option('prefix') / qemu_c
>>> config_host_data.set_quoted('CONFIG_QEMU_BUNDLE_DATADIR', qemu_datadir)
>>> config_host_data.set_quoted('CONFIG_QEMU_DESKTOPDIR', get_option('prefix') / qemu_desktopdir)
>>> config_host_data.set_quoted('CONFIG_QEMU_FIRMWAREPATH', get_option('qemu_firmwarepath'))
>>> -config_host_data.set_quoted('CONFIG_QEMU_HELPERDIR', get_option('prefix') / get_option('libexecdir'))
>>> -config_host_data.set_quoted('CONFIG_QEMU_ICONDIR', get_option('prefix') / qemu_icondir)
>>> +config_host_data.set_quoted('CONFIG_QEMU_BUNDLE_ICONDIR', qemu_icondir)
>>> config_host_data.set_quoted('CONFIG_QEMU_LOCALEDIR', get_option('prefix') / get_option('localedir'))
>>> config_host_data.set_quoted('CONFIG_QEMU_LOCALSTATEDIR', get_option('prefix') / get_option('localstatedir'))
>>> config_host_data.set_quoted('CONFIG_QEMU_MODDIR', get_option('prefix') / qemu_moddir)
>>> diff --git a/ui/cocoa.m b/ui/cocoa.m
>>> index 9f72844b079..d459dfaf595 100644
>>> --- a/ui/cocoa.m
>>> +++ b/ui/cocoa.m
>>> @@ -1477,15 +1477,17 @@ - (void)make_about_window
>>>    NSRect picture_rect = NSMakeRect(x, y, picture_width, picture_height);
>>> 
>>>    /* Make the picture of QEMU */
>>> -    NSImageView *picture_view = [[NSImageView alloc] initWithFrame:
>>> -                                                     picture_rect];
>>> -    char *qemu_image_path_c = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/512x512/apps/qemu.png");
>>> -    NSString *qemu_image_path = [NSString stringWithUTF8String:qemu_image_path_c];
>>> -    g_free(qemu_image_path_c);
>>> -    NSImage *qemu_image = [[NSImage alloc] initWithContentsOfFile:qemu_image_path];
>>> -    [picture_view setImage: qemu_image];
>>> -    [picture_view setImageScaling: NSImageScaleProportionallyUpOrDown];
>>> -    [superView addSubview: picture_view];
>>> +    char *qemu_image_path_c = find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR "/hicolor/512x512/apps/qemu.png");
>>> +    if (qemu_image_path_c) {
>>> +        NSString *qemu_image_path = [NSString stringWithUTF8String:qemu_image_path_c];
>>> +        g_free(qemu_image_path_c);
>>> +        NSImageView *picture_view = [[NSImageView alloc] initWithFrame:
>>> +                                                         picture_rect];
>>> +        NSImage *qemu_image = [[NSImage alloc] initWithContentsOfFile:qemu_image_path];
>>> +        [picture_view setImage: qemu_image];
>>> +        [picture_view setImageScaling: NSImageScaleProportionallyUpOrDown];
>>> +        [superView addSubview: picture_view];
>>> +    }
>>> 
>>>    /* Make the name label */
>>>    NSBundle *bundle = [NSBundle mainBundle];
>>> diff --git a/ui/gtk.c b/ui/gtk.c
>>> index 98046f577b9..e250f9e18a0 100644
>>> --- a/ui/gtk.c
>>> +++ b/ui/gtk.c
>>> @@ -2198,9 +2198,11 @@ static void gtk_display_init(DisplayState *ds, DisplayOptions *opts)
>>>    s->opts = opts;
>>> 
>>>    theme = gtk_icon_theme_get_default();
>>> -    dir = get_relocated_path(CONFIG_QEMU_ICONDIR);
>>> -    gtk_icon_theme_prepend_search_path(theme, dir);
>>> -    g_free(dir);
>>> +    dir = find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR);
>>> +    if (dir) {
>>> +        gtk_icon_theme_prepend_search_path(theme, dir);
>>> +        g_free(dir);
>>> +    }
>>>    g_set_prgname("qemu");
>>> 
>>>    s->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
>>> diff --git a/ui/sdl2.c b/ui/sdl2.c
>>> index a203cb0239e..7b7ed9f9065 100644
>>> --- a/ui/sdl2.c
>>> +++ b/ui/sdl2.c
>>> @@ -877,15 +877,19 @@ static void sdl2_display_init(DisplayState *ds, DisplayOptions *o)
>>>    }
>>> 
>>> #ifdef CONFIG_SDL_IMAGE
>>> -    dir = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/128x128/apps/qemu.png");
>>> -    icon = IMG_Load(dir);
>>> +    dir = find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR "/hicolor/128x128/apps/qemu.png");
>>> +    if (dir) {
>>> +        icon = IMG_Load(dir);
>>> +    }
>>> #else
>>>    /* Load a 32x32x4 image. White pixels are transparent. */
>>> -    dir = get_relocated_path(CONFIG_QEMU_ICONDIR "/hicolor/32x32/apps/qemu.bmp");
>>> -    icon = SDL_LoadBMP(dir);
>>> -    if (icon) {
>>> -        uint32_t colorkey = SDL_MapRGB(icon->format, 255, 255, 255);
>>> -        SDL_SetColorKey(icon, SDL_TRUE, colorkey);
>>> +    dir = find_bundle(CONFIG_QEMU_BUNDLE_ICONDIR "/hicolor/32x32/apps/qemu.bmp");
>>> +    if (dir) {
>>> +        icon = SDL_LoadBMP(dir);
>>> +        if (icon) {
>>> +            uint32_t colorkey = SDL_MapRGB(icon->format, 255, 255, 255);
>>> +            SDL_SetColorKey(icon, SDL_TRUE, colorkey);
>>> +        }
>>>    }
>>> #endif
>>>    g_free(dir);
>>> --
>>> 2.30.1 (Apple Git-130)
>>> 
>> 
>> This is a lot of code for just loading an icon. I think it would be best to simply revert commit e31746ecf8dd2f25f687c94ac14016a3ba5debfc instead.
>> 
>> Thank you.
>> 



  reply	other threads:[~2021-07-10  2:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-08 17:25 [PATCH 1/4] cutils: Introduce bundle mechanism Akihiko Odaki
2021-07-08 17:25 ` [PATCH 2/4] datadir: Use " Akihiko Odaki
2021-07-08 17:25 ` [PATCH 3/4] ui/icons: " Akihiko Odaki
2021-07-08 18:52   ` Programmingkid
2021-07-09  0:31     ` Akihiko Odaki
2021-07-10  2:48       ` Programmingkid [this message]
2021-07-08 17:25 ` [PATCH 4/4] net: " Akihiko Odaki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202D0876-4A6E-4159-8A42-572DE1FA87AF@gmail.com \
    --to=programmingkidx@gmail.com \
    --cc=akihiko.odaki@gmail.com \
    --cc=jasowang@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.