Tag Archives: .NET

How to resize a Gdk.Pixbuf to the size of a Gtk.Image visible area

I wrote a simple image viewer that will load a photo image into a Gtk.Image widget using a Gdk.Pixbuf.  I then added a tool bar with four clickable icons.  Zoom out, zoom in, fit to window and original size.

All but the fit to window worked well.  When I pulled the width and height from image1.GetSizeRequest(out width, out height), width & height were returned as -1.  Not helpful.  Google didn’t give me many clues either :(

What I needed was something that would provide the visible area of the Gdk.Image widget:

In order to get the visible area, we need to:

  • upcast Gtk.Image to a Gtk.GdkWindow
  • retrieve a Gdk.Region from the VisibleRegion method
  • retrieve the first Gdk.Rectangle from the array returned from the visibleRegion.GetRectangles method
  • extract the Height and Width from the Gdk.Rectangle

Now that we have the height and the width of the visible area of the Gtk.Image widget, we need to scale the image (Gdk.Pixbuf) while keeping the aspect. Assigning the image to the Gtk.Image widget will automatically redraw itself.

protected virtual void zoomToWindow (object sender, System.EventArgs e)
{
   if (image1.Pixbuf != null) {
     int new_width, new_height;
     int height = image1.Pixbuf.Height;
     int width = image1.Pixbuf.Width;

     Gdk.Region visibleRegion = image1.GdkWindow.VisibleRegion;
     Gdk.Rectangle rectangle = visibleRegion.GetRectangles()[0];
     new_height = rectangle.Height;
     new_width = rectangle.Width;
     scaleImage(height, width, ref new_height, ref new_width, 0);
     image1.Pixbuf = pictureBuf.ScaleSimple(new_width, new_height, Gdk.InterpType.Bilinear);
   }
}

There we go :)
While the code above is C#, the same principle goes for any language that uses Gtk.

Share Button

For those of you on Facebook and are interested in PowerBuilder….

Subject: Old PowerBuilder Facebook page deactivated



PowerBuilder Fan Page

PowerBuilder Fan Page

Hi Everyone, Happy new year! As of today, the old PowerBuilder facebook page is deactivated. Please be sure to become a fan of PowerBuilder here: http://www.facebook.com/pages/PowerBuilder/160355699256 Go PB!!
Share Button

Reinstalling Beagle on Ubuntu 8.04 causes System.DllNotFoundException libgalago error

A while back I removed the Beagle and Tracker desktop search engines from my Ubuntu 8.04.  As I’ve been consolidating more and more information into my home directory, I thought I would be able to simply install Beagle.

Installing Beagle

Boy was I wrong!  When I started up beagle search, I was rewarded with it dying on me:

$ beagle-search
Debug: Done reading conf from /etc/beagle/config-files/BeagleSearch.xml
Debug: Done reading conf from /home/jason/.beagle/config/Daemon.xml
Debug: Done reading conf from /etc/beagle/config-files/Daemon.xml
Exception in Gtk# callback delegate
  Note: Applications can use GLib.ExceptionManager.UnhandledException to handle the exception.
System.DllNotFoundException: libgalago
  at (wrapper managed-to-native) Galago.Global:galago_init (intptr,int)
  at Galago.Global.Init (System.String name, InitFlags flags) [0x00000] 
  at Galago.Global.Init (System.String name) [0x00000] 
  at Beagle.Util.GalagoTools.GetPresence (System.String service_id, System.String username) [0x00000] 
  at Search.Tiles.IMLog.GetBuddyStatus () [0x00000] 
  at Search.Tiles.IMLog.GetDetails () [0x00000] 
  at Search.Tiles.Tile.get_Details () [0x00000] 
  at Search.MainWindow.ShowInformation (Search.Tiles.Tile tile) [0x00000] 
  at Search.GroupView.OnTileSelected (System.Object tile, System.EventArgs args) [0x00000] 
  at Search.Tiles.Tile.OnFocusInEvent (Gdk.EventFocus f) [0x00000] 
  at Gtk.Widget.focusinevent_cb (IntPtr widget, IntPtr evnt) [0x00000] 
   at GLib.ExceptionManager.RaiseUnhandledException(System.Exception e, Boolean is_terminal)
   at Gtk.Widget.focusinevent_cb(IntPtr widget, IntPtr evnt)
   at Gtk.Widget.focusinevent_cb(IntPtr , IntPtr )
   at Gtk.Widget.gtk_widget_grab_focus(IntPtr )
   at Gtk.Widget.gtk_widget_grab_focus(IntPtr )
   at Gtk.Widget.GrabFocus()
   at Search.Category.Select(Boolean focus, Boolean extended)
   at Search.GroupView.Finished(Boolean grabFocus)
   at Search.MainWindow.OnFinished(Beagle.FinishedResponse response)
   at Beagle.Query.OnFinished(Beagle.ResponseMessage r)
   at Beagle.RequestMessage.OnAsyncResponse(Beagle.ResponseMessage response)
   at Beagle.Transport+EventThrowingClosure.ThrowEvent()
   at GLib.Idle+IdleProxy.Handler()
   at GLib.Idle+IdleProxy.Handler()
   at Gtk.Application.gtk_main()
   at Gtk.Application.gtk_main()
   at Gtk.Application.Run()
   at Gnome.Program.Run()
   at Search.MainWindow.Main(System.String[] args)

I not so quickly determined I was missing libgalago-gtk1 and libgalago-gtk1.0-cil.  Once I installed them, everything was working properly!

Installing libgalago

Share Button

PowerBuilder 11.2 is coming out shortly

Speed in Development. Speed in Deployment. Speed in Performance.

PowerBuilder 11.2 will be available shortly and we are holding a Web seminar with John Strano to highlight the key features of this release. During this Web seminar, John will show you the new capabilities found in PowerBuilder 11.2 that bring increased performance to your mission-critical applications, including using AJAX and .NET development to EAServer. In addition, John will show you a range of as well as database, UI, and usability enhancements.

PowerBuilder 11.2 Web Seminar: Increased Performance is Here
Wednesday, April 2, 2008
9:00 AM PT
/ 12:00 PM EST

The PowerBuilder 11.2 webcast will cover:

  • Certificate Store Support for Smart Client-published Applications
  • Usability and UI Enhancements
  • Database Connectivity Enhancements
  • Enabling the DEBUG Condition for ORCA and OrcaScript
  • Application Pools for Web Forms in IIS7
  • EAServer Support for .NET-deployed PowerBuilder Clients
  • AJAX Functionality for WebForm-Deployed Applications

Register for the PowerBuilder 11.2 Web seminar today and speed up your development, deployment, and performance.

Find out more and sign up here.

Regards,

The PowerBuilder Team

Share Button

New developers for Sybase’s Powerbuilder 11?

There still seems to be a steep learning curve when it comes to Sybase’s PowerBuilder. In this specific case, PB11 is no easier.

What *I* personally would like to see is:

  1. step by step online tutorials to create a multitude of projects – from simple ‘hello world’ applications to database connected applications to .NET to AJAX enabled .NET web apps
  2. online videos for the new and experienced developers rather than just feature highlights
  3. more books… from the “Beginning PowerBuilder 11″ (perhaps a ‘for Dummies’ series type book) to super advanced PB11
  4. more podcasts ( take a look at Meet the Gimp for example format )
  5. PowerBuilder gallery of open source and commercial PB applications (please don’t just point to the abomination known as codexchange) and online pb communities
  6. A better tiered licensing model: Free version (take a look at Microsoft’s VB Express for a model of what should be included for free), Student (K-university) edition, Professional / Small Business, Enterprise. There should be NO feature differences between the student and enterprise editions – the only difference should be in what PB can be used for (licensing).
  7. Open source & hobby-ist development should be actively promoted to help rebuild the PB community

Can anyone think of anything else to help new developers learn PowerBuilder?

Share Button