comparison src/bar_exif.c @ 1419:c520cfd40aef

Code cleanup.
author zas_
date Wed, 11 Mar 2009 23:36:01 +0000
parents 79b32088ecc4
children 2908c28eb593
comparison
equal deleted inserted replaced
1418:1817f5178db3 1419:c520cfd40aef
148 { 148 {
149 GtkWidget *old_pane = entry->parent; 149 GtkWidget *old_pane = entry->parent;
150 PaneExifData *ped = g_object_get_data(G_OBJECT(pane), "pane_data"); 150 PaneExifData *ped = g_object_get_data(G_OBJECT(pane), "pane_data");
151 PaneExifData *old_ped = g_object_get_data(G_OBJECT(old_pane), "pane_data"); 151 PaneExifData *old_ped = g_object_get_data(G_OBJECT(old_pane), "pane_data");
152 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); 152 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data");
153
153 if (!ped || !old_ped || !ee) return; 154 if (!ped || !old_ped || !ee) return;
154 155
155 g_object_ref(entry); 156 g_object_ref(entry);
156 157
157 gtk_size_group_remove_widget(old_ped->size_group, ee->title_label); 158 gtk_size_group_remove_widget(old_ped->size_group, ee->title_label);
172 173
173 static void bar_pane_exif_update_entry(PaneExifData *ped, GtkWidget *entry, gboolean update_title) 174 static void bar_pane_exif_update_entry(PaneExifData *ped, GtkWidget *entry, gboolean update_title)
174 { 175 {
175 gchar *text; 176 gchar *text;
176 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); 177 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data");
178
177 if (!ee) return; 179 if (!ee) return;
178 text = metadata_read_string(ped->fd, ee->key, METADATA_FORMATTED); 180 text = metadata_read_string(ped->fd, ee->key, METADATA_FORMATTED);
179 181
180 if (!ped->show_all && ee->if_set && (!text || !*text)) 182 if (!ped->show_all && ee->if_set && (!text || !*text))
181 { 183 {
207 work = list; 209 work = list;
208 while (work) 210 while (work)
209 { 211 {
210 GtkWidget *entry = work->data; 212 GtkWidget *entry = work->data;
211 work = work->next; 213 work = work->next;
212
213 214
214 bar_pane_exif_update_entry(ped, entry, FALSE); 215 bar_pane_exif_update_entry(ped, entry, FALSE);
215 } 216 }
216 g_list_free(list); 217 g_list_free(list);
217 218
256 { 257 {
257 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); 258 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data");
258 259
259 switch (info) 260 switch (info)
260 { 261 {
261
262 case TARGET_APP_EXIF_ENTRY: 262 case TARGET_APP_EXIF_ENTRY:
263 gtk_selection_data_set(selection_data, selection_data->target, 263 gtk_selection_data_set(selection_data, selection_data->target,
264 8, (gpointer) &entry, sizeof(entry)); 264 8, (gpointer) &entry, sizeof(entry));
265 break; 265 break;
266 266
279 { 279 {
280 PaneExifData *ped; 280 PaneExifData *ped;
281 GList *work, *list; 281 GList *work, *list;
282 gint pos; 282 gint pos;
283 GtkWidget *new_entry = NULL; 283 GtkWidget *new_entry = NULL;
284
284 ped = g_object_get_data(G_OBJECT(pane), "pane_data"); 285 ped = g_object_get_data(G_OBJECT(pane), "pane_data");
285 if (!ped) return; 286 if (!ped) return;
286 287
287 switch (info) 288 switch (info)
288 { 289 {
296 /* FIXME: this needs a check for valid exif keys */ 297 /* FIXME: this needs a check for valid exif keys */
297 new_entry = bar_pane_exif_add_entry(ped, (gchar *)selection_data->data, NULL, TRUE); 298 new_entry = bar_pane_exif_add_entry(ped, (gchar *)selection_data->data, NULL, TRUE);
298 break; 299 break;
299 } 300 }
300 301
301
302 list = gtk_container_get_children(GTK_CONTAINER(ped->vbox)); 302 list = gtk_container_get_children(GTK_CONTAINER(ped->vbox));
303 work = list; 303 work = list;
304 pos = 0; 304 pos = 0;
305 while (work) 305 while (work)
306 { 306 {
321 } 321 }
322 322
323 static void bar_pane_exif_entry_dnd_begin(GtkWidget *entry, GdkDragContext *context, gpointer data) 323 static void bar_pane_exif_entry_dnd_begin(GtkWidget *entry, GdkDragContext *context, gpointer data)
324 { 324 {
325 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); 325 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data");
326
326 if (!ee) return; 327 if (!ee) return;
327 dnd_set_drag_label(entry, context, ee->key); 328 dnd_set_drag_label(entry, context, ee->key);
328 } 329 }
329 330
330 static void bar_pane_exif_entry_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data) 331 static void bar_pane_exif_entry_dnd_end(GtkWidget *widget, GdkDragContext *context, gpointer data)
372 373
373 static void bar_pane_exif_edit_cancel_cb(GenericDialog *gd, gpointer data) 374 static void bar_pane_exif_edit_cancel_cb(GenericDialog *gd, gpointer data)
374 { 375 {
375 } 376 }
376 377
377
378 static void bar_pane_exif_edit_ok_cb(GenericDialog *gd, gpointer data) 378 static void bar_pane_exif_edit_ok_cb(GenericDialog *gd, gpointer data)
379 { 379 {
380 ConfDialogData *cdd = data; 380 ConfDialogData *cdd = data;
381 381
382 /* either one or the other */ 382 /* either one or the other */
388 bar_pane_exif_add_entry(ped, 388 bar_pane_exif_add_entry(ped,
389 gtk_entry_get_text(GTK_ENTRY(cdd->key_entry)), 389 gtk_entry_get_text(GTK_ENTRY(cdd->key_entry)),
390 gtk_entry_get_text(GTK_ENTRY(cdd->title_entry)), 390 gtk_entry_get_text(GTK_ENTRY(cdd->title_entry)),
391 cdd->if_set); 391 cdd->if_set);
392 } 392 }
393
393 if (ee) 394 if (ee)
394 { 395 {
395 const gchar *title; 396 const gchar *title;
396 GtkWidget *pane = cdd->widget->parent; 397 GtkWidget *pane = cdd->widget->parent;
398
397 while (pane) 399 while (pane)
398 { 400 {
399 ped = g_object_get_data(G_OBJECT(pane), "pane_data"); 401 ped = g_object_get_data(G_OBJECT(pane), "pane_data");
400 if (ped) break; 402 if (ped) break;
401 pane = pane->parent; 403 pane = pane->parent;
507 if (ee) 509 if (ee)
508 { 510 {
509 /* for the entry */ 511 /* for the entry */
510 gchar *conf = g_strdup_printf(_("Configure \"%s\""), ee->title); 512 gchar *conf = g_strdup_printf(_("Configure \"%s\""), ee->title);
511 gchar *del = g_strdup_printf(_("Delete \"%s\""), ee->title); 513 gchar *del = g_strdup_printf(_("Delete \"%s\""), ee->title);
514
512 menu_item_add_stock(menu, conf, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_exif_conf_dialog_cb), widget); 515 menu_item_add_stock(menu, conf, GTK_STOCK_EDIT, G_CALLBACK(bar_pane_exif_conf_dialog_cb), widget);
513 menu_item_add_stock(menu, del, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_exif_delete_entry_cb), widget); 516 menu_item_add_stock(menu, del, GTK_STOCK_DELETE, G_CALLBACK(bar_pane_exif_delete_entry_cb), widget);
514 menu_item_add_divider(menu); 517 menu_item_add_divider(menu);
518
515 g_free(conf); 519 g_free(conf);
516 g_free(del); 520 g_free(del);
517 } 521 }
522
518 /* for the pane */ 523 /* for the pane */
519 menu_item_add_stock(menu, _("Add entry"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_exif_conf_dialog_cb), ped->widget); 524 menu_item_add_stock(menu, _("Add entry"), GTK_STOCK_ADD, G_CALLBACK(bar_pane_exif_conf_dialog_cb), ped->widget);
520 menu_item_add_check(menu, _("Show hidden entries"), ped->show_all, G_CALLBACK(bar_pane_exif_toggle_show_all_cb), ped); 525 menu_item_add_check(menu, _("Show hidden entries"), ped->show_all, G_CALLBACK(bar_pane_exif_toggle_show_all_cb), ped);
521 526
522 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME); 527 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 0, GDK_CURRENT_TIME);
523 } 528 }
524
525 529
526 static gboolean bar_pane_exif_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data) 530 static gboolean bar_pane_exif_menu_cb(GtkWidget *widget, GdkEventButton *bevent, gpointer data)
527 { 531 {
528 PaneExifData *ped = data; 532 PaneExifData *ped = data;
529 if (bevent->button == MOUSE_BUTTON_RIGHT) 533 if (bevent->button == MOUSE_BUTTON_RIGHT)
531 bar_pane_exif_menu_popup(widget, ped); 535 bar_pane_exif_menu_popup(widget, ped);
532 return TRUE; 536 return TRUE;
533 } 537 }
534 return FALSE; 538 return FALSE;
535 } 539 }
536
537
538
539 540
540 static void bar_pane_exif_entry_write_config(GtkWidget *entry, GString *outstr, gint indent) 541 static void bar_pane_exif_entry_write_config(GtkWidget *entry, GString *outstr, gint indent)
541 { 542 {
542 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data"); 543 ExifEntry *ee = g_object_get_data(G_OBJECT(entry), "entry_data");
543 if (!ee) return; 544 if (!ee) return;
626 ped->pane.pane_write_config = bar_pane_exif_write_config; 627 ped->pane.pane_write_config = bar_pane_exif_write_config;
627 ped->pane.title = bar_pane_expander_title(title); 628 ped->pane.title = bar_pane_expander_title(title);
628 ped->pane.expanded = expanded; 629 ped->pane.expanded = expanded;
629 630
630 ped->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); 631 ped->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
631 ped->widget = gtk_event_box_new();; 632 ped->widget = gtk_event_box_new();
632 ped->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP); 633 ped->vbox = gtk_vbox_new(FALSE, PREF_PAD_GAP);
633 gtk_container_add(GTK_CONTAINER(ped->widget), ped->vbox); 634 gtk_container_add(GTK_CONTAINER(ped->widget), ped->vbox);
634 gtk_widget_show(ped->vbox); 635 gtk_widget_show(ped->vbox);
635 636
636 ped->min_height = MIN_HEIGHT; 637 ped->min_height = MIN_HEIGHT;
684 const gchar *option = *attribute_names++; 685 const gchar *option = *attribute_names++;
685 const gchar *value = *attribute_values++; 686 const gchar *value = *attribute_values++;
686 687
687 if (READ_CHAR_FULL("pane.title", title)) continue; 688 if (READ_CHAR_FULL("pane.title", title)) continue;
688 if (READ_BOOL_FULL("pane.expanded", expanded)) continue; 689 if (READ_BOOL_FULL("pane.expanded", expanded)) continue;
689
690 690
691 DEBUG_1("unknown attribute %s = %s", option, value); 691 DEBUG_1("unknown attribute %s = %s", option, value);
692 } 692 }
693 693
694 return bar_pane_exif_new(title, expanded, FALSE); 694 return bar_pane_exif_new(title, expanded, FALSE);
711 711
712 if (READ_CHAR_FULL("key", key)) continue; 712 if (READ_CHAR_FULL("key", key)) continue;
713 if (READ_CHAR_FULL("title", title)) continue; 713 if (READ_CHAR_FULL("title", title)) continue;
714 if (READ_BOOL_FULL("if_set", if_set)) continue; 714 if (READ_BOOL_FULL("if_set", if_set)) continue;
715 715
716
717 DEBUG_1("unknown attribute %s = %s", option, value); 716 DEBUG_1("unknown attribute %s = %s", option, value);
718 } 717 }
718
719 if (key && key[0]) bar_pane_exif_add_entry(ped, key, title, if_set); 719 if (key && key[0]) bar_pane_exif_add_entry(ped, key, title, if_set);
720 } 720 }
721 721
722 722
723 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */ 723 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */