summaryrefslogtreecommitdiffstats
path: root/perl-install/ugtk2.pm
diff options
context:
space:
mode:
authorThierry Vignaud <tvignaud@mandriva.org>2003-07-14 19:21:17 +0000
committerThierry Vignaud <tvignaud@mandriva.org>2003-07-14 19:21:17 +0000
commit52094cbbfb2a26bbf518e2d2d527aa6ecfaec2e6 (patch)
treef506770fc1a73eb2f851520aa27b7ff9bd61150c /perl-install/ugtk2.pm
parent1a21cac00c1449a159d6ff5bb0d87a305d44b7d2 (diff)
downloaddrakx-52094cbbfb2a26bbf518e2d2d527aa6ecfaec2e6.tar
drakx-52094cbbfb2a26bbf518e2d2d527aa6ecfaec2e6.tar.gz
drakx-52094cbbfb2a26bbf518e2d2d527aa6ecfaec2e6.tar.bz2
drakx-52094cbbfb2a26bbf518e2d2d527aa6ecfaec2e6.tar.xz
drakx-52094cbbfb2a26bbf518e2d2d527aa6ecfaec2e6.zip
for more GUIes coherency, GtkOptionMenu is recommended instead of a combo if
the user is selecting from a fixed set of options. since both GtkCombo and GtkOptionMenu will be deprecated in 2.4.x in favor of much better designed widget (see libegg's combo), we introduce a compatibility layer that makes OptionMenu looks like Combo at API level to minimize changes: - now, when using OptionMenu instead of Combo - when new widget will come to live in gtk+-2.4.x
Diffstat (limited to 'perl-install/ugtk2.pm')
-rw-r--r--perl-install/ugtk2.pm62
1 files changed, 62 insertions, 0 deletions
diff --git a/perl-install/ugtk2.pm b/perl-install/ugtk2.pm
index 4f7cc68b2..acf32e422 100644
--- a/perl-install/ugtk2.pm
+++ b/perl-install/ugtk2.pm
@@ -1309,6 +1309,7 @@ sub ask_browse_tree_info_given_widgets {
$w->{w}->main;
}
+
# misc helpers:
package Gtk2::TreeStore;
@@ -1321,6 +1322,7 @@ sub append_set {
return $iter;
}
+
package Gtk2::ListStore;
# Append a new row, set the values, return the TreeIter
sub append_set {
@@ -1332,6 +1334,7 @@ sub append_set {
return $iter;
}
+
package Gtk2::TreeModel;
# gets the string representation of a TreeIter
sub get_path_str {
@@ -1341,6 +1344,7 @@ sub get_path_str {
$path->to_string;
}
+
package Gtk2::TreeView;
# likewise gtk-1.2 function
sub toggle_expansion {
@@ -1353,12 +1357,70 @@ sub toggle_expansion {
}
+# With GTK+, for more GUIes coherency, GtkOptionMenu is recommended instead of a
+# combo if the user is selecting from a fixed set of options.
+#
+# That is, non-editable combo boxes are not encouraged. GtkOptionMenu is much
+# easier to use than GtkCombo as well. Use GtkCombo only when you need the
+# editable text entry.
+#
+# GtkOptionMenu is a much better-implemented widget and also the right UI for
+# noneditable sets of choices.)
+#
+# GtkCombo isn't deprecated yet in 2.2 but will be in 2.4.x because it still
+# uses deprecated GtkList.
+#
+# A replacement widget for both GtkCombo and GtkOption menu is expected in 2.4
+# (currently in libegg). This widget will be themeable to look like either a
+# combo box or the current option menu.
+#
+#
+# This layer try to make OptionMenu look be api compatible with Combo since new
+# widget API seems following the current Combo API.
+
+package Gtk2::OptionMenu;
+use common;
+
+# try to get combox <==> option menu mapping
+sub set_popdown_strings {
+ my ($w, @strs) = @_;
+ my $menu = Gtk2::Menu->new;
+ # keep string list around for ->set_text compatibilty helper
+ $w->{strings} = \@strs;
+ #$w->set_menu((ugtk2::create_factory_menu($window, [ "File", (undef) x 3, '<Branch>' ], map { [ "File/" . $_, (undef) x 3, '<Item>' ] } @strs))[0]);
+ $menu->append(ugtk2::gtkshow(Gtk2::MenuItem->new_with_label($_))) foreach @strs;
+ $w->set_menu($menu);
+ $w
+}
+
+sub entry {
+ my ($w) = @_;
+ return $w;
+}
+
+sub get_text {
+ my ($w) = @_;
+ $w->{strings}->[$w->get_history];
+}
+
+sub set_text {
+ my ($w, $val) = @_;
+ each_index {
+ if ($_ eq $val) {
+ $w->set_history($::i);
+ return;
+ }
+ } @{$w->{strings}};
+}
+
+
package Gtk2::Label;
sub set {
my ($label) = shift;
$label->set_label(@_);
}
+
package Gtk2::Entry;
sub new_with_text {
shift;