Re: How to "extend" a widget?
- From: Michael Cronenworth <mike cchtml com>
- To: gtk-app-devel-list gnome org
- Subject: Re: How to "extend" a widget?
- Date: Fri, 16 Dec 2011 16:37:35 -0600
jjacky wrote:
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.
Your composite widget project is similar to mine. I created a custom
widget that is a text input combo box that if you click on the drop down
button it displays a GtkCalendar. You can type in the date (in any
format) and it will select the date in the GtkCalendar widget.
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.
You can certainly modify their behaviors. I catch and call signals that
you normally wouldn't in order to parse and display the correct date
format and positioning of the GtkCalendar widget.
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.
If signal catching/calling are not enough then you might be best off
creating a brand new widget. It seems you want to change the drawing of
the GtkCalendar widget so you are on the right track of creating your
own widget.
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?
I'll admit I hadn't looked at your example the first go around. If you
wish to customize the positioning, coloring, and text of each day then
you must create your own widget. However, if all you want is to color
the current day, then I think there already exist ways to do this
without having to create a whole new widget. First, you have to set the
day, and second you can theme it as you are trying to do already.
Setting the day alone will color the current day. Is that all you want?
In regards to your second question: As long as you are not modifying
your system's GTK libraries you will not have problems in the future.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]