[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Perlpanel-devel] Panel Sizing and Resizing: 2 diffs (resend with diffs
From: |
James Mitchell |
Subject: |
[Perlpanel-devel] Panel Sizing and Resizing: 2 diffs (resend with diffs attached) |
Date: |
Wed, 29 Sep 2004 12:55:09 -0500 |
User-agent: |
Mozilla Thunderbird 0.8 (X11/20040913) |
1> The button widget seems (to my unexperienced eye) to require a border
of several pixels around the icon it contains. This isn't very
efficient for icon sizes < Large. perlpanel-eventbox.diff changes
several applets I use to use EventBoxes instead of buttons as a proof of
concept.
2> Adjust the width of the panel to correspond to current needs. If an
applet defines a width_request sub, then use the request width,
otherwise use the current width. perlpanel-resize.diff changes
PerlPanel.pm to resize the panel every second, and adds a width_request
sub to Tasklist. This should be a configurable if it's supported at all.
diff -urNw PerlPanel-0.8.0/lib/PerlPanel/Applet/ActionMenu.pm
PerlPanel-James/lib/PerlPanel/Applet/ActionMenu.pm
--- PerlPanel-0.8.0/lib/PerlPanel/Applet/ActionMenu.pm 2004-09-17
06:28:53.000000000 -0500
+++ PerlPanel-James/lib/PerlPanel/Applet/ActionMenu.pm 2004-09-29
12:37:06.000000000 -0500
@@ -24,12 +24,11 @@
sub configure {
my $self = shift;
- $self->{widget} = Gtk2::Button->new;
+ $self->{widget} = Gtk2::EventBox->new;
+ $self->{widget}->set_border_width(0);
$self->{menu} = Gtk2::Menu->new;
$self->{config} = PerlPanel::get_config('ActionMenu');
- $self->widget->set_relief($self->{config}->{relief} eq 'true' ? 'half'
: 'none');
-
$self->{pixbuf} = PerlPanel::get_applet_pbf('ActionMenu',
PerlPanel::icon_size);
$self->{icon} = Gtk2::Image->new_from_pixbuf($self->{pixbuf});
@@ -47,7 +46,7 @@
$self->create_menu;
- $self->widget->signal_connect('clicked', sub { $self->popup });
+ $self->widget->signal_connect('button_release_event', sub {
$self->popup });
$self->widget->show_all;
return 1;
}
diff -urNw PerlPanel-0.8.0/lib/PerlPanel/Applet/Launcher.pm
PerlPanel-James/lib/PerlPanel/Applet/Launcher.pm
--- PerlPanel-0.8.0/lib/PerlPanel/Applet/Launcher.pm 2004-09-29
08:17:43.000000000 -0500
+++ PerlPanel-James/lib/PerlPanel/Applet/Launcher.pm 2004-09-29
12:37:30.000000000 -0500
@@ -39,8 +39,8 @@
sub configure {
my $self = shift;
- $self->{widget} = Gtk2::Button->new;
- $self->{widget}->set_relief('none');
+ $self->{widget} = Gtk2::EventBox->new;
+ $self->widget->set_border_width(0);
$self->widget->add(Gtk2::Image->new);
$self->init;
diff -urNw PerlPanel-0.8.0/lib/PerlPanel/Applet/Lock.pm
PerlPanel-James/lib/PerlPanel/Applet/Lock.pm
--- PerlPanel-0.8.0/lib/PerlPanel/Applet/Lock.pm 2004-09-17
06:28:53.000000000 -0500
+++ PerlPanel-James/lib/PerlPanel/Applet/Lock.pm 2004-09-29
12:37:46.000000000 -0500
@@ -34,10 +34,10 @@
sub configure {
my $self = shift;
$self->{config} = PerlPanel::get_config('Lock');
- $self->{widget} = Gtk2::Button->new;
+ $self->{widget} = Gtk2::EventBox->new;
$self->widget->add(Gtk2::Image->new_from_pixbuf(PerlPanel::get_applet_pbf('lock',
PerlPanel::icon_size)));
- $self->widget->signal_connect('clicked', sub { $self->lock });
- $self->widget->set_relief('none');
+ $self->widget->signal_connect('button_release_event', sub { $self->lock
});
+ $self->widget->set_border_width(0);
PerlPanel::tips->set_tip($self->widget, _('Lock the Screen'));
Glib::Timeout->add(1000, sub {
--- PerlPanel-0.8.0/lib/PerlPanel/Applet/Tasklist.pm 2004-09-27
09:33:24.000000000 -0500
+++ PerlPanel-James/lib/PerlPanel/Applet/Tasklist.pm 2004-09-29
11:43:18.000000000 -0500
@@ -42,6 +42,18 @@
return 1;
}
+sub width_request {
+ my $self = shift;
+ $self->{screen}->force_update;
+ my $request = '';
+
+ foreach my $hint ($self->{tasklist}->get_size_hint_list) {
+ last if $hint == 0;
+ $request = $hint;
+ }
+ return $request;
+}
+
sub widget {
return $_[0]->{widget};
}
diff -urNw PerlPanel-0.8.0/lib/PerlPanel.pm PerlPanel-James/lib/PerlPanel.pm
--- PerlPanel-0.8.0/lib/PerlPanel.pm 2004-09-29 10:09:40.000000000 -0500
+++ PerlPanel-James/lib/PerlPanel.pm 2004-09-29 12:35:49.000000000 -0500
@@ -84,6 +84,7 @@
tiny => ['16', 'menu'],
small => ['18', 'small-toolbar'],
medium => ['24', 'large-toolbar'],
+ medium_large => ['32', 'large-toolbar'],
large => ['48', 'dialog'],
);
@@ -106,6 +107,7 @@
my $self = {};
$self->{package} = shift;
$self->{rcfile} = (defined($ARGV[0]) ? $ARGV[0] :
sprintf('%s/.%src', $ENV{HOME}, lc($NAME)));
+ $self->{all_applets} = [];
$OBJECT_REF = $self;
bless($self, $self->{package});
@@ -178,6 +180,9 @@
chdir($ENV{HOME});
+ $self->update_size;
+ Glib::Timeout->add(1000, sub { $self->update_size });
+
Gtk2->main;
return 1;
@@ -346,6 +351,40 @@
return 1;
}
+sub update_size {
+ my $self = shift;
+
+ my $total = 0;
+ my $minHeight;
+
+ foreach my $applet (@{$self->{all_applets}}) {
+ my ($x);
+ eval {
+ $x = $applet->width_request();
+ };
+ my $rect = $applet->widget->allocation();
+ if ($@ || !$x) {
+ $x = $rect->width;
+ }
+ $minHeight = $rect->height if $rect->height > $minHeight;
+ $total += $x;
+ }
+
+ my $sw = $self->screen_width;
+
+ my ($px, $py) = $self->panel->get_position();
+
+ if ($total > $sw) {
+ $total = $sw;
+ }
+
+ $self->panel->resize($total, $minHeight );
+ $self->panel->move($sw-$total, $py);
+
+ return 1;
+}
+
+
sub load_applet {
my ($self, $raw, $position) = @_;
@@ -422,6 +461,7 @@
} else {
$self->add_applet($applet->widget, $applet->expand,
$applet->fill, $position);
$applet->widget->show;
+ push @{$self->{all_applets}}, $applet;
if ($id ne '') {
$self->{widgets}->{$id} = $applet->widget;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Perlpanel-devel] Panel Sizing and Resizing: 2 diffs (resend with diffs attached),
James Mitchell <=