Gnome2::DateEdit cant turn off time section

View: New views
4 Messages — Rating Filter:   Alert me  

Gnome2::DateEdit cant turn off time section

by Mitchell Laks-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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);
$gui->signal_autoconnect_from_package('main');


$window->show_all();

Gtk2->main;

sub on_window1_delete_event {

Gtk2->main_quit;
}

*********************
this did not work, it still displayed the time:

So I did an explicit construction from scratch:

#! /usr/bin/perl -w

use strict;
use Gtk2 '-init';
use Glib qw/TRUE FALSE/;
use Gnome2;

#standard window creation, placement, and signal connecting
my $window = Gtk2::Window->new('toplevel');
$window->signal_connect('delete_event' => sub { Gtk2->main_quit; });
$window->set_border_width(5);
$window->set_position('center_always');


my $dateedit =Gnome2::DateEdit->new(0,0,0);
my $scalar = $dateedit->get_flags;
print "my scalar is $scalar \n";
$window->add($dateedit);
$window->show_all();
Gtk2->main();

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

notice I set the flag to 0.

This also displays the time.
It seems to ignore the flag about showing time!
Why?

How do I stop time :)?

Thanks for all your wonderful work and help !,

Mitchell
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: Gnome2::DateEdit cant turn off time section

by muppet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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


_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: Gnome2::DateEdit cant turn off time section

by Mitchell Laks-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 22:37 Sun 27 Jan     , muppet wrote:

>
> 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



Dear Muppet,

Thank you very much for your very clear and informative message.
Indeed setting the function
set_no_show_all(1);

