diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/Makefile.am gphoto/src/Makefile.am --- gphoto.orig/src/Makefile.am Sun Sep 10 18:22:03 2000 +++ gphoto/src/Makefile.am Sun Sep 10 18:23:38 2000 @@ -32,7 +32,9 @@ developer.h \ developer_dialog.h \ exif.c \ - exif.h + exif.h \ + canvas.c \ + canvas.h gphoto_LDFLAGS = -export-dynamic diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/callbacks.c gphoto/src/callbacks.c --- gphoto.orig/src/callbacks.c Sun Sep 10 18:22:03 2000 +++ gphoto/src/callbacks.c Wed Sep 6 18:18:19 2000 @@ -22,6 +22,8 @@ #include "main.h" #include "util.h" #include "callbacks.h" +#include "toolbar.h" +#include "canvas.h" #include #include @@ -113,9 +115,9 @@ error_dialog("Camera is already busy"); return; } - cam_busy=1; + set_toolbar_busy(); ret=Camera->ops->initialize(); - cam_busy=0; + set_toolbar_ready(); if (ret) return; } } @@ -128,9 +130,9 @@ error_dialog("Camera is already busy"); return; } - cam_busy=1; + set_toolbar_busy(); ret=Camera->ops->configure(); - cam_busy=0; + set_toolbar_ready(); if (ret == 0) error_dialog("No configuration options."); } @@ -151,9 +153,9 @@ error_dialog("Camera is already busy"); return; } - cam_busy=1; + set_toolbar_busy(); picNum = Camera->ops->take_picture(); - cam_busy=0; + set_toolbar_ready(); if (!picNum) { error_dialog("Could not take a picture."); @@ -175,7 +177,7 @@ error_dialog("Camera is already busy"); return; } - cam_busy=1; + set_toolbar_busy(); no_pics = Camera->ops->number_of_pictures(); i = no_pics; @@ -198,7 +200,7 @@ update_status("Deleted all images."); update_progress(0); gtk_widget_destroy(dialog); - cam_busy=0; + set_toolbar_ready(); } void del_pics(GtkWidget *dialog, GtkObject *button) @@ -211,14 +213,14 @@ error_dialog("Camera is already busy"); return; } - cam_busy=1; + set_toolbar_busy(); gtk_widget_hide(dialog); update_status("Deleting selected pictures..."); /* delete from camera... */ node = node->next; /* Point at first thumbnail */ while (node != NULL) { - if (GTK_TOGGLE_BUTTON(node->button)->active) { + if (node->active) { node = node->next; if (Camera->ops->delete_picture(i) != 0) { remove_thumbnail(i); @@ -234,7 +236,7 @@ } gtk_widget_destroy(dialog); update_status("Done."); - cam_busy=0; + set_toolbar_ready(); } void del_dialog(int type) @@ -252,7 +254,7 @@ while (node->next != NULL) { node = node->next; - if (GTK_TOGGLE_BUTTON(node->button)->active) + if (node->active) nothing_selected = 0; } if (nothing_selected) { @@ -325,9 +327,9 @@ error_dialog("Camera is already busy"); return; } - cam_busy=1; + set_toolbar_busy(); im = Camera->ops->get_picture(picNum, thumbnail); - cam_busy=0; + set_toolbar_ready(); if (im == 0) { sprintf(error, "Could not save #%i", picNum); error_dialog(error); @@ -408,7 +410,7 @@ while (node->next) { node = node->next; i++; - if (GTK_TOGGLE_BUTTON(node->button)->active) { + if (node->active) { if ((strcmp("i", type)==0)||(strcmp("in", type)==0)) { sprintf(status, "Saving Image #%03i...", i); update_status(status); @@ -461,9 +463,9 @@ error_dialog("Camera is already busy"); return; } - cam_busy=1; + set_toolbar_busy(); im = Camera->ops->get_picture(picNum, thumbnail); - cam_busy=0; + set_toolbar_ready(); if (im == 0) { sprintf(error, "Could not retrieve #%i", picNum); error_dialog(error); @@ -1173,13 +1175,7 @@ sprintf(status, "Getting thumbnail %i...", i); update_status(status); - if (cam_busy) { - error_dialog("Camera is already busy"); - return; - } - cam_busy=1; im = Camera->ops->get_picture(i, 1); - cam_busy=0; if (im==0) { sprintf(error, "Could not retrieve #%i", i); error_dialog(error); @@ -1246,16 +1242,19 @@ /* Double click will (re)-load the thumbnail */ if (event->type == GDK_2BUTTON_PRESS) { + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + set_toolbar_busy(); insert_thumbnail((struct ImageMembers *)callback_data); + set_toolbar_ready(); return TRUE; } return FALSE; } -extern void activate_button(GtkWidget *cur_button); -extern void deactivate_button(GtkWidget *cur_button); - /* get index of images and place in main page table calling with getthumbs==0 makes a set of blank buttons @@ -1277,31 +1276,37 @@ while (Thumbnails.next != NULL) remove_thumbnail(1); - if (index_table) - gtk_widget_destroy(index_table); - - index_table = gtk_table_new(100,6,FALSE); - gtk_widget_show(index_table); - gtk_container_add(GTK_CONTAINER(index_vp), index_table); - if (cam_busy) { error_dialog("Camera is already busy"); return; } - cam_busy=1; + set_toolbar_busy(); num_pictures_taken = Camera->ops->number_of_pictures(); - cam_busy=0; + set_toolbar_ready(); fprintf(stderr, "num_pictures_taken is %d\n", num_pictures_taken); if (num_pictures_taken == -1) { error_dialog("Could not get the number of pictures"); return; } + if (index_table) { + gtk_container_remove (GTK_CONTAINER(index_vp), index_table); + index_table=NULL; + gphoto_canvas_destroy(); + } + index_table=gphoto_canvas_create (97*6+5,97*(num_pictures_taken/6)+5); + gtk_container_add(GTK_CONTAINER(index_vp), index_table); + + if (cam_busy) { + error_dialog("Camera is already busy"); + return; + } + + set_toolbar_busy(); okAction = 1; - activate_button(stop_button); for (i = 0; i < num_pictures_taken; i++) { if (!okAction) { - deactivate_button(stop_button); + set_toolbar_ready(); update_progress(0); update_status("Download cancelled."); return; @@ -1315,6 +1320,8 @@ node->label = NULL; node->info = NULL; node->next = NULL; + node->frame=NULL; + node->active=0; node->button = gtk_toggle_button_new(); gtk_widget_show(node->button); @@ -1356,13 +1363,14 @@ GTK_SIGNAL_FUNC(thumb_click), node); - gtk_table_attach(GTK_TABLE(index_table), - node->button, - i%6,i%6+1,i/6,i/6+1, - GTK_FILL,GTK_FILL,5,5); + node->x = 97*(i%6)+5; + node->y = 97*(i/6)+5; + node->width = 87; + node->height= 87; + add_to_canvas (node); update_progress(progress_max); } - deactivate_button(stop_button); + set_toolbar_ready(); update_progress(0); update_status("Done getting index."); } @@ -1401,7 +1409,7 @@ while (node->next) { node = node->next; - if (GTK_TOGGLE_BUTTON(node->button)->active) + if (node->active) x++; } if (!x) { @@ -1412,11 +1420,10 @@ node = &Thumbnails; update_progress(0); okAction = 1; - activate_button(stop_button); while (node->next && okAction) { node = node->next; i++; - if (GTK_TOGGLE_BUTTON(node->button)->active) { + if (node->active) { progress_min=(float)y/(float)x; progress_max=(float)(y+1)/(float)x; y++; @@ -1432,9 +1439,7 @@ sprintf(status, "Getting Thumbnail #%03i...", i); update_status(status); } - gtk_toggle_button_set_state( - GTK_TOGGLE_BUTTON(node->button), - FALSE); + gphoto_canvas_item_toggle_active (node); update_progress(progress_max); } } @@ -1443,7 +1448,6 @@ update_status("Done downloading."); else update_status("Download halted."); - deactivate_button(stop_button); update_progress(0); } @@ -1662,35 +1666,69 @@ gtk_widget_destroy(dialog); } -void select_all(void) +void +select_all(void) +{ + struct ImageMembers *node = &Thumbnails; + + while (node->next) { + node = node->next; + gphoto_canvas_item_set_active (node); + } +} + +void +select_inverse(void) { struct ImageMembers *node = &Thumbnails; while (node->next) { node = node->next; - if (!GTK_TOGGLE_BUTTON(node->button)->active) - gtk_button_clicked(GTK_BUTTON(node->button)); + gphoto_canvas_item_toggle_active (node); } } -void select_inverse(void) +void +select_none(void) { struct ImageMembers *node = &Thumbnails; while (node->next) { node = node->next; - gtk_button_clicked(GTK_BUTTON(node->button)); + gphoto_canvas_item_unset_active (node); } } -void select_none(void) +static int +test_overlap (double x0, double x1, double x2, double x3) +{ + double x0_,x1_,x2_,x3_; + + x0_=MIN (x0,x1); + x1_=MAX (x0,x1); + x2_=MIN (x2,x3); + x3_=MAX (x2,x3); + return ((x0_<=x2_ && x2_<=x1_) + ||(x0_<=x3_ && x3_<=x1_) + ||(x2_<=x0_ && x0_<=x3_) + ||(x2_<=x1_ && x1_<=x3_)); +} + +void +toggle_in_area(double x1, double y1, double x2, double y2) { struct ImageMembers *node = &Thumbnails; + double nx1,nx2,ny1,ny2; while (node->next) { node = node->next; - if (GTK_TOGGLE_BUTTON(node->button)->active) - gtk_button_clicked(GTK_BUTTON(node->button)); + nx1=node->x; + ny1=node->y; + nx2=node->x+80; + ny2=node->y+60; + if (test_overlap (nx1, nx2, x1, x2) + && test_overlap (ny1, ny2, y1, y2)) + gphoto_canvas_item_toggle_active (node); } } @@ -1927,10 +1965,10 @@ error_dialog("Camera is already busy"); return; } - cam_busy=1; + set_toolbar_busy(); message_window("Camera Summary", Camera->ops->summary(), GTK_JUSTIFY_FILL); - cam_busy=0; + set_toolbar_ready(); } /* Decreases image size by factor n % */ diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/callbacks.h gphoto/src/callbacks.h --- gphoto.orig/src/callbacks.h Sun Sep 10 18:22:03 2000 +++ gphoto/src/callbacks.h Wed Sep 6 16:57:18 2000 @@ -1,3 +1,8 @@ +#ifndef _CALLBACKS_H +#define _CALLBACKS_H +#include +#include "gphoto.h" + gint delete_event (GtkWidget *widget, GdkEvent *event, gpointer data); gint thumb_click (GtkWidget *widget, GdkEventButton *event, gpointer callback_data); char* find_tag(struct Image *im, char* name); @@ -39,6 +44,7 @@ void select_all(); void select_inverse(); void select_none(); +void toggle_in_area(double, double, double, double); void color_dialog(); void resize_dialog(); void manip_pic (gchar *Option); @@ -73,3 +79,4 @@ void browse_themes(); void browse_links(); void browse_todo(); +#endif diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/canvas.c gphoto/src/canvas.c --- gphoto.orig/src/canvas.c Thu Jan 1 01:00:00 1970 +++ gphoto/src/canvas.c Sun Sep 10 18:21:11 2000 @@ -0,0 +1,329 @@ +/* gPhoto - Thumbnail handling with the Gnome Canvas + * + * Copyright (C) 2000 The Free Software Foundation + * + * Author: Fabrice Bellet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "callbacks.h" +#include "gphoto.h" + +GnomeCanvasGroup *gphoto_canvas_root = NULL; +GtkWidget *gphoto_canvas = NULL; +GtkWidget *gphoto_canvas_table = NULL; +static GnomeCanvasItem *gphoto_rect; + +extern struct ImageMembers Thumbnails; + +static void +gphoto_zoom_changed (GtkAdjustment *adj, gpointer data) +{ + gnome_canvas_set_pixels_per_unit (data, adj->value); +} + +void +gphoto_canvas_item_destroy (struct ImageMembers *node) +{ + if (node) { + node->active=0; + if (node->frame) { + gtk_object_destroy (GTK_OBJECT (node->frame)); + node->frame=NULL; + } + if (node->picture) { + gtk_object_destroy (GTK_OBJECT (node->picture)); + node->picture=NULL; + } + if (node->text) { + gtk_object_destroy (GTK_OBJECT (node->text)); + node->text=NULL; + } + } +} + +void +gphoto_canvas_destroy () +{ + struct ImageMembers *node = &Thumbnails; + + gphoto_rect=NULL; + gphoto_canvas_root=NULL; + gphoto_canvas=NULL; + gphoto_canvas_table=NULL; + + while (node->next) { + node = node->next; + gphoto_canvas_item_destroy (node); + } +} + +void +gphoto_canvas_item_set_active (struct ImageMembers *node) +{ + if (node && !node->active) { + if (node->frame) { + gnome_canvas_item_set (node->frame, + "x1",(double)(node->x-2), + "y1",(double)(node->y-2), + "x2",(double)(node->x+81), + "y2",(double)(node->y+61), + NULL); + gnome_canvas_item_show (node->frame); + } else + node->frame = gnome_canvas_item_new (gphoto_canvas_root, + gnome_canvas_rect_get_type(), + "x1",(double)(node->x-2), + "y1",(double)(node->y-2), + "x2",(double)(node->x+81), + "y2",(double)(node->y+61), + "outline_color", "red", + "width_pixels", 3, + NULL); + node->active=1; + } +} + +void +gphoto_canvas_item_unset_active (struct ImageMembers *node) +{ + if (node && node->active) { + if (node->frame) + gnome_canvas_item_hide (node->frame); + node->active=0; + } +} + +void +gphoto_canvas_item_toggle_active (struct ImageMembers *node) +{ + if (node->active) + gphoto_canvas_item_unset_active (node); + else + gphoto_canvas_item_set_active (node); +} + +static gint +event_handler (GtkWidget *widget, GdkEvent *event, gpointer data) +{ + static double x1, y1; + static double x2, y2; + double item_x, item_y; + GdkCursor *fleur; + static int dragging; + struct ImageMembers *node=data; + + item_x = event->button.x; + item_y = event->button.y; + + switch (event->type) { + case GDK_BUTTON_PRESS: + if (event->button.button==1) { + if (GNOME_IS_CANVAS (widget)) { + gnome_canvas_window_to_world (GNOME_CANVAS (widget), + item_x, item_y, &x1, &y1); + + fleur = gdk_cursor_new (GDK_FLEUR); + gdk_cursor_destroy (fleur); + dragging = TRUE; + x2=x1; + y2=y1; + if (gphoto_rect) { + gnome_canvas_item_set (gphoto_rect, + "x1",x1, + "y1",y1, + "x2",x2, + "y2",y2, + NULL); + gnome_canvas_item_show (gphoto_rect); + } else + gphoto_rect = gnome_canvas_item_new (gphoto_canvas_root, + gnome_canvas_rect_get_type(), + "x1",x1, + "y1",y1, + "x2",x2, + "y2",y2, + "outline_color", "red", + "width_pixels", 1, + NULL); + gnome_canvas_item_raise_to_top (gphoto_rect); + } else + if (node) + gphoto_canvas_item_toggle_active (node); + } + return TRUE; + case GDK_MOTION_NOTIFY: + if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { + gnome_canvas_window_to_world (GNOME_CANVAS (gphoto_canvas), + item_x, item_y, &x2, &y2); + gnome_canvas_item_set (gphoto_rect, + "x1",MIN(x1,x2), + "y1",MIN(y1,y2), + "x2",MAX(x1,x2), + "y2",MAX(y1,y2), + NULL); + } + break; + case GDK_BUTTON_RELEASE: + if (dragging) { + dragging = FALSE; + gnome_canvas_item_hide (gphoto_rect); + toggle_in_area(MIN(x1,x2), MIN(y1,y2), + MAX(x1,x2), MAX(y1,y2)); + } + break; + + default: + break; + } + return FALSE; +} + +static GnomeCanvasItem * +setup_item (GnomeCanvasItem *item, gpointer data) +{ + gtk_signal_connect (GTK_OBJECT (item), "event", + (GtkSignalFunc) event_handler, + data); + return item; +} + +GtkWidget * +gphoto_canvas_create (guint width, guint height) +{ + GtkWidget *w; + GtkWidget *frame; + GtkWidget *hbox; + GtkAdjustment *adj; + + gtk_widget_push_visual (gdk_imlib_get_visual ()); + gtk_widget_push_colormap (gdk_imlib_get_colormap ()); + gphoto_canvas = gnome_canvas_new (); + + /* Setup canvas items */ + + gphoto_canvas_root = gnome_canvas_root (GNOME_CANVAS (gphoto_canvas)); + + gtk_signal_connect (GTK_OBJECT (gphoto_canvas), "event", + (GtkSignalFunc) event_handler, + NULL); + + gtk_widget_pop_colormap (); + gtk_widget_pop_visual (); + + /* + * Layout + */ + + gphoto_canvas_table = gtk_table_new (2, 3, FALSE); + gtk_table_set_row_spacings (GTK_TABLE (gphoto_canvas_table), 4); + gtk_table_set_col_spacings (GTK_TABLE (gphoto_canvas_table), 4); + gtk_widget_show (gphoto_canvas_table); + + frame = gtk_frame_new (NULL); + gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); + gtk_table_attach (GTK_TABLE (gphoto_canvas_table), frame, + 0, 1, 0, 1, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, + 0, 0); + gtk_widget_show (frame); + + gtk_widget_set_usize (gphoto_canvas, width, height); + gnome_canvas_set_scroll_region (GNOME_CANVAS (gphoto_canvas), + 0, 0, width, height); + gtk_container_add (GTK_CONTAINER (frame), gphoto_canvas); + gtk_widget_show (gphoto_canvas); + + w = gtk_hscrollbar_new (GTK_LAYOUT (gphoto_canvas)->hadjustment); + gtk_table_attach (GTK_TABLE (gphoto_canvas_table), w, + 0, 1, 1, 2, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, + GTK_FILL, + 0, 0); + gtk_widget_show (w); + + w = gtk_vscrollbar_new (GTK_LAYOUT (gphoto_canvas)->vadjustment); + gtk_table_attach (GTK_TABLE (gphoto_canvas_table), w, + 1, 2, 0, 1, + GTK_FILL, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, + 0, 0); + gtk_widget_show (w); + + GTK_WIDGET_SET_FLAGS (gphoto_canvas, GTK_CAN_FOCUS); + gtk_widget_grab_focus (gphoto_canvas); + + /* + * Zoom + */ + + hbox = gtk_hbox_new (FALSE, 4); + w = gtk_label_new ("Zoom:"); + gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0); + gtk_widget_show (w); + adj = gtk_adjustment_new (1.00, 0.05, 4.00, 0.05, 0.50, 0.50); + gtk_signal_connect (GTK_OBJECT(adj), "value_changed", + (GtkSignalFunc) gphoto_zoom_changed, + gphoto_canvas); + w = gtk_spin_button_new (adj, 0.0, 2); + gtk_widget_set_usize (w, 50, 0); + gtk_box_pack_start (GTK_BOX(hbox), w, FALSE, FALSE, 0); + gtk_widget_show (w); + gtk_widget_show (hbox); + + gtk_table_attach (GTK_TABLE(gphoto_canvas_table), hbox, + 0, 1, 2, 3, + GTK_EXPAND | GTK_FILL | GTK_SHRINK, + GTK_FILL, + 0, 0); + + return gphoto_canvas_table;; +} + +void +add_to_canvas (struct ImageMembers *node) +{ + GnomeCanvasItem *item; + GdkImlibImage *im; + + item = setup_item (gnome_canvas_item_new (gphoto_canvas_root, + gnome_canvas_image_get_type(), + "image", node->imlibimage, + "x", (double)node->x, + "y", (double)node->y, + "width", (double)node->imlibimage->rgb_width, + "height", (double)node->imlibimage->rgb_height, + "anchor", GTK_ANCHOR_NW, + NULL), node); + gnome_canvas_item_lower (item, 1); + node->picture = item; + item = setup_item (gnome_canvas_item_new (gphoto_canvas_root, + gnome_canvas_text_get_type(), + "text", node->info, + "x", (double)node->x, + "y", (double)node->y, + "font", "-*-clean-medium-r-*-*-12-*-*-*-*-*-*-*", + "anchor", GTK_ANCHOR_NW, + "clip_width", (double)node->imlibimage->rgb_width, + "clip_height", (double)node->imlibimage->rgb_height, + "x_offset", 30.0, + "y_offset", 64.0, + "fill_color", "darkgreen", + NULL), NULL); + gnome_canvas_item_lower (item, 1); + node->text = item; +} diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/canvas.h gphoto/src/canvas.h --- gphoto.orig/src/canvas.h Thu Jan 1 01:00:00 1970 +++ gphoto/src/canvas.h Sun Sep 10 18:21:22 2000 @@ -0,0 +1,39 @@ +/* gPhoto - Thumbnail handling with the Gnome Canvas + * + * Copyright (C) 2000 The Free Software Foundation + * + * Author: Fabrice Bellet + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef GPHOTO_CANVAS_H +#define GPHOTO_CANVAS_H + +#include +#include +#include "gphoto.h" + +extern GnomeCanvasGroup *gphoto_canvas_root; +extern GtkWidget *gphoto_canvas; +extern GtkWidget *gphoto_canvas_table; + +void gphoto_canvas_item_unset_active (struct ImageMembers *node); +void gphoto_canvas_item_set_active (struct ImageMembers *node); +void gphoto_canvas_item_toggle_active (struct ImageMembers *node); +GtkWidget *gphoto_canvas_create (guint width, guint height); +void add_to_canvas (struct ImageMembers *node); + +#endif diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/gallery.c gphoto/src/gallery.c --- gphoto.orig/src/gallery.c Sun Sep 10 18:22:03 2000 +++ gphoto/src/gallery.c Wed Sep 6 18:35:44 2000 @@ -192,6 +192,7 @@ #include "gphoto.h" #include "util.h" #include "callbacks.h" +#include "toolbar.h" #include "gallery.h" #include @@ -440,7 +441,7 @@ i = 0; while (node->next != NULL) { node = node->next; - if (GTK_TOGGLE_BUTTON(node->button)->active) + if (node->active) num_selected++; } if (num_selected == 0) { @@ -703,7 +704,7 @@ while (node->next != NULL) { node = node->next; sprintf(filename, "%s%s", outputdir, output_filename); - if (GTK_TOGGLE_BUTTON(node->button)->active) { + if (node->active) { if ((i%5==0) && (i!=0)) { sprintf(cp, "echo \"\" >> %s", filename); @@ -720,9 +721,9 @@ } progress_min=(float)(2*i)/(float)(num_selected*2); progress_max=(float)(2*i+1)/(float)(num_selected*2); - cam_busy=1; + set_toolbar_busy(); im = Camera->ops->get_picture(j+1, 1); - cam_busy=0; + set_toolbar_ready(); if (im==0) { sprintf(error, "Could not retrieve #%i", j+1); @@ -762,9 +763,9 @@ } progress_min=(float)(2*i+1)/(float)(num_selected*2); progress_max=(float)(2*i+2)/(float)(num_selected*2); - cam_busy=1; + set_toolbar_busy(); im = Camera->ops->get_picture(j+1, 0); - cam_busy=0; + set_toolbar_ready(); if (im==0) { sprintf(error, "Could not retrieve #%i", j+1); error_dialog(error); diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/gphoto.h gphoto/src/gphoto.h --- gphoto.orig/src/gphoto.h Sun Sep 10 18:22:03 2000 +++ gphoto/src/gphoto.h Sun Sep 10 18:10:30 2000 @@ -7,13 +7,11 @@ * silly. */ +#include #include #include #include -/* Include the EXIF support functions */ -// #include "exif.h" - struct Image { int image_size; /* # of bytes of image */ char *image; /* image data */ @@ -53,12 +51,18 @@ struct ImageMembers { GdkImlibImage *imlibimage; - GtkWidget *image; - GtkWidget *button; - GtkWidget *page; - GtkWidget *label; - char *info; - struct ImageMembers *next; + GtkWidget *image; + GtkWidget *button; + GtkWidget *page; + GtkWidget *label; + gint active; + GnomeCanvasItem *frame; + GnomeCanvasItem *picture; + GnomeCanvasItem *text; + gint x, y; + guint width, height; + char *info; + struct ImageMembers *next; }; #define GPHOTO_CAMERA_NONE 0 @@ -75,6 +79,13 @@ extern char *gphotoDir; /* gPhoto directory */ extern char serial_port[20]; /* Serial port */ extern int camera_type; +#endif + +#if !defined(MAX) +#define MAX(a,b) ((a)>(b)?:(a):(b)) +#endif +#if !defined(MIN) +#define MIN(a,b) ((a)<(b)?:(a):(b)) #endif void update_progress (float percentage); diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/live.c gphoto/src/live.c --- gphoto.orig/src/live.c Sun Sep 10 18:22:03 2000 +++ gphoto/src/live.c Thu Aug 24 16:09:49 2000 @@ -2,6 +2,7 @@ #include "gphoto.h" #include "callbacks.h" #include "util.h" +#include "toolbar.h" #include "live.h" #include @@ -31,12 +32,13 @@ return; } update_status("Getting live image..."); - cam_busy=1; + set_toolbar_busy(); if ((im = Camera->ops->get_preview()) == 0) { error_dialog("Could not get preview"); + set_toolbar_ready(); return; } - cam_busy=0; + set_toolbar_ready(); if (im) { imlibimage = gdk_imlib_load_image_mem(im->image, im->image_size); free_image(im); @@ -126,12 +128,12 @@ gtk_signal_connect_object(GTK_OBJECT(cbutton), "clicked", GTK_SIGNAL_FUNC(live_close), GTK_OBJECT(dialog)); - cam_busy=1; + set_toolbar_busy(); if ((im = Camera->ops->get_preview()) == 0) { error_dialog("Could not get preview"); return; } - cam_busy=0; + set_toolbar_ready(); imlibimage = gdk_imlib_load_image_mem(im->image, im->image_size); free(im->image); free(im); diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/main.c gphoto/src/main.c --- gphoto.orig/src/main.c Sun Sep 10 18:22:03 2000 +++ gphoto/src/main.c Sun Sep 3 18:15:28 2000 @@ -24,6 +24,7 @@ #include "toolbar.h" #include "commandline.h" #include "developer_dialog.h" +#include "canvas.h" #include "icons/splash.xpm" /* Splash screen */ #include "icons/post_processing_off.xpm" @@ -139,7 +140,7 @@ } else command_line_mode = 0; - gtk_init(&argc, &argv); + gnome_init ("gPhoto", VERSION, argc, argv); gdk_imlib_init(); gpio_init(1); @@ -157,7 +158,7 @@ gtk_window_set_title(GTK_WINDOW(mainWin), title); gtk_signal_connect(GTK_OBJECT(mainWin), "delete_event", GTK_SIGNAL_FUNC(delete_event), NULL); - gtk_widget_set_usize(mainWin, 730, 480); + gtk_widget_set_usize(mainWin, 806, 480); gtk_widget_realize(mainWin); /* set up the menu --------------------------------------- */ diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/toolbar.c gphoto/src/toolbar.c --- gphoto.orig/src/toolbar.c Sun Sep 10 18:22:03 2000 +++ gphoto/src/toolbar.c Thu Aug 24 16:16:18 2000 @@ -3,10 +3,10 @@ #include "callbacks.h" #include "gallery.h" #include "live.h" +#include "toolbar.h" /* The toolbar xpm icons */ -/* #include "batch_save.xpm" */ #include "icons/close_image.xpm" #include "icons/colors.xpm" #include "icons/configure.xpm" @@ -28,16 +28,18 @@ #include "icons/rotcc.xpm" #include "icons/save_current_image.xpm" #include "icons/stop.xpm" +#include "icons/web_browse.xpm" +#include "icons/take_picture.xpm" -/* #include "web_browse.xpm" */ -/* #include "take_picture.xpm" */ -/* GtkWidget *browse_button = NULL; */ +GtkWidget *buttons[NB_BUTTONS]; +extern int cam_busy; -GtkWidget *stop_button = NULL; - -GtkWidget *add_to_toolbar (GtkWidget *mainWin, gchar *tooltipText, +GtkWidget * +add_to_toolbar (GtkWidget *mainWin, + int button_number, gchar *tooltipText, gchar ** xpmIcon, GtkSignalFunc f, gpointer data, - GtkWidget *box, int Beginning) { + GtkWidget *box, int Beginning) +{ GtkWidget *button, *gpixmap; GdkPixmap *pixmap; @@ -48,7 +50,7 @@ if (f == NULL) button = gtk_label_new(" "); else { - button = gtk_button_new(); + buttons[button_number] = button = gtk_button_new(); tooltip = gtk_tooltips_new(); gtk_tooltips_set_tip(tooltip,button,tooltipText, NULL); gtk_signal_connect_object(GTK_OBJECT(button), "clicked", @@ -69,80 +71,99 @@ return (button); } -void deactivate_button (GtkWidget *cur_button) { - gtk_widget_set_sensitive(GTK_WIDGET(cur_button), FALSE); +void +deactivate_button (int button_number) +{ + if (buttons[button_number]) + gtk_widget_set_sensitive(GTK_WIDGET(buttons[button_number]), FALSE); } -void activate_button (GtkWidget *cur_button) { - gtk_widget_set_sensitive(GTK_WIDGET(cur_button), TRUE); +void +activate_button (int button_number) +{ + if (buttons[button_number]) + gtk_widget_set_sensitive(GTK_WIDGET(buttons[button_number]), TRUE); } -/* void deactivate_stop_button() { */ -/* gtk_widget_set_sensitive(GTK_WIDGET(stop_button), FALSE); */ -/* } */ +void +set_toolbar_busy () +{ + int i; + + for (i = 0; i < NB_BUTTONS; i++) + deactivate_button (i); + activate_button (STOP_BUTTON); + cam_busy=1; +} -/* void activate_stop_button() { */ -/* gtk_widget_set_sensitive(GTK_WIDGET(stop_button), TRUE); */ -/* } */ +void +set_toolbar_ready () +{ + int i; + + for (i = 0; i < NB_BUTTONS; i++) + activate_button (i); + deactivate_button (STOP_BUTTON); + cam_busy=0; +} -void create_toolbar (GtkWidget *box, GtkWidget *mainWin) { +void +create_toolbar (GtkWidget *box, GtkWidget *mainWin) +{ - add_to_toolbar(mainWin, "Open Image", open_image_xpm, + add_to_toolbar(mainWin, OPEN_BUTTON, "Open Image", open_image_xpm, GTK_SIGNAL_FUNC(open_dialog), NULL, box, 1); - add_to_toolbar(mainWin, "Save Opened Image(s)", save_current_image_xpm, + add_to_toolbar(mainWin, SAVE_BUTTON, "Save Opened Image(s)", save_current_image_xpm, GTK_SIGNAL_FUNC(save_dialog), NULL, box, 1); - add_to_toolbar(mainWin, "Print Image", print_image_xpm, + add_to_toolbar(mainWin, PRINT_BUTTON, "Print Image", print_image_xpm, GTK_SIGNAL_FUNC(print_pic), NULL, box, 1); - add_to_toolbar(mainWin, "Close Image", delete_images_xpm, + add_to_toolbar(mainWin, CLOSE_BUTTON, "Close Image", delete_images_xpm, GTK_SIGNAL_FUNC(closepic), "c", box, 1); - add_to_toolbar(mainWin, NULL, NULL, NULL, NULL, box, 1); - add_to_toolbar(mainWin, "Previous page", left_arrow_xpm, + add_to_toolbar(mainWin, 0, NULL, NULL, NULL, NULL, box, 1); + add_to_toolbar(mainWin, PREVIOUS_BUTTON, "Previous page", left_arrow_xpm, GTK_SIGNAL_FUNC(prev_page), "i", box, 1); - add_to_toolbar(mainWin, "Next page", right_arrow_xpm, + add_to_toolbar(mainWin, NEXT_BUTTON, "Next page", right_arrow_xpm, GTK_SIGNAL_FUNC(next_page), "i", box, 1); - add_to_toolbar(mainWin, NULL, NULL, NULL, NULL, box, 1); - add_to_toolbar(mainWin, "Download Thumbnail Index", get_index_xpm, + add_to_toolbar(mainWin, 0, NULL, NULL, NULL, NULL, box, 1); + add_to_toolbar(mainWin, DOWNLOAD_THUMB_BUTTON, "Download Thumbnail Index", get_index_xpm, GTK_SIGNAL_FUNC(getindex), NULL, box, 1); - add_to_toolbar(mainWin, "Download Empty Index", get_index_empty_xpm, + add_to_toolbar(mainWin, DOWNLOAD_EMPTY_BUTTON, "Download Empty Index", get_index_empty_xpm, GTK_SIGNAL_FUNC(getindex_empty), NULL, box, 1); - add_to_toolbar(mainWin, "Download Selected Images", get_selected_images_xpm, + add_to_toolbar(mainWin, DOWNLOAD_SELECTED_BUTTON, "Download Selected Images", get_selected_images_xpm, GTK_SIGNAL_FUNC(getpics), "i", box, 1); - add_to_toolbar(mainWin, "Delete Selected Images", close_image_xpm, + add_to_toolbar(mainWin, DELETE_BUTTON, "Delete Selected Images", close_image_xpm, GTK_SIGNAL_FUNC(del_dialog), NULL, box, 1); - add_to_toolbar(mainWin, NULL, NULL, NULL, NULL, box, 1); - stop_button = add_to_toolbar(mainWin, "Halt Download", stop_xpm, + add_to_toolbar(mainWin, 0, NULL, NULL, NULL, NULL, box, 1); + add_to_toolbar(mainWin, STOP_BUTTON, "Halt Download", stop_xpm, GTK_SIGNAL_FUNC(halt_action), NULL, box, 1); - deactivate_button(stop_button); - add_to_toolbar(mainWin, NULL, NULL, NULL, NULL, box, 1); - add_to_toolbar(mainWin, "Rotate Clockwise", rotc_xpm, + add_to_toolbar(mainWin, 0, NULL, NULL, NULL, NULL, box, 1); + add_to_toolbar(mainWin, ROTATE_CLOCKWISE_BUTTON, "Rotate Clockwise", rotc_xpm, GTK_SIGNAL_FUNC(manip_pic), "r", box, 1); - add_to_toolbar(mainWin, "Rotate Counter-Clockwise", rotcc_xpm, + add_to_toolbar(mainWin, ROTATE_CCLOCKWISE_BUTTON, "Rotate Counter-Clockwise", rotcc_xpm, GTK_SIGNAL_FUNC(manip_pic), "l", box, 1); - add_to_toolbar(mainWin, "Flip Horizontal", fliph_xpm, + add_to_toolbar(mainWin, FLIP_HORIZ_BUTTON, "Flip Horizontal", fliph_xpm, GTK_SIGNAL_FUNC(manip_pic), "h", box, 1); - add_to_toolbar(mainWin, "Flip Vertical", flipv_xpm, + add_to_toolbar(mainWin, FLIP_VERT_BUTTON, "Flip Vertical", flipv_xpm, GTK_SIGNAL_FUNC(manip_pic), "v", box, 1); - add_to_toolbar(mainWin, "Resize", resize_xpm, - GTK_SIGNAL_FUNC(resize_dialog), - "Resize", box, 1); - add_to_toolbar(mainWin, "Colors", colors_xpm, - GTK_SIGNAL_FUNC(color_dialog), - "Colors", box, 1); - add_to_toolbar(mainWin, NULL, NULL, NULL, NULL, box, 1); + add_to_toolbar(mainWin, RESIZE_BUTTON, "Resize", resize_xpm, + GTK_SIGNAL_FUNC(resize_dialog), "Resize", box, 1); + add_to_toolbar(mainWin, COLORS_BUTTON, "Colors", colors_xpm, + GTK_SIGNAL_FUNC(color_dialog), "Colors", box, 1); + add_to_toolbar(mainWin, 0, NULL, NULL, NULL, NULL, box, 1); -/* - browse_button = add_to_toolbar(mainWin, "HTML Gallery", web_browse_xpm, + add_to_toolbar(mainWin, GALLERY_BUTTON, "HTML Gallery", web_browse_xpm, GTK_SIGNAL_FUNC(gallery_main), NULL, box, 1); - add_to_toolbar(mainWin, "Live Camera!", take_picture_xpm, + add_to_toolbar(mainWin, LIVE_BUTTON, "Live Camera!", take_picture_xpm, GTK_SIGNAL_FUNC(live_main), NULL, box, 1); - add_to_toolbar(mainWin, NULL, NULL, NULL, NULL, box, 1); -*/ + add_to_toolbar(mainWin, 0, NULL, NULL, NULL, NULL, box, 1); - add_to_toolbar(mainWin, "Camera Configuration", configure_xpm, + add_to_toolbar(mainWin, CONFIG_BUTTON, "Camera Configuration", configure_xpm, GTK_SIGNAL_FUNC(configure_call), NULL, box, 1); - add_to_toolbar(mainWin, NULL, NULL, NULL, NULL, box, 1); - add_to_toolbar(mainWin, "Help", help_xpm, + add_to_toolbar(mainWin, 0, NULL, NULL, NULL, NULL, box, 1); + add_to_toolbar(mainWin, HELP_BUTTON, "Help", help_xpm, GTK_SIGNAL_FUNC(usersmanual_dialog), NULL, box, 1); - add_to_toolbar(mainWin, "Exit gPhoto", exit_xpm, + add_to_toolbar(mainWin, EXIT_BUTTON, "Exit gPhoto", exit_xpm, GTK_SIGNAL_FUNC(delete_event), NULL, box, 1); + + deactivate_button(STOP_BUTTON); } diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/toolbar.h gphoto/src/toolbar.h --- gphoto.orig/src/toolbar.h Sun Sep 10 18:22:03 2000 +++ gphoto/src/toolbar.h Thu Aug 24 15:59:48 2000 @@ -1,5 +1,38 @@ -GtkWidget *add_to_toolbar (GtkWidget *mainWin, gchar *tooltipText, +#ifndef TOOLBAR_H +#define TOOLBAR_H +enum { + OPEN_BUTTON=0, + SAVE_BUTTON, + PRINT_BUTTON, + CLOSE_BUTTON, + PREVIOUS_BUTTON, + NEXT_BUTTON, + DOWNLOAD_THUMB_BUTTON, + DOWNLOAD_EMPTY_BUTTON, + DOWNLOAD_SELECTED_BUTTON, + DELETE_BUTTON, + STOP_BUTTON, + ROTATE_CLOCKWISE_BUTTON, + ROTATE_CCLOCKWISE_BUTTON, + FLIP_HORIZ_BUTTON, + FLIP_VERT_BUTTON, + RESIZE_BUTTON, + COLORS_BUTTON, + GALLERY_BUTTON, + LIVE_BUTTON, + CONFIG_BUTTON, + HELP_BUTTON, + EXIT_BUTTON, + NB_BUTTONS +}; + +GtkWidget *add_to_toolbar (GtkWidget *mainWin, + int button_number, gchar *tooltipText, gchar ** xpmIcon, GtkSignalFunc f, gpointer data, GtkWidget *box, int Beginning); - void create_toolbar (GtkWidget *box, GtkWidget *mainWin); +void deactivate_button (int button_number); +void activate_button (int button_number); +void set_toolbar_busy (); +void set_toolbar_ready (); +#endif diff -u --recursive --new-file --exclude-from=/tmp/cvs.exclude gphoto.orig/src/util.c gphoto/src/util.c --- gphoto.orig/src/util.c Sun Sep 10 14:17:31 2000 +++ gphoto/src/util.c Sun Sep 10 18:12:31 2000 @@ -206,6 +206,7 @@ void free_imagemembers (struct ImageMembers *im) { + gphoto_canvas_item_destroy (im); if (im->imlibimage) gdk_imlib_kill_image(im->imlibimage);