Update so that toplevel windows accomodate for the titlebar when sizing.
Tue Nov 16 00:08:07 2004 Jonathan Blandford <jrb@redhat.com> * docs/tools/widgets.c: Update so that toplevel windows accomodate for the titlebar when sizing. Also clean up statusbar * docs/reference/gtk/images/*png: update
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.5 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 8.2 KiB After Width: | Height: | Size: 9.0 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 2.0 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.6 KiB |
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 3.9 KiB |
Before Width: | Height: | Size: 9.0 KiB After Width: | Height: | Size: 9.1 KiB |
@ -212,6 +212,7 @@ int main (int argc, char **argv)
|
||||
gtk_main_iteration ();
|
||||
}
|
||||
sleep (1);
|
||||
|
||||
while (gtk_events_pending ())
|
||||
{
|
||||
gtk_main_iteration ();
|
||||
|
@ -1,12 +1,91 @@
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <X11/Xatom.h>
|
||||
#include <gdkx.h>
|
||||
#include "widgets.h"
|
||||
|
||||
typedef enum
|
||||
|
||||
#define SMALL_WIDTH 240
|
||||
#define SMALL_HEIGHT 75
|
||||
#define MEDIUM_WIDTH 240
|
||||
#define MEDIUM_HEIGHT 165
|
||||
#define LARGE_WIDTH 240
|
||||
#define LARGE_HEIGHT 240
|
||||
|
||||
static Window
|
||||
find_toplevel_window (Window xid)
|
||||
{
|
||||
SMALL,
|
||||
MEDIUM,
|
||||
LARGE
|
||||
} WidgetSize;
|
||||
Window root, parent, *children;
|
||||
int nchildren;
|
||||
|
||||
do
|
||||
{
|
||||
if (XQueryTree (GDK_DISPLAY (), xid, &root,
|
||||
&parent, &children, &nchildren) == 0)
|
||||
{
|
||||
g_warning ("Couldn't find window manager window");
|
||||
return None;
|
||||
}
|
||||
|
||||
if (root == parent)
|
||||
return xid;
|
||||
|
||||
xid = parent;
|
||||
}
|
||||
while (TRUE);
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
adjust_size_callback (WidgetInfo *info)
|
||||
{
|
||||
Window toplevel;
|
||||
Window root;
|
||||
gint tx;
|
||||
gint ty;
|
||||
guint twidth;
|
||||
guint theight;
|
||||
guint tborder_width;
|
||||
guint tdepth;
|
||||
gint target_width = 0;
|
||||
gint target_height = 0;
|
||||
|
||||
toplevel = find_toplevel_window (GDK_WINDOW_XID (info->window->window));
|
||||
XGetGeometry (GDK_WINDOW_XDISPLAY (info->window->window),
|
||||
toplevel,
|
||||
&root, &tx, &ty, &twidth, &theight, &tborder_width, &tdepth);
|
||||
|
||||
switch (info->size)
|
||||
{
|
||||
case SMALL:
|
||||
target_width = SMALL_WIDTH;
|
||||
target_height = SMALL_HEIGHT;
|
||||
break;
|
||||
case MEDIUM:
|
||||
target_width = MEDIUM_WIDTH;
|
||||
target_height = MEDIUM_HEIGHT;
|
||||
break;
|
||||
case LARGE:
|
||||
target_width = LARGE_WIDTH;
|
||||
target_height = LARGE_HEIGHT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (twidth > target_width ||
|
||||
theight > target_height)
|
||||
{
|
||||
gtk_widget_set_size_request (info->window,
|
||||
2 + target_width - (twidth - target_width), /* Dunno why I need the +2 fudge factor; */
|
||||
2 + target_height - (theight - target_height));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
realize_callback (GtkWidget *widget,
|
||||
WidgetInfo *info)
|
||||
{
|
||||
g_timeout_add (500, (GSourceFunc)adjust_size_callback, info);
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
new_widget_info (const char *name,
|
||||
@ -17,10 +96,13 @@ new_widget_info (const char *name,
|
||||
|
||||
info = g_new0 (WidgetInfo, 1);
|
||||
info->name = g_strdup (name);
|
||||
info->size = size;
|
||||
if (GTK_IS_WINDOW (widget))
|
||||
{
|
||||
info->window = widget;
|
||||
gtk_window_set_resizable (GTK_WINDOW (info->window), FALSE);
|
||||
info->include_decorations = TRUE;
|
||||
g_signal_connect (info->window, "realize", G_CALLBACK (realize_callback), info);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -454,8 +536,7 @@ create_window (void)
|
||||
WidgetInfo *info;
|
||||
GtkWidget *widget;
|
||||
|
||||
widget = gtk_frame_new (NULL);
|
||||
gtk_frame_set_shadow_type (GTK_FRAME (widget), GTK_SHADOW_NONE);
|
||||
widget = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
info = new_widget_info ("window", widget, MEDIUM);
|
||||
info->include_decorations = TRUE;
|
||||
gtk_window_set_title (GTK_WINDOW (info->window), "Window");
|
||||
@ -525,7 +606,7 @@ create_message_dialog (void)
|
||||
GTK_BUTTONS_OK,
|
||||
NULL);
|
||||
gtk_message_dialog_set_markup (GTK_MESSAGE_DIALOG (widget),
|
||||
"<b>Message Dialog</b>");
|
||||
"<b>Message Dialog</b>\n\nWith secondary text");
|
||||
return new_widget_info ("messagedialog", widget, MEDIUM);
|
||||
}
|
||||
|
||||
@ -602,23 +683,28 @@ create_spinbutton (void)
|
||||
static WidgetInfo *
|
||||
create_statusbar (void)
|
||||
{
|
||||
WidgetInfo *info;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *vbox, *align;
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 0);
|
||||
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_add (GTK_CONTAINER (align), gtk_label_new ("Status Bar"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox),
|
||||
align,
|
||||
TRUE, TRUE, 0);
|
||||
widget = gtk_statusbar_new ();
|
||||
align = gtk_alignment_new (0.5, 1.0, 1.0, 0.0);
|
||||
gtk_container_add (GTK_CONTAINER (align), widget);
|
||||
gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (widget), TRUE);
|
||||
gtk_statusbar_push (GTK_STATUSBAR (widget), 0, "Hold on...");
|
||||
gtk_widget_set_size_request (widget, 220, -1);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 3);
|
||||
align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
|
||||
gtk_container_add (GTK_CONTAINER (align), widget);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), align, FALSE, FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox),
|
||||
gtk_label_new ("Status Bar"),
|
||||
FALSE, FALSE, 0);
|
||||
gtk_box_pack_end (GTK_BOX (vbox), align, FALSE, FALSE, 0);
|
||||
|
||||
return new_widget_info ("statusbar", vbox, SMALL);
|
||||
info = new_widget_info ("statusbar", vbox, SMALL);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (info->window), 0);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
static WidgetInfo *
|
||||
@ -669,34 +755,34 @@ get_all_widgets (void)
|
||||
{
|
||||
GList *retval = NULL;
|
||||
|
||||
retval = g_list_prepend (retval, create_button ());
|
||||
retval = g_list_prepend (retval, create_toggle_button ());
|
||||
retval = g_list_prepend (retval, create_check_button ());
|
||||
retval = g_list_prepend (retval, create_entry ());
|
||||
retval = g_list_prepend (retval, create_radio ());
|
||||
retval = g_list_prepend (retval, create_label ());
|
||||
retval = g_list_prepend (retval, create_combo_box_entry ());
|
||||
retval = g_list_prepend (retval, create_text_view ());
|
||||
retval = g_list_prepend (retval, create_tree_view ());
|
||||
retval = g_list_prepend (retval, create_color_button ());
|
||||
retval = g_list_prepend (retval, create_font_button ());
|
||||
retval = g_list_prepend (retval, create_separator ());
|
||||
retval = g_list_prepend (retval, create_panes ());
|
||||
retval = g_list_prepend (retval, create_frame ());
|
||||
retval = g_list_prepend (retval, create_window ());
|
||||
retval = g_list_prepend (retval, create_accel_label ());
|
||||
retval = g_list_prepend (retval, create_button ());
|
||||
retval = g_list_prepend (retval, create_check_button ());
|
||||
retval = g_list_prepend (retval, create_color_button ());
|
||||
retval = g_list_prepend (retval, create_combo_box_entry ());
|
||||
retval = g_list_prepend (retval, create_entry ());
|
||||
retval = g_list_prepend (retval, create_file_button ());
|
||||
retval = g_list_prepend (retval, create_font_button ());
|
||||
retval = g_list_prepend (retval, create_frame ());
|
||||
retval = g_list_prepend (retval, create_icon_view ());
|
||||
retval = g_list_prepend (retval, create_toolbar ());
|
||||
retval = g_list_prepend (retval, create_image ());
|
||||
retval = g_list_prepend (retval, create_label ());
|
||||
retval = g_list_prepend (retval, create_menubar ());
|
||||
retval = g_list_prepend (retval, create_notebook ());
|
||||
retval = g_list_prepend (retval, create_message_dialog ());
|
||||
retval = g_list_prepend (retval, create_notebook ());
|
||||
retval = g_list_prepend (retval, create_panes ());
|
||||
retval = g_list_prepend (retval, create_progressbar ());
|
||||
retval = g_list_prepend (retval, create_radio ());
|
||||
retval = g_list_prepend (retval, create_scales ());
|
||||
retval = g_list_prepend (retval, create_scrolledwindow ());
|
||||
retval = g_list_prepend (retval, create_separator ());
|
||||
retval = g_list_prepend (retval, create_spinbutton ());
|
||||
retval = g_list_prepend (retval, create_statusbar ());
|
||||
retval = g_list_prepend (retval, create_scales ());
|
||||
retval = g_list_prepend (retval, create_image ());
|
||||
retval = g_list_prepend (retval, create_text_view ());
|
||||
retval = g_list_prepend (retval, create_toggle_button ());
|
||||
retval = g_list_prepend (retval, create_toolbar ());
|
||||
retval = g_list_prepend (retval, create_tree_view ());
|
||||
retval = g_list_prepend (retval, create_window ());
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
@ -3,12 +3,21 @@
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SMALL,
|
||||
MEDIUM,
|
||||
LARGE
|
||||
} WidgetSize;
|
||||
|
||||
typedef struct WidgetInfo
|
||||
{
|
||||
GtkWidget *window;
|
||||
gchar *name;
|
||||
gboolean no_focus;
|
||||
gboolean include_decorations;
|
||||
WidgetSize size;
|
||||
} WidgetInfo;
|
||||
|
||||
GList *get_all_widgets (void);
|
||||
|