* #HildonWindow. Applications that use stackable windows are organized
* in a hierarchical way so users can go from any window back to the
* application's root window.
+ *
+ * To add a window to the stack, use hildon_program_add_window(). Once
+ * you show the new window, the previous one will be automatically
+ * hidden. When the new window is destroyed, the previous one will
+ * appear again.
+ *
+ * <example>
+ * <programlisting>
+ * void
+ * show_first_window (void)
+ * {
+ * HildonProgram *program;
+ * GtkWidget *win1;
+ * <!-- -->
+ * program = hildon_program_get_instance ();
+ * win1 = hildon_stackable_window_new ();
+ * <!-- -->
+ * // ... configure first window
+ * <!-- -->
+ * hildon_program_add_window (program, HILDON_WINDOW (win1));
+ * gtk_widget_show (win1);
+ * }
+ * <!-- -->
+ * void
+ * show_second_window (void)
+ * {
+ * HildonProgram *program;
+ * GtkWidget *win2;
+ * <!-- -->
+ * program = hildon_program_get_instance ();
+ * win2 = hildon_stackable_window_new ();
+ * <!-- -->
+ * // ... configure second window
+ * <!-- -->
+ * hildon_program_add_window (program, HILDON_WINDOW (win2));
+ * gtk_widget_show (win2);
+ * }
+ * </programlisting>
+ * </example>
*/
#include <X11/X.h>
GSList *iter = get_window_list (widget);
GSList *previous = NULL;
- g_return_val_if_fail (iter != NULL, NULL);
+ /* Return NULL if the window hasn't been added to the HildonProgram */
+ if (iter == NULL)
+ {
+ return NULL;
+ }
/* Go to the end of the window list */
while (iter->next != NULL)
static void
hildon_stackable_window_map (GtkWidget *widget)
{
- GtkWidget *lastwin;
+ GtkWidget *previous = get_previous_window_if_last (widget);
if (GTK_WIDGET_CLASS (hildon_stackable_window_parent_class)->map)
GTK_WIDGET_CLASS (hildon_stackable_window_parent_class)->map (widget);
- lastwin = get_previous_window_if_last (widget);
-
- if (HILDON_IS_STACKABLE_WINDOW (lastwin) && GTK_WIDGET_VISIBLE (lastwin))
- gtk_widget_hide (lastwin);
+ if (HILDON_IS_STACKABLE_WINDOW (previous) && GTK_WIDGET_VISIBLE (previous))
+ gtk_widget_hide (previous);
}
static void
hildon_stackable_window_unmap (GtkWidget *widget)
{
- GtkWidget *lastwin;
+ GtkWidget *previous = get_previous_window_if_last (widget);
if (GTK_WIDGET_CLASS (hildon_stackable_window_parent_class)->unmap)
GTK_WIDGET_CLASS (hildon_stackable_window_parent_class)->unmap (widget);
- lastwin = get_previous_window_if_last (widget);
-
- if (HILDON_IS_STACKABLE_WINDOW (lastwin) && !GTK_WIDGET_VISIBLE (lastwin) &&
+ if (HILDON_IS_STACKABLE_WINDOW (previous) && !GTK_WIDGET_VISIBLE (previous) &&
!hildon_stackable_window_get_going_home (HILDON_STACKABLE_WINDOW (widget)))
{
- gtk_widget_show (lastwin);
+ gtk_widget_show (previous);
}
}
static void
hildon_stackable_window_unset_program (HildonWindow *hwin)
{
- GSList *windows = get_window_list (GTK_WIDGET (hwin));
- gint l = g_slist_length (windows);
- GtkWidget *nextwin = GTK_WIDGET (g_slist_nth_data (windows, l - 2));
+ GtkWidget *previous = get_previous_window_if_last (GTK_WIDGET (hwin));
if (HILDON_WINDOW_CLASS (hildon_stackable_window_parent_class)->unset_program)
HILDON_WINDOW_CLASS (hildon_stackable_window_parent_class)->unset_program (hwin);
- if (HILDON_IS_STACKABLE_WINDOW (nextwin) && !GTK_WIDGET_VISIBLE (nextwin) &&
+ if (HILDON_IS_STACKABLE_WINDOW (previous) && !GTK_WIDGET_VISIBLE (previous) &&
!hildon_stackable_window_get_going_home (HILDON_STACKABLE_WINDOW (hwin)))
{
- gtk_widget_show (nextwin);
+ gtk_widget_show (previous);
}
}