demos/gtk-demo/changedisplay.c demos/gtk-demo/clipboard.c

2008-08-11  Sven Neumann  <sven@gimp.org>

	* demos/gtk-demo/changedisplay.c
	* demos/gtk-demo/clipboard.c
	* demos/gtk-demo/drawingarea.c
	* demos/gtk-demo/iconview.c
	* demos/gtk-demo/images.c
	* demos/gtk-demo/pixbufs.c: use canonical signal names in the 
demos.


svn path=/trunk/; revision=21074
This commit is contained in:
Sven Neumann 2008-08-11 19:12:58 +00:00 committed by Sven Neumann
parent 987da8416f
commit 092187e99c
7 changed files with 172 additions and 161 deletions

View File

@ -1,3 +1,12 @@
2008-08-11 Sven Neumann <sven@gimp.org>
* demos/gtk-demo/changedisplay.c
* demos/gtk-demo/clipboard.c
* demos/gtk-demo/drawingarea.c
* demos/gtk-demo/iconview.c
* demos/gtk-demo/images.c
* demos/gtk-demo/pixbufs.c: use canonical signal names in the demos.
2008-08-11 Matthias Clasen <mclasen@redhat.com>
Bug 547211 Duplicated mnemonic

View File

@ -1,5 +1,5 @@
/* Change Display
*
*
* Demonstrates migrating a window between different displays and
* screens. A display is a mouse and keyboard with some number of
* associated monitors. A screen is a set of monitors grouped
@ -21,7 +21,7 @@
* - Changing the screen for a window
*
* - Letting the user choose a window by clicking on it
*
*
* - Using GtkListStore and GtkTreeView
*
* - Using GtkDialog
@ -45,7 +45,7 @@ struct _ChangeDisplayInfo
GtkTreeModel *display_model;
GtkTreeModel *screen_model;
GtkTreeSelection *screen_selection;
GdkDisplay *current_display;
GdkScreen *current_screen;
};
@ -111,23 +111,23 @@ query_for_toplevel (GdkScreen *screen,
GtkWidget *popup, *label, *frame;
GdkCursor *cursor;
GtkWidget *toplevel = NULL;
popup = gtk_window_new (GTK_WINDOW_POPUP);
gtk_window_set_screen (GTK_WINDOW (popup), screen);
gtk_window_set_modal (GTK_WINDOW (popup), TRUE);
gtk_window_set_position (GTK_WINDOW (popup), GTK_WIN_POS_CENTER);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT);
gtk_container_add (GTK_CONTAINER (popup), frame);
label = gtk_label_new (prompt);
gtk_misc_set_padding (GTK_MISC (label), 10, 10);
gtk_container_add (GTK_CONTAINER (frame), label);
gtk_widget_show_all (popup);
cursor = gdk_cursor_new_for_display (display, GDK_CROSSHAIR);
if (gdk_pointer_grab (popup->window, FALSE,
GDK_BUTTON_RELEASE_MASK,
NULL,
@ -135,26 +135,26 @@ query_for_toplevel (GdkScreen *screen,
GDK_CURRENT_TIME) == GDK_GRAB_SUCCESS)
{
gboolean clicked = FALSE;
g_signal_connect (popup, "button-release-event",
G_CALLBACK (button_release_event_cb), &clicked);
/* Process events until clicked is set by button_release_event_cb.
* We pass in may_block=TRUE since we want to wait if there
* are no events currently.
*/
while (!clicked)
g_main_context_iteration (NULL, TRUE);
toplevel = find_toplevel_at_pointer (gdk_screen_get_display (screen));
if (toplevel == popup)
toplevel = NULL;
}
gdk_cursor_unref (cursor);
gtk_widget_destroy (popup);
gdk_flush (); /* Really release the grab */
return toplevel;
}
@ -188,12 +188,12 @@ fill_screens (ChangeDisplayInfo *info)
{
gint n_screens = gdk_display_get_n_screens (info->current_display);
gint i;
for (i = 0; i < n_screens; i++)
{
GdkScreen *screen = gdk_display_get_screen (info->current_display, i);
GtkTreeIter iter;
gtk_list_store_append (GTK_LIST_STORE (info->screen_model), &iter);
gtk_list_store_set (GTK_LIST_STORE (info->screen_model), &iter,
SCREEN_COLUMN_NUMBER, i,
@ -234,7 +234,7 @@ open_display_cb (GtkWidget *button,
GtkWidget *dialog_label;
gchar *new_screen_name = NULL;
GdkDisplay *result = NULL;
dialog = gtk_dialog_new_with_buttons ("Open Display",
GTK_WINDOW (info->window),
GTK_DIALOG_MODAL,
@ -253,13 +253,13 @@ open_display_cb (GtkWidget *button,
gtk_widget_grab_focus (display_entry);
gtk_widget_show_all (GTK_BIN (dialog)->child);
while (!result)
{
gint response_id = gtk_dialog_run (GTK_DIALOG (dialog));
if (response_id != GTK_RESPONSE_OK)
break;
new_screen_name = gtk_editable_get_chars (GTK_EDITABLE (display_entry),
0, -1);
@ -278,7 +278,7 @@ open_display_cb (GtkWidget *button,
g_free (new_screen_name);
}
}
gtk_widget_destroy (dialog);
}
@ -351,7 +351,7 @@ create_frame (ChangeDisplayInfo *info,
GtkTreeSelection *selection;
GtkWidget *scrollwin;
GtkWidget *hbox;
*frame = gtk_frame_new (title);
hbox = gtk_hbox_new (FALSE, 8);
@ -377,7 +377,7 @@ create_frame (ChangeDisplayInfo *info,
if (!info->size_group)
info->size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (GTK_SIZE_GROUP (info->size_group), *button_vbox);
}
@ -413,7 +413,7 @@ create_display_frame (ChangeDisplayInfo *info)
button = left_align_button_new ("_Open...");
g_signal_connect (button, "clicked", G_CALLBACK (open_display_cb), info);
gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0);
button = left_align_button_new ("_Close");
g_signal_connect (button, "clicked", G_CALLBACK (close_display_cb), info);
gtk_box_pack_start (GTK_BOX (button_vbox), button, FALSE, FALSE, 0);
@ -484,7 +484,7 @@ display_closed_cb (GdkDisplay *display,
valid = gtk_tree_model_iter_next (info->display_model, &iter))
{
GdkDisplay *tmp_display;
gtk_tree_model_get (info->display_model, &iter,
DISPLAY_COLUMN_DISPLAY, &tmp_display,
-1);
@ -506,7 +506,7 @@ add_display (ChangeDisplayInfo *info,
{
const gchar *name = gdk_display_get_name (display);
GtkTreeIter iter;
gtk_list_store_append (GTK_LIST_STORE (info->display_model), &iter);
gtk_list_store_set (GTK_LIST_STORE (info->display_model), &iter,
DISPLAY_COLUMN_NAME, name,
@ -514,7 +514,7 @@ add_display (ChangeDisplayInfo *info,
-1);
g_signal_connect (display, "closed",
G_CALLBACK (display_closed_cb), info);
G_CALLBACK (display_closed_cb), info);
}
/* Called when a new display is opened
@ -543,7 +543,7 @@ initialize_displays (ChangeDisplayInfo *info)
g_slist_free (tmp_list);
g_signal_connect (manager, "display_opened",
g_signal_connect (manager, "display-opened",
G_CALLBACK (display_opened_cb), info);
}
@ -566,7 +566,7 @@ destroy_info (ChangeDisplayInfo *info)
g_signal_handlers_disconnect_by_func (tmp_list->data,
display_closed_cb,
info);
g_slist_free (tmp_list);
g_object_unref (info->size_group);
@ -605,7 +605,7 @@ do_changedisplay (GtkWidget *do_widget)
info = g_new0 (ChangeDisplayInfo, 1);
info->window = gtk_dialog_new_with_buttons ("Change Screen or display",
GTK_WINDOW (do_widget),
GTK_WINDOW (do_widget),
GTK_DIALOG_NO_SEPARATOR,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
"Change", GTK_RESPONSE_OK,
@ -620,13 +620,13 @@ do_changedisplay (GtkWidget *do_widget)
vbox = gtk_vbox_new (FALSE, 5);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (info->window)->vbox), vbox,
TRUE, TRUE, 0);
frame = create_display_frame (info);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
frame = create_screen_frame (info);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);

View File

@ -1,9 +1,9 @@
/* Clipboard
*
* GtkClipboard is used for clipboard handling. This demo shows how to
* copy and paste text to and from the clipboard.
* copy and paste text to and from the clipboard.
*
* It also shows how to transfer images via the clipboard or via
* It also shows how to transfer images via the clipboard or via
* drag-and-drop, and how to make clipboard contents persist after
* the application exits. Clipboard persistence requires a clipboard
* manager to run.
@ -22,7 +22,7 @@ copy_button_clicked (GtkWidget *button,
GtkClipboard *clipboard;
entry = GTK_WIDGET (user_data);
/* Get the clipboard object */
clipboard = gtk_widget_get_clipboard (entry,
GDK_SELECTION_CLIPBOARD);
@ -39,7 +39,7 @@ paste_received (GtkClipboard *clipboard,
GtkWidget *entry;
entry = GTK_WIDGET (user_data);
/* Set the entry text */
if(text)
gtk_entry_set_text (GTK_ENTRY (entry), text);
@ -53,7 +53,7 @@ paste_button_clicked (GtkWidget *button,
GtkClipboard *clipboard;
entry = GTK_WIDGET (user_data);
/* Get the clipboard object */
clipboard = gtk_widget_get_clipboard (entry,
GDK_SELECTION_CLIPBOARD);
@ -80,7 +80,7 @@ get_image_pixbuf (GtkImage *image)
return gtk_widget_render_icon (GTK_WIDGET (image),
stock_id, size, NULL);
default:
g_warning ("Image storage type %d not handled",
g_warning ("Image storage type %d not handled",
gtk_image_get_storage_type (image));
return NULL;
}
@ -98,7 +98,7 @@ drag_begin (GtkWidget *widget,
g_object_unref (pixbuf);
}
void
void
drag_data_get (GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
@ -171,12 +171,12 @@ button_press (GtkWidget *widget,
{
GtkWidget *menu;
GtkWidget *item;
if (button->button != 3)
return FALSE;
menu = gtk_menu_new ();
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, NULL);
g_signal_connect (item, "activate", G_CALLBACK (copy_image), data);
gtk_widget_show (item);
@ -201,18 +201,18 @@ do_clipboard (GtkWidget *do_widget)
GtkWidget *entry, *button;
GtkWidget *ebox, *image;
GtkClipboard *clipboard;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_set_border_width (GTK_CONTAINER (vbox), 8);
gtk_container_add (GTK_CONTAINER (window), vbox);
label = gtk_label_new ("\"Copy\" will copy the text\nin the entry to the clipboard");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
hbox = gtk_hbox_new (FALSE, 4);
@ -222,7 +222,7 @@ do_clipboard (GtkWidget *do_widget)
/* Create the first entry */
entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
/* Create the button */
button = gtk_button_new_from_stock (GTK_STOCK_COPY);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
@ -239,13 +239,13 @@ do_clipboard (GtkWidget *do_widget)
/* Create the second entry */
entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0);
/* Create the button */
button = gtk_button_new_from_stock (GTK_STOCK_PASTE);
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
g_signal_connect (button, "clicked",
G_CALLBACK (paste_button_clicked), entry);
label = gtk_label_new ("Images can be transferred via the clipboard, too");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
@ -254,7 +254,7 @@ do_clipboard (GtkWidget *do_widget)
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
/* Create the first image */
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING,
GTK_ICON_SIZE_BUTTON);
ebox = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (ebox), image);
@ -263,24 +263,24 @@ do_clipboard (GtkWidget *do_widget)
/* make ebox a drag source */
gtk_drag_source_set (ebox, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (ebox);
g_signal_connect (ebox, "drag_begin",
g_signal_connect (ebox, "drag-begin",
G_CALLBACK (drag_begin), image);
g_signal_connect (ebox, "drag_data_get",
g_signal_connect (ebox, "drag-data-get",
G_CALLBACK (drag_data_get), image);
/* accept drops on ebox */
gtk_drag_dest_set (ebox, GTK_DEST_DEFAULT_ALL,
gtk_drag_dest_set (ebox, GTK_DEST_DEFAULT_ALL,
NULL, 0, GDK_ACTION_COPY);
gtk_drag_dest_add_image_targets (ebox);
g_signal_connect (ebox, "drag_data_received",
g_signal_connect (ebox, "drag-data-received",
G_CALLBACK (drag_data_received), image);
/* context menu on ebox */
g_signal_connect (ebox, "button_press_event",
g_signal_connect (ebox, "button-press-event",
G_CALLBACK (button_press), image);
/* Create the second image */
image = gtk_image_new_from_stock (GTK_STOCK_STOP,
image = gtk_image_new_from_stock (GTK_STOCK_STOP,
GTK_ICON_SIZE_BUTTON);
ebox = gtk_event_box_new ();
gtk_container_add (GTK_CONTAINER (ebox), image);
@ -289,22 +289,22 @@ do_clipboard (GtkWidget *do_widget)
/* make ebox a drag source */
gtk_drag_source_set (ebox, GDK_BUTTON1_MASK, NULL, 0, GDK_ACTION_COPY);
gtk_drag_source_add_image_targets (ebox);
g_signal_connect (ebox, "drag_begin",
g_signal_connect (ebox, "drag-begin",
G_CALLBACK (drag_begin), image);
g_signal_connect (ebox, "drag_data_get",
g_signal_connect (ebox, "drag-data-get",
G_CALLBACK (drag_data_get), image);
/* accept drops on ebox */
gtk_drag_dest_set (ebox, GTK_DEST_DEFAULT_ALL,
gtk_drag_dest_set (ebox, GTK_DEST_DEFAULT_ALL,
NULL, 0, GDK_ACTION_COPY);
gtk_drag_dest_add_image_targets (ebox);
g_signal_connect (ebox, "drag_data_received",
g_signal_connect (ebox, "drag-data-received",
G_CALLBACK (drag_data_received), image);
/* context menu on ebox */
g_signal_connect (ebox, "button_press_event",
g_signal_connect (ebox, "button-press-event",
G_CALLBACK (button_press), image);
/* tell the clipboard manager to make the data persistent */
clipboard = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_can_store (clipboard, NULL, 0);

View File

@ -55,7 +55,7 @@ scribble_expose_event (GtkWidget *widget,
* but honestly any GC would work. The only thing to worry about
* is whether the GC has an inappropriate clip region set.
*/
gdk_draw_drawable (widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
pixmap,
@ -63,7 +63,7 @@ scribble_expose_event (GtkWidget *widget,
event->area.x, event->area.y,
event->area.x, event->area.y,
event->area.width, event->area.height);
return FALSE;
}
@ -100,7 +100,7 @@ scribble_button_press_event (GtkWidget *widget,
{
if (pixmap == NULL)
return FALSE; /* paranoia check, in case we haven't gotten a configure event */
if (event->button == 1)
draw_brush (widget, event->x, event->y);
@ -129,9 +129,9 @@ scribble_motion_notify_event (GtkWidget *widget,
* we avoid getting a huge number of events faster than we
* can cope.
*/
gdk_window_get_pointer (event->window, &x, &y, &state);
if (state & GDK_BUTTON1_MASK)
draw_brush (widget, x, y);
@ -148,10 +148,10 @@ checkerboard_expose (GtkWidget *da,
gint i, j, xcount, ycount;
GdkGC *gc1, *gc2;
GdkColor color;
#define CHECK_SIZE 10
#define SPACING 2
/* At the start of an expose handler, a clip region of event->area
* is set on the window, and event->area has been cleared to the
* widget's background color. The docs for
@ -174,7 +174,7 @@ checkerboard_expose (GtkWidget *da,
color.green = 65535;
color.blue = 65535;
gdk_gc_set_rgb_fg_color (gc2, &color);
xcount = 0;
i = SPACING;
while (i < da->allocation.width)
@ -184,7 +184,7 @@ checkerboard_expose (GtkWidget *da,
while (j < da->allocation.height)
{
GdkGC *gc;
if (ycount % 2)
gc = gc1;
else
@ -208,10 +208,10 @@ checkerboard_expose (GtkWidget *da,
i += CHECK_SIZE + SPACING;
++xcount;
}
g_object_unref (gc1);
g_object_unref (gc2);
/* return TRUE because we've handled this event, so no
* further processing is required.
*/
@ -235,7 +235,7 @@ do_drawingarea (GtkWidget *do_widget)
GtkWidget *vbox;
GtkWidget *da;
GtkWidget *label;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@ -254,38 +254,38 @@ do_drawingarea (GtkWidget *do_widget)
/*
* Create the checkerboard area
*/
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Checkerboard pattern</u>");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
da = gtk_drawing_area_new ();
/* set a minimum size */
gtk_widget_set_size_request (da, 100, 100);
gtk_container_add (GTK_CONTAINER (frame), da);
g_signal_connect (da, "expose_event",
g_signal_connect (da, "expose-event",
G_CALLBACK (checkerboard_expose), NULL);
/*
* Create the scribble area
*/
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Scribble area</u>");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
gtk_box_pack_start (GTK_BOX (vbox), frame, TRUE, TRUE, 0);
da = gtk_drawing_area_new ();
/* set a minimum size */
gtk_widget_set_size_request (da, 100, 100);
@ -293,17 +293,17 @@ do_drawingarea (GtkWidget *do_widget)
gtk_container_add (GTK_CONTAINER (frame), da);
/* Signals used to handle backing pixmap */
g_signal_connect (da, "expose_event",
g_signal_connect (da, "expose-event",
G_CALLBACK (scribble_expose_event), NULL);
g_signal_connect (da,"configure_event",
g_signal_connect (da,"configure-event",
G_CALLBACK (scribble_configure_event), NULL);
/* Event signals */
g_signal_connect (da, "motion_notify_event",
g_signal_connect (da, "motion-notify-event",
G_CALLBACK (scribble_motion_notify_event), NULL);
g_signal_connect (da, "button_press_event",
g_signal_connect (da, "button-press-event",
G_CALLBACK (scribble_button_press_event), NULL);

View File

@ -1,7 +1,7 @@
/* Icon View/Icon View Basics
*
* The GtkIconView widget is used to display and manipulate icons.
* It uses a GtkTreeModel for data storage, so the list store
* The GtkIconView widget is used to display and manipulate icons.
* It uses a GtkTreeModel for data storage, so the list store
* example might be helpful.
*/
@ -47,10 +47,10 @@ load_pixbufs (GError **error)
file_pixbuf = gdk_pixbuf_new_from_file (filename, error);
g_free (filename);
if (!file_pixbuf)
return FALSE; /* Note that "error" was filled with a GError */
filename = demo_find_file (FOLDER_NAME, error);
if (!filename)
return FALSE; /* note that "error" was filled in and returned */
@ -67,7 +67,7 @@ fill_store (GtkListStore *store)
GDir *dir;
const gchar *name;
GtkTreeIter iter;
/* First clear the store */
gtk_list_store_clear (store);
@ -82,14 +82,14 @@ fill_store (GtkListStore *store)
{
gchar *path, *display_name;
gboolean is_dir;
/* We ignore hidden files that start with a '.' */
if (name[0] != '.')
{
path = g_build_filename (parent, name, NULL);
is_dir = g_file_test (path, G_FILE_TEST_IS_DIR);
display_name = g_filename_to_utf8 (name, -1, NULL, NULL, NULL);
gtk_list_store_append (store, &iter);
@ -103,7 +103,7 @@ fill_store (GtkListStore *store)
g_free (display_name);
}
name = g_dir_read_name (dir);
name = g_dir_read_name (dir);
}
}
@ -121,7 +121,7 @@ sort_func (GtkTreeModel *model,
* folders before files.
*/
gtk_tree_model_get (model, a,
COL_IS_DIRECTORY, &is_dir_a,
COL_DISPLAY_NAME, &name_a,
@ -153,12 +153,12 @@ create_store (void)
GtkListStore *store;
store = gtk_list_store_new (NUM_COLS,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_STRING,
GDK_TYPE_PIXBUF,
G_TYPE_BOOLEAN);
/* Set sort column and function */
/* Set sort column and function */
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (store),
sort_func,
NULL, NULL);
@ -178,7 +178,7 @@ item_activated (GtkIconView *icon_view,
gchar *path;
GtkTreeIter iter;
gboolean is_dir;
store = GTK_LIST_STORE (user_data);
gtk_tree_model_get_iter (GTK_TREE_MODEL (store),
@ -193,7 +193,7 @@ item_activated (GtkIconView *icon_view,
g_free (path);
return;
}
/* Replace parent with path and re-fill the model*/
g_free (parent);
parent = path;
@ -215,7 +215,7 @@ up_clicked (GtkToolItem *item,
dir_name = g_path_get_dirname (parent);
g_free (parent);
parent = dir_name;
fill_store (store);
@ -261,10 +261,10 @@ do_iconview (GtkWidget *do_widget)
if (!window)
{
GError *error;
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
gtk_window_set_screen (GTK_WINDOW (window),
gtk_widget_get_screen (do_widget));
gtk_window_set_title (GTK_WINDOW (window), "GtkIconView demo");
@ -299,13 +299,13 @@ do_iconview (GtkWidget *do_widget)
GtkWidget *vbox;
GtkWidget *tool_bar;
GtkToolItem *home_button;
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
tool_bar = gtk_toolbar_new ();
gtk_box_pack_start (GTK_BOX (vbox), tool_bar, FALSE, FALSE, 0);
up_button = gtk_tool_button_new_from_stock (GTK_STOCK_GO_UP);
gtk_tool_item_set_is_important (up_button, TRUE);
gtk_widget_set_sensitive (GTK_WIDGET (up_button), FALSE);
@ -314,17 +314,17 @@ do_iconview (GtkWidget *do_widget)
home_button = gtk_tool_button_new_from_stock (GTK_STOCK_HOME);
gtk_tool_item_set_is_important (home_button, TRUE);
gtk_toolbar_insert (GTK_TOOLBAR (tool_bar), home_button, -1);
sw = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw),
GTK_SHADOW_ETCHED_IN);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0);
/* Create the store and fill it with the contents of '/' */
parent = g_strdup ("/");
store = create_store ();
@ -334,7 +334,7 @@ do_iconview (GtkWidget *do_widget)
gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view),
GTK_SELECTION_MULTIPLE);
g_object_unref (store);
/* Connect to the "clicked" signal of the "Up" tool button */
g_signal_connect (up_button, "clicked",
G_CALLBACK (up_clicked), store);
@ -342,22 +342,22 @@ do_iconview (GtkWidget *do_widget)
/* Connect to the "clicked" signal of the "Home" tool button */
g_signal_connect (home_button, "clicked",
G_CALLBACK (home_clicked), store);
/* We now set which model columns that correspond to the text
* and pixbuf of each item
*/
gtk_icon_view_set_text_column (GTK_ICON_VIEW (icon_view), COL_DISPLAY_NAME);
gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (icon_view), COL_PIXBUF);
/* Connect to the "item_activated" signal */
g_signal_connect (icon_view, "item_activated",
/* Connect to the "item-activated" signal */
g_signal_connect (icon_view, "item-activated",
G_CALLBACK (item_activated), store);
gtk_container_add (GTK_CONTAINER (sw), icon_view);
gtk_widget_grab_focus (icon_view);
}
}
if (!GTK_WIDGET_VISIBLE (window))
gtk_widget_show_all (window);
else

View File

@ -31,14 +31,14 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
GtkWidget *image;
image = GTK_WIDGET (data);
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
/* Avoid displaying random memory contents, since the pixbuf
* isn't filled in yet.
*/
gdk_pixbuf_fill (pixbuf, 0xaaaaaaff);
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
}
@ -51,7 +51,7 @@ progressive_updated_callback (GdkPixbufLoader *loader,
gpointer data)
{
GtkWidget *image;
image = GTK_WIDGET (data);
/* We know the pixbuf inside the GtkImage has changed, but the image
@ -61,7 +61,7 @@ progressive_updated_callback (GdkPixbufLoader *loader,
* the pixbuf on the display, then we could queue a draw for only
* the updated area of the image.
*/
gtk_widget_queue_draw (image);
}
@ -71,24 +71,24 @@ progressive_timeout (gpointer data)
GtkWidget *image;
image = GTK_WIDGET (data);
/* This shows off fully-paranoid error handling, so looks scary.
* You could factor out the error handling code into a nice separate
* function to make things nicer.
*/
if (image_stream)
{
size_t bytes_read;
guchar buf[256];
GError *error = NULL;
bytes_read = fread (buf, 1, 256, image_stream);
if (ferror (image_stream))
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
@ -103,7 +103,7 @@ progressive_timeout (gpointer data)
image_stream = NULL;
gtk_widget_show (dialog);
load_timeout = 0;
return FALSE; /* uninstall the timeout */
@ -114,7 +114,7 @@ progressive_timeout (gpointer data)
&error))
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
@ -123,13 +123,13 @@ progressive_timeout (gpointer data)
error->message);
g_error_free (error);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
fclose (image_stream);
image_stream = NULL;
gtk_widget_show (dialog);
load_timeout = 0;
@ -151,29 +151,29 @@ progressive_timeout (gpointer data)
&error))
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
"Failed to load image: %s",
error->message);
g_error_free (error);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
g_object_unref (pixbuf_loader);
pixbuf_loader = NULL;
load_timeout = 0;
return FALSE; /* uninstall the timeout */
}
g_object_unref (pixbuf_loader);
pixbuf_loader = NULL;
}
@ -182,7 +182,7 @@ progressive_timeout (gpointer data)
{
gchar *filename;
gchar *error_message = NULL;
GError *error = NULL;
GError *error = NULL;
/* demo_find_file() looks in the current directory first,
* so you can run gtk-demo without installing GTK, then looks
@ -207,7 +207,7 @@ progressive_timeout (gpointer data)
if (image_stream == NULL)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
@ -217,7 +217,7 @@ progressive_timeout (gpointer data)
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
load_timeout = 0;
@ -231,13 +231,13 @@ progressive_timeout (gpointer data)
g_object_unref (pixbuf_loader);
pixbuf_loader = NULL;
}
pixbuf_loader = gdk_pixbuf_loader_new ();
g_signal_connect (pixbuf_loader, "area_prepared",
g_signal_connect (pixbuf_loader, "area-prepared",
G_CALLBACK (progressive_prepared_callback), image);
g_signal_connect (pixbuf_loader, "area_updated",
g_signal_connect (pixbuf_loader, "area-updated",
G_CALLBACK (progressive_updated_callback), image);
}
@ -269,7 +269,7 @@ cleanup_callback (GtkObject *object,
g_source_remove (load_timeout);
load_timeout = 0;
}
if (pixbuf_loader)
{
gdk_pixbuf_loader_close (pixbuf_loader, NULL);
@ -289,7 +289,7 @@ toggle_sensitivity_callback (GtkWidget *togglebutton,
GtkContainer *container = user_data;
GList *list;
GList *tmp;
list = gtk_container_get_children (container);
tmp = list;
@ -299,13 +299,13 @@ toggle_sensitivity_callback (GtkWidget *togglebutton,
if (GTK_WIDGET (tmp->data) != togglebutton)
gtk_widget_set_sensitive (GTK_WIDGET (tmp->data),
!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (togglebutton)));
tmp = tmp->next;
}
g_list_free (list);
}
GtkWidget *
do_images (GtkWidget *do_widget)
@ -319,7 +319,7 @@ do_images (GtkWidget *do_widget)
GdkPixbuf *pixbuf;
GError *error = NULL;
char *filename;
if (!window)
{
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@ -342,7 +342,7 @@ do_images (GtkWidget *do_widget)
gtk_label_set_markup (GTK_LABEL (label),
"<u>Image loaded from a file</u>");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
/* The alignment keeps the frame from growing when users resize
@ -373,7 +373,7 @@ do_images (GtkWidget *do_widget)
* be displayed instead.
*/
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
@ -381,13 +381,13 @@ do_images (GtkWidget *do_widget)
"Unable to open image file 'gtk-logo-rgb.gif': %s",
error->message);
g_error_free (error);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_widget_show (dialog);
}
image = gtk_image_new_from_pixbuf (pixbuf);
gtk_container_add (GTK_CONTAINER (frame), image);
@ -399,7 +399,7 @@ do_images (GtkWidget *do_widget)
gtk_label_set_markup (GTK_LABEL (label),
"<u>Animation loaded from a file</u>");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
/* The alignment keeps the frame from growing when users resize
@ -414,16 +414,16 @@ do_images (GtkWidget *do_widget)
g_free (filename);
gtk_container_add (GTK_CONTAINER (frame), image);
/* Progressive */
label = gtk_label_new (NULL);
gtk_label_set_markup (GTK_LABEL (label),
"<u>Progressive image loading</u>");
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
/* The alignment keeps the frame from growing when users resize

View File

@ -218,8 +218,10 @@ do_pixbufs (GtkWidget *do_widget)
gtk_window_set_title (GTK_WINDOW (window), "Pixbufs");
gtk_window_set_resizable (GTK_WINDOW (window), FALSE);
g_signal_connect (window, "destroy", G_CALLBACK (gtk_widget_destroyed), &window);
g_signal_connect (window, "destroy", G_CALLBACK (cleanup_callback), NULL);
g_signal_connect (window, "destroy",
G_CALLBACK (gtk_widget_destroyed), &window);
g_signal_connect (window, "destroy",
G_CALLBACK (cleanup_callback), NULL);
error = NULL;
@ -249,7 +251,7 @@ do_pixbufs (GtkWidget *do_widget)
da = gtk_drawing_area_new ();
g_signal_connect (da, "expose_event",
g_signal_connect (da, "expose-event",
G_CALLBACK (expose_cb), NULL);
gtk_container_add (GTK_CONTAINER (window), da);