Skip to content

Commit

Permalink
Fixed SliderMenuItem
Browse files Browse the repository at this point in the history
  • Loading branch information
rilian-la-te committed Mar 3, 2015
1 parent b5c4c89 commit 9f91fe4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 9 deletions.
2 changes: 1 addition & 1 deletion archlinux/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maintainer: rilian-la-te <[email protected]>

pkgname=xfce4-sntray-plugin
pkgver=0.1.4
pkgver=0.1.5
pkgrel=1
pkgdesc="Plugin for xfce4-panel to show StatusNotifierItems (AppIndicators) via FlowBox"
url="https://github.com/rilian-la-te/xfce4-sntray-plugin"
Expand Down
42 changes: 34 additions & 8 deletions src/dbusmenu.vala
Original file line number Diff line number Diff line change
Expand Up @@ -646,37 +646,39 @@ namespace DBusMenu
}
public class GtkSliderItem: Gtk.MenuItem, GtkItemIface
{
private static const string[] allowed_properties = {"visible","enabled","icon-name","x-valapanel-secondary-icon-name",
private static const string[] allowed_properties = {"visible","enabled","icon-name",
"x-valapanel-min-value","x-valapanel-current-value","x-valapanel-max-value",
"x-valapanel-step-increment","x-valapanel-page-increment","x-valapanel-draw-value",
"x-valapanel-format-value"};
public Item item
{get; protected set;}
private Box box;
private Image primary;
private Image secondary;
private Scale slider;
private Adjustment adj;
private string item_format;
private bool grabbed;
public GtkSliderItem(Item item)
{
this.item = item;
box = new Box(Orientation.HORIZONTAL,5);
primary = new Image();
secondary = new Image();
adj = new Adjustment(0,0,0,0,0,0);
adj = new Adjustment(0,0,double.MAX,0,0,0);
slider = new Scale(Orientation.HORIZONTAL,adj);
slider.hexpand = true;
box.add(primary);
box.add(slider);
box.add(secondary);
this.add(box);
this.show_all();
this.init();
item.property_changed.connect(on_prop_changed_cb);
adj.value_changed.connect(on_value_changed_cb);
slider.format_value.connect(on_value_format_cb);
slider.value_pos = PositionType.RIGHT;
this.add_events (Gdk.EventMask.SCROLL_MASK
|Gdk.EventMask.POINTER_MOTION_MASK
|Gdk.EventMask.BUTTON_MOTION_MASK);
this.set_size_request(200,-1);
}
private void on_prop_changed_cb(string name, Variant? val)
{
Expand All @@ -691,9 +693,6 @@ namespace DBusMenu
case "icon-name":
primary.set_from_gicon (icon_from_name(val),IconSize.MENU);
break;
case "x-valapanel-secondary-icon-name":
secondary.set_from_gicon (icon_from_name(val),IconSize.MENU);
break;
case "x-valapanel-min-value":
adj.lower = val.get_double();
break;
Expand Down Expand Up @@ -738,6 +737,33 @@ namespace DBusMenu
foreach (var prop in allowed_properties)
on_prop_changed_cb(prop,item.get_variant_property(prop));
}
protected override bool button_press_event(Gdk.EventButton event)
{
slider.event(event);
if (!grabbed)
grabbed = true;
return true;
}
protected override bool button_release_event(Gdk.EventButton event)
{
slider.event (event);
if (grabbed)
{
grabbed = false;
this.grab_broken_event (null);
}
return true;
}
protected override bool motion_notify_event(Gdk.EventMotion event)
{
slider.event (event);
return true;
}
protected override bool scroll_event(Gdk.EventScroll event)
{
slider.event (event);
return true;
}
}
public class GtkClient : Client
{
Expand Down

0 comments on commit 9f91fe4

Please sign in to comment.