2008-06-25 Alberto Garcia <agarcia@igalia.com>
+ * examples/hildon-stackable-window-example.c (new_window):
+ * src/Makefile.am (noinst_HEADERS):
+ * src/hildon-program.c (hildon_program_go_to_root_window):
+ * src/hildon-program.h:
+ * src/hildon-stackable-window-private.h:
+ * src/hildon-stackable-window.c:
+ * src/hildon-stackable-window.h:
+ Create hildon-stackable-window-private.h
+ Move hildon_stackable_window_go_to_root_window() to HildonProgram
+
* examples/hildon-app-menu-example.c (create_menu):
* examples/hildon-hvolumebar-insensitive-example.c (main):
* examples/hildon-hvolumebar-timer-example.c (on_idle):
gtk_box_pack_end (GTK_BOX (hbbox), back, FALSE, FALSE, 0);
g_signal_connect_swapped (G_OBJECT (back), "clicked",
- G_CALLBACK (hildon_stackable_window_go_to_root_window),
- HILDON_STACKABLE_WINDOW (window));
+ G_CALLBACK (hildon_program_go_to_root_window),
+ hildon_program_get_instance ());
}
return window;
hildon-volumebar-private.h \
hildon-weekday-picker-private.h \
hildon-window-private.h \
+ hildon-stackable-window-private.h \
hildon-wizard-dialog-private.h \
hildon-calendar-private.h \
hildon-app-menu-private.h \
#include "hildon-program.h"
#include "hildon-program-private.h"
#include "hildon-window-private.h"
+#include "hildon-stackable-window.h"
+#include "hildon-stackable-window-private.h"
#include <X11/Xatom.h>
static void
return priv->is_topmost;
}
+
+/**
+ * hildon_program_go_to_root_window:
+ * @self: A #HildonProgram
+ *
+ * Will close all windows in the #HildonProgram but the first one (the
+ * root window) by sending them a delete event. If any of the windows
+ * refuses to close (by handling it) no further events will be
+ * sent. All windows in the program must be #HildonStackableWindow for
+ * this to work.
+ */
+void
+hildon_program_go_to_root_window (HildonProgram *self)
+{
+ HildonProgramPrivate *priv;
+ GSList *windows, *iter;
+ gboolean windows_left;
+
+ g_return_if_fail (HILDON_IS_PROGRAM (self));
+ priv = HILDON_PROGRAM_GET_PRIVATE (self);
+ g_assert (priv);
+
+ /* List of windows in reverse order (starting from the topmost one) */
+ windows = g_slist_reverse (g_slist_copy (priv->windows));
+ iter = windows;
+
+ /* Destroy all the windows but the last one (which is the root
+ * window, as the list is reversed) */
+ windows_left = (iter != NULL && iter->next != NULL);
+ while (windows_left)
+ {
+ if (HILDON_IS_STACKABLE_WINDOW (iter->data))
+ {
+ GdkEvent *event;
+ HildonStackableWindow *win;
+
+ /* Mark the window as "going home" */
+ win = HILDON_STACKABLE_WINDOW (iter->data);
+ hildon_stackable_window_set_going_home (win, TRUE);
+
+ /* Set win pointer to NULL if the window is destroyed */
+ g_object_add_weak_pointer (G_OBJECT (win), (gpointer) &win);
+
+ /* Send a delete event */
+ event = gdk_event_new (GDK_DELETE);
+ event->any.window = g_object_ref (GTK_WIDGET (win)->window);
+ gtk_main_do_event (event);
+ gdk_event_free (event);
+
+ /* Continue sending delete events if the window has been destroyed */
+ if (win == NULL)
+ {
+ iter = iter->next;
+ windows_left = (iter != NULL && iter->next != NULL);
+ }
+ else
+ {
+ g_object_remove_weak_pointer (G_OBJECT (win), (gpointer) &win);
+ hildon_stackable_window_set_going_home (win, FALSE);
+ windows_left = FALSE;
+ }
+ }
+ else
+ {
+ g_warning ("Window list contains a non-stackable window");
+ windows_left = FALSE;
+ }
+ }
+
+ /* Show the last window that hasn't been destroyed */
+ if (iter != NULL && GTK_IS_WIDGET (iter->data))
+ {
+ gtk_widget_show (GTK_WIDGET (iter->data));
+ }
+
+ g_slist_free (windows);
+}
gboolean
hildon_program_get_is_topmost (HildonProgram *self);
+void
+hildon_program_go_to_root_window (HildonProgram *self);
+
G_END_DECLS
#endif /* __HILDON_PROGRAM_H__ */
--- /dev/null
+/*
+ * This file is a part of hildon
+ *
+ * Copyright (C) 2008 Nokia Corporation, all rights reserved.
+ *
+ * Contact: Karl Lattimer <karl.lattimer@nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef __HILDON_STACKABLE_WINDOW_PRIVATE_H__
+#define __HILDON_STACKABLE_WINDOW_PRIVATE_H__
+
+G_BEGIN_DECLS
+
+typedef struct _HildonStackableWindowPrivate HildonStackableWindowPrivate;
+
+struct _HildonStackableWindowPrivate
+{
+ gboolean going_home;
+};
+
+#define HILDON_STACKABLE_WINDOW_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\
+ HILDON_TYPE_STACKABLE_WINDOW, HildonStackableWindowPrivate))
+
+void G_GNUC_INTERNAL
+hildon_stackable_window_set_going_home (HildonStackableWindow *self,
+ gboolean going_home);
+
+gboolean G_GNUC_INTERNAL
+hildon_stackable_window_get_going_home (HildonStackableWindow *self);
+
+G_END_DECLS
+
+#endif /* __HILDON_STACKABLE_WINDOW_PRIVATE_H__ */
#include <X11/X.h>
#include <X11/Xatom.h>
#include "hildon-stackable-window.h"
+#include "hildon-stackable-window-private.h"
#include "hildon-program.h"
#include "hildon-window-private.h"
#include "hildon-program-private.h"
-typedef struct _HildonStackableWindowPrivate HildonStackableWindowPrivate;
-
-struct _HildonStackableWindowPrivate
-{
- gboolean going_home;
-};
-
-#define HILDON_STACKABLE_WINDOW_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((obj),\
- HILDON_TYPE_STACKABLE_WINDOW, HildonStackableWindowPrivate))
-
G_DEFINE_TYPE (HildonStackableWindow, hildon_stackable_window, HILDON_TYPE_WINDOW);
-static void
+void G_GNUC_INTERNAL
hildon_stackable_window_set_going_home (HildonStackableWindow *self,
gboolean going_home)
{
priv->going_home = going_home;
}
-static gboolean
+gboolean G_GNUC_INTERNAL
hildon_stackable_window_get_going_home (HildonStackableWindow *self)
{
HildonStackableWindowPrivate *priv = HILDON_STACKABLE_WINDOW_GET_PRIVATE (self);
return GTK_WIDGET (newwindow);
}
-
-/**
- * hildon_stackable_window_go_to_root_window:
- * @self: A #HildonStackableWindow
- *
- * Will close all the stackable windows in the @HildonProgram but the
- * first one (the root window) by sending them a delete event. If any
- * of the windows refuses to close (by handling it) no further events
- * will be sent.
- */
-void
-hildon_stackable_window_go_to_root_window (HildonStackableWindow *self)
-{
- GSList *windows, *iter;
- gboolean windows_left;
-
- g_return_if_fail (HILDON_IS_STACKABLE_WINDOW (self));
-
- /* List of windows in reverse order (starting from the topmost one) */
- windows = g_slist_reverse (g_slist_copy (get_window_list (GTK_WIDGET (self))));
- iter = windows;
-
- /* Destroy all the windows but the last one (which is the root
- * window, as the list is reversed) */
- windows_left = (iter != NULL && iter->next != NULL);
- while (windows_left)
- {
- if (HILDON_IS_STACKABLE_WINDOW (iter->data))
- {
- GdkEvent *event;
- HildonStackableWindow *win;
-
- /* Mark the window as "going home" */
- win = HILDON_STACKABLE_WINDOW (iter->data);
- hildon_stackable_window_set_going_home (win, TRUE);
-
- /* Set win pointer to NULL if the window is destroyed */
- g_object_add_weak_pointer (G_OBJECT (win), (gpointer) &win);
-
- /* Send a delete event */
- event = gdk_event_new (GDK_DELETE);
- event->any.window = g_object_ref (GTK_WIDGET (win)->window);
- gtk_main_do_event (event);
- gdk_event_free (event);
-
- /* Continue sending delete events if the window has been destroyed */
- if (win == NULL)
- {
- iter = iter->next;
- windows_left = (iter != NULL && iter->next != NULL);
- }
- else
- {
- g_object_remove_weak_pointer (G_OBJECT (win), (gpointer) &win);
- hildon_stackable_window_set_going_home (win, FALSE);
- windows_left = FALSE;
- }
- }
- else
- {
- g_warning ("Window list contains a non-stackable window");
- windows_left = FALSE;
- }
- }
-
- /* Show the last window that hasn't been destroyed */
- if (iter != NULL && GTK_IS_WIDGET (iter->data))
- {
- gtk_widget_show (GTK_WIDGET (iter->data));
- }
-
- g_slist_free (windows);
-}
GtkWidget*
hildon_stackable_window_new (void);
-void
-hildon_stackable_window_go_to_root_window (HildonStackableWindow* self);
-
G_END_DECLS
#endif /* __HILDON_STACKABLE_WINDOW_H__ */