MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / video_file_drop_received

Function video_file_drop_received

gtk/src/application.c:587–659  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585 GdkNotifyType notify, signal_user_data_t *ud);
586
587static gboolean
588video_file_drop_received (GtkDropTarget* self, const GValue* value,
589 double x, double y, signal_user_data_t *ud)
590{
591/* The GdkFileList method is preferred as it handles multiple
592 * files and also allows access to sandboxed files via the portal */
593 if (G_VALUE_HOLDS(value, GDK_TYPE_FILE_LIST))
594 {
595 GdkFileList *gdk_file_list = g_value_get_boxed(value);
596 GSList *slist = gdk_file_list_get_files(gdk_file_list);
597 g_autoptr(GListStore) video_files = g_list_store_new(G_TYPE_FILE);
598 g_autoptr(GListStore) subtitle_files = g_list_store_new(G_TYPE_FILE);
599 const char *filename = NULL;
600
601 while (slist)
602 {
603 filename = g_file_peek_path(slist->data);
604 if (ghb_file_is_subtitle(filename))
605 {
606 g_debug("Subtitle file dropped on window: %s", filename);
607 g_list_store_append(subtitle_files, slist->data);
608 }
609 else
610 {
611 g_debug("Video file dropped on window: %s", filename);
612 g_list_store_append(video_files, slist->data);
613 }
614 slist = slist->next;
615 }
616
617 if (g_list_model_get_n_items(G_LIST_MODEL(video_files)))
618 {
619 ghb_dict_set_string(ud->prefs, "default_source", filename);
620 ghb_pref_save(ud->prefs, "default_source");
621 ghb_dvd_set_current(filename, ud);
622 ghb_do_scan_list(ud, G_LIST_MODEL(video_files), 0, TRUE);
623 }
624 else if (subtitle_files)
625 {
626 ghb_add_subtitle_files(G_LIST_MODEL(subtitle_files), ud);
627 }
628 return TRUE;
629 }
630
631 g_autoptr(GFile) file = NULL;
632 g_autofree gchar *filename = NULL;
633
634 if (G_VALUE_HOLDS(value, G_TYPE_FILE))
635 {
636 file = g_value_dup_object(value);
637 }
638 else if (G_VALUE_HOLDS(value, G_TYPE_URI))
639 {
640 file = g_file_new_for_uri(g_value_get_string(value));
641 }
642 else
643 {
644 return FALSE;

Callers

nothing calls this directly

Calls 7

ghb_file_is_subtitleFunction · 0.85
ghb_dict_set_stringFunction · 0.85
ghb_pref_saveFunction · 0.85
ghb_dvd_set_currentFunction · 0.85
ghb_do_scan_listFunction · 0.85
ghb_add_subtitle_filesFunction · 0.85
ghb_do_scanFunction · 0.85

Tested by

no test coverage detected