Author: debacker
Date: 2008-02-07 06:12:24 -0500 (Thu, 07 Feb 2008)
New Revision: 95127
Modified:
trunk/gtk-sharp-ribbon/Ribbons/ChangeLog
trunk/gtk-sharp-ribbon/Ribbons/Gallery.cs
trunk/gtk-sharp-ribbon/Ribbons/GalleryPopupWindow.cs
Log:
* Gallery.cs, GalleryPopupWindow.cs: * You can now click anywhere to
close the popup. (Pawe?\197?\130 'X4lldux' Drygas).
* Proper tile selection. (Pawe?\197?\130 'X4lldux' Drygas).
Modified: trunk/gtk-sharp-ribbon/Ribbons/ChangeLog
===================================================================
--- trunk/gtk-sharp-ribbon/Ribbons/ChangeLog 2008-02-07 10:39:51 UTC (rev
95126)
+++ trunk/gtk-sharp-ribbon/Ribbons/ChangeLog 2008-02-07 11:12:24 UTC (rev
95127)
@@ -1,3 +1,10 @@
+2008-01-29 Laurent Debacker <[EMAIL PROTECTED]>
+
+ * Gallery.cs, GalleryPopupWindow.cs: * You can now click anywhere to
close
+ the popup. (Paweł 'X4lldux' Drygas).
+
+ * Proper tile selection. (Paweł 'X4lldux' Drygas).
+
2008-01-24 Laurent Debacker <[EMAIL PROTECTED]>
* RibbonGroup.cs, Button.cs: Added signal names to enable accelerators.
Modified: trunk/gtk-sharp-ribbon/Ribbons/Gallery.cs
===================================================================
--- trunk/gtk-sharp-ribbon/Ribbons/Gallery.cs 2008-02-07 10:39:51 UTC (rev
95126)
+++ trunk/gtk-sharp-ribbon/Ribbons/Gallery.cs 2008-02-07 11:12:24 UTC (rev
95127)
@@ -11,9 +11,11 @@
protected Theme theme = new Theme ();
private int tileWidth, tileHeight;
private List<Tile> tiles;
- private Button up, down, expand;
+ private Button up, down;
+ private ToggleButton expand;
private int defaultTilesPerRow;
private int tileSpacing;
+ private GalleryPopupWindow popup;
private Tile selectedTile;
private int firstDisplayedTileIndex, lastDisplayedTileIndex;
@@ -76,6 +78,17 @@
{
set
{
+ if(popup != null)
+ {
+ Grab.Remove(popup);
+ Gdk.Pointer.Ungrab(0);
+ Gdk.Keyboard.Ungrab(0);
+
+ popup.Hide ();
+ popup.Destroy();
+ popup = null;
+ }
+
if(selectedTile != null) selectedTile.Selected
= false;
selectedTile = value;
if(selectedTile != null)
@@ -85,7 +98,7 @@
int idx = tiles.FindIndex (delegate
(Tile t) { return t == selectedTile; });
if(idx != -1)
{
- firstDisplayedTileIndex = idx;
+ firstDisplayedTileIndex =
idx/defaultTilesPerRow*defaultTilesPerRow;
lastDisplayedTileIndex = -1;
UpdateTilesLayout ();
QueueDraw ();
@@ -143,10 +156,10 @@
this.down.Padding = 0;
this.down.Clicked += down_Clicked;
- this.expand = new Button ("\u2193");
+ this.expand = new ToggleButton ("\u2193");
this.expand.Parent = this;
this.expand.Padding = 0;
- this.expand.Clicked += expand_Clicked;
+ this.expand.ValueChanged += expand_ValueChanged;
}
/// <summary>Adds a tile before all existing tiles.</summary>
@@ -177,6 +190,9 @@
tiles.Insert (TileIndex, t);
}
+ if (tiles.Count == 1)
+ SelectedTile = t;
+
//t.Parent = this;
t.Visible = true;
t.Clicked += Tile_Clicked;
@@ -204,17 +220,61 @@
MoveDown ();
}
- private void expand_Clicked(object Sender, EventArgs e)
+ private void expand_ValueChanged(object Sender, EventArgs e)
{
- GalleryPopupWindow popup = new GalleryPopupWindow
(this);
- popup.ShowAll ();
-
- int x, y;
- ParentWindow.GetRootOrigin (out x, out y);
- x += Allocation.X;
- y += Allocation.Y;
-
- popup.GdkWindow.Move (x, y);
+ if(expand.Value)
+ {
+ popup = new GalleryPopupWindow (this);
+ popup.Realized += delegate {
+ int x, y;
+ ParentWindow.GetRootOrigin (out x, out
y);
+ x += Allocation.X;
+ y += Allocation.Y;
+ popup.GdkWindow.Move (x, y);
+ };
+
+ popup.Hidden += delegate {
+ expand.ValueChanged -=
expand_ValueChanged;
+ expand.Value = false;
+ expand.QueueDraw ();
+ expand.ValueChanged +=
expand_ValueChanged;
+ };
+ popup.Show ();
+
+ popup.ButtonReleaseEvent += OnButtonReleased;
+ popup.AddEvents ((int)
Gdk.EventMask.ButtonPressMask);
+ Grab.Add(popup);
+
+ Gdk.GrabStatus grabbed =
Gdk.Pointer.Grab(popup.GdkWindow, true, Gdk.EventMask.ButtonReleaseMask, null,
null, 0);
+ if(grabbed == Gdk.GrabStatus.Success) {
+ grabbed =
Gdk.Keyboard.Grab(popup.GdkWindow, true, 0);
+
+ if(grabbed != Gdk.GrabStatus.Success)
+ {
+ Grab.Remove(popup);
+ popup.Hide ();
+ popup.Destroy();
+ popup = null;
+
+ return;
+ }
+ } else {
+ Grab.Remove(popup);
+ popup.Hide ();
+ popup.Destroy();
+ popup = null;
+ }
+ }
+ else
+ {
+ if (popup != null)
+ {
+ Grab.Remove(popup);
+ popup.Hide ();
+ popup.Destroy();
+ popup = null;
+ }
+ }
}
private void Tile_Clicked(object Sender, EventArgs e)
@@ -254,6 +314,19 @@
if(TileSelected != null) TileSelected (this, new
TileSelectedEventArgs (SelectedTile));
}
+ private void OnButtonReleased(object o, ButtonReleaseEventArgs
args)
+ {
+ if(popup != null) {
+ Grab.Remove(popup);
+ Gdk.Pointer.Ungrab(0);
+ Gdk.Keyboard.Ungrab(0);
+
+ popup.Hide ();
+ popup.Destroy();
+ popup = null;
+ }
+ }
+
private void UpdateTilesLayout ()
{
Gdk.Rectangle tileAlloc;
Modified: trunk/gtk-sharp-ribbon/Ribbons/GalleryPopupWindow.cs
===================================================================
--- trunk/gtk-sharp-ribbon/Ribbons/GalleryPopupWindow.cs 2008-02-07
10:39:51 UTC (rev 95126)
+++ trunk/gtk-sharp-ribbon/Ribbons/GalleryPopupWindow.cs 2008-02-07
11:12:24 UTC (rev 95127)
@@ -35,6 +35,7 @@
foreach(Tile t in UnderlyingGallery.Tiles)
{
Tile copy = t.Copy ();
+ copy.Show ();
tiles.Add (copy);
if(t == UnderlyingGallery.SelectedTile)
@@ -52,13 +53,16 @@
rows = (uint)Math.Ceiling ((double)tiles.Count /
columns);
this.tileTable = new Table (rows, columns, true);
+ this.tileTable.Show ();
this.tileTable.HeightRequest = (int)rows *
UnderlyingGallery.TileHeight;
this.tileTable.WidthRequest = (int)columns *
UnderlyingGallery.TileWidth;
Viewport vp = new Viewport ();
+ vp.Show ();
vp.Child = tileTable;
this.internalWindow = new ScrolledWindow ();
+ this.internalWindow.Show ();
this.internalWindow.Child = vp;
this.internalWindow.HeightRequest = Math.Min
(this.tileTable.HeightRequest, MAX_HEIGHT) + SCROLLBAR_SIZE;
this.internalWindow.WidthRequest =
this.tileTable.WidthRequest + SCROLLBAR_SIZE;
@@ -67,6 +71,7 @@
foreach(Tile t in tiles)
{
ExtraEventBox box = new ExtraEventBox ();
+ box.Show ();
box.AddEvents
((int)(Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonReleaseMask |
Gdk.EventMask.PointerMotionMask));
box.Child = t;
@@ -81,6 +86,9 @@
}
this.Child = internalWindow;
+ this.Child.ButtonPressEvent += delegate (object o,
ButtonPressEventArgs args) {
+ args.RetVal = true;
+ };
}
private void tile_Clicked (object Sender, EventArgs e)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches