Mercurial > geeqie
comparison src/pan-view.c @ 102:73443803ea59
Tue Nov 7 19:54:44 2006 John Ellis <johne@verizon.net>
* pan-view.c: For calendar view only show months that contain an image.
Allow choice of size when displaying an image with the info popup.
author | gqview |
---|---|
date | Wed, 08 Nov 2006 00:57:04 +0000 |
parents | d19b0de6d0bb |
children | de64a683d5d0 |
comparison
equal
deleted
inserted
replaced
101:847e4bc6b54c | 102:73443803ea59 |
---|---|
126 | 126 |
127 | 127 |
128 #define PAN_PREF_GROUP "pan_view_options" | 128 #define PAN_PREF_GROUP "pan_view_options" |
129 #define PAN_PREF_HIDE_WARNING "hide_performance_warning" | 129 #define PAN_PREF_HIDE_WARNING "hide_performance_warning" |
130 #define PAN_PREF_EXIF_DATE "use_exif_date" | 130 #define PAN_PREF_EXIF_DATE "use_exif_date" |
131 #define PAN_PREF_INFO_IMAGE "info_includes_image" | 131 #define PAN_PREF_INFO_IMAGE "info_image_size" |
132 #define PAN_PREF_INFO_EXIF "info_includes_exif" | 132 #define PAN_PREF_INFO_EXIF "info_includes_exif" |
133 | 133 |
134 | 134 |
135 typedef enum { | 135 typedef enum { |
136 LAYOUT_TIMELINE = 0, | 136 LAYOUT_TIMELINE = 0, |
242 gint thumb_size; | 242 gint thumb_size; |
243 gint thumb_gap; | 243 gint thumb_gap; |
244 gint image_size; | 244 gint image_size; |
245 gint exif_date_enable; | 245 gint exif_date_enable; |
246 | 246 |
247 gint info_includes_image; | 247 gint info_image_size; |
248 gint info_includes_exif; | 248 gint info_includes_exif; |
249 | 249 |
250 gint ignore_symlinks; | 250 gint ignore_symlinks; |
251 | 251 |
252 GList *list; | 252 GList *list; |
2075 count++; | 2075 count++; |
2076 if (day_max < count) day_max = count; | 2076 if (day_max < count) day_max = count; |
2077 } | 2077 } |
2078 } | 2078 } |
2079 | 2079 |
2080 printf("biggest day contains %d images\n", day_max); | 2080 if (debug) printf("biggest day contains %d images\n", day_max); |
2081 | 2081 |
2082 grid = (gint)(sqrt((double)day_max) + 0.5) * (PAN_THUMB_SIZE + PAN_SHADOW_OFFSET * 2 + PAN_THUMB_GAP); | 2082 grid = (gint)(sqrt((double)day_max) + 0.5) * (PAN_THUMB_SIZE + PAN_SHADOW_OFFSET * 2 + PAN_THUMB_GAP); |
2083 day_width = MAX(PAN_CAL_DAY_WIDTH, grid); | 2083 day_width = MAX(PAN_CAL_DAY_WIDTH, grid); |
2084 day_height = MAX(PAN_CAL_DAY_HEIGHT, grid); | 2084 day_height = MAX(PAN_CAL_DAY_HEIGHT, grid); |
2085 | 2085 |
2115 gint col; | 2115 gint col; |
2116 gint row; | 2116 gint row; |
2117 time_t dt; | 2117 time_t dt; |
2118 gchar *buf; | 2118 gchar *buf; |
2119 | 2119 |
2120 /* figure last second of this month */ | |
2120 dt = date_to_time((month == 12) ? year + 1 : year, (month == 12) ? 1 : month + 1, 1); | 2121 dt = date_to_time((month == 12) ? year + 1 : year, (month == 12) ? 1 : month + 1, 1); |
2121 dt -= 60 * 60 * 24; | 2122 dt -= 60 * 60 * 24; |
2123 | |
2124 /* anything to show this month? */ | |
2125 if (!date_compare(((FileData *)(work->data))->date, dt, DATE_LENGTH_MONTH)) | |
2126 { | |
2127 month ++; | |
2128 if (month > 12) | |
2129 { | |
2130 year++; | |
2131 month = 1; | |
2132 } | |
2133 continue; | |
2134 } | |
2135 | |
2122 days = date_value(dt, DATE_LENGTH_DAY); | 2136 days = date_value(dt, DATE_LENGTH_DAY); |
2123 dt = date_to_time(year, month, 1); | 2137 dt = date_to_time(year, month, 1); |
2124 col = date_value(dt, DATE_LENGTH_WEEK); | 2138 col = date_value(dt, DATE_LENGTH_WEEK); |
2125 row = 1; | 2139 row = 1; |
2126 | 2140 |
3315 } | 3329 } |
3316 else if (pw->cache_tick > 9) | 3330 else if (pw->cache_tick > 9) |
3317 { | 3331 { |
3318 gchar *buf; | 3332 gchar *buf; |
3319 | 3333 |
3320 buf = g_strdup_printf("%s %d", _("Reading image data..."), | 3334 buf = g_strdup_printf("%s %d / %d", _("Reading image data..."), |
3321 pw->cache_total - pw->cache_count); | 3335 pw->cache_count, pw->cache_total); |
3322 pan_window_message(pw, buf); | 3336 pan_window_message(pw, buf); |
3323 g_free(buf); | 3337 g_free(buf); |
3324 | 3338 |
3325 pw->cache_tick = 0; | 3339 pw->cache_tick = 0; |
3326 } | 3340 } |
3910 pan_text_alignment_free(ta); | 3924 pan_text_alignment_free(ta); |
3911 | 3925 |
3912 pan_item_box_shadow(pbox, PAN_SHADOW_OFFSET * 2, PAN_SHADOW_FADE * 2); | 3926 pan_item_box_shadow(pbox, PAN_SHADOW_OFFSET * 2, PAN_SHADOW_FADE * 2); |
3913 pan_item_added(pw, pbox); | 3927 pan_item_added(pw, pbox); |
3914 | 3928 |
3915 if (pw->info_includes_image) | 3929 if (pw->info_image_size > LAYOUT_SIZE_THUMB_NONE) |
3916 { | 3930 { |
3917 gint iw, ih; | 3931 gint iw, ih; |
3918 if (image_load_dimensions(pi->fd->path, &iw, &ih)) | 3932 if (image_load_dimensions(pi->fd->path, &iw, &ih)) |
3919 { | 3933 { |
3934 gint scale = 25; | |
3935 | |
3936 switch (pw->info_image_size) | |
3937 { | |
3938 case LAYOUT_SIZE_10: | |
3939 scale = 10; | |
3940 break; | |
3941 case LAYOUT_SIZE_25: | |
3942 scale = 25; | |
3943 break; | |
3944 case LAYOUT_SIZE_33: | |
3945 scale = 33; | |
3946 break; | |
3947 case LAYOUT_SIZE_50: | |
3948 scale = 50; | |
3949 break; | |
3950 case LAYOUT_SIZE_100: | |
3951 scale = 100; | |
3952 break; | |
3953 } | |
3954 | |
3955 iw = MAX(1, iw * scale / 100); | |
3956 ih = MAX(1, ih * scale / 100); | |
3957 | |
3920 pbox = pan_item_new_box(pw, NULL, pbox->x, pbox->y + pbox->height + 8, 10, 10, | 3958 pbox = pan_item_new_box(pw, NULL, pbox->x, pbox->y + pbox->height + 8, 10, 10, |
3921 PAN_POPUP_BORDER, | 3959 PAN_POPUP_BORDER, |
3922 PAN_POPUP_COLOR, PAN_POPUP_ALPHA, | 3960 PAN_POPUP_COLOR, PAN_POPUP_ALPHA, |
3923 PAN_POPUP_BORDER_COLOR, PAN_POPUP_ALPHA); | 3961 PAN_POPUP_BORDER_COLOR, PAN_POPUP_ALPHA); |
3924 pan_item_set_key(pbox, "info"); | 3962 pan_item_set_key(pbox, "info"); |
4623 static void pan_window_close(PanWindow *pw) | 4661 static void pan_window_close(PanWindow *pw) |
4624 { | 4662 { |
4625 pan_window_list = g_list_remove(pan_window_list, pw); | 4663 pan_window_list = g_list_remove(pan_window_list, pw); |
4626 | 4664 |
4627 pref_list_int_set(PAN_PREF_GROUP, PAN_PREF_EXIF_DATE, pw->exif_date_enable); | 4665 pref_list_int_set(PAN_PREF_GROUP, PAN_PREF_EXIF_DATE, pw->exif_date_enable); |
4628 pref_list_int_set(PAN_PREF_GROUP, PAN_PREF_INFO_IMAGE, pw->info_includes_image); | 4666 pref_list_int_set(PAN_PREF_GROUP, PAN_PREF_INFO_IMAGE, pw->info_image_size); |
4629 pref_list_int_set(PAN_PREF_GROUP, PAN_PREF_INFO_EXIF, pw->info_includes_exif); | 4667 pref_list_int_set(PAN_PREF_GROUP, PAN_PREF_INFO_EXIF, pw->info_includes_exif); |
4630 | 4668 |
4631 if (pw->idle_id != -1) | 4669 if (pw->idle_id != -1) |
4632 { | 4670 { |
4633 g_source_remove(pw->idle_id); | 4671 g_source_remove(pw->idle_id); |
4673 | 4711 |
4674 if (!pref_list_int_get(PAN_PREF_GROUP, PAN_PREF_EXIF_DATE, &pw->exif_date_enable)) | 4712 if (!pref_list_int_get(PAN_PREF_GROUP, PAN_PREF_EXIF_DATE, &pw->exif_date_enable)) |
4675 { | 4713 { |
4676 pw->exif_date_enable = FALSE; | 4714 pw->exif_date_enable = FALSE; |
4677 } | 4715 } |
4678 if (!pref_list_int_get(PAN_PREF_GROUP, PAN_PREF_INFO_IMAGE, &pw->info_includes_image)) | 4716 if (!pref_list_int_get(PAN_PREF_GROUP, PAN_PREF_INFO_IMAGE, &pw->info_image_size)) |
4679 { | 4717 { |
4680 pw->info_includes_image = FALSE; | 4718 pw->info_image_size = LAYOUT_SIZE_THUMB_NONE; |
4681 } | 4719 } |
4682 if (!pref_list_int_get(PAN_PREF_GROUP, PAN_PREF_INFO_EXIF, &pw->info_includes_exif)) | 4720 if (!pref_list_int_get(PAN_PREF_GROUP, PAN_PREF_INFO_EXIF, &pw->info_includes_exif)) |
4683 { | 4721 { |
4684 pw->info_includes_exif = TRUE; | 4722 pw->info_includes_exif = TRUE; |
4685 } | 4723 } |
4966 *----------------------------------------------------------------------------- | 5004 *----------------------------------------------------------------------------- |
4967 * menus | 5005 * menus |
4968 *----------------------------------------------------------------------------- | 5006 *----------------------------------------------------------------------------- |
4969 */ | 5007 */ |
4970 | 5008 |
5009 #define INFO_IMAGE_SIZE_KEY "image_size_data" | |
5010 | |
5011 | |
4971 static void pan_new_window_cb(GtkWidget *widget, gpointer data) | 5012 static void pan_new_window_cb(GtkWidget *widget, gpointer data) |
4972 { | 5013 { |
4973 PanWindow *pw = data; | 5014 PanWindow *pw = data; |
4974 const gchar *path; | 5015 const gchar *path; |
4975 | 5016 |
5086 | 5127 |
5087 static void pan_info_toggle_image_cb(GtkWidget *widget, gpointer data) | 5128 static void pan_info_toggle_image_cb(GtkWidget *widget, gpointer data) |
5088 { | 5129 { |
5089 PanWindow *pw = data; | 5130 PanWindow *pw = data; |
5090 | 5131 |
5091 pw->info_includes_image = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | 5132 pw->info_image_size = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), INFO_IMAGE_SIZE_KEY)); |
5092 /* fixme: sync info now */ | 5133 /* fixme: sync info now */ |
5093 } | 5134 } |
5094 | 5135 |
5095 static void pan_fullscreen_cb(GtkWidget *widget, gpointer data) | 5136 static void pan_fullscreen_cb(GtkWidget *widget, gpointer data) |
5096 { | 5137 { |
5107 } | 5148 } |
5108 | 5149 |
5109 static GtkWidget *pan_popup_menu(PanWindow *pw) | 5150 static GtkWidget *pan_popup_menu(PanWindow *pw) |
5110 { | 5151 { |
5111 GtkWidget *menu; | 5152 GtkWidget *menu; |
5153 GtkWidget *submenu; | |
5112 GtkWidget *item; | 5154 GtkWidget *item; |
5113 gint active; | 5155 gint active; |
5114 | 5156 |
5115 active = (pw->click_pi != NULL); | 5157 active = (pw->click_pi != NULL); |
5116 | 5158 |
5147 item = menu_item_add_check(menu, _("Sort by E_xif date"), pw->exif_date_enable, | 5189 item = menu_item_add_check(menu, _("Sort by E_xif date"), pw->exif_date_enable, |
5148 G_CALLBACK(pan_exif_date_toggle_cb), pw); | 5190 G_CALLBACK(pan_exif_date_toggle_cb), pw); |
5149 gtk_widget_set_sensitive(item, (pw->layout == LAYOUT_TIMELINE || pw->layout == LAYOUT_CALENDAR)); | 5191 gtk_widget_set_sensitive(item, (pw->layout == LAYOUT_TIMELINE || pw->layout == LAYOUT_CALENDAR)); |
5150 | 5192 |
5151 menu_item_add_divider(menu); | 5193 menu_item_add_divider(menu); |
5152 menu_item_add_check(menu, _("Show EXIF information"), pw->info_includes_exif, | 5194 |
5195 menu_item_add_check(menu, _("_Show Exif information"), pw->info_includes_exif, | |
5153 G_CALLBACK(pan_info_toggle_exif_cb), pw); | 5196 G_CALLBACK(pan_info_toggle_exif_cb), pw); |
5154 menu_item_add_check(menu, _("Show full size image"), pw->info_includes_image, | 5197 item = menu_item_add(menu, _("Show im_age"), NULL, NULL); |
5155 G_CALLBACK(pan_info_toggle_image_cb), pw); | 5198 submenu = gtk_menu_new(); |
5199 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); | |
5200 | |
5201 item = menu_item_add_check(submenu, _("_None"), (pw->info_image_size == LAYOUT_SIZE_THUMB_NONE), | |
5202 G_CALLBACK(pan_info_toggle_image_cb), pw); | |
5203 g_object_set_data(G_OBJECT(item), INFO_IMAGE_SIZE_KEY, GINT_TO_POINTER(LAYOUT_SIZE_THUMB_NONE)); | |
5204 | |
5205 item = menu_item_add_check(submenu, _("_Full size"), (pw->info_image_size == LAYOUT_SIZE_100), | |
5206 G_CALLBACK(pan_info_toggle_image_cb), pw); | |
5207 g_object_set_data(G_OBJECT(item), INFO_IMAGE_SIZE_KEY, GINT_TO_POINTER(LAYOUT_SIZE_100)); | |
5208 | |
5209 item = menu_item_add_check(submenu, _("1:2 (50%)"), (pw->info_image_size == LAYOUT_SIZE_50), | |
5210 G_CALLBACK(pan_info_toggle_image_cb), pw); | |
5211 g_object_set_data(G_OBJECT(item), INFO_IMAGE_SIZE_KEY, GINT_TO_POINTER(LAYOUT_SIZE_50)); | |
5212 | |
5213 item = menu_item_add_check(submenu, _("1:3 (33%)"), (pw->info_image_size == LAYOUT_SIZE_33), | |
5214 G_CALLBACK(pan_info_toggle_image_cb), pw); | |
5215 g_object_set_data(G_OBJECT(item), INFO_IMAGE_SIZE_KEY, GINT_TO_POINTER(LAYOUT_SIZE_33)); | |
5216 | |
5217 item = menu_item_add_check(submenu, _("1:4 (25%)"), (pw->info_image_size == LAYOUT_SIZE_25), | |
5218 G_CALLBACK(pan_info_toggle_image_cb), pw); | |
5219 g_object_set_data(G_OBJECT(item), INFO_IMAGE_SIZE_KEY, GINT_TO_POINTER(LAYOUT_SIZE_25)); | |
5220 | |
5221 item = menu_item_add_check(submenu, _("1:10 (10%)"), (pw->info_image_size == LAYOUT_SIZE_10), | |
5222 G_CALLBACK(pan_info_toggle_image_cb), pw); | |
5223 g_object_set_data(G_OBJECT(item), INFO_IMAGE_SIZE_KEY, GINT_TO_POINTER(LAYOUT_SIZE_10)); | |
5224 | |
5225 | |
5156 | 5226 |
5157 menu_item_add_divider(menu); | 5227 menu_item_add_divider(menu); |
5158 | 5228 |
5159 if (pw->fs) | 5229 if (pw->fs) |
5160 { | 5230 { |