Re: How to "extend" a widget?
- From: jjacky <i am jack mail gmail com>
- To: gtk-app-devel-list gnome org
- Subject: Re: How to "extend" a widget?
- Date: Fri, 16 Dec 2011 23:18:53 +0100
Right, thanks. Alright so using "extend" might not have been the right
term (probably comes because I've done some PHP and have been influenced
by that), sorry.
Oh, and I've used the term "composite widget" simply because I read it
here, and assumed it was how such widgets were called:
http://developer.gnome.org/gtk-tutorial/stable/x2200.html
Anyways, I don't have a problem with creating a new (shell/composite)
widget using another one inside of it, it's actually exactly what I did
in my example: created a widget JjkCalendar which contains a GtkCalendar.
It's just that I felt (from tutorials and such I read) that such
(composite) widgets were only using widgets they contain and "combining"
them together, rather than modifying their behaviors.
I guess my question is more: how do I affect this widget's internal
behavior? how do I add a new feature (which might imply alter current
way to draw the widget) ?
That is, do something not really supported/planned by the widget's
public API.
Like I said, in the example code I posted, in order to do that, and
alter GtkCalendar's behavior, I needed to redefine GtkCalendarPrivate in
my widget, so that I could change values contained the GtkCalendar's
private struct. Also had to copy/paste a few functions as well -- is
that okay, or will it lead to problems? And if so, what's the right way
to do it then?
-jacky
On 12/16/2011 11:03 PM, Michael Cronenworth wrote:
jacky wrote:
What I was looking into would be more taking an existing widget, and
modifying it a little, as in changing its behavior on some aspect, or
adding a feature, something like that.
My question is: what would be the best/standard/recommanded way to do
such a thing?
Widgets are not plugins. They are whole objects. There is no extensible
feature to them.
You will have two choices:
1. Copy an entire GTK widget and give it a unique name.
Example: GtkButton becomes GtkMyButton
2. Create a shell widget that uses existing GTK widgets inside of it to
do what you want. In the event you need to touch the GTK widgets inside,
you can make your new widget a simple struct and have pointers to the
interior GTK widgets.
I would suggest number 2, unless you are doing something very radical.
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]