Re: Gnome2::DateEdit cant turn off time section




On Jan 27, 2008, at 1:21 PM, Mitchell Laks wrote:

Hi,

The Gome2::DateEdit widget has two sections, date and time. For my application the only relevant issue is the date. I don't want to display the time as it is not relevant
and will confuse the users.

I noticed that when I set up a gui with glade-3 and succeeded in turning off the time section however when I invoked it with my gtk2-perl driver it stil displayed the time.

So, I said, maybe a bug in gtk2-perl, well let me shut downt the time section with an explicit
flag after display. Thus I tried:

***********************

#!/usr/bin/perl -w
use strict;
use Gtk2 '-init';
use Gtk2::GladeXML;

my $gui=Gtk2::GladeXML->new('mefilm2.glade');
my $window = $gui->get_widget('window1');

my $dateedit=$gui->get_widget('gnomedateedit1');
$dateedit->set_flags('show-time',0);

I created a simple glade file with only a DateEdit in it, with the show-time flag turned off, and your script fails with

        Usage: Gnome2::DateEdit::set_flags(gde, flags) at mltime.pl line 12.

This is an actual bug in your code.  You have

        $dateedit->set_flags ('show-time', 0);

but the proper signature is Gnome2::DateEdit::set_flags(gde, flags), where flags is a Gnome2::DateEditFlags enumeration value. I think what you want to pass here is the empty flagset "[]", since you want none of those options, only the date.

$dateedit->set_flags ([]);

However, that still doesn't give me a window with only the date, because...

$gui->signal_autoconnect_from_package('main');


$window->show_all();

gtk_widget_show_all() shows the widget and all its children. Widget implementations can opt out of this by setting the flag "no-show-all" or overriding the show_all vfunc.

It looks like most compound widgets in gtk+ (that is, the widgets made up of other widgets) set this flag on themselves, and therefore retain control over which children are shown or hidden.

But GnomeDateEdit does not.  Naughty GnomeDateEdit.

So, you create the widget in glade with the show-time flag turned off, and the time widgets do not get gtk_widget_show()n. But when you do $window->show_all(), gtk+ dutifully walks down the widget tree and shows the DateEdit's time widgets.

Fail.

Now, GnomeDateEdit is part of libgnomeui, and many efforts of the gtk+ team over the last several years have served the purpose of nuking libgnomeui from orbit. However, GnomeDateEdit remains one of the holdouts that has no direct replacement in gtk+. It is known that GnomeDateEdit's flags-based API sucks (http://bugzilla.gnome.org/show_bug.cgi?id=52372 ), and EggDateTime, in libegg (http://svn.gnome.org/viewvc/libegg/trunk/libegg/datetime/ ), seems like a decent replacement, but there is no binding for it, nor reliable distribution. So, you're stuck with Gnome2::DateEdit.

There are two basic ways to make this work in your script:

a. Don't call show_all() on the toplevel window containing the DateEdit widget

OR

b. Call $dateedit->set_no_show_all(TRUE) before your call to show_all() on the toplevel window containing the DateEdit widget.


I'd opt for b, since it's really GnomeDateEdit that's broken here, not you.


--
Doing a good job around here is like wetting your pants in a dark suit; you get a warm feeling, but no one notices.
  -- unknown





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]