137
140
/* Keeps track of our browsing position and history */
138
141
GList *source_stack;
139
142
GList *container_stack;
140
GrlMediaSource *cur_source;
143
GrlSource *cur_source;
141
144
GrlMedia *cur_container;
143
146
/* Keeps track of the last element we showed metadata for */
144
GrlMediaSource *cur_md_source;
147
GrlSource *cur_md_source;
145
148
GrlMedia *cur_md_media;
147
150
/* Keeps track of browse/search state */
148
151
gboolean op_ongoing;
149
GrlMediaSource *cur_op_source;
152
GrlSource *cur_op_source;
151
154
gboolean multiple;
192
static void show_plugins (void);
195
static GrlOperationOptions *default_options = NULL;
196
static GrlOperationOptions *default_resolve_options = NULL;
198
static void show_browsable_sources (void);
193
199
static void quit_cb (GtkAction *action);
195
201
static gchar *authorize_flickr (void);
202
208
static void load_all_plugins (void);
204
210
static void changes_notification_cb (GtkToggleAction *action);
205
static void content_changed_cb (GrlMediaSource *source,
211
static void content_changed_cb (GrlSource *source,
206
212
GPtrArray *changed_medias,
207
GrlMediaSourceChangeType change_type,
213
GrlSourceChangeType change_type,
208
214
gboolean location_unknown,
253
259
changes_notification_cb (GtkToggleAction *action)
255
261
GList *sources, *source;
256
GrlPluginRegistry *registry;
262
GrlRegistry *registry;
258
264
ui_state->changes_notification = gtk_toggle_action_get_active (action);
260
registry = grl_plugin_registry_get_default ();
261
sources = grl_plugin_registry_get_sources (registry, FALSE);
266
registry = grl_registry_get_default ();
267
sources = grl_registry_get_sources (registry, FALSE);
262
268
for (source = sources; source; source = g_list_next (source)) {
263
if (grl_metadata_source_supported_operations (GRL_METADATA_SOURCE (source->data)) &
269
if (grl_source_supported_operations (GRL_SOURCE (source->data)) &
264
270
GRL_OP_NOTIFY_CHANGE) {
265
271
if (ui_state->changes_notification) {
266
grl_media_source_notify_change_start (GRL_MEDIA_SOURCE (source->data),
268
g_signal_connect (GRL_MEDIA_SOURCE (source->data),
272
grl_source_notify_change_start (GRL_SOURCE (source->data), NULL);
273
g_signal_connect (GRL_SOURCE (source->data),
269
274
"content-changed",
270
275
G_CALLBACK (content_changed_cb),
273
grl_media_source_notify_change_stop (GRL_MEDIA_SOURCE (source->data),
278
grl_source_notify_change_stop (GRL_SOURCE (source->data), NULL);
275
279
g_signal_handlers_disconnect_by_func (source->data,
276
280
content_changed_cb,
358
GrlPluginRegistry *registry;
362
GrlRegistry *registry;
359
363
static GList *keys = NULL;
362
registry = grl_plugin_registry_get_default ();
363
keys = grl_plugin_registry_get_metadata_keys (registry);
366
registry = grl_registry_get_default ();
367
keys = grl_registry_get_metadata_keys (registry);
370
browse_history_push (GrlMediaSource *source, GrlMedia *media)
374
browse_history_push (GrlSource *source, GrlMedia *media)
373
377
g_object_ref (source);
382
browse_history_pop (GrlMediaSource **source, GrlMedia **media)
386
browse_history_pop (GrlSource **source, GrlMedia **media)
385
389
tmp = g_list_last (ui_state->source_stack);
387
*source = GRL_MEDIA_SOURCE (tmp->data);
391
*source = GRL_SOURCE (tmp->data);
388
392
ui_state->source_stack = g_list_delete_link (ui_state->source_stack, tmp);
390
394
tmp = g_list_last (ui_state->container_stack);
399
set_cur_browse (GrlMediaSource *source, GrlMedia *media)
403
set_cur_browse (GrlSource *source, GrlMedia *media)
401
405
if (ui_state->cur_source)
402
406
g_object_unref (ui_state->cur_source);
416
set_cur_metadata (GrlMediaSource *source, GrlMedia *media)
420
set_cur_resolve (GrlSource *source, GrlMedia *media)
418
422
if (ui_state->cur_md_source)
419
423
g_object_unref (ui_state->cur_md_source);
444
448
gtk_list_store_clear (GTK_LIST_STORE (view->metadata_model));
445
449
g_object_unref (view->metadata_model);
447
view->metadata_model = create_metadata_model ();
451
view->metadata_model = create_resolve_model ();
448
452
gtk_tree_view_set_model (GTK_TREE_VIEW (view->metadata),
449
453
view->metadata_model);
504
value_description (const GValue *value)
507
return g_strdup ("");
509
if (G_VALUE_HOLDS_BOXED (value)
510
&& G_VALUE_TYPE (value) == G_TYPE_DATE_TIME) {
511
GDateTime *date_time = g_value_get_boxed (value);
512
return g_date_time_format (date_time, "%FT%H:%M:%SZ");
513
} else if (G_VALUE_HOLDS_STRING (value)) {
514
return g_value_dup_string (value);
517
return g_strdup_value_contents (value);
500
metadata_cb (GrlMediaSource *source,
521
resolve_cb (GrlSource *source,
507
528
GtkTreeIter iter;
530
const gchar *key_name;
509
532
/* Not interested if not the last media we
510
533
requested metadata for */
516
539
gtk_list_store_clear (GTK_LIST_STORE (view->metadata_model));
517
540
g_object_unref (view->metadata_model);
519
view->metadata_model = create_metadata_model ();
542
view->metadata_model = create_resolve_model ();
520
543
gtk_tree_view_set_model (GTK_TREE_VIEW (view->metadata),
521
544
view->metadata_model);
535
558
keys = grl_data_get_keys (GRL_DATA (media));
538
if (grl_data_has_key (GRL_DATA (media), i->data)) {
539
const GValue *g_value = grl_data_get (GRL_DATA (media), i->data);
540
gchar *value = g_value ? g_strdup_value_contents (g_value) : "";
561
key = GRLPOINTER_TO_KEYID (i->data);
562
key_name = grl_metadata_key_get_name (key);
563
if (grl_data_has_key (GRL_DATA (media), key)) {
564
const GValue *g_value = grl_data_get (GRL_DATA (media), key);
565
GRL_DEBUG ("handling key %d (%s)", key, key_name);
566
gchar *value = value_description (g_value);
541
567
gtk_list_store_append (GTK_LIST_STORE (view->metadata_model), &iter);
542
568
gtk_list_store_set (GTK_LIST_STORE (view->metadata_model),
544
570
METADATA_MODEL_NAME,
545
GRL_METADATA_KEY_GET_NAME (i->data),
546
572
METADATA_MODEL_VALUE, value,
548
GRL_DEBUG (" %s: %s", GRL_METADATA_KEY_GET_NAME (i->data), value);
574
GRL_DEBUG (" %s: %s", key_name, value);
550
576
i = g_list_next (i);
553
579
g_list_free (keys);
555
/* Don't free media (we do not ref it when issuing metadata(),
581
/* Don't free media (we do not ref it when issuing resolve(),
556
582
so its reference comes from the treeview and that's freed
557
583
when the treeview is cleared */
573
operation_started (GrlMediaSource *source, guint operation_id,
599
operation_started (GrlSource *source, guint operation_id,
574
600
gboolean multiple)
576
602
ui_state->op_ongoing = TRUE;
598
browse_search_query_cb (GrlMediaSource *source,
624
browse_search_query_cb (GrlSource *source,
606
632
const gchar *name;
607
633
GtkTreeIter iter;
609
635
OperationState *state = (OperationState *) user_data;
610
guint next_op_id = 0;
613
639
if (g_error_matches (error,
662
688
state->offset += state->count;
663
689
if (state->count >= BROWSE_CHUNK_SIZE &&
664
690
state->offset < BROWSE_MAX_COUNT) {
691
GrlOperationOptions *options =
692
grl_operation_options_copy (default_options);
693
GrlTypeFilter filter = GRL_TYPE_FILTER_NONE;
694
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (view->filter_audio))) {
695
filter |= GRL_TYPE_FILTER_AUDIO;
697
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (view->filter_video))) {
698
filter |= GRL_TYPE_FILTER_VIDEO;
700
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (view->filter_image))) {
701
filter |= GRL_TYPE_FILTER_IMAGE;
703
grl_operation_options_set_type_filter (options, filter);
665
705
GRL_DEBUG ("operation (%d) requesting more data from source", op_id);
666
706
state->count = 0;
708
grl_operation_options_set_skip (options, state->offset);
709
grl_operation_options_set_count (options, BROWSE_CHUNK_SIZE);
711
GrlOperationOptions *supported_options = NULL;
712
grl_operation_options_obey_caps (options,
713
grl_source_get_caps (source, GRL_OP_SEARCH),
667
716
switch (state->type) {
668
717
case OP_TYPE_BROWSE:
670
grl_media_source_browse (source,
719
grl_source_browse (source,
671
720
ui_state->cur_container,
673
state->offset, BROWSE_CHUNK_SIZE,
675
723
browse_search_query_cb,
678
726
case OP_TYPE_SEARCH:
680
grl_media_source_search (source,
728
grl_source_search (source,
683
state->offset, BROWSE_CHUNK_SIZE,
685
732
browse_search_query_cb,
688
735
case OP_TYPE_QUERY:
690
grl_media_source_query (source,
737
grl_source_query (source,
693
state->offset, BROWSE_CHUNK_SIZE,
695
741
browse_search_query_cb,
699
745
/* this shouldn't happen as multiple search has no chunk
700
746
* size parameter */
701
747
g_warn_if_reached ();
748
g_object_unref (options);
702
749
goto operation_finished;
752
g_object_unref (options);
753
g_object_unref (supported_options);
705
754
operation_started (source, next_op_id, FALSE);
707
756
/* We browsed all requested elements */
733
782
OperationState *state = g_new0 (OperationState, 1);
734
783
state->type = OP_TYPE_BROWSE;
735
browse_id = grl_media_source_browse (source,
738
0, BROWSE_CHUNK_SIZE,
740
browse_search_query_cb,
784
browse_id = grl_source_browse (source,
788
browse_search_query_cb,
742
790
operation_started (source, browse_id, FALSE);
792
show_browsable_sources ();
747
795
set_cur_browse (source, container);
748
set_cur_metadata (NULL, NULL);
796
set_cur_resolve (NULL, NULL);
796
metadata (GrlMediaSource *source, GrlMedia *media)
844
resolve (GrlSource *source, GrlMedia *media)
799
/* If source does not support metadata() operation, then use the current
847
/* If source does not support resolve() operation, then use the current
801
if ((grl_metadata_source_supported_operations (GRL_METADATA_SOURCE (source)) &
803
grl_media_source_metadata (source,
849
if ((grl_source_supported_operations (source) &
851
grl_source_resolve (source,
854
default_resolve_options,
810
metadata_cb (source, 0, media, NULL, NULL);
858
resolve_cb (source, 0, media, NULL, NULL);
835
883
if (source != ui_state->cur_md_source ||
836
884
content != ui_state->cur_md_media) {
837
set_cur_metadata (source, content);
838
metadata (source, content);
885
set_cur_resolve (source, content);
886
resolve (source, content);
841
889
/* Check if we can store content in the selected item */
842
890
if (content == NULL &&
843
(grl_metadata_source_supported_operations (GRL_METADATA_SOURCE (source)) &
891
(grl_source_supported_operations (GRL_SOURCE (source)) &
845
893
gtk_widget_set_sensitive (view->store_btn, TRUE);
846
894
} else if (content && GRL_IS_MEDIA_BOX (content) &&
847
grl_metadata_source_supported_operations (GRL_METADATA_SOURCE (source)) &
895
grl_source_supported_operations (GRL_SOURCE (source)) &
848
896
GRL_OP_STORE_PARENT) {
849
897
gtk_widget_set_sensitive (view->store_btn, TRUE);
912
960
back_btn_clicked_cb (GtkButton *btn, gpointer user_data)
914
GrlMediaSource *prev_source = NULL;
962
GrlSource *prev_source = NULL;
915
963
GrlMedia *prev_container = NULL;
917
965
/* TODO: when using dynamic sources this will break
1006
1054
grl_media_set_title (media, gtk_entry_get_text (GTK_ENTRY (e1)));
1007
1055
grl_media_set_description (media,
1008
1056
gtk_entry_get_text (GTK_ENTRY (e3)));
1009
grl_media_source_store (source, GRL_MEDIA_BOX (container),
1010
media, store_cb, NULL);
1057
grl_source_store (source, GRL_MEDIA_BOX (container),
1058
media, GRL_WRITE_FULL, store_cb, NULL);
1013
1061
gtk_widget_destroy (dialog);
1081
1129
BROWSER_MODEL_CONTENT, &media,
1084
grl_media_source_remove (source, media, remove_cb, NULL);
1132
grl_source_remove (source, media, remove_cb, NULL);
1087
1135
g_object_unref (source);
1095
search (GrlMediaSource *source, const gchar *text)
1143
search (GrlSource *source, const gchar *text)
1097
1145
OperationState *state;
1098
1146
guint search_id;
1099
1147
gboolean multiple = FALSE;
1148
GrlOperationOptions *options;
1149
GrlOperationOptions *supported_options;
1150
GrlTypeFilter filter;
1101
1152
/* If we have an operation ongoing, let's cancel it first */
1102
1153
cancel_current_operation ();
1104
1155
state = g_new0 (OperationState, 1);
1105
1156
state->text = (gchar *) text;
1157
options = grl_operation_options_copy (default_options);
1158
filter = GRL_TYPE_FILTER_NONE;
1159
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (view->filter_audio))) {
1160
filter |= GRL_TYPE_FILTER_AUDIO;
1162
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (view->filter_video))) {
1163
filter |= GRL_TYPE_FILTER_VIDEO;
1165
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (view->filter_image))) {
1166
filter |= GRL_TYPE_FILTER_IMAGE;
1168
grl_operation_options_set_type_filter (options, filter);
1107
1171
/* Normal search */
1108
1172
state->type = OP_TYPE_SEARCH;
1109
search_id = grl_media_source_search (source,
1173
grl_operation_options_obey_caps (options,
1174
grl_source_get_caps (GRL_SOURCE (source), GRL_OP_SEARCH),
1177
g_object_unref (options);
1178
search_id = grl_source_search (source,
1112
0, BROWSE_CHUNK_SIZE,
1114
1182
browse_search_query_cb,
1137
1205
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (view->search_combo),
1139
GrlMediaSource *source;
1140
1208
const gchar *text;
1141
1209
gtk_tree_model_get (view->search_combo_model, &iter,
1142
1210
SEARCH_MODEL_SOURCE, &source,
1167
1235
state = g_new0 (OperationState, 1);
1168
1236
state->text = (gchar *) text;
1169
1237
state->type = OP_TYPE_QUERY;
1170
query_id = grl_media_source_query (source,
1173
0, BROWSE_CHUNK_SIZE,
1175
browse_search_query_cb,
1238
query_id = grl_source_query (source,
1242
browse_search_query_cb,
1177
1244
clear_panes ();
1178
1245
operation_started (source, query_id, FALSE);
1186
1253
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (view->query_combo),
1188
GrlMediaSource *source;
1189
1256
const gchar *text;
1190
1257
gtk_tree_model_get (view->query_combo_model, &iter,
1191
1258
QUERY_MODEL_SOURCE, &source,
1270
set_filter_cb (GtkComboBox *widget,
1274
GrlTypeFilter filter;
1278
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->filter_audio), TRUE);
1279
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->filter_image), TRUE);
1280
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (view->filter_video), TRUE);
1282
gtk_widget_set_sensitive (view->filter_audio, FALSE);
1283
gtk_widget_set_sensitive (view->filter_video, FALSE);
1284
gtk_widget_set_sensitive (view->filter_image, FALSE);
1286
if (!gtk_combo_box_get_active_iter (widget, &iter)) {
1290
gtk_tree_model_get (gtk_combo_box_get_model (widget),
1292
SEARCH_MODEL_SOURCE, &source,
1298
caps = grl_source_get_caps (GRL_SOURCE (source), GRL_OP_SEARCH);
1301
filter = grl_caps_get_type_filter (caps);
1303
if (filter & GRL_TYPE_FILTER_AUDIO) {
1304
gtk_widget_set_sensitive (view->filter_audio, TRUE);
1306
if (filter & GRL_TYPE_FILTER_VIDEO) {
1307
gtk_widget_set_sensitive (view->filter_video, TRUE);
1309
if (filter & GRL_TYPE_FILTER_IMAGE) {
1310
gtk_widget_set_sensitive (view->filter_image, TRUE);
1203
1315
query_combo_setup (void)
1205
GrlPluginRegistry *registry;
1317
GrlRegistry *registry;
1206
1318
GList *sources = NULL;
1207
1319
GList *sources_iter;
1208
1320
GtkTreeIter iter;
1210
1322
clear_query_combo ();
1212
registry = grl_plugin_registry_get_default ();
1213
sources = grl_plugin_registry_get_sources_by_operations (registry,
1324
registry = grl_registry_get_default ();
1325
sources = grl_registry_get_sources_by_operations (registry,
1216
1328
for (sources_iter = sources; sources_iter;
1217
1329
sources_iter = g_list_next (sources_iter)) {
1218
GrlMetadataSource *source = GRL_METADATA_SOURCE (sources_iter->data);
1219
const gchar *name = grl_metadata_source_get_name (source);
1330
GrlSource *source = GRL_SOURCE (sources_iter->data);
1331
const gchar *name = grl_source_get_name (source);
1221
1333
gtk_list_store_append (GTK_LIST_STORE (view->query_combo_model), &iter);
1222
1334
gtk_list_store_set (GTK_LIST_STORE (view->query_combo_model),
1234
1346
search_combo_setup (void)
1236
GrlPluginRegistry *registry;
1348
GrlRegistry *registry;
1237
1349
GList *sources = NULL;
1238
1350
GList *sources_iter;
1239
1351
GtkTreeIter iter;
1241
1353
clear_search_combo ();
1243
registry = grl_plugin_registry_get_default ();
1244
sources = grl_plugin_registry_get_sources_by_operations (registry,
1355
registry = grl_registry_get_default ();
1356
sources = grl_registry_get_sources_by_operations (registry,
1247
1359
for (sources_iter = sources; sources_iter;
1248
1360
sources_iter = g_list_next (sources_iter)) {
1249
GrlMetadataSource *source = GRL_METADATA_SOURCE (sources_iter->data);
1250
const gchar *name = grl_metadata_source_get_name (source);
1361
GrlSource *source = GRL_SOURCE (sources_iter->data);
1362
const gchar *name = grl_source_get_name (source);
1252
1364
gtk_list_store_append (GTK_LIST_STORE (view->search_combo_model), &iter);
1253
1365
gtk_list_store_set (GTK_LIST_STORE (view->search_combo_model),
1379
1491
load_file_config (void)
1381
GrlPluginRegistry *registry;
1493
GrlRegistry *registry;
1382
1494
gchar *config_file;
1384
registry = grl_plugin_registry_get_default ();
1496
registry = grl_registry_get_default ();
1385
1497
config_file = g_strconcat (g_get_user_config_dir(),
1386
1498
G_DIR_SEPARATOR_S, "grilo-test-ui",
1387
1499
G_DIR_SEPARATOR_S, "grilo.conf",
1389
1501
if (g_file_test (config_file, G_FILE_TEST_EXISTS)) {
1390
grl_plugin_registry_add_config_from_file (registry, config_file, NULL);
1502
grl_registry_add_config_from_file (registry, config_file, NULL);
1392
1504
g_free (config_file);
1473
1585
set_flickr_config (void)
1475
1587
GrlConfig *config;
1476
GrlPluginRegistry *registry;
1588
GrlRegistry *registry;
1479
registry = grl_plugin_registry_get_default ();
1591
registry = grl_registry_get_default ();
1481
1593
config = grl_config_new ("grl-flickr", NULL);
1482
1594
grl_config_set_api_key (config, FLICKR_KEY);
1483
1595
grl_config_set_api_secret (config, FLICKR_SECRET);
1484
grl_plugin_registry_add_config (registry, config, NULL);
1596
grl_registry_add_config (registry, config, NULL);
1486
1598
token = load_flickr_token ();
1498
1610
grl_config_set_api_key (config, FLICKR_KEY);
1499
1611
grl_config_set_api_secret (config, FLICKR_SECRET);
1500
1612
grl_config_set_api_token (config, token);
1501
grl_plugin_registry_add_config (registry, config, NULL);
1613
grl_registry_add_config (registry, config, NULL);
1503
1615
g_free (token);
1507
1619
set_youtube_config (void)
1509
1621
GrlConfig *config;
1510
GrlPluginRegistry *registry;
1622
GrlRegistry *registry;
1512
1624
config = grl_config_new ("grl-youtube", NULL);
1513
1625
grl_config_set_api_key (config, YOUTUBE_KEY);
1515
registry = grl_plugin_registry_get_default ();
1516
grl_plugin_registry_add_config (registry, config, NULL);
1627
registry = grl_registry_get_default ();
1628
grl_registry_add_config (registry, config, NULL);
1520
1632
set_vimeo_config (void)
1522
1634
GrlConfig *config;
1523
GrlPluginRegistry *registry;
1635
GrlRegistry *registry;
1525
1637
config = grl_config_new ("grl-vimeo", NULL);
1526
1638
grl_config_set_api_key (config, VIMEO_KEY);
1527
1639
grl_config_set_api_secret (config, VIMEO_SECRET);
1529
registry = grl_plugin_registry_get_default ();
1530
grl_plugin_registry_add_config (registry, config, NULL);
1641
registry = grl_registry_get_default ();
1642
grl_registry_add_config (registry, config, NULL);
1534
1646
set_local_config (void)
1536
1648
GrlConfig *config;
1537
GrlPluginRegistry *registry;
1649
GrlRegistry *registry;
1539
1651
config = grl_config_new ("grl-local-metadata", NULL);
1540
1652
grl_config_set_boolean (config, "guess-video", TRUE);
1542
registry = grl_plugin_registry_get_default ();
1543
grl_plugin_registry_add_config (registry, config, NULL);
1654
registry = grl_registry_get_default ();
1655
grl_registry_add_config (registry, config, NULL);
1678
options_setup (void)
1680
default_options = grl_operation_options_new (NULL);
1681
grl_operation_options_set_flags (default_options, BROWSE_FLAGS);
1682
grl_operation_options_set_skip (default_options, 0);
1683
grl_operation_options_set_count (default_options, BROWSE_CHUNK_SIZE);
1685
default_resolve_options = grl_operation_options_new (NULL);
1686
grl_operation_options_set_flags (default_resolve_options, RESOLVE_FLAGS);
1566
1690
ui_setup (void)
1568
1692
view = g_new0 (UiView, 1);
1647
1771
search_combo_setup ();
1648
1772
query_combo_setup ();
1774
/* Advanced search */
1775
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
1776
view->filter_audio = gtk_check_button_new_with_label ("Audio");
1777
view->filter_video = gtk_check_button_new_with_label ("Video");
1778
view->filter_image = gtk_check_button_new_with_label ("Image");
1779
gtk_widget_set_sensitive (view->filter_audio, FALSE);
1780
gtk_widget_set_sensitive (view->filter_video, FALSE);
1781
gtk_widget_set_sensitive (view->filter_image, FALSE);
1783
gtk_container_add_with_properties (GTK_CONTAINER (box),
1785
"expand", FALSE, NULL);
1786
gtk_container_add_with_properties (GTK_CONTAINER (box),
1788
"expand", FALSE, NULL);
1789
gtk_container_add_with_properties (GTK_CONTAINER (box),
1791
"expand", FALSE, NULL);
1792
gtk_container_add_with_properties (GTK_CONTAINER (view->lpane),
1794
"expand", FALSE, NULL);
1795
g_signal_connect (G_OBJECT (view->search_combo),
1797
G_CALLBACK (set_filter_cb), NULL);
1650
1799
/* Toolbar buttons */
1651
1800
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
1652
1801
view->back_btn = gtk_button_new ();
1779
1928
METADATA_MIN_WIDTH,
1780
1929
METADATA_MIN_HEIGHT);
1782
/* Populate the browser with the plugins */
1931
/* Populate the browser with the sources */
1932
show_browsable_sources ();
1785
1934
gtk_widget_show_all (view->window);
1938
show_browsable_sources ()
1791
1940
GList *sources;
1792
1941
GList *sources_iter;
1793
1942
GtkTreeIter iter;
1794
GrlPluginRegistry *registry;
1943
GrlRegistry *registry;
1796
registry = grl_plugin_registry_get_default ();
1945
registry = grl_registry_get_default ();
1798
1947
clear_panes ();
1800
sources = grl_plugin_registry_get_sources_by_operations (registry,
1949
sources = grl_registry_get_sources_by_operations (registry,
1803
1952
for (sources_iter = sources; sources_iter;
1804
1953
sources_iter = g_list_next (sources_iter)) {
1805
GrlMetadataSource *source;
1806
1955
const gchar *name;
1807
1956
GdkPixbuf *icon;
1809
source = GRL_METADATA_SOURCE (sources_iter->data);
1958
source = GRL_SOURCE (sources_iter->data);
1810
1959
icon = load_icon (GTK_STOCK_DIRECTORY);
1811
name = grl_metadata_source_get_name (source);
1960
name = grl_source_get_name (source);
1812
1961
GRL_DEBUG ("Loaded source: '%s'", name);
1813
1962
gtk_list_store_append (GTK_LIST_STORE (view->browser_model), &iter);
1814
1963
gtk_list_store_set (GTK_LIST_STORE (view->browser_model),
1847
1996
free_stack (&ui_state->source_stack);
1848
1997
free_stack (&ui_state->container_stack);
1849
1998
set_cur_browse (NULL, NULL);
1850
set_cur_metadata (NULL, NULL);
1999
set_cur_resolve (NULL, NULL);
1873
content_changed_cb (GrlMediaSource *source,
2022
content_changed_cb (GrlSource *source,
1874
2023
GPtrArray *changed_medias,
1875
GrlMediaSourceChangeType change_type,
2024
GrlSourceChangeType change_type,
1876
2025
gboolean location_unknown,
1905
2054
if (GRL_IS_MEDIA_BOX (media)) {
1907
2056
g_strdup_printf ("%s: container '%s' has %s%s",
1908
grl_metadata_source_get_name (GRL_METADATA_SOURCE (source)),
2057
grl_source_get_name (source),
1909
2058
media_id? media_id: "root",
1910
2059
change_type_string,
1911
2060
location_string);
1914
2063
g_strdup_printf ("%s: element '%s' has %s",
1915
grl_metadata_source_get_name (GRL_METADATA_SOURCE (source)),
2064
grl_source_get_name (GRL_SOURCE (source)),
1917
2066
change_type_string);
1932
source_added_cb (GrlPluginRegistry *registry,
1933
GrlMediaPlugin *source,
2081
source_added_cb (GrlRegistry *registry,
1936
2085
GRL_DEBUG ("Detected new source available: '%s'",
1937
grl_metadata_source_get_name (GRL_METADATA_SOURCE (source)));
2086
grl_source_get_name (source));
1939
GRL_DEBUG ("\tPlugin's name: %s", grl_media_plugin_get_name (GRL_MEDIA_PLUGIN (source)));
1940
GRL_DEBUG ("\tPlugin's description: %s", grl_media_plugin_get_description (GRL_MEDIA_PLUGIN (source)));
1941
GRL_DEBUG ("\tPlugin's author: %s", grl_media_plugin_get_author (GRL_MEDIA_PLUGIN (source)));
1942
GRL_DEBUG ("\tPlugin's license: %s", grl_media_plugin_get_license (GRL_MEDIA_PLUGIN (source)));
1943
GRL_DEBUG ("\tPlugin's version: %s", grl_media_plugin_get_version (GRL_MEDIA_PLUGIN (source)));
1944
GRL_DEBUG ("\tPlugin's web site: %s", grl_media_plugin_get_site (GRL_MEDIA_PLUGIN (source)));
2088
GRL_DEBUG ("\tSource's name: %s", grl_source_get_name (source));
2089
GRL_DEBUG ("\tSource's description: %s", grl_source_get_description (source));
1946
2091
/* If showing the plugin list, refresh it */
1947
2092
if (!ui_state->cur_source && !ui_state->cur_container) {
2093
show_browsable_sources ();
1951
2096
/* Also refresh the search combos */
1955
2100
/* Check for changes in source (if supported) */
1956
2101
if (ui_state->changes_notification &&
1957
(grl_metadata_source_supported_operations (GRL_METADATA_SOURCE (source)) &
2102
(grl_source_supported_operations (source) &
1958
2103
GRL_OP_NOTIFY_CHANGE)) {
1959
if (grl_media_source_notify_change_start (GRL_MEDIA_SOURCE (source), NULL)) {
1960
g_signal_connect (GRL_MEDIA_SOURCE (source), "content-changed",
2104
if (grl_source_notify_change_start (GRL_SOURCE (source), NULL)) {
2105
g_signal_connect (GRL_SOURCE (source), "content-changed",
1961
2106
G_CALLBACK (content_changed_cb), NULL);
1967
source_removed_cb (GrlPluginRegistry *registry,
1968
GrlMediaPlugin *source,
2112
source_removed_cb (GrlRegistry *registry,
1971
2116
GRL_DEBUG ("Source '%s' is gone",
1972
grl_metadata_source_get_name (GRL_METADATA_SOURCE (source)));
2117
grl_source_get_name (source));
1974
2119
if (!ui_state->cur_source && !ui_state->cur_container) {
1975
2120
/* If showing the plugin list, refresh it */
2121
show_browsable_sources ();
1977
2122
} else if ((gpointer)ui_state->cur_source == user_data ) {
1978
2123
/* If we were browsing that source, cancel operation and go back to
1979
2124
plugin list view */
1990
2135
load_plugins (void)
1992
GrlPluginRegistry *registry;
1993
registry = grl_plugin_registry_get_default ();
2137
GrlRegistry *registry;
2138
registry = grl_registry_get_default ();
1994
2139
g_signal_connect (registry, "source-added",
1995
2140
G_CALLBACK (source_added_cb), NULL);
1996
2141
g_signal_connect (registry, "source-removed",
1997
2142
G_CALLBACK (source_removed_cb), NULL);
1998
if (!grl_plugin_registry_load_all (registry, NULL)) {
2143
if (!grl_registry_load_all_plugins (registry, NULL)) {
1999
2144
g_error ("Failed to load plugins.");
2013
2159
we are about to shut down */
2016
registry = grl_plugin_registry_get_default ();
2162
registry = grl_registry_get_default ();
2018
2164
/* Disable "source-removed" handler */
2019
2165
g_signal_handlers_block_by_func (G_OBJECT (registry), source_removed_cb,
2022
2168
/* Shut down the plugins now */
2023
sources = grl_plugin_registry_get_sources (registry, FALSE);
2025
const gchar *plugin_id;
2026
GrlMediaPlugin *source;
2028
source = GRL_MEDIA_PLUGIN (sources->data);
2029
plugin_id = grl_media_plugin_get_id (source);
2030
grl_plugin_registry_unload (registry, plugin_id, NULL);
2032
g_list_free (sources);
2033
sources = grl_plugin_registry_get_sources (registry, FALSE);
2169
plugins = grl_registry_get_plugins (registry, TRUE);
2170
for (plugin_iter = plugins;
2172
plugin_iter = g_list_next (plugin_iter)) {
2173
grl_registry_unload_plugin (registry,
2174
grl_plugin_get_id (GRL_PLUGIN (plugin_iter->data)),
2035
g_list_free (sources);
2177
g_list_free (plugins);
2037
2179
/* Re-enable "source-removed" handler */
2038
2180
g_signal_handlers_unblock_by_func (G_OBJECT (registry), source_removed_cb,
2048
2190
load_all_plugins ()
2050
GrlPluginRegistry *registry;
2052
registry = grl_plugin_registry_get_default ();
2054
grl_plugin_registry_load_all (registry, NULL);
2192
GrlRegistry *registry;
2194
registry = grl_registry_get_default ();
2196
grl_registry_load_all_plugins (registry, NULL);