(or with use Glib qw(TRUE FALSE);  set_no_show_all(TRUE)

works perfectly.

I also noticed that glade-3 comes to the rescue!!!
Even if GnomeDateEdit is broken.

Within the "Common"properties tab of glade-3 there is a "No show all"
choice.
Thus if I select that, then indeed it does not show the time section!!!!!!
Yay!!!

Now as you mention, I do not understand the flags bit at all.

In my direct trial

my $dateedit =Gnome2::DateEdit->new(0,0,0);
my $scalar = $dateedit->get_flags;
print "my scalar is $scalar \n";

I got printed out to console:

my scalar is [  ]

which is cute, but certaily cryptic to me :(.

So do you simply put an anonymous array reference [] with the selected
flags, sort of like
[ flag1, flag2, flag3 ] ie like ['show-time','24-hr','week-starts-on-monday']
turns them on and [] alone will turn them off?

(question to self: What is the corresponding structure of this in Gtk+)


Can you point out to me where flags are talked about in
/gtk2-perl/Gtk+/
documentation.

This business with enums/properties/flags is not fully clear in my mind.
In my first app last week  I was able to figure out how to use

set_property. Thus:

$renderer->set_property('width-chars',95);
$renderer->set_property('wrap-width',780)
$renderer->set_property('wrap-mode','word');

or
$renderer1->set_property('xalign',1.0);
$renderer1->set_property('width-chars',1);
$renderer1->set_property('wrap-width',20);


after I was able to find in different Gtk documents the list of properties
of the CellRendererText

I had more trouble for instance, sort of winging it with


my $tree_store = Gtk2::TreeStore->new(qw/Glib::String Glib::String Glib::String Glib::Int /);

where I was putting an integer into the fourth column of the tree store.
Thus what would i use for float or doubles if I wanted to store them in
the table? The Gtk2::TreeStore documentation is cryptic on this.


Thus in general Where to get a list of acceptable entries for a 'thing'.

I saw code in the beautiful gtk2-study book that uses
 

       foreach my $s_type (Glib::Type->list_values ('Gtk2::SelectionMode')){

                $cmb_box->append_text($s_type->{'nick'});

to full a combobox with the nicknames of the types, which I thought very
clever, and I use this method to print out info to console too while debugging.


So to illustrate my ignorance.

For instance for TreeStore the pod says

treestore = Gtk2::TreeStore->new (...)
    *
      ... (list) of strings, package names

which is cryptic to me.

So I go elsewhere
So I am puzzled. Now I recall from reading the treeview tutorial
http://scentric.net/tutorial/

qw(

The GLib type system (GType) is used to indicate what type of data is stored in a model column. These are the most commonly used types:

    *

      G_TYPE_BOOLEAN
    *

      G_TYPE_INT, G_TYPE_UINT
    *

      G_TYPE_LONG, G_TYPE_ULONG, G_TYPE_INT64, G_TYPE_UINT64 (these are not supported in early gtk+-2.0.x versions)
    *

      G_TYPE_FLOAT, G_TYPE_DOUBLE
    *

      G_TYPE_STRING - stores a string in the store (makes a copy of the original string)
    *

      G_TYPE_POINTER - stores a pointer value (does not copy any data into the store, just stores the pointer value!)
    *

      GDK_TYPE_PIXBUF - stores a GdkPixbuf in the store (increases the pixbuf's refcount, see below)

)

and I guess for Gtk2 we convert those to Glib::Float for floats.

(could we also keep it as G_TYPE_FLOAT in case we are using perl to
prototype a future gtkmm  app (for other people to implement :))
and keep ourselves sane?)

So I guess "is there a way to extract this info directly from within the
gtk-perl so we can 'print out all the possible good values'".

Another thing would be for a widget we can call set_property up the hierarchy,
it is nice to use things like
Appendix A of "Foundations of Gtk+ development" by  A Krause
which I found in the library this week,
which gives a nice list of properties for each GObject.

Can information like this be extracted in one place centrally
directly from anything online?

With regard to flags, I point out that Krause does not even have a
entry in the index for flags.

With regards to enums and flags I see different widgets in the
pod have listings
for example for TextIter

# ENUMS AND FLAGS

    * flags Gtk2::TextSearchFlags


flags Gtk2::TextSearchFlags

    *

      'visible-only' / 'GTK_TEXT_SEARCH_VISIBLE_ONLY'
    *

      'text-only' / 'GTK_TEXT_SEARCH_TEXT_ONLY'

with the corresponding method:

(match_start, match_end) = $iter->forward_search ($str, $flags, $limit=NULL)

    *

      $str (string)
    *

So is there a rule and
how does one use 'flags', I am getting the idea that they are like
bitfields in c.

Similarly (while I have your attention :) ) for widgets like
ComboBox or scrolledwindow hich have enums like
 
enum Gtk2::ScrollType

    *

      'none' / 'GTK_SCROLL_NONE'
    *

      'jump' / 'GTK_SCROLL_JUMP'
    *

      'step-backward' / 'GTK_SCROLL_STEP_BACKWARD'
    *

      'step-forward' / 'GTK_SCROLL_STEP_FORWARD'
    *

      'page-backward' / 'GTK_SCROLL_PAGE_BACKWARD'
    *

      'page-forward' / 'GTK_SCROLL_PAGE_FORWARD'
    *

      'step-up' / 'GTK_SCROLL_STEP_UP'
    *

      'step-down' / 'GTK_SCROLL_STEP_DOWN'
    *

      'page-up' / 'GTK_SCROLL_PAGE_UP'
    *

      'page-down' / 'GTK_SCROLL_PAGE_DOWN'
    *

      'step-left' / 'GTK_SCROLL_STEP_LEFT'
    *

      'step-right' / 'GTK_SCROLL_STEP_RIGHT'
    *

      'page-left' / 'GTK_SCROLL_PAGE_LEFT'
    *

      'page-right' / 'GTK_SCROLL_PAGE_RIGHT'
    *

      'start' / 'GTK_SCROLL_START'
    *

      'end' / 'GTK_SCROLL_END'

But these are not used in the constructors- rather only in the
signals, so it is clear how to use them.

Similary often the enums such as Gtk2::SelectionMode are used in
set_selection_mode methods, also clear how to use.

2. Even if  pod gives me the enums, I can get it valid values via  
       foreach my $s_type (Glib::Type->list_values ('Gtk2::SelectionMode')){

my $nick = $s_type->{'nick'});
my $name = $s_type->{'name'});

print " my name is $name my nick is $nick \n";
}

3, For flags what would list them? Syntax for using them?
Thus (Using [] will
zero them - Is it simply a anonymous  array reference?)

Thanks,

I hope I have not bothered you too much :(. I am a newbie :).

Mitchell
_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list

Re: Gnome2::DateEdit cant turn off time section

by muppet :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


On Jan 28, 2008, at 3:33 AM, Mitchell Laks wrote:

