Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

library: Add Avatar entry #197

Merged
merged 9 commits into from Mar 6, 2023
Merged

Conversation

AkshayWarrier
Copy link
Contributor

@AkshayWarrier AkshayWarrier commented Feb 24, 2023

I have kept this demo fairly simple now. I wasn't sure if I should show set_custom_image or set_icon_name.

Relates to issue workbenchdev/demos#3

Copy link
Contributor

@sonnyp sonnyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start, thanks!

There are 3 “main” modes for avatar, see below for what I mean. Feel free to use as is.

The "Image…" button should let the user select a file. I'll let you figure this out but feel free to ask in the room if you struggle.

We should go with the simplest file chooser API. I'd suggest using https://docs.gtk.org/gtk4/class.FileDialog.html

It's brand new and will only be available in the next GNOME platform release but that doesn't mean we can't use it already.

You will need to set "runtime-version": "master", in re.sonny.Workbench.Devel.json to make use of it.

using Gtk 4.0;
using Adw 1;

Adw.StatusPage {
  title: "Avatar";
  description: "Display a round avatar for image or initials.";

  Box {
    orientation: vertical;
    halign: center;
    
    Adw.Avatar {
      size: 96;
      show-initials: true;
      text: "John Doe";
      margin-bottom: 6;
    }
    
    Label {
      label: "Initials";
      margin-bottom: 30;
    }
    
    Adw.Avatar {
      size: 96;
      margin-bottom:6;
    }
    
    Button {
      label: "Image…";
      margin-bottom: 30;
      styles ["pill"]
    }
    
    Adw.Avatar {
      size:96;
      margin-bottom:6;
    }
    
    Label {
      label: "Fallback";
      margin-bottom: 30;
    }


    LinkButton {
      label: "API Reference";
      uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/1.2/class.Avatar.html";
    }
  }
}

src/Library/demos/Avatar/main.blp Outdated Show resolved Hide resolved
src/Library/demos/Avatar/main.json Outdated Show resolved Hide resolved
src/Library/demos/Avatar/main.json Outdated Show resolved Hide resolved
src/app.gresource.xml Outdated Show resolved Hide resolved
src/Library/demos/Avatar/main.blp Outdated Show resolved Hide resolved
src/Library/demos/Avatar/main.blp Outdated Show resolved Hide resolved
@AkshayWarrier
Copy link
Contributor Author

Thank you so much for the detailed review! I'll get back to you with the changes as quickly as possible.

@sonnyp sonnyp changed the title Add AdwAvatar demo library: Add Avatar entry Feb 28, 2023
Copy link
Contributor

@sonnyp sonnyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

const dialog = new Gtk.FileDialog();

const filter = new Gtk.FileFilter();
filter.name = "Image files";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the filter name doesn't seem to work – this is what I see in the bottom right of the dialog

image

could you look into it?

try

new Gtk.FileFilter({
  name: "something"
})

also "Images" is fine - no need to be overly specific

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Gtk.FileFilter({
  name: "something"
})

This does not seem to solve the issue. I'll still just leave it in, if it gets fixed in the future.

src/Library/demos/Avatar/main.js Show resolved Hide resolved
src/Library/demos/Avatar/main.js Outdated Show resolved Hide resolved
src/Library/demos/Avatar/main.js Outdated Show resolved Hide resolved
src/Library/demos/Avatar/main.js Outdated Show resolved Hide resolved
Copy link
Contributor

@sonnyp sonnyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done.

I have made minor changes before merging 5c14700

@sonnyp sonnyp merged commit 36d17cc into workbenchdev:main Mar 6, 2023
sonnyp pushed a commit to SoNiC-HeRE/Workbench that referenced this pull request Mar 13, 2023
@AkshayWarrier AkshayWarrier deleted the add-avatar-demo branch March 15, 2023 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants