diff options
author | Anders Carlsson <andersca@gnu.org> | 2002-03-11 15:57:14 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@src.gnome.org> | 2002-03-11 15:57:14 +0000 |
commit | 376977b17c5a9aae655f595eff36645c53bda5c2 (patch) | |
tree | d3efb20c0cd9098985c6eb89f9912e731bf3a9a0 /libnautilus-private | |
parent | 31cfe051116b5a50599b3a1497f2c8ddd86719f9 (diff) | |
download | nautilus-376977b17c5a9aae655f595eff36645c53bda5c2.tar.gz |
Add progress jar feature; the progress dialog icon now looks like a jar
2002-03-11 Anders Carlsson <andersca@gnu.org>
* libnautilus-private/nautilus-file-operations-progress-icons.h:
* libnautilus-private/nautilus-file-operations-progress.c:
(nautilus_file_operations_progress_update_icon),
(nautilus_file_operations_progress_update),
(nautilus_file_operations_progress_init),
(nautilus_file_operations_progress_class_init):
Add progress jar feature; the progress dialog icon now looks like
a jar that fills up as the files is copied. This idea was suggested
by Tuomas Kuosmanen.
Diffstat (limited to 'libnautilus-private')
-rw-r--r-- | libnautilus-private/nautilus-file-operations-progress-icons.h | 97 | ||||
-rw-r--r-- | libnautilus-private/nautilus-file-operations-progress.c | 53 |
2 files changed, 147 insertions, 3 deletions
diff --git a/libnautilus-private/nautilus-file-operations-progress-icons.h b/libnautilus-private/nautilus-file-operations-progress-icons.h new file mode 100644 index 000000000..77fc2acbc --- /dev/null +++ b/libnautilus-private/nautilus-file-operations-progress-icons.h @@ -0,0 +1,97 @@ +/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */ + +static const guint8 progress_jar_empty_icon[] = +{ "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (346) */ + "\0\0\1r" + /* pixdata_type (0x2010002) */ + "\2\1\0\2" + /* rowstride (64) */ + "\0\0\0@" + /* width (16) */ + "\0\0\0\20" + /* height (16) */ + "\0\0\0\20" + /* pixel_data: */ + "\1\0\0\0\\\216\0\0\0\377\3\0\0\0\\\0\0\0\377\205\204\177\377\205\344" + "\342\334\377\4\352\350\343\377\344\342\334\377\352\350\343\377\344\342" + "\334\377\203\352\350\343\377\1\221\220\215\377\202\0\0\0\377\203\344" + "\342\334\377\4\352\350\343\377\344\342\334\377\352\350\343\377\344\342" + "\334\377\206\352\350\343\377\1\361\361\361\377\202\0\0\0\377\202\344" + "\342\334\377\213\352\350\343\377\1\377\377\377\377\202\0\0\0\377\1\344" + "\342\334\377\214\352\350\343\377\1\377\377\377\377\202\0\0\0\377\202" + "\344\342\334\377\213\352\350\343\377\1\377\377\377\377\202\0\0\0\377" + "\1\344\342\334\377\214\352\350\343\377\1\377\377\377\377\202\0\0\0\377" + "\202\344\342\334\377\213\352\350\343\377\1\377\377\377\377\202\0\0\0" + "\377\215\352\350\343\377\1\377\377\377\377\202\0\0\0\377\1\344\342\334" + "\377\214\352\350\343\377\1\377\377\377\377\202\0\0\0\377\1\344\342\334" + "\377\214\352\350\343\377\1\377\377\377\377\202\0\0\0\377\215\352\350" + "\343\377\1\377\377\377\377\202\0\0\0\377\215\352\350\343\377\1\377\377" + "\377\377\202\0\0\0\377\212\352\350\343\377\4\353\351\344\377\354\352" + "\346\377\352\350\343\377\377\377\377\377\202\0\0\0\377\2\221\220\215" + "\377\361\361\361\377\213\377\377\377\377\3\324\324\323\377\0\0\0\377" + "\0\0\0\\\216\0\0\0\377\1\0\0\0\\"}; + + +/* GdkPixbuf RGBA C-Source image dump 1-byte-run-length-encoded */ + +static const guint8 progress_jar_full_icon[] = +{ "" + /* Pixbuf magic (0x47646b50) */ + "GdkP" + /* length: header (24) + pixel_data (817) */ + "\0\0\3I" + /* pixdata_type (0x2010002) */ + "\2\1\0\2" + /* rowstride (64) */ + "\0\0\0@" + /* width (16) */ + "\0\0\0\20" + /* height (16) */ + "\0\0\0\20" + /* pixel_data: */ + "\1\0\0\0\\\216\0\0\0\377\3\0\0\0\\\0\0\0\377k\204\223\377\214\201\246" + "\276\377\1n\207\230\377\202\0\0\0\377\3\201\246\276\377\335\347\354\377" + "\327\342\352\377\203\320\335\346\377\205\274\317\333\377\3\264\311\327" + "\377\225\264\310\377{\236\264\377\202\0\0\0\377\16\201\246\276\377\351" + "\357\362\377\263\310\327\377\247\277\317\377\245\277\317\377\227\265" + "\310\377\243\275\317\377\226\264\307\377\241\274\315\377\223\263\306" + "\377\223\261\306\377\221\257\302\377\220\257\301\377u\225\252\377\202" + "\0\0\0\377\7\201\246\276\377\332\345\353\377\260\306\324\377\226\263" + "\307\377\225\262\306\377\224\263\307\377\223\262\306\377\202\222\261" + "\305\377\5\220\256\303\377\220\256\301\377\214\253\277\377\211\251\276" + "\377u\225\252\377\202\0\0\0\377\7\201\246\276\377\325\341\350\377\242" + "\274\316\377\223\262\306\377\221\261\306\377\220\260\305\377\217\257" + "\304\377\202\216\255\303\377\5\214\253\277\377\211\250\274\377\210\251" + "\273\377\204\244\273\377l\217\245\377\202\0\0\0\377\4\201\246\276\377" + "\317\335\345\377\255\303\323\377\220\257\303\377\202\216\256\303\377" + "\10\214\254\301\377\212\252\277\377\210\252\275\377\204\246\273\377\203" + "\245\272\377\202\241\267\377~\240\265\377f\212\241\377\202\0\0\0\377" + "\3\201\246\276\377\310\330\342\377\235\267\311\377\202\214\253\301\377" + "\11\211\251\276\377\210\247\273\377\204\244\271\377\202\244\271\377\202" + "\243\267\377\177\241\264\377|\240\263\377{\237\262\377`\205\235\377\202" + "\0\0\0\377\7\201\246\276\377\300\322\336\377\210\252\277\377\210\247" + "\275\377\205\250\274\377\204\246\273\377\200\243\271\377\202\200\242" + "\267\377\5}\237\264\377{\236\262\377z\234\262\377x\232\257\377]\200\230" + "\377\202\0\0\0\377\16\201\246\276\377\260\305\323\377\225\263\305\377" + "\203\245\272\377\201\244\270\377\200\242\267\377~\240\265\377|\237\263" + "\377{\235\262\377x\234\257\377w\232\256\377u\232\256\377u\231\254\377" + "\\\177\225\377\202\0\0\0\377\12\201\246\276\377\252\277\317\377\201\244" + "\270\377\177\242\266\377~\241\265\377|\237\263\377z\236\263\377y\235" + "\260\377w\233\256\377v\230\255\377\202t\227\255\377\2q\230\254\377X|" + "\223\377\202\0\0\0\377\7\201\246\276\377\230\263\307\377\217\255\277" + "\377|\236\263\377{\235\262\377z\234\261\377x\234\261\377\202t\232\255" + "\377\5t\230\253\377p\227\253\377m\225\252\377l\225\253\377Tr\207\377" + "\202\0\0\0\377\16\201\246\276\377\216\251\300\377{\235\262\377y\235\262" + "\377x\232\257\377t\232\255\377t\227\255\377r\226\253\377p\224\253\377" + "n\226\253\377k\223\252\377k\225\252\377h\223\251\377Qn\202\377\202\0" + "\0\0\377\16\201\246\276\377\211\245\275\377w\232\260\377t\231\255\377" + "t\230\255\377s\227\254\377o\224\252\377m\224\252\377l\223\251\377k\223" + "\252\377h\223\251\377f\222\251\377f\220\251\377Rp\207\377\202\0\0\0\377" + "\1dz\212\377\202z\235\263\377\202u\225\252\377\13s\226\252\377h\213\243" + "\377a\206\236\377^\203\235\377Wy\216\377Vy\215\377Ux\216\377Tw\215\377" + "`v\204\377\0\0\0\377\0\0\0\\\216\0\0\0\377\1\0\0\0\\"}; + + diff --git a/libnautilus-private/nautilus-file-operations-progress.c b/libnautilus-private/nautilus-file-operations-progress.c index 70208cdfe..471928ad3 100644 --- a/libnautilus-private/nautilus-file-operations-progress.c +++ b/libnautilus-private/nautilus-file-operations-progress.c @@ -39,8 +39,8 @@ #include <gtk/gtkstock.h> #include <gtk/gtktable.h> #include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-stock-icons.h> #include <libgnomevfs/gnome-vfs-utils.h> +#include "nautilus-file-operations-progress-icons.h" /* The default width of the progress dialog. It will be wider * only if the font is really huge and the fixed labels don't @@ -53,6 +53,8 @@ #define MINIMUM_TIME_UP 1000 +static GdkPixbuf *empty_jar_pixbuf, *full_jar_pixbuf; + static void nautilus_file_operations_progress_class_init (NautilusFileOperationsProgressClass *klass); static void nautilus_file_operations_progress_init (NautilusFileOperationsProgress *dialog); @@ -83,13 +85,44 @@ struct NautilusFileOperationsProgressDetails { gint64 start_time; guint delayed_close_timeout_id; + + int progress_jar_position; }; /* Private functions. */ static void +nautilus_file_operations_progress_update_icon (NautilusFileOperationsProgress *progress, + double fraction) +{ + GdkPixbuf *pixbuf; + int position; + + position = gdk_pixbuf_get_height (empty_jar_pixbuf) * (1 - fraction); + + if (position == progress->details->progress_jar_position) { + return; + } + + progress->details->progress_jar_position = position; + + pixbuf = gdk_pixbuf_copy (empty_jar_pixbuf); + gdk_pixbuf_copy_area (full_jar_pixbuf, + 0, position, + gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf) - position, + pixbuf, + 0, position); + + gtk_window_set_icon (GTK_WINDOW (progress), pixbuf); + g_object_unref (pixbuf); +} + + +static void nautilus_file_operations_progress_update (NautilusFileOperationsProgress *progress) { + double fraction; + if (progress->details->bytes_total == 0) { /* We haven't set up the file count yet, do not update * the progress bar until we do. @@ -97,10 +130,13 @@ nautilus_file_operations_progress_update (NautilusFileOperationsProgress *progre return; } + fraction = (double)progress->details->bytes_copied / + progress->details->bytes_total; + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress->details->progress_bar), - (double) progress->details->bytes_copied / - progress->details->bytes_total); + fraction); + nautilus_file_operations_progress_update_icon (progress, fraction); } static void @@ -260,6 +296,12 @@ nautilus_file_operations_progress_init (NautilusFileOperationsProgress *progress &progress->details->to_path_label); gtk_box_pack_start (vbox, GTK_WIDGET (titled_label_table), FALSE, FALSE, 0); + + /* Set window icon */ + gtk_window_set_icon (GTK_WINDOW (progress), empty_jar_pixbuf); + + /* Set progress jar position */ + progress->details->progress_jar_position = gdk_pixbuf_get_height (empty_jar_pixbuf); } static void @@ -289,6 +331,11 @@ nautilus_file_operations_progress_class_init (NautilusFileOperationsProgressClas widget_class->map = map_callback; dialog_class->close = close_callback; + + /* Load the jar pixbufs */ + empty_jar_pixbuf = gdk_pixbuf_new_from_inline (-1, progress_jar_empty_icon, FALSE, NULL); + full_jar_pixbuf = gdk_pixbuf_new_from_inline (-1, progress_jar_full_icon, FALSE, NULL); + } NautilusFileOperationsProgress * |