forked from AuroraMiddleware/gtk
testgtk: Remove resize grips example
Resize grips are gone. And just showing an empty window is not terribly exciting.
This commit is contained in:
parent
3f75b11982
commit
f2f5941d65
185
tests/testgtk.c
185
tests/testgtk.c
@ -1705,190 +1705,6 @@ create_reparent (GtkWidget *widget)
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
/*
|
||||
* Resize Grips
|
||||
*/
|
||||
static gboolean
|
||||
grippy_button_press (GtkWidget *area, GdkEventButton *event, GdkWindowEdge edge)
|
||||
{
|
||||
if (event->type == GDK_BUTTON_PRESS)
|
||||
{
|
||||
if (event->button == GDK_BUTTON_PRIMARY)
|
||||
gtk_window_begin_resize_drag (GTK_WINDOW (gtk_widget_get_toplevel (area)), edge,
|
||||
event->button, event->x_root, event->y_root,
|
||||
event->time);
|
||||
else if (event->button == GDK_BUTTON_MIDDLE)
|
||||
gtk_window_begin_move_drag (GTK_WINDOW (gtk_widget_get_toplevel (area)),
|
||||
event->button, event->x_root, event->y_root,
|
||||
event->time);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
grippy_draw (GtkWidget *area, cairo_t *cr, GdkWindowEdge edge)
|
||||
{
|
||||
GtkStyleContext *context;
|
||||
GtkJunctionSides sides;
|
||||
|
||||
switch (edge)
|
||||
{
|
||||
case GDK_WINDOW_EDGE_NORTH_WEST:
|
||||
sides = GTK_JUNCTION_CORNER_TOPLEFT;
|
||||
break;
|
||||
case GDK_WINDOW_EDGE_NORTH:
|
||||
sides = GTK_JUNCTION_TOP;
|
||||
break;
|
||||
case GDK_WINDOW_EDGE_NORTH_EAST:
|
||||
sides = GTK_JUNCTION_CORNER_TOPRIGHT;
|
||||
break;
|
||||
case GDK_WINDOW_EDGE_WEST:
|
||||
sides = GTK_JUNCTION_LEFT;
|
||||
break;
|
||||
case GDK_WINDOW_EDGE_EAST:
|
||||
sides = GTK_JUNCTION_RIGHT;
|
||||
break;
|
||||
case GDK_WINDOW_EDGE_SOUTH_WEST:
|
||||
sides = GTK_JUNCTION_CORNER_BOTTOMLEFT;
|
||||
break;
|
||||
case GDK_WINDOW_EDGE_SOUTH:
|
||||
sides = GTK_JUNCTION_BOTTOM;
|
||||
break;
|
||||
case GDK_WINDOW_EDGE_SOUTH_EAST:
|
||||
sides = GTK_JUNCTION_CORNER_BOTTOMRIGHT;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
context = gtk_widget_get_style_context (area);
|
||||
gtk_style_context_save (context);
|
||||
gtk_style_context_add_class (context, "grip");
|
||||
gtk_style_context_set_junction_sides (context, sides);
|
||||
gtk_render_handle (context, cr,
|
||||
0, 0,
|
||||
gtk_widget_get_allocated_width (area),
|
||||
gtk_widget_get_allocated_height (area));
|
||||
|
||||
gtk_style_context_restore (context);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
create_resize_grips (GtkWidget *widget)
|
||||
{
|
||||
static GtkWidget *window = NULL;
|
||||
GtkWidget *area;
|
||||
GtkWidget *hbox, *vbox;
|
||||
if (!window)
|
||||
{
|
||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||
|
||||
gtk_window_set_screen (GTK_WINDOW (window),
|
||||
gtk_widget_get_screen (widget));
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (window), "resize grips");
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_widget_destroyed),
|
||||
&window);
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_container_add (GTK_CONTAINER (window), vbox);
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE);
|
||||
|
||||
/* North west */
|
||||
area = gtk_drawing_area_new ();
|
||||
gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE);
|
||||
g_signal_connect (area, "draw", G_CALLBACK (grippy_draw),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH_WEST));
|
||||
g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH_WEST));
|
||||
|
||||
/* North */
|
||||
area = gtk_drawing_area_new ();
|
||||
gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE);
|
||||
g_signal_connect (area, "draw", G_CALLBACK (grippy_draw),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH));
|
||||
g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH));
|
||||
|
||||
/* North east */
|
||||
area = gtk_drawing_area_new ();
|
||||
gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE);
|
||||
g_signal_connect (area, "draw", G_CALLBACK (grippy_draw),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH_EAST));
|
||||
g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_NORTH_EAST));
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE);
|
||||
|
||||
/* West */
|
||||
area = gtk_drawing_area_new ();
|
||||
gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE);
|
||||
g_signal_connect (area, "draw", G_CALLBACK (grippy_draw),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_WEST));
|
||||
g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_WEST));
|
||||
|
||||
/* Middle */
|
||||
area = gtk_drawing_area_new ();
|
||||
gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE);
|
||||
|
||||
/* East */
|
||||
area = gtk_drawing_area_new ();
|
||||
gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE);
|
||||
g_signal_connect (area, "draw", G_CALLBACK (grippy_draw),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_EAST));
|
||||
g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_EAST));
|
||||
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE);
|
||||
|
||||
/* South west */
|
||||
area = gtk_drawing_area_new ();
|
||||
gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE);
|
||||
g_signal_connect (area, "draw", G_CALLBACK (grippy_draw),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH_WEST));
|
||||
g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH_WEST));
|
||||
/* South */
|
||||
area = gtk_drawing_area_new ();
|
||||
gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE);
|
||||
g_signal_connect (area, "draw", G_CALLBACK (grippy_draw),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH));
|
||||
g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH));
|
||||
|
||||
/* South east */
|
||||
area = gtk_drawing_area_new ();
|
||||
gtk_widget_add_events (area, GDK_BUTTON_PRESS_MASK);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), area, TRUE, TRUE);
|
||||
g_signal_connect (area, "draw", G_CALLBACK (grippy_draw),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH_EAST));
|
||||
g_signal_connect (area, "button_press_event", G_CALLBACK (grippy_button_press),
|
||||
GINT_TO_POINTER (GDK_WINDOW_EDGE_SOUTH_EAST));
|
||||
}
|
||||
|
||||
if (!gtk_widget_get_visible (window))
|
||||
gtk_widget_show_all (window);
|
||||
else
|
||||
gtk_widget_destroy (window);
|
||||
}
|
||||
|
||||
/*
|
||||
* Saved Position
|
||||
*/
|
||||
@ -8842,7 +8658,6 @@ struct {
|
||||
{ "radio buttons", create_radio_buttons },
|
||||
{ "range controls", create_range_controls },
|
||||
{ "reparent", create_reparent },
|
||||
{ "resize grips", create_resize_grips },
|
||||
{ "rotated label", create_rotated_label },
|
||||
{ "rotated text", create_rotated_text },
|
||||
{ "saved position", create_saved_position },
|
||||
|
Loading…
Reference in New Issue
Block a user