Time to rethink GTK+ Tab Dragging

I’ve been planning on adding tab drag-and-drop functionality to VMware Workstation 6.0. Rather than implementing this ability from scratch (which I did with Gaim, and would rather not do again), I took the sane approach and started investigating the GTK+ 2.10 API for GtkNotebook tab drag-and-drop.

This is functionality that many applications have had to implement themselves, so it’s great that support had finally gone into GTK+ 2.10. So I must wonder, with all the various applications that would benefit from this new API, how did we get it so wrong?

Now, before I continue, let me say that I applaud the effort in getting this into GTK+ in the first place. Reordering tabs looks smooth, it’s only one API call, and the basics are trivial. Where this all falls down is when you try to do anything complicated with it, and by complicated I mean anything beyond a simple text editor.

Before starting, I investigated how many projects were using this API. A quick Google Code search shows that almost nobody does, aside from maybe the tab reordering API. I did find this list of complaints, which I remember reading before. I won’t repeat everything on this list, but I will list what I’ve ran into, and how I think we can improve this API.

Global functions are very bad. (Bug 386935)

In order to allow for a tab to be dragged out and form a new window, the application must call gtk_notebook_set_window_creation_hook and pass a callback function. When a tab marked as detachable is dragged to the root window, this function will be called. It is expected that the function create a new window, position it as per the x and y coordinates of the drop (if it so desires), show it, and return the resulting notebook. GTK+ will then add the tab to that notebook.

While useful, this suffers from a major design flaw. You can’t set a window creation hook per-notebook. You get exactly one window creation hook function, which must be responsible for any and all notebooks in the program. The hook function can only distinguish between them using the notebook’s group ID.

For smaller programs, this isn’t a huge limitation. Simple text editors and the like only need one function. However, imagine if your application has multiple notebooks that each need to be dragged, and imagine if the code for those notebooks are in two separate parts of the tree. Maybe you have a nice separation of the different parts of the project. Regardless, now you have to have one common function that knows about both and handles their window creations.

The problem gets far worse for applications separated into different libraries, or those using widget utility libraries. Two separate libraries both providing a notebook with drag-and-drop with their own window creation won’t be able to set up a hook. They would require that the main application handle determining the group IDs of the notebook widgets they care about and then calling the proper functions in the libraries. While doable, it’s a horrible burden on the application, and it doesn’t always work.

Of course, the whole thing completely breaks down when you’re writing a plugin with a notebook rather than an application. The plugin won’t be able to offer its own window creation, due to possible conflicts with the main application and other plugins.

The solution, of course, is to have per-notebook window creation hooks. GTK+ could attempt to call one of these and then fall back to the global hook, if it exists. If calling the global hook, GTK+ could spit out a warning informing the user that the program should be upgraded to the new API and that the existing method is deprecated.

Rather than functions, though, a signal handler may make more sense. It could use a collector and call the handlers until it finds one that returns a GtkNotebook. I could see this being useful if a widget component library (as part of a larger project) provides a default window creation handler that the calling application wants to override for a specific case.

Numeric group IDs lead to namespace collisions. (Bug 386930)

Right now, in order to indicate which notebooks are compatible for drag-and-drop operations, each GtkNotebook gets a group ID. This is an unsigned integer with absolutely no rules on how an ID should be picked. This is very dangerous, as it could cause namespace collisions in larger applications, resulting in tabs being droppable onto incompatible notebooks. This could easily crash such applications.

There’s no reason for us to be using integers. Take a look at GtkRadioButton. They also have groups, but they work a bit differently. The first GtkRadioButton defines the group, and the rest get passed that as the group identifier. In gtkmm, you actually have a Gtk::RadioButtonGroup object that you simply instantiate and then pass to each radio button.

Now, in any well-designed program, there should be only one place creating the notebook for a certain type of window, and usually that’s the only type of notebook capable of accepting tabs from the same class of notebook. So, why not do something like what gtkmm does and have some sort of static object that represents that group, define it once, and pass it to each notebook? This is guaranteed to be unique, and solves the namespace collision issue.

Signals need to be more clear. (Bug 386943)

You can determine if a page was added to a notebook or removed from it, but there’s no clear way of determining if it was due to an API call, or a drag-and-drop operation. We worked around it in VMware Workstation, but it would have been very helpful to know precisely that a page was added due to drag-and-drop. Same with the removed signal. I know they wanted to condense the signals and figured it would work in all cases, but it doesn’t, so please, give us some more specific signals!

