Active Topics

 


Reply
Thread Tools
Posts: 27 | Thanked: 37 times | Joined on Jan 2012
#1
Hi,

I'm having trouble writing a hildonised GTK interface that fully supports autorotation. The attached example code demonstrates my issue. When testing on my device (with CSSU-testing) the application window opens in portrait or landscape mode depending on the device's orientation, and updates its orientation as expected. I expected dialogs in the application to follow the window orientation. However, when a dialog is opened (from the menu) while in portrait mode, the orientation changes to landscape. On dismissing the dialog, the window autorotates back (depending on current orientation).

If I set HILDON_PORTRAIT_MODE_REQUEST on the window (instead of _SUPPORT) the window always opens in portrait mode, but the dialog still reorients to landscape.

I understood that setting the dialog as task modal should result in the portrait flags being inherited from the window. Doubting this, I tried setting the flags directly on the dialog. Setting _SUPPORT on the dialog as well as the window has no effect. If the window has _REQUEST set and the dialog has _SUPPORT then the dialog does open in portrait mode, but the application is now portrait only.

Can anyone point out what I'm missing here?

Thanks.

Code:
/*
 * file based on hildon examples
 */
#include <gtk/gtk.h>
#include <hildon/hildon.h>

static void test_dialog(gpointer data)
{
    GtkWidget *win = (GtkWidget *)data;
    HildonDialog *d;
    
    d = HILDON_DIALOG (hildon_dialog_new ());
    gtk_window_set_modal(GTK_WINDOW(d), TRUE);
    gtk_window_set_transient_for(GTK_WINDOW(d), GTK_WINDOW(win));
    /*hildon_gtk_window_set_portrait_flags(GTK_WINDOW(d), HILDON_PORTRAIT_MODE_SUPPORT);*/
    
    gtk_window_set_title (GTK_WINDOW (d), "Hi!");
    hildon_dialog_add_button (HILDON_DIALOG (d), GTK_STOCK_OK, GTK_RESPONSE_NONE);

    gtk_widget_show_all (GTK_WIDGET (d));
}

static HildonAppMenu *
create_menu ()
{
    GtkWidget *button;
    HildonAppMenu *menu = HILDON_APP_MENU (hildon_app_menu_new ());

    button = hildon_gtk_button_new(HILDON_SIZE_AUTO);
    gtk_button_set_label (GTK_BUTTON (button), "Open dialog");
    g_signal_connect_after (button, "clicked", G_CALLBACK (test_dialog), NULL);
    hildon_app_menu_append (menu, GTK_BUTTON (button));

    gtk_widget_show_all (GTK_WIDGET (menu));

    return menu;
}

int main (int argc, char **argv)
{
    GtkWidget *win;
    HildonAppMenu *menu;

    hildon_gtk_init (&argc, &argv);

    win = hildon_stackable_window_new ();
    hildon_gtk_window_set_portrait_flags(GTK_WINDOW(win), HILDON_PORTRAIT_MODE_SUPPORT);

    menu = create_menu ();
    hildon_window_set_app_menu (HILDON_WINDOW (win), menu);

    g_signal_connect (win, "delete_event", G_CALLBACK (gtk_main_quit), NULL);

    gtk_widget_show_all (win);

    gtk_main ();

    return 0;
}
 
Reply


 
Forum Jump


All times are GMT. The time now is 08:28.