Mercurial > geeqie
comparison src/bar_info.c @ 442:4b2d7f9af171
Big whitespaces cleanup:
- drop whitespaces at end of lines
- convert eight spaces to tab at start of lines
- drop spurious spaces mixed with tabs
- remove empty lines at end of files
author | zas_ |
---|---|
date | Sun, 20 Apr 2008 13:04:57 +0000 |
parents | 134beb10d916 |
children | 89f8bffbce21 |
comparison
equal
deleted
inserted
replaced
441:08eb7137cd94 | 442:4b2d7f9af171 |
---|---|
237 if (comment) | 237 if (comment) |
238 { | 238 { |
239 ExifItem *item = exif_get_item(exif, comment_key); | 239 ExifItem *item = exif_get_item(exif, comment_key); |
240 *comment = exif_item_get_string(item, 0); | 240 *comment = exif_item_get_string(item, 0); |
241 } | 241 } |
242 | 242 |
243 if (keywords) | 243 if (keywords) |
244 { | 244 { |
245 ExifItem *item = exif_get_item(exif, keyword_key); | 245 ExifItem *item = exif_get_item(exif, keyword_key); |
246 int count = exif_item_get_elements(item); | 246 int count = exif_item_get_elements(item); |
247 int i = 0; | 247 int i = 0; |
248 GList *work = NULL; | 248 GList *work = NULL; |
249 char *kw = NULL; | 249 char *kw = NULL; |
250 | 250 |
251 while (i < count && (kw = exif_item_get_string(item, i++))) | 251 while (i < count && (kw = exif_item_get_string(item, i++))) |
252 { | 252 { |
253 work = g_list_append(work, (gpointer) kw); | 253 work = g_list_append(work, (gpointer) kw); |
254 } | 254 } |
255 | 255 |
256 *keywords = work; | 256 *keywords = work; |
257 } | 257 } |
258 | 258 |
259 exif_free(exif); | 259 exif_free(exif); |
260 | 260 |
261 success = *comment || *keywords; | 261 success = *comment || *keywords; |
262 | 262 |
263 return success; | 263 return success; |
264 } | 264 } |
265 | 265 |
266 static gint comment_xmp_write(FileData *fd, GList *keywords, const gchar *comment) | 266 static gint comment_xmp_write(FileData *fd, GList *keywords, const gchar *comment) |
267 { | 267 { |
269 GList *work = keywords; | 269 GList *work = keywords; |
270 ExifData *exif = exif_read_fd(fd, FALSE); | 270 ExifData *exif = exif_read_fd(fd, FALSE); |
271 if (!exif) return FALSE; | 271 if (!exif) return FALSE; |
272 | 272 |
273 ExifItem *item = exif_get_item(exif, comment_key); | 273 ExifItem *item = exif_get_item(exif, comment_key); |
274 | 274 |
275 if (item && !(comment && comment[0])) | 275 if (item && !(comment && comment[0])) |
276 { | 276 { |
277 exif_item_delete(exif, item); | 277 exif_item_delete(exif, item); |
278 item = NULL; | 278 item = NULL; |
279 } | 279 } |
280 | 280 |
281 if (!item && comment && comment[0]) item = exif_add_item(exif, comment_key); | 281 if (!item && comment && comment[0]) item = exif_add_item(exif, comment_key); |
282 if (item) exif_item_set_string(item, comment); | 282 if (item) exif_item_set_string(item, comment); |
283 | 283 |
284 | 284 |
285 | 285 |
286 while ((item = exif_get_item(exif, keyword_key))) | 286 while ((item = exif_get_item(exif, keyword_key))) |
287 { | 287 { |
288 exif_item_delete(exif, item); | 288 exif_item_delete(exif, item); |
289 } | 289 } |
290 | 290 |
291 if (work) | 291 if (work) |
292 { | 292 { |
293 item = exif_add_item(exif, keyword_key); | 293 item = exif_add_item(exif, keyword_key); |
294 | 294 |
295 while (work) | 295 while (work) |
296 { | 296 { |
297 gchar *kw = (gchar *) work->data; | 297 gchar *kw = (gchar *) work->data; |
298 work = work->next; | 298 work = work->next; |
299 | 299 |
300 exif_item_set_string(item, kw); | 300 exif_item_set_string(item, kw); |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 success = exif_write(exif); | 304 success = exif_write(exif); |
305 | 305 |
306 exif_free(exif); | 306 exif_free(exif); |
307 | 307 |
308 return success; | 308 return success; |
309 } | 309 } |
310 | 310 |
311 gint comment_write(FileData *fd, GList *keywords, const gchar *comment) | 311 gint comment_write(FileData *fd, GList *keywords, const gchar *comment) |
312 { | 312 { |
332 | 332 |
333 if (!fd) return FALSE; | 333 if (!fd) return FALSE; |
334 | 334 |
335 res1 = comment_xmp_read(fd, &keywords1, &comment1); | 335 res1 = comment_xmp_read(fd, &keywords1, &comment1); |
336 res2 = comment_legacy_read(fd, &keywords2, &comment2); | 336 res2 = comment_legacy_read(fd, &keywords2, &comment2); |
337 | 337 |
338 if (!res1 && !res2) | 338 if (!res1 && !res2) |
339 { | 339 { |
340 return FALSE; | 340 return FALSE; |
341 } | 341 } |
342 | 342 |
343 if (keywords) | 343 if (keywords) |
344 { | 344 { |
345 if (res1 && res2) | 345 if (res1 && res2) |
346 *keywords = g_list_concat(keywords1, keywords2); | 346 *keywords = g_list_concat(keywords1, keywords2); |
347 else | 347 else |
350 else | 350 else |
351 { | 351 { |
352 if (res1) string_list_free(keywords1); | 352 if (res1) string_list_free(keywords1); |
353 if (res2) string_list_free(keywords2); | 353 if (res2) string_list_free(keywords2); |
354 } | 354 } |
355 | 355 |
356 | 356 |
357 if (comment) | 357 if (comment) |
358 { | 358 { |
359 if (res1 && res2 && comment1 && comment2 && comment1[0] && comment2[0]) | 359 if (res1 && res2 && comment1 && comment2 && comment1[0] && comment2[0]) |
360 *comment = g_strdup_printf("%s\n%s", comment1, comment2); | 360 *comment = g_strdup_printf("%s\n%s", comment1, comment2); |
361 else | 361 else |
362 *comment = res1 ? comment1 : comment2; | 362 *comment = res1 ? comment1 : comment2; |
363 } | 363 } |
364 if (res1 && (!comment || *comment != comment1)) g_free(comment1); | 364 if (res1 && (!comment || *comment != comment1)) g_free(comment1); |
365 if (res2 && (!comment || *comment != comment2)) g_free(comment2); | 365 if (res2 && (!comment || *comment != comment2)) g_free(comment2); |
366 | 366 |
367 return TRUE; | 367 return TRUE; |
368 } | 368 } |
369 | 369 |
370 | 370 |
371 static gchar *comment_pull(GtkWidget *textview) | 371 static gchar *comment_pull(GtkWidget *textview) |
372 { | 372 { |
373 GtkTextBuffer *buffer; | 373 GtkTextBuffer *buffer; |
374 GtkTextIter start, end; | 374 GtkTextIter start, end; |
375 | 375 |
376 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); | 376 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview)); |
377 gtk_text_buffer_get_bounds(buffer, &start, &end); | 377 gtk_text_buffer_get_bounds(buffer, &start, &end); |
378 | 378 |
379 return gtk_text_buffer_get_text(buffer, &start, &end, FALSE); | 379 return gtk_text_buffer_get_text(buffer, &start, &end, FALSE); |
380 } | 380 } |
381 | 381 |
382 static gint keyword_list_find(GList *list, const gchar *keyword) | 382 static gint keyword_list_find(GList *list, const gchar *keyword) |
383 { | 383 { |
424 while (*ptr != '\0' && !KEYWORDS_SEPARATOR(*ptr)) | 424 while (*ptr != '\0' && !KEYWORDS_SEPARATOR(*ptr)) |
425 { | 425 { |
426 ptr++; | 426 ptr++; |
427 l++; | 427 l++; |
428 } | 428 } |
429 | 429 |
430 /* trim starting and ending whitespaces */ | 430 /* trim starting and ending whitespaces */ |
431 while (l > 0 && g_ascii_isspace(*begin)) begin++, l--; | 431 while (l > 0 && g_ascii_isspace(*begin)) begin++, l--; |
432 while (l > 0 && g_ascii_isspace(begin[l-1])) l--; | 432 while (l > 0 && g_ascii_isspace(begin[l-1])) l--; |
433 | 433 |
434 if (l > 0) | 434 if (l > 0) |
435 { | 435 { |
436 gchar *keyword = g_strndup(begin, l); | 436 gchar *keyword = g_strndup(begin, l); |
437 | 437 |
438 /* only add if not already in the list */ | 438 /* only add if not already in the list */ |
439 if (keyword_list_find(list, keyword) == FALSE) | 439 if (keyword_list_find(list, keyword) == FALSE) |
440 list = g_list_append(list, keyword); | 440 list = g_list_append(list, keyword); |
441 else | 441 else |
442 g_free(keyword); | 442 g_free(keyword); |
1310 bar_info_update(bd); | 1310 bar_info_update(bd); |
1311 | 1311 |
1312 bar_info_selection(bd->vbox, 0); | 1312 bar_info_selection(bd->vbox, 0); |
1313 | 1313 |
1314 bar_list = g_list_append(bar_list, bd); | 1314 bar_list = g_list_append(bar_list, bd); |
1315 | 1315 |
1316 return bd->vbox; | 1316 return bd->vbox; |
1317 } | 1317 } |
1318 | 1318 |
1319 void bar_info_set_selection_func(GtkWidget *bar, GList *(*list_func)(gpointer data), gpointer data) | 1319 void bar_info_set_selection_func(GtkWidget *bar, GList *(*list_func)(gpointer data), gpointer data) |
1320 { | 1320 { |