Re: Gnome2::DateEdit cant turn off time section
- From: Mitchell Laks <mlaks post harvard edu>
- To: gtk-perl-list gnome org
- Subject: Re: Gnome2::DateEdit cant turn off time section
- Date: Mon, 28 Jan 2008 03:33:01 -0500
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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]