> Now as you mention, I do not understand the flags bit at all.
>
> In my direct trial
>
> my $dateedit =Gnome2::DateEdit->new(0,0,0);
> my $scalar = $dateedit->get_flags;
> print "my scalar is $scalar \n";
>
> I got printed out to console:
>
> my scalar is [  ]
>
> which is cute, but certaily cryptic to me :(.
>
> So do you simply put an anonymous array reference [] with the selected
> flags, sort of like
> [ flag1, flag2, flag3 ] ie like ['show-time','24-hr','week-starts-on-
> monday']
> turns them on and [] alone will turn them off?
>
> (question to self: What is the corresponding structure of this in Gtk
> +)
>
>
> Can you point out to me where flags are talked about in
> /gtk2-perl/Gtk+/
> documentation.

Flags are C bitfields.  Perl handles them differently.

http://gtk2-perl.sourceforge.net/doc/pod/Glib.html#This_Is_Now_That
http://gtk2-perl.sourceforge.net/doc/pod/Gtk2/api.html#Flags_and_Enums


> This business with enums/properties/flags is not fully clear in my  
> mind.

Properties are a different beast.  Do not confuse them with flags or  
enums.


> I had more trouble for instance, sort of winging it with
>
> my $tree_store = Gtk2::TreeStore->new(qw/Glib::String Glib::String  
> Glib::String Glib::Int /);
>
> where I was putting an integer into the fourth column of the tree  
> store.
> Thus what would i use for float or doubles if I wanted to store them  
> in
> the table?

Again, the "This is now that" section (http://gtk2-perl.sourceforge.net/doc/pod/Glib.html#This_Is_Now_That 
) lists the package names corresponding to the GLib fundamental  
types.  They're designed to be easily guessable --- double is  
Glib::Double, for example.


> So to illustrate my ignorance.
>
> For instance for TreeStore the pod says
>
> treestore = Gtk2::TreeStore->new (...)
>    *
>      ... (list) of strings, package names
>
> which is cryptic to me.

The strings are the names of the packages corresponding to the column  
types.

It's important to understand that the API reference docs are generated  
by parsing the bindings' code, and exist primarily to serve as a guide  
to how to call the methods in Perl code.  Since our team has always  
been small, we have not attempted to duplicate all the documentation  
effort from gtk+.

You could argue that specific points like this need more documentation  
than most others, and you'd be right.  However, it's simply an issue  
of how much time a person has.



> (could we also keep it as G_TYPE_FLOAT in case we are using perl to
> prototype a future gtkmm  app (for other people to implement :))
> and keep ourselves sane?)

We go out of our way to hide the concept of GType from perl code, so  
this is unlikely to happen.  The Perl package names make a direct  
analogue.


> So I guess "is there a way to extract this info directly from within  
> the
> gtk-perl so we can 'print out all the possible good values'".

There is no way to extract all possible values for a column type, as  
types are dynamically registrable.

If you put in an invalid value for an enumeration or flag type, you'll  
already get a listing of valid values.


> Can information like this be extracted in one place centrally
> directly from anything online?

http://gtk2-perl.sourceforge.net/doc/pod/Glib/Object.html#list_object_or_class

Long ago i wrote an interactive object browser, which will list the  
properties for you.

http://asofyet.org/muppet/software/gtk2-perl/object_browser-methodscraper


> With regards to enums and flags I see different widgets in the
> pod have listings

Gtk2 has a single page that lists all the values of all the enums and  
flags types in Gtk2 itself -- Gtk2::enums -- and each autogenerated  
POD page attempts to list the enum and flags types used by the methods  
listed in that page (it sometimes misses).


> 3, For flags what would list them? Syntax for using them?
> Thus (Using [] will
> zero them - Is it simply a anonymous  array reference?)

Glib::Type->list_values() does a fine job here, too.  But still, see  
the Gtk2::enums manpage.




--
The Master in the art of living makes little distinction between his  
work and his play, his labor and his leisure, his mind and his body,  
his education and his recreation, his love and his religion. He hardly  
knows which is which. He simply pursues his vision of excellence in  
whatever he does, leaving others to decide whether he is working or  
playing. To him he is always doing both.

   -- Zen Philosophy



_______________________________________________
gtk-perl-list mailing list
gtk-perl-list@...
http://mail.gnome.org/mailman/listinfo/gtk-perl-list