xverizex / RetroSpriteEditor

The drawing tool for retro consoles
GNU General Public License v3.0
8 stars 1 forks source link

[Feature Request] Use AdwMessageDialog for 'New NES Project' Dialog #4

Closed sungsphinx closed 10 months ago

sungsphinx commented 10 months ago

AdwMessageDialog Docs

Currently, the dialog looks pretty weird and clunky: New NES Project Dialog

The furthest I have got with AdwMessageDialog is: AdwMessageDialog

Code to show a basic AdwMessageDialog in main-window.c:

static void
action_new_project_nes (GSimpleAction *simple,
        GVariant *parameter,
        gpointer user_data)
{
    MainWindow *self = MAIN_WINDOW (user_data);
    GtkWidget *dialog;
    //gtk_window_set_transient_for (GTK_WINDOW (self->new_project_nes_window), GTK_WINDOW(self));
    //gtk_window_present (GTK_WINDOW (self->new_project_nes_window));

    const char *heading = "New NES Project";
    const char *body = "Body Text";

    dialog = adw_message_dialog_new (GTK_WINDOW(self), heading, body);
    adw_message_dialog_add_responses (ADW_MESSAGE_DIALOG (dialog),
                                          "cancel", ("Cancel"),
                                          "create", ("Create"),
                                          NULL);
    adw_message_dialog_set_response_appearance (ADW_MESSAGE_DIALOG (dialog), "cancel", ADW_RESPONSE_DESTRUCTIVE);
    //g_signal_connect (dialog, "response", G_CALLBACK (cool_epic_function_here), self);
    gtk_window_present (GTK_WINDOW (dialog));
}

You could use the AdwMessageDialog extra-child property to add things like text boxes, etc.

Also, setting the dialog window as transient / showing over the main window doesn't work: New NES Project Dialog not transient

What it should be like: About Window which is transient

It should be centered, move the main window with the dialog & not let you focus the main window while the dialog open.

xverizex commented 10 months ago

This is cool! This is fits!

sungsphinx commented 10 months ago

If the dialog has not been set as transient for the main window automatically, you could try:

gtk_window_set_transient_for (GTK_WINDOW (dialog_window_here), GTK_WINDOW(application_window_here));
xverizex commented 10 months ago

So, have you them doing? Or I will make this feature?

sungsphinx commented 10 months ago

I am not sure how to implement the functionality or extra-child stuff, so probably not, maybe you could? (obviously no rush of course)

xverizex commented 10 months ago

Of course. I'll take care of it.

sungsphinx commented 10 months ago

Of course. I'll take care of it.

Thanks :+1:

sungsphinx commented 10 months ago

Didn't realise that's how you do it, still learning I guess 😅

xverizex commented 10 months ago

With GTK I work not often, but this fix does the problem. I think the window with parameters is don't dialog in the usual sense. And https://docs.gtk.org/gtk4/class.Dialog.html the dialog is deprecated. I decided leave it as it is and add only modal.

xverizex commented 10 months ago

Yes, I know that adw dialog is available, but why the fix window to add dialog if this look identically.