Drop operations should be able to be programatically rejected. (Bug 386950)

There are times when you want to allow a tab to be draggable, but want to reject it in notebooks under certain circumstances. For example, in VMware Workstation, we have the “Home” tab. I would like to be able to drag this to empty windows, but if that window has a “Home” tab already, I want to reject the drag. To my knowledge, there is no way to do this currently.

Detaching tabs into new windows requires a drag to the desktop. (Bug 360225)

In most any program with tab drag-and-drop, you can drag a tab off into any area not in the tab bar and it will detach into a new window. With the GTK+ tab dragging, you have to actually drag it to the root desktop. Even dragging off into another window isn’t good enough. This sucks. Let’s fix this properly. We’re not doing anybody any favors.

I’m missing a few annoyances I ran into, but I’ll be blogging about them separately once I remember.

So, to recap, I believe we should:

  • Deprecate gtk_notebook_set_window_creation_hook and add a new create_window signal, returning a GtkNotebook.
  • Ditch the numeric group IDs and use some sort of identifier object or generic pointer to a static variable and pass that in instead.
  • Add new signals or something telling us specifically how the tab was added/removed.
  • Provide a way to reject a tab drop on a particular notebook programatically.
  • Call the window creation hook any time the tab is dragged off the tab portion of the notebook.

It would be great to see these things fixed so that more applications can actually use this API without major headaches. Anyone up for the task?

I plan to put up a new post soon giving a couple of tips for using the current API.

Update: Bugs have been filed for the above. They’re in the topic headers.

Time to rethink GTK+ Tab Dragging Read More »

A Wii Surprise for Mii

Like every other self-respecting Nintendo lover out there, I tried to get a Wii on opening day, with of course no success. I was heading back home to visit family on opening day, and had researched roughly how many Wiis each store in town had in stock, but there were more people than Wiis at each store. I called up Circuit City later that day and asked when they expected another shipment in. They said they didn’t know, but after talking to the guy for a couple minutes I was told that if I came in, I could place a special order and would be notified when my Wii arrived.

I went to Circuit City and talked to the guy who handles the special orders. He seemed a bit upset that someone had told me that they were accepting special orders and was quick to tell me that they weren’t officially doing that and that my special order might be canceled at any given time. However, after a little bit of pushing, he took my credit card info and put me on the list. He said I would get a call if and when a Wii arrived that they could give me, but told me that I would likely be called and told that the special order was canceled, at which point they would refund my money.

That was Sunday the 19th. On Wednesday the 22nd, I was woken up with a call from Circuit City letting me know that they randomly received one Wii, and that it was being held for me. I was told I could pick it up at any time. Well, I wasted no time on this one. An hour later, I was setting up my brand new Wii.

The Wii is a very impressive system. The controls work far better than I had expected. I have Wii Sports and Excite Truck, with plans to pick up Elebits, Zelda, and Mario Galaxy when possible. Wii Sports is a great multiplayer game, but I must recommend stretching before play. Excite Truck is also loads of fun, though its multiplayer support could stand improvement. It’s limited to a two-player versus mode, so if you want any more players, you’re out of luck. Still, fun game, and I highly recommend it.

I invited my friends Jen, Amanda, and Dell, and my girlfriend Jamie over to play with my Wii (don’t bother with the jokes, we’ve already made them). I had them create Miis, which they loved, and we all played some Wii Sports. They had a blast and talked about how much fun the system was. Now, they’re all gamer girls to some degree, but I’m looking forward to inviting some of my non-gamer girl friends over to see what they think of the system. If Nintendo is right, they’ll hopefully be drawn to it. We shall see 🙂

Now, part of the reason I wanted a Wii so bad was to play classic games using the Wii’s Virtual Console. I added $40 in Wii points and picked up Legend of Zelda, Solomon’s Key, Bomberman 93, and Solomon’s Key. The emulation works very well. I spent most of today playing (and beating) Legend of Zelda. What’s cool is that most of the console games can be suspended and resumed later on, so if you suddenly get the urge to play something else, you simply press the Home button, play another game, and then come back to the emulated game whenever you want to.

What excites me the most isn’t the Wii itself, but what’s coming next. I can’t help but wonder what the next generation of consoles will be a few years from now, what they’ll be capable of, and how they will change gaming.

