[maemo-developers] Portrait Maemo app
From: David Greaves david at dgreaves.comDate: Thu Jun 12 19:36:02 EEST 2008
- Previous message: Portrait Maemo app
- Next message: Portrait Maemo app
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Dave Neary wrote:
> Hi,
>
> David Greaves wrote:
>> Also, I've just written my first app in gtk/C.
>> After sobbing quietly and trying to avoid getting tears on my N800 I'm looking
>> forward to getting back to Qt!!
>>
>> Apologies to any gtk fans out there - I just have a hard time with all the
>> pointer casting and trying to bludgeon the OO api into C. Qt was so much more
>> elegant.
>>
>> check = (GtkCheckButton*) gtk_check_button_new_with_label("aargh");
>> Since when does a constructor need type casting?
>
> Actually, it (usually) doesn't.
>
> GtkWidget *frame = gtk_frame_new("Checkbox");
> GtkWidget *check = gtk_check_button_new_with_label("aargh");
>
> gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check), TRUE);
> gtk_container_add(GTK_CONTAINER(frame),check);
>
> gtk_widget_show(check);
> gtk_widget_show(frame);
Ta - I hadn't picked up that idiom from the api docs I found.
It does make things a bit better - the principle then becomes to cast the Widget
as far down the tree as you need for any type specific functionality.
So I could call new_checkbox and actually cast to a toggle_button to do toggles.
I think my discomfort comes from the weak run-time type checking and the verbiage...
check.set_active(TRUE);
seems so much less error prone; especially for people who have to pick up this
new toolkit (and that's got to be important for attracting developers to Maemo
and making their early experience pleasant).
I mentioned gtkmm (hopefully not a sensitive topic) a moment ago - what are
peoples thoughts on that?
David
- Previous message: Portrait Maemo app
- Next message: Portrait Maemo app
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
