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

Function source_dialog_start_scan

gtk/src/callbacks.c:1755–1829  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1753}
1754
1755static void
1756source_dialog_start_scan (GtkFileChooser *chooser, int title_id)
1757{
1758 gboolean recursive = FALSE;
1759 g_autoptr(GListModel) files = NULL;
1760 g_autofree char *def_src = NULL;
1761 signal_user_data_t *ud = ghb_ud();
1762
1763 if (gtk_file_chooser_get_action(chooser) == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
1764 {
1765 // The recursive choice only exists in directory mode
1766 recursive = !g_strcmp0(gtk_file_chooser_get_choice(chooser, "recursive"), "true");
1767 ghb_dict_set_bool(ud->prefs, "RecursiveFolderScan", recursive);
1768 ghb_pref_save(ud->prefs, "RecursiveFolderScan");
1769 }
1770 else if (has_drive)
1771 {
1772 // The drive choice only exists in file mode when a DVD drive is detected
1773 const char *drivename = gtk_file_chooser_get_choice(chooser, "drive");
1774 if (drivename && g_strcmp0(drivename, _("Not Selected")))
1775 {
1776 files = G_LIST_MODEL(g_list_store_new(G_TYPE_FILE));
1777 g_list_store_append(G_LIST_STORE(files), g_file_new_for_path(drivename));
1778 def_src = g_strdup(drivename);
1779 }
1780 }
1781
1782 if (!def_src)
1783 {
1784 g_autoptr(GListModel) selected_files = gtk_file_chooser_get_files(chooser);
1785
1786 if (g_list_model_get_n_items(selected_files))
1787 {
1788 g_autoptr(GFile) file = g_list_model_get_item(selected_files, 0);
1789 def_src = g_file_get_path(file);
1790 }
1791
1792 if (recursive)
1793 {
1794 // Scan the directories provided for files
1795 GListStore *out_files = g_list_store_new(G_TYPE_FILE);
1796 for (guint i = 0; i < g_list_model_get_n_items(selected_files); i++)
1797 {
1798 g_autoptr(GFile) dir = g_list_model_get_item(selected_files, i);
1799 scan_directory(dir, out_files, TRUE);
1800 }
1801 files = G_LIST_MODEL(out_files);
1802 ghb_log("Recursive scan found %u files", g_list_model_get_n_items(files));
1803 }
1804 else
1805 {
1806 // Use the list of chosen files or folders directly
1807 files = g_steal_pointer(&selected_files);
1808 }
1809 }
1810
1811 if (def_src != NULL && def_src[0] != '\0')
1812 {

Callers 2

Calls 10

ghb_udFunction · 0.85
ghb_dict_set_boolFunction · 0.85
ghb_pref_saveFunction · 0.85
scan_directoryFunction · 0.85
ghb_logFunction · 0.85
ghb_get_scan_sourceFunction · 0.85
ghb_dict_set_stringFunction · 0.85
ghb_dvd_set_currentFunction · 0.85
ghb_do_scan_listFunction · 0.85
ghb_file_chooser_destroyFunction · 0.85

Tested by

no test coverage detected