Re[2]: [PHP-GTK-DEV] Overrides for GtkUIManager and GtkCalendar
| From: | Tom Rogers | Date: | Mon, 19 Dec 2005 02:07:12 +0000 |
| Subject: | Re[2]: [PHP-GTK-DEV] Overrides for GtkUIManager and GtkCalendar | ||
| References: | 1 2 | Groups: | php.gtk.dev |
| Request: | Send a blank email to php-gtk-dev+get-2128@lists.php.net to get a copy of this message | ||
Hi,
Sunday, December 18, 2005, 6:07:56 AM, you wrote:
SF> Tom, hi,
SF> Would you mind putting short test scripts in with your patches? It takes
SF> much longer to review things like this when I'm having to look through
SF> sources to figure out what the expected behaviour is and how to reproduce it
SF> via PHP... and I'd guess you tested it already, no?
SF> I'm really not sure about the date addition. I can see where you're coming
SF> from with the idea but it's a diversion from the target of language
SF> binding... and it's pretty trivial to produce that kind of a string from the
SF> data already available in GTK, with userland PHP code.
SF> Andrei, anyone - any strong feelings about it, either way?
SF> - Steph
Here is the test code I used.
Returning a full date is more useful I think in most cases and as the
function return is different to the Gtk call anyway it seemed a very
simple addition. It replaces:
$date = $calendar->get_date();
$selected_date = $date[0].'-'.($date[1]+1).'-'.$date[3]; //messy :)
Anyway test code:
<?php
class window extends GtkWindow {
function __construct() {
parent::__construct();
$this->connect_simple('destroy', array('gtk', 'main_quit'));
$this->set_title('Notebook Demos');
$this->set_default_size(500, 400);
$hbox = new GtkHBox(false, 3);
$this->add($hbox);
$calendar = new GtkCalendar();
$hbox->pack_start($calendar, true);
/* create a new style for the calendar, based on the old one */
$oldstyle = $calendar->style;
$newstyle = $oldstyle->copy();
//$font = gdk::font_load('-unknown-Arial-normal-r-normal--*-160-*-*-p-0-iso8859-1');
$red = &new GdkColor(255*255, 0, 0);
//$newstyle->font = $font;
$newstyle->fg[Gtk::STATE_SELECTED] = $red;
$calendar->set_style($newstyle);
/* have today's date highlighted on opening */
$calendar->select_day(date('d'));
$r = $calendar->get_date();
print_r($r);
$this->show_all();
}
}
new window();
gtk::main();
--
regards,
Tom