The one downside to the Wii is that when you’re sick, it’s hard to play some games (Wii Sports mainly). I’ve been dealing with a head cold for a few days, and it’s difficult to play some Wii games when you don’t feel like moving. Fortunately, there’s always the classic games.

If you know me and you have a Wii, contact me and we can exchange Wii console numbers.

A Wii Surprise for Mii Read More »

Planet VMware, Planet V12n

We officially announced two new planets last night at VMware: Planet VMware and Planet V12n, both powered by Planet.

Planet VMware is a Planet for VMware employees, in the spirit of Planet GNOME and such. There are currently ten VMware bloggers on there. This will of course increase in time.

Planet V12n is designed to be the go-to source for virtualization news. Blogs and sites such as virtualization.info and Virtual Strategy Magazine are included, with news covering all things virtualization, VMware and otherwise. The VMware employee blogs are also shown alongside the virtualization blogs.

The planets are very new, so there’s a couple of bugs to work out. The Planet VMware atom feed is busted right now, but it’s a known problem and will be fixed shortly. Please let us know if there are any other glaring problems.

Planet VMware, Planet V12n Read More »

libsexy v0.1.9 released

libsexy, libsexymm, and sexy-python 0.1.9 have been released.

libsexy v0.1.9 is just bug fix release (but a good one), containing the following fixes:

  • Fixed a bug where the cursor position in a SexySpellEntry would change if the position was at the end of the entry and word was replaced.
  • Fixed a few enchant-related bugs in SexySpellEntry.
  • Fixed our GModule loading for enchant to let glib figure out the proper file extension, rather than hard-coding “.so”.
  • Fixed some uninitialized variables when creating the icon windows for SexyIconEntry that were causing valgrind to complain. Patch by Benjamin Otte. (Bug #349701)
  • Fixed a bug in SexyIconEntry where the caret would be invisible at the start of the entry when no icon was shown. Patch by Ed Catmur. (Bug #353671)
  • Fixed a bug with SexyToolTip positioning in treeviews without headers where the tooltips would immediately disappear when shown at the bottom of the screen. (Bug #333424)
  • Fixed a linking bug when building on win32. Patch by Steffen Eschenbacher. (Bug #351796)

libsexymm and sexy-python contain license updates and were updated to work with libsexy v0.1.9. Both bindings claimed to be GPL, while they were intended to be LGPL. Sorry for the confusion, packagers 🙂

libsexy v0.1.9 released Read More »

Foo Camp 2006

This year, I was one of the lucky few who received an invitation to O’Reilly’s Foo Camp. Like many people, I had heard just how cool this exclusive get-together is, but I was nowhere near prepared for how mind-blowingly awesome the Foo Camp experience can be.

I arrived in Sebastopol on Friday afternoon and began to unpack my tent. The tent I bought ended up being bigger than I expected I think I grabbed the wrong one, but it worked out fine given that I was sharing it with Alex Graveley. Alex wasn’t there yet, though, so I started to unpack it myself, which ended up being a bit difficult… But then a very kind and helpful Mark Shuttleworth walked by and offered a hand. Before long, the tent was set up and I was ready for the fun.

There were only a handful of people there at this point, so I decided to walk around and see the place. One of the rooms had this interesting table with a map on it. A projector was mounted above, and people were around the table, turning and tilting. It was quite cool. Turn the table and it zooms in and out. Tilt it and the map moves. It was the most natural way of viewing maps that I’ve ever used. Quite addicting in a way.

Outside was this kind of round spinnable art thing. It was like the table, but had this colored fluid sand-like substance inside. It was held up at an angle, and when you spun it, the sand-like stuff made some cool patterns. That was also fun to play with. 🙂

Before long, most of the Foo Camp guys were there, and we gathered under a tent to introduce ourselves and learn what was in store for us. It was amazing to see the people who were there. The creators of Digg, del.icio.us, LiveJournal, Second Life, 43things, Amazon, Meebo, Django, Chumby, people from Google, Microsoft, Intel, Yahoo… The list goes on and on.

I went to several sessions. There was one on the future of IM, another on robots, one on Dr. Who vs. Snakes on a Plane, another on Chumby hacking. I think I went to another one or two, but I can’t remember right now. They were all pretty interesting, and there were many more I didn’t have time to go to.

As mentioned above, one of the session talks was about Chumby. Chumby is a cute, soft, squishy Linux computer that is designed to sit next to your couch or your bed or whatever and stream flash content to you. The software and hardware are all open source, and there’s people modifying the casing of the Chumby and sticking it in teddy bears, Teletubbies, Hello Kitties, etc. It’s currently very pre-alpha (both the hardware and the software), but we all knew that. The Foo campers received free Chumbies. The public release will be in like 6 months or so, and should by then have more features and be a bit more stable. Still, it’s an interesting concept, and I hope they come up with a killer app for it. With an intended price tag of $150, it could be a good purchase with the right target audience and apps.

At nights, we would play Werewolf. This is pretty much a Foo Camp tradition, and is played well into the night. I was a werewolf only once, but we kicked ass that one time 🙂

Let’s see, what else was there… A Google plane flew overhead and took pictures, which will go on Google Maps at a 2 inch resolution. There were flame-throwing robots, a clown, lots of good food, new friends, a reverse scavenger hunt… Probably more things than I can list. It is the best event I have ever gone to, and I hope to be invited back next year. To whoever it was that put me on the invite list, thank you. This was an opportunity I will never forget.

(More pictures available in my gallery and tagged on Flickr.)

Foo Camp 2006 Read More »

Gallery Virtual Appliance

Virtual machines used to be all about managing your data center or server consolidation or running applications that only run on some other operating system. Lately, virtual machines have been gaining momentum in a new area: software distribution.

This is actually quite powerful. Instead of a giving a user a complex set of instructions for installing some application or web service, and telling them what they need to install beforehand and what distros or operating systems it works on, the distributor or project can instead provide a bare-bones virtual machine containing the application or service pre-configured, and users can simply download it and power it on. It’s a great way of previewing applications or even running them day-to-day (depending on the application).

There’s a wonderful service out there called Gallery. It’s a web-based photo gallery that users can install on their server in order to share photos with the world. There’s a number of modules available. Many programs work with it. You can do things like order prints through the web. Great program.

And it’s now available in a virtual appliance! They have a description and instructions for setting it up, and I’ve been informed that they plan to keep it updated with each new release. It contains both Gallery 1 and Gallery 2, giving users a chance to see the differences between the versions and decide which suits them best. It can be used in VMware Player, Server, Workstation, and probably ESX (I haven’t tried). It’s downloadable from their website or from VMTN. You can see h0bbel’s blog post for more information on the appliance.

I think this is awesome and I hope it works out well for them and for the users. I’d love to see more projects go this route, and with any luck, Gallery will have set a precedent in the web services world. And for the developers creating these appliances, please feel free to let us know what VMware could do to make your lives easier. We welcome feedback, and you can send it directly to me.

Gallery Virtual Appliance Read More »

Snakes on a Plane in a Movie Theater on a Friday

Several members of our team at work went to see Snakes on a Plane on Friday. A number of us have been looking forward to this movie and were jazzed about it. I didn’t expect it to be a good movie, but I expected it to be enjoyable. It actually exceeded my expectations in a number of ways. They even made somewhat of an attempt to come up with a plot! Not that you need one, given that in this movie, you have motherf***’n snakes on a motherf***’n plane. I mean, how awesome is that?

I don’t know if he was kidding or not, but Samuel L. Jackson mentioned on the daily show (video) that he’ll be in the sequel. I don’t know whether a sequel would be a good thing or a bad thing, but if they make it, it should definitely be called “Snakes on a Plane Again.”

And to further add to the, um, coolness? … someone made an All Your Snakes are Belong to Us video.

Oh, and Alex Graveley is now a zombie.

Snakes on a Plane in a Movie Theater on a Friday Read More »

VMware Server 1.0 Released

As most people have probably seen on Slashdot or Digg by now, we just released VMware Server 1.0. As promised, it is a free product and should run your virtual machines much faster than the earlier betas did.

(If you’re not sure what VMware Server is all about, please read my original post.)

VMware Server has already been deployed at several companies ever since beta 1. I’ve always found that amusing, given how young the product was at that stage (even though this is essentially GSX 4). However, my experience in talking to beta testers so far is that most people are pretty happy with the product, especially given the price. I am personally running it at home for my Linux development VMs and it has been working nicely.

My thanks go out to all the testers that have reported problems or who have given us feedback of any kind. As one of the developers on VMware Server, it has been nice hearing positive reports and stories :).

VMware Server 1.0 Released Read More »

Scroll to Top