int main (int argc, char* argv[]) { GtkWidget *window; GList *sources; GFile *dest; GFile *source; int i; GList *infos; NautilusProgressInfoManager *manager; NautilusProgressInfo *progress_info; test_init (&argc, &argv); if (argc < 3) { g_print ("Usage test-copy <sources...> <dest dir>\n"); return 1; } sources = NULL; for (i = 1; i < argc - 1; i++) { source = g_file_new_for_commandline_arg (argv[i]); sources = g_list_prepend (sources, source); } sources = g_list_reverse (sources); dest = g_file_new_for_commandline_arg (argv[i]); window = test_window_new ("copy test", 5); gtk_widget_show (window); manager = nautilus_progress_info_manager_new (); nautilus_file_operations_copy (sources, NULL /* GArray *relative_item_points */, dest, GTK_WINDOW (window), copy_done, NULL); infos = nautilus_progress_info_manager_get_all_infos (manager); if (infos == NULL) { g_object_unref (manager); return 0; } progress_info = NAUTILUS_PROGRESS_INFO (infos->data); g_signal_connect (progress_info, "changed", (GCallback)changed_cb, NULL); g_signal_connect (progress_info, "progress-changed", (GCallback)progress_changed_cb, NULL); g_signal_connect (progress_info, "finished", (GCallback)finished_cb, NULL); gtk_main (); g_object_unref (manager); return 0; }
static GtkWidget * labeled_image_button_window_new (const char *title, GdkPixbuf *pixbuf) { GtkWidget *window; GtkWidget *vbox; GtkWidget *button; GtkWidget *toggle_button; GtkWidget *check_button; GtkWidget *plain; window = test_window_new (title, 20); vbox = gtk_vbox_new (FALSE, 10); gtk_container_add (GTK_CONTAINER (window), vbox); if (1) button = eel_labeled_image_button_new ("GtkButton with LabeledImage", pixbuf); if (1) toggle_button = eel_labeled_image_toggle_button_new ("GtkToggleButton with LabeledImage", pixbuf); if (1) check_button = eel_labeled_image_check_button_new ("GtkCheckButton with LabeledImage", pixbuf); if (1) { plain = eel_labeled_image_new ("Plain LabeledImage", pixbuf); eel_labeled_image_set_can_focus (EEL_LABELED_IMAGE (plain), TRUE); } if (button) gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0); if (toggle_button) gtk_box_pack_start (GTK_BOX (vbox), toggle_button, TRUE, TRUE, 0); if (check_button) gtk_box_pack_start (GTK_BOX (vbox), check_button, TRUE, TRUE, 0); if (plain) gtk_box_pack_start (GTK_BOX (vbox), plain, TRUE, TRUE, 0); if (button) { g_signal_connect (button, "enter", G_CALLBACK (button_callback), "enter"); g_signal_connect (button, "leave", G_CALLBACK (button_callback), "leave"); g_signal_connect (button, "pressed", G_CALLBACK (button_callback), "pressed"); g_signal_connect (button, "released", G_CALLBACK (button_callback), "released"); g_signal_connect (button, "clicked", G_CALLBACK (button_callback), "clicked"); } gtk_widget_show_all (vbox); return window; }
static GtkWidget * image_table_new_scrolled (void) { GtkWidget *scrolled; GtkWidget *viewport; GtkWidget *window; GtkWidget *image_table; int i; window = test_window_new ("Image Table Test", 10); gtk_window_set_default_size (GTK_WINDOW (window), 400, 300); /* Scrolled window */ scrolled = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (window), scrolled); /* Viewport */ viewport = gtk_viewport_new (NULL, NULL); gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_OUT); gtk_container_add (GTK_CONTAINER (scrolled), viewport); image_table = eel_image_table_new (FALSE); if (0) g_signal_connect (image_table, "size_allocate", G_CALLBACK (image_table_size_allocate), window); eel_wrap_table_set_x_justification (EEL_WRAP_TABLE (image_table), EEL_JUSTIFICATION_MIDDLE); eel_wrap_table_set_y_justification (EEL_WRAP_TABLE (image_table), EEL_JUSTIFICATION_END); gtk_container_add (GTK_CONTAINER (viewport), image_table); g_signal_connect (image_table, "child_enter", G_CALLBACK (image_table_child_enter_callback), NULL); g_signal_connect (image_table, "child_leave", G_CALLBACK (image_table_child_leave_callback), NULL); g_signal_connect (image_table, "child_pressed", G_CALLBACK (image_table_child_pressed_callback), NULL); g_signal_connect (image_table, "child_released", G_CALLBACK (image_table_child_released_callback), NULL); g_signal_connect (image_table, "child_clicked", G_CALLBACK (image_table_child_clicked_callback), NULL); eel_gtk_widget_set_background_color (viewport, BG_COLOR_SPEC); for (i = 0; i < 100; i++) { char *text; GtkWidget *image; text = g_strdup_printf ("%s %d", names[random () % G_N_ELEMENTS (names)], i); image = labeled_image_new (text, pixbuf_name); g_free (text); gtk_container_add (GTK_CONTAINER (image_table), image); gtk_widget_show (image); } gtk_widget_show (viewport); gtk_widget_show (scrolled); gtk_widget_show (image_table); return window; }
int main (int argc, char* argv[]) { NautilusCustomizationData *customization_data; GtkWidget *window; GtkWidget *emblems_table, *button, *scroller; char *emblem_name, *dot_pos; GdkPixbuf *pixbuf; char *label; test_init (&argc, &argv); window = test_window_new ("Wrap Table Test", 10); gtk_window_set_default_size (GTK_WINDOW (window), 400, 300); /* The emblems wrapped table */ emblems_table = eel_wrap_table_new (TRUE); gtk_widget_show (emblems_table); gtk_container_set_border_width (GTK_CONTAINER (emblems_table), GNOME_PAD); scroller = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroller), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); /* Viewport */ gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scroller), emblems_table); gtk_container_add (GTK_CONTAINER (window), scroller); gtk_widget_show (scroller); #if 0 /* Get rid of default lowered shadow appearance. * This must be done after the widget is realized, due to * an apparent bug in gtk_viewport_set_shadow_type. */ g_signal_connect (GTK_BIN (scroller->child), "realize", remove_default_viewport_shadow, NULL); #endif /* Use nautilus_customization to make the emblem widgets */ customization_data = nautilus_customization_data_new ("emblems", TRUE, NAUTILUS_ICON_SIZE_SMALL, NAUTILUS_ICON_SIZE_SMALL); while (nautilus_customization_data_get_next_element_for_display (customization_data, &emblem_name, &pixbuf, &label) == GNOME_VFS_OK) { /* strip the suffix, if any */ dot_pos = strrchr(emblem_name, '.'); if (dot_pos) { *dot_pos = '\0'; } if (strcmp (emblem_name, "erase") == 0) { g_object_unref (pixbuf); g_free (label); g_free (emblem_name); continue; } button = eel_labeled_image_check_button_new (label, pixbuf); g_free (label); g_object_unref (pixbuf); /* Attach parameters and signal handler. */ g_object_set_data_full (G_OBJECT (button), "nautilus_property_name", emblem_name, (GDestroyNotify) g_free); gtk_container_add (GTK_CONTAINER (emblems_table), button); } gtk_widget_show_all (emblems_table); gtk_widget_show (window); gtk_main (); return 0; }