⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ifp_device.c

📁 Aqualung is an advanced music player primarily targeted for the GNU/Linux operating system, but als
💻 C
📖 第 1 页 / 共 3 页
字号:
}voidremove_directory_cb (GtkButton *button, gpointer user_data) {        GtkWidget *info_dialog;        gint response, k;        if (strcmp(remote_directory, ROOTDIR)) {                sprintf(temp, _("Directory '%s' will be removed with its entire contents.\n\nAre you sure?"),                         remote_directory);                info_dialog = gtk_message_dialog_new (GTK_WINDOW(aifp_window),                                                      GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,                                                      GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO, temp);                gtk_window_set_title(GTK_WINDOW(info_dialog), _("Remove directory"));                gtk_widget_show (info_dialog);                response = aqualung_dialog_run (GTK_DIALOG (info_dialog));                     gtk_widget_destroy(info_dialog);                if (response == GTK_RESPONSE_YES) {                           strncpy(temp, "\\", MAXLEN-1);                        strncat(temp, remote_directory, MAXLEN-1);                        k = ifp_delete_dir_recursive(&ifpdev, temp);                        aifp_update_info();                        aifp_check_size();                        aifp_directory_listing (NULL);                }        }}/* "directory selected" handler */void directory_selected_cb (GtkTreeSelection *selection, gpointer data) {        GtkTreeIter iter;        GtkTreeModel *model;          gchar *text;                if (gtk_tree_selection_get_selected (selection, &model, &iter)) {                gtk_tree_model_get (model, &iter, 0, &text, -1);                  strncpy(remote_directory, text, MAXLEN-1);                g_free(text);        }}/* display root directory of iFP device */gint aifp_dump_dir(void *context, int type, const char *name, int filesize) {        GtkTreeIter iter;        gint i;        i = 1;  /* 0 is for ROOTDIR */        if (type == IFP_DIR) {                gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(list_store), &iter, NULL, i++);                gtk_list_store_append(list_store, &iter);	        gtk_list_store_set(list_store, &iter, 0, name, -1);        }        return 0;}gintaifp_directory_listing(gchar *name) {        GtkTreeIter iter;        GtkTreePath *path;        gint d;        gchar * item_name;        gtk_list_store_clear(list_store);        gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(list_store), &iter, NULL, 0);	gtk_list_store_append(list_store, &iter);	gtk_list_store_set(list_store, &iter, 0, ROOTDIR, -1);        if (ifp_list_dirs(&ifpdev, "\\", aifp_dump_dir, NULL)) {                fprintf(stderr, "ifp_device.c: aifp_directory_listing(): list dirs failed.\n");                return -1;        }        if (!name) {                path = gtk_tree_path_new_first();                gtk_tree_view_set_cursor(GTK_TREE_VIEW(list), path, NULL, FALSE);                g_free(path);        } else {                d = 0;                while(gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(list_store), &iter, NULL, d++)) {	                gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, 0, &item_name, -1);                        if (!strcmp(item_name, name)) {                                path = gtk_tree_path_new_from_indices (d-1, -1);                                gtk_tree_view_set_cursor(GTK_TREE_VIEW(list), path, NULL, FALSE);                                gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (list), path,                                              NULL, TRUE, 0.5, 0.0);                                g_free(path);                                break;                        }                }        }        return 0;}/* update status information */voidaifp_update_info(void) {        gchar tmp[MAXLEN];        gfloat space;        sprintf(temp, "%d", number_of_songs);         sprintf(tmp, _(" (%.1f MB)"), (float)songs_size / (1024*1024));         strncat (temp, tmp, MAXLEN-1);        gtk_label_set_text(GTK_LABEL(label_songs), temp);        battery_status = ifp_battery(&ifpdev);        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar_battery), battery_status / 4.0);        ifp_model(&ifpdev, temp, sizeof(temp));        capacity = ifp_capacity(&ifpdev);        sprintf(tmp, _(" (capacity = %.1f MB)"), (float)capacity / (1024*1024));         strncat (temp, tmp, MAXLEN-1);        gtk_label_set_text(GTK_LABEL(label_model), temp);                freespace = ifp_freespace(&ifpdev);        sprintf(temp, _(" Free space (%.1f MB)"), (float)freespace / (1024*1024));         space = (float)freespace/capacity;        gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progressbar_freespace), temp);        gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(progressbar_freespace), space);}/* get the number of songs to send and overall data size to be transmitted */voidaifp_get_songs_info_foreach(GtkTreeIter * iter, void * data) {        struct stat statbuf;	gchar * file;	gint * num = (int *)data;	gtk_tree_model_get(GTK_TREE_MODEL(play_store), iter, 1, &file, -1);	if (stat(file, &statbuf) != -1) {		songs_size += statbuf.st_size;		(*num)++;	}	g_free(file);}gintaifp_get_songs_info(void) {	gint num = 0;	playlist_foreach_selected(aifp_get_songs_info_foreach, &num);	return num;}void aifp_show_message(gint type, gchar *message) {        GtkWidget *info_dialog;        info_dialog = gtk_message_dialog_new (options.playlist_is_embedded ? GTK_WINDOW(main_window) : GTK_WINDOW(playlist_window),                                               GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,                                              type, GTK_BUTTONS_CLOSE, message);        gtk_widget_show (info_dialog);        aqualung_dialog_run(GTK_DIALOG(info_dialog));        gtk_widget_destroy(info_dialog);}gint aifp_check_and_init_device(void) {        gint i, e;        usb_init();        dh = ifp_find_device();        if (dh == NULL) {                aifp_show_message(GTK_MESSAGE_ERROR, _("No suitable iRiver iFP device found.\n"                                  "Perhaps it is unplugged or turned off."));                return -1;        }        dev = usb_device(dh);        /* "must be called" written in the libusb documentation */        if (usb_claim_interface(dh, dev->config->interface->altsetting->bInterfaceNumber)) {                aifp_show_message(GTK_MESSAGE_ERROR, _("Device is busy.\n(Aqualung was unable to claim its interface.)"));                e = ifp_release_device(dh);                if (e) {                         fprintf(stderr, "ifp_device.c: aifp_check_and_init_device(): release_device failed, i=%d\n", e);                }                return -1;        }        i = ifp_init(&ifpdev, dh);        if (i) {                                sprintf(temp, _("Device is not responding.\nTry jiggling the handle. (error %d)"),i);                aifp_show_message(GTK_MESSAGE_ERROR, temp);                usb_release_interface(dh, dev->config->interface->altsetting->bInterfaceNumber);                e = ifp_release_device(dh);                if (e) {                         fprintf(stderr, "ifp_device.c: aifp_check_and_init_device(): release_device failed, i=%d\n", e);                }                return -1;        }        return 0;}intaifp_window_close(GtkWidget * widget, gpointer * data) {        gint e;        e = ifp_finalize(&ifpdev);        if (e) {                 fprintf(stderr, "ifp_device.c: aifp_window_close(): finalize failed, i=%d\n", e);          }        usb_release_interface(dh, dev->config->interface->altsetting->bInterfaceNumber);        e = ifp_release_device(dh);        if (e) {                 fprintf(stderr, "ifp_device.c: aifp_window_close(): release_device failed, i=%d\n", e);         }        gtk_widget_destroy(aifp_window);        aifp_window = NULL;        return 0;}void aifp_check_size(void) {        if(songs_size > freespace)                gtk_widget_set_sensitive(upload_button, FALSE);        else                gtk_widget_set_sensitive(upload_button, TRUE);}gintaifp_window_key_pressed(GtkWidget * widget, GdkEventKey * kevent) {	switch (kevent->keyval) {        case GDK_Escape:                aifp_window_close (NULL, NULL);        	return TRUE;                break;        case GDK_c:                create_directory_cb (NULL, NULL);        	return TRUE;                break;        case GDK_r:                rename_directory_cb (NULL, NULL);        	return TRUE;                break;        case GDK_Delete:	case GDK_KP_Delete:                remove_directory_cb (NULL, NULL);        	return TRUE;                break;        }	return FALSE;}void aifp_transfer_files(void) {        GtkWidget * vbox1;        GtkWidget * vbox2;        GtkWidget * vbox3;        GtkWidget * vbox4;          GtkWidget * hbox1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -