aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/ui_util.h
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2004-05-23 17:37:36 +0000
committerUlf Lamping <ulf.lamping@web.de>2004-05-23 17:37:36 +0000
commit01c236864ac165449462e9d197efee3e47fde43e (patch)
tree86264de02e07c71a7d27de5313ec8c5f6f09d361 /gtk/ui_util.h
parent461c0d59cd323ef1c437e49503b76a99bcc2279f (diff)
next step to save the size and postition of the dialogs (using a hashtable)
move the get/set window size functionality from main to ui_util, add some functions to handle windows/dialogs. changed help and about dialog to suit the current window API svn path=/trunk/; revision=10974
Diffstat (limited to 'gtk/ui_util.h')
-rw-r--r--gtk/ui_util.h92
1 files changed, 88 insertions, 4 deletions
diff --git a/gtk/ui_util.h b/gtk/ui_util.h
index b8e1d0cb9c..05ffb5ec8a 100644
--- a/gtk/ui_util.h
+++ b/gtk/ui_util.h
@@ -1,7 +1,7 @@
/* ui_util.h
* Definitions for UI utility routines
*
- * $Id: ui_util.h,v 1.9 2004/05/20 18:18:12 ulfl Exp $
+ * $Id: ui_util.h,v 1.10 2004/05/23 17:37:36 ulfl Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -25,16 +25,100 @@
#ifndef __GTKGUIUI_UTIL_H__
#define __GTKGUIUI_UTIL_H__
+/* Some words about windows / dialogs.
+ *
+ * delete event: the window managers "X" (e.g. upper right edge) of the window
+ * was clicked, default handler will call gtk_widget_destroy()
+ * destroy event: everything is already gone, only cleanup of left over ressources
+ * can/should be done now
+ *
+ * Hint: don't use WIDGET_SET_SIZE() to set the size of a window,
+ * use gtk_window_set_default_size() for that purpose!
+ *
+ * be sure, to call window_present() / window_destroy() appropriately, if you
+ * want to have size and position handled by ui_util
+ *
+ * A typical window / dialog will be created by:
+ *
+ * window_new(...) will create a new window with default position and size
+ * use dlg_window_new() if you need a dialog (transient to the main window)
+ *
+ * gtk_window_set_default_size(...) to set the default size of the window, only
+ * needed, if the initial size is not appropriate, e.g. a scrolled_window_new() is used
+ * be sure the given is larger than the initial size, otherwise might get clipped content on GTK1
+ *
+ * SIGNAL_CONNECT(my_win, "destroy", my_destroy_cb, NULL) callback, if some cleanup needs to be
+ * done after the window is destroyed, e.g. free up memory, or set the window pointer
+ * of a singleton window (only one instance allowed, e.g. about dialog) back to zero
+ *
+ * create and fill in the content and button widgets
+ *
+ * gtk_widget_show_all(my_win) show all the widgets in the window
+ *
+ * window_present(...) present the window on screen and
+ * (if available) set previously saved position and size
+ *
+ * if you want to save size and position, be sure to call window_destroy() instead of only
+ * gtk_widget_destroy(), so you will probably have to SIGNAL_CONNECT to the "delete_event"!
+ */
+
/* Create a new window, of the specified type, with the specified title
- (if any) and the Ethereal icon. */
-GtkWidget *window_new(GtkWindowType, const gchar *);
+ * (if any) and the Ethereal icon.
+ * If you want to create a dialog, use dlg_window_new() instead.
+ * type window type, typical GTK_WINDOW_TOPLEVEL
+ * title title to show, will also set the window class for saving size etc. */
+extern GtkWidget *window_new(GtkWindowType type, const gchar *title);
+
+/* Present the created window. This will put the window on top and
+ * (if available) set previously saved position and size. */
+extern void window_present(GtkWidget *win);
+
+typedef void (*window_cancel_button_fct) (GtkWidget *w, gpointer data);
+
+/* register the default cancel button "Cancel"/"Close"/"Ok" of this window */
+extern void window_set_cancel_button(GtkWidget *win, GtkWidget *bt, window_cancel_button_fct cb);
+
+/* Remember current window position and size and then destroy the window,
+ * call this instead of gtk_widget_destroy(); */
+extern void window_destroy(GtkWidget *win);
+
+/* default callback handler for cancel button "clicked" signal,
+ * use this for window_set_cancel_button(), will simply call window_destroy() */
+extern void window_cancel_button_cb(GtkWidget *w _U_, gpointer data);
+
+/* default callback handler: the window managers X of the window was clicked (delete_event),
+ * use this for SIGNAL_CONNECT(), will simply call window_destroy() */
+extern gboolean
+window_delete_event_cb(GtkWidget *win, GdkEvent *event _U_, gpointer user_data _U_);
+
+
+typedef struct window_geometry_s {
+ gchar *key;
+ gboolean set_pos;
+ gint x;
+ gint y;
+ gboolean set_size;
+ gint width;
+ gint height;
+
+ gboolean set_maximized;
+ gboolean maximized; /* this is valid in GTK2 only */
+} window_geometry_t;
+
+/* get the geometry of a window from window_new() */
+extern void window_get_geometry(GtkWidget *win, window_geometry_t *geom);
+/* set the geometry of a window from window_new() */
+extern void window_set_geometry(GtkWidget *win, window_geometry_t *geom);
+
+/* load the geometry values for a window from previously saved values */
+extern gboolean window_load_geom(GtkWidget *win, window_geometry_t *geom);
/* Given a pointer to a GtkWidget for a top-level window, raise it and
de-iconify it. This routine is used if the user has done something to
ask that a window of a certain type be popped up when there can be only
one such window and such a window has already been popped up - we
pop up the existing one rather than creating a new one. */
-void reactivate_window(GtkWidget *);
+void reactivate_window(GtkWidget *win);
/* Create a GtkScrolledWindow, set its scrollbar placement appropriately,
and remember it. */