added file deletion to gtk-old. now icon list updates on resizing (neat). only a couple things left :)
git-svn-id: https://svn.code.sf.net/p/gphoto/code/trunk/libgphoto2@678 67ed7778-7388-44ab-90cf-0a291f65f57c
This commit is contained in:
@@ -33,6 +33,22 @@ void idle() {
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
|
||||
void icon_resize(GtkWidget *window) {
|
||||
|
||||
GtkWidget *icon_list = (GtkWidget*)lookup_widget(gp_gtk_main_window, "icons");
|
||||
int x, y;
|
||||
|
||||
gdk_window_get_size(gp_gtk_main_window->window, &x, &y);
|
||||
|
||||
if (abs(gp_gtk_old_width-x)>60) {
|
||||
gtk_icon_list_freeze(GTK_ICON_LIST(icon_list));
|
||||
gtk_icon_list_thaw(GTK_ICON_LIST(icon_list));
|
||||
gp_gtk_old_width = x;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int camera_set() {
|
||||
|
||||
GtkWidget *camera_tree, *message, *message_label, *camera_label, *icon_list;
|
||||
@@ -624,7 +640,6 @@ void camera_index_common(int thumbnails) {
|
||||
camera_select();
|
||||
return;
|
||||
}
|
||||
|
||||
if (gp_camera_abilities_by_name(buf, &a)==GP_ERROR) {
|
||||
gp_message ("Could not retrieve the camera's abilities");
|
||||
return;
|
||||
@@ -703,12 +718,79 @@ void camera_download_both() {
|
||||
|
||||
}
|
||||
|
||||
void camera_delete_selected() {
|
||||
debug_print("camera delete selected");
|
||||
void camera_delete_common(int all) {
|
||||
|
||||
GtkWidget *icon_list;
|
||||
GtkIconListItem *item;
|
||||
CameraAbilities a;
|
||||
char buf[1024];
|
||||
int x, count=0;
|
||||
|
||||
if (!gp_gtk_camera_init)
|
||||
if (camera_set()==GP_ERROR) {return;}
|
||||
|
||||
if (gp_confirm("Are you sure you want to DELETE the photos?")==0)
|
||||
return;
|
||||
|
||||
if (gp_setting_get("camera", buf)==GP_ERROR) {
|
||||
gp_message ("ERROR: please choose your camera model again");
|
||||
camera_select();
|
||||
return;
|
||||
}
|
||||
if (gp_camera_abilities_by_name(buf, &a)==GP_ERROR) {
|
||||
gp_message ("Could not retrieve the camera's abilities");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Not working? */
|
||||
if (!a.file_delete) {
|
||||
gp_message ("This camera does not support deleting photos.");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((count = gp_file_count())==GP_ERROR) {
|
||||
gp_message ("Could not retrieve the number of pictures");
|
||||
return;
|
||||
}
|
||||
|
||||
if (all) {
|
||||
for (x=0; x<count; x++) {
|
||||
if (gp_file_delete(0)==GP_ERROR) {
|
||||
sprintf(buf, "Could not delete photo #%04i. Stopping.", x);
|
||||
gp_message(buf);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
icon_list = (GtkWidget*) lookup_widget(gp_gtk_main_window, "icons");
|
||||
for (x=0; x<count; x++) {
|
||||
item = gtk_icon_list_get_nth(GTK_ICON_LIST(icon_list), x);
|
||||
if (item->state == GTK_STATE_SELECTED) {
|
||||
if (gp_file_delete(0)==GP_ERROR) {
|
||||
sprintf(buf, "Could not delete photo #%04i. Stopping.", x);
|
||||
gp_message(buf);
|
||||
return;
|
||||
}
|
||||
gtk_icon_list_remove(GTK_ICON_LIST(icon_list), item);
|
||||
x--;
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
for (x=0; x<count; x++) {
|
||||
item = gtk_icon_list_get_nth(GTK_ICON_LIST(icon_list), x);
|
||||
sprintf(buf, "#%04i", x);
|
||||
gtk_icon_list_set_label (GTK_ICON_LIST(icon_list), item, buf);
|
||||
gtk_icon_list_freeze(GTK_ICON_LIST(icon_list));
|
||||
gtk_icon_list_thaw(GTK_ICON_LIST(icon_list));
|
||||
}
|
||||
}
|
||||
|
||||
void camera_delete_selected() {
|
||||
debug_print("camera delete selected");
|
||||
|
||||
camera_delete_common(0);
|
||||
}
|
||||
|
||||
void camera_delete_all() {
|
||||
@@ -717,6 +799,7 @@ void camera_delete_all() {
|
||||
if (!gp_gtk_camera_init)
|
||||
if (camera_set()==GP_ERROR) {return;}
|
||||
|
||||
camera_delete_common(1);
|
||||
}
|
||||
|
||||
void camera_configure() {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
int main_quit(GtkWidget *widget, gpointer data);
|
||||
void debug_print (char *message);
|
||||
void idle();
|
||||
void icon_resize(GtkWidget *window);
|
||||
|
||||
/* General callbacks */
|
||||
/* ------------------------------------------------------*/
|
||||
|
||||
@@ -2,4 +2,5 @@ extern GtkWidget *gp_gtk_main_window;
|
||||
extern GtkWidget *gp_gtk_progress_window;
|
||||
extern int gp_gtk_debug;
|
||||
extern int gp_gtk_camera_init;
|
||||
extern int gp_gtk_old_width;
|
||||
extern char gp_gtk_camera_model[];
|
||||
|
||||
@@ -34,6 +34,8 @@ int gp_interface_message_long(char *message) {
|
||||
|
||||
wait_for_hide(window, ok, NULL);
|
||||
|
||||
gtk_widget_destroy(window);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
@@ -60,6 +62,8 @@ int gp_interface_message(char *message) {
|
||||
|
||||
wait_for_hide(window, ok, NULL);
|
||||
|
||||
gtk_widget_destroy(window);
|
||||
|
||||
return (GP_OK);
|
||||
}
|
||||
|
||||
@@ -79,7 +83,19 @@ int gp_interface_progress(float percentage) {
|
||||
|
||||
int gp_interface_confirm(char *message) {
|
||||
|
||||
return (GP_OK);
|
||||
GtkWidget *confirm = create_confirm_window();
|
||||
GtkWidget *label = (GtkWidget*) lookup_widget(confirm, "message");
|
||||
GtkWidget *yes = (GtkWidget*) lookup_widget(confirm, "yes");
|
||||
GtkWidget *no = (GtkWidget*) lookup_widget(confirm, "no");
|
||||
int ret = 0;
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(label), message);
|
||||
ret = wait_for_hide(confirm, yes, no);
|
||||
|
||||
if (ret)
|
||||
gtk_widget_destroy(confirm);
|
||||
|
||||
return (ret);
|
||||
}
|
||||
|
||||
void hide_progress_window (GtkWidget *widget, gpointer data) {
|
||||
@@ -140,11 +156,6 @@ create_main_window (void)
|
||||
GtkAccelGroup *camera1_menu_accels;
|
||||
GtkWidget *select2;
|
||||
GtkWidget *separator6;
|
||||
GtkWidget *download_index1;
|
||||
GtkWidget *download_index1_menu;
|
||||
GtkAccelGroup *download_index1_menu_accels;
|
||||
GtkWidget *thumbnails1;
|
||||
GtkWidget *no_thumbnails1;
|
||||
GtkWidget *download_selected1;
|
||||
GtkWidget *download_selected1_menu;
|
||||
GtkAccelGroup *download_selected1_menu_accels;
|
||||
@@ -528,52 +539,6 @@ create_main_window (void)
|
||||
gtk_container_add (GTK_CONTAINER (camera1_menu), separator6);
|
||||
gtk_widget_set_sensitive (separator6, FALSE);
|
||||
|
||||
download_index1 = gtk_menu_item_new_with_label ("");
|
||||
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (download_index1)->child),
|
||||
_("Download _Index"));
|
||||
gtk_widget_add_accelerator (download_index1, "activate_item", camera1_menu_accels,
|
||||
tmp_key, 0, 0);
|
||||
gtk_widget_ref (download_index1);
|
||||
gtk_object_set_data_full (GTK_OBJECT (main_window), "download_index1", download_index1,
|
||||
(GtkDestroyNotify) gtk_widget_unref);
|
||||
gtk_widget_show (download_index1);
|
||||
gtk_container_add (GTK_CONTAINER (camera1_menu), download_index1);
|
||||
|
||||
download_index1_menu = gtk_menu_new ();
|
||||
gtk_widget_ref (download_index1_menu);
|
||||
gtk_object_set_data_full (GTK_OBJECT (main_window), "download_index1_menu", download_index1_menu,
|
||||
(GtkDestroyNotify) gtk_widget_unref);
|
||||
gtk_menu_item_set_submenu (GTK_MENU_ITEM (download_index1), download_index1_menu);
|
||||
download_index1_menu_accels = gtk_menu_ensure_uline_accel_group (GTK_MENU (download_index1_menu));
|
||||
|
||||
thumbnails1 = gtk_menu_item_new_with_label ("");
|
||||
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (thumbnails1)->child),
|
||||
_("_Thumbnails"));
|
||||
gtk_widget_add_accelerator (thumbnails1, "activate_item", download_index1_menu_accels,
|
||||
tmp_key, 0, 0);
|
||||
gtk_widget_ref (thumbnails1);
|
||||
gtk_object_set_data_full (GTK_OBJECT (main_window), "thumbnails1", thumbnails1,
|
||||
(GtkDestroyNotify) gtk_widget_unref);
|
||||
gtk_widget_show (thumbnails1);
|
||||
gtk_container_add (GTK_CONTAINER (download_index1_menu), thumbnails1);
|
||||
gtk_widget_add_accelerator (thumbnails1, "activate", accel_group,
|
||||
GDK_i, GDK_MOD1_MASK,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
no_thumbnails1 = gtk_menu_item_new_with_label ("");
|
||||
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (no_thumbnails1)->child),
|
||||
_("_No Thumbnails"));
|
||||
gtk_widget_add_accelerator (no_thumbnails1, "activate_item", download_index1_menu_accels,
|
||||
tmp_key, 0, 0);
|
||||
gtk_widget_ref (no_thumbnails1);
|
||||
gtk_object_set_data_full (GTK_OBJECT (main_window), "no_thumbnails1", no_thumbnails1,
|
||||
(GtkDestroyNotify) gtk_widget_unref);
|
||||
gtk_widget_show (no_thumbnails1);
|
||||
gtk_container_add (GTK_CONTAINER (download_index1_menu), no_thumbnails1);
|
||||
gtk_widget_add_accelerator (no_thumbnails1, "activate", accel_group,
|
||||
GDK_e, GDK_MOD1_MASK,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
|
||||
download_selected1 = gtk_menu_item_new_with_label ("");
|
||||
tmp_key = gtk_label_parse_uline (GTK_LABEL (GTK_BIN (download_selected1)->child),
|
||||
_("Download _Selected"));
|
||||
@@ -1104,12 +1069,6 @@ create_main_window (void)
|
||||
gtk_signal_connect (GTK_OBJECT (select2), "activate",
|
||||
GTK_SIGNAL_FUNC (on_select_camera_activate),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (thumbnails1), "activate",
|
||||
GTK_SIGNAL_FUNC (on_index_thumbnails_activate),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (no_thumbnails1), "activate",
|
||||
GTK_SIGNAL_FUNC (on_index_no_thumbnails_activate),
|
||||
NULL);
|
||||
gtk_signal_connect (GTK_OBJECT (thumbnails2), "activate",
|
||||
GTK_SIGNAL_FUNC (on_download_thumbnails_activate),
|
||||
NULL);
|
||||
@@ -1217,7 +1176,7 @@ create_message_window_long (void)
|
||||
GtkWidget*
|
||||
create_confirm_window (void)
|
||||
{
|
||||
/* widget labels: "yes" "no" */
|
||||
/* widget labels: "message" "yes" "no" */
|
||||
|
||||
GtkWidget *confirm_window;
|
||||
GtkWidget *vbox4;
|
||||
@@ -1244,7 +1203,7 @@ create_confirm_window (void)
|
||||
|
||||
confirm_label = gtk_label_new (_("Are you sure?"));
|
||||
gtk_widget_ref (confirm_label);
|
||||
gtk_object_set_data_full (GTK_OBJECT (confirm_window), "confirm_label", confirm_label,
|
||||
gtk_object_set_data_full (GTK_OBJECT (confirm_window), "message", confirm_label,
|
||||
(GtkDestroyNotify) gtk_widget_unref);
|
||||
gtk_widget_show (confirm_label);
|
||||
gtk_box_pack_start (GTK_BOX (vbox4), confirm_label, TRUE, TRUE, 0);
|
||||
@@ -1254,7 +1213,6 @@ create_confirm_window (void)
|
||||
gtk_object_set_data_full (GTK_OBJECT (confirm_window), "hsep", hsep,
|
||||
(GtkDestroyNotify) gtk_widget_unref);
|
||||
gtk_widget_show (hsep);
|
||||
gtk_box_pack_end (GTK_BOX (vbox4), hsep, FALSE, FALSE, 0);
|
||||
|
||||
hbox2 = gtk_hbox_new (TRUE, 5);
|
||||
gtk_widget_ref (hbox2);
|
||||
@@ -1262,6 +1220,7 @@ create_confirm_window (void)
|
||||
(GtkDestroyNotify) gtk_widget_unref);
|
||||
gtk_widget_show (hbox2);
|
||||
gtk_box_pack_end (GTK_BOX (vbox4), hbox2, FALSE, TRUE, 0);
|
||||
gtk_box_pack_end (GTK_BOX (vbox4), hsep, FALSE, FALSE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox2), 5);
|
||||
|
||||
button19 = gtk_button_new_with_label (_("Yes"));
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
#include "interface.h"
|
||||
#include "support.h"
|
||||
|
||||
/* The Globals */
|
||||
GtkWidget *gp_gtk_main_window;
|
||||
GtkWidget *gp_gtk_progress_window;
|
||||
int gp_gtk_debug;
|
||||
char gp_gtk_camera_model[1024];
|
||||
int gp_gtk_camera_init=0;
|
||||
int gp_gtk_old_width;
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
@@ -54,6 +56,8 @@ main (int argc, char *argv[])
|
||||
gp_gtk_progress_window = create_progress_window();
|
||||
gp_gtk_main_window = create_main_window ();
|
||||
gtk_widget_show (gp_gtk_main_window);
|
||||
gtk_signal_connect(GTK_OBJECT(gp_gtk_main_window), "check_resize",
|
||||
GTK_SIGNAL_FUNC(icon_resize), NULL);
|
||||
|
||||
/* Retrieve the last width/height of the window */
|
||||
if (gp_setting_get("width", buf)==GP_OK) {
|
||||
@@ -64,6 +68,9 @@ main (int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
gdk_window_get_size(gp_gtk_main_window->window, &x, &y);
|
||||
gp_gtk_old_width = x;
|
||||
|
||||
/* Retrieve the last camera used */
|
||||
if (gp_setting_get("camera", buf)==GP_OK) {
|
||||
/* Set the camera model label */
|
||||
|
||||
Reference in New Issue
Block a user