📄 playlistwin.c
字号:
_("Ok"), TRUE, NULL, NULL); gtk_window_set_transient_for(GTK_WINDOW(w), GTK_WINDOW(filesel)); g_free(m); return; } } else if (playlistwin_save_type == PLAYLISTWIN_SAVE_PLS) pls = TRUE; g_free(cfg.playlist_path); cfg.playlist_path = g_strndup(filename, len); if (stat(filename, &statd) == 0) playlistwin_check_overwrite(GTK_WIDGET(filesel), filename, pls); else { if (!playlist_save(filename, pls)) playlistwin_save_playlist_error(filename, GTK_WIDGET(filesel)); else gtk_widget_hide(GTK_WIDGET(filesel)); }}static void playlistwin_load_filesel_ok(GtkWidget * w, GtkWidget * filesel){ char *filename, *text, *tmp; if (util_filebrowser_is_dir(GTK_FILE_SELECTION(filesel))) return; filename = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(filesel))); text = g_strdup(filename); if ((tmp = strrchr(text, '/')) != NULL) *(tmp + 1) = '\0'; g_free(cfg.playlist_path); cfg.playlist_path = g_strdup(text); g_free(text); if (filename && *filename) { playlist_clear(); mainwin_clear_song_info(); mainwin_set_info_text(); playlist_load(filename); } gtk_widget_destroy(GTK_WIDGET(filesel));}static void playlistwin_show_sub_misc_menu(void){ int x, y; GtkWidget *widget; widget = gtk_item_factory_get_widget(playlistwin_sub_menu, "/Physically Delete Files"); gtk_widget_set_sensitive(widget, playlist_get_num_selected() > 0); gdk_window_get_pointer(NULL, &x, &y, NULL); util_item_factory_popup(GTK_ITEM_FACTORY(playlistwin_sub_menu), x, y, 1, GDK_CURRENT_TIME);}static void playlistwin_show_load_filesel(void){ static GtkWidget *load_filesel; GtkObject *object; if (load_filesel != NULL) return; load_filesel = gtk_file_selection_new(_("Load playlist")); if (cfg.playlist_path) gtk_file_selection_set_filename(GTK_FILE_SELECTION(load_filesel), cfg.playlist_path); object = GTK_OBJECT(GTK_FILE_SELECTION(load_filesel)->ok_button); gtk_signal_connect(object, "clicked", GTK_SIGNAL_FUNC(playlistwin_load_filesel_ok), load_filesel); object = GTK_OBJECT(GTK_FILE_SELECTION(load_filesel)->cancel_button); gtk_signal_connect_object(object, "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(load_filesel)); gtk_signal_connect(GTK_OBJECT(load_filesel), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &load_filesel); gtk_widget_show(load_filesel);}static void playlistwin_show_save_filesel(void){ static GtkWidget *filesel; GtkWidget *frame, *hbox, *label, *menu, *om; GtkObject *object; if (filesel != NULL) { if (!GTK_WIDGET_VISIBLE(filesel)) { if (cfg.playlist_path) gtk_file_selection_set_filename( GTK_FILE_SELECTION(filesel), cfg.playlist_path); gtk_widget_show(filesel); } return; } filesel = gtk_file_selection_new(_("Save playlist")); if (cfg.playlist_path) gtk_file_selection_set_filename(GTK_FILE_SELECTION(filesel), cfg.playlist_path); object = GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button); gtk_signal_connect(object, "clicked", GTK_SIGNAL_FUNC(playlistwin_save_filesel_ok), filesel); object = GTK_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button); gtk_signal_connect_object(object, "clicked", GTK_SIGNAL_FUNC(gtk_widget_hide), GTK_OBJECT(filesel)); gtk_signal_connect(GTK_OBJECT(filesel), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &filesel); /* * I18N: "Save options" here is "options for saving, not "save * the options" */ frame = gtk_frame_new(_("Save options")); hbox = gtk_hbox_new(FALSE, 5); gtk_container_set_border_width(GTK_CONTAINER(hbox), 5); gtk_container_add(GTK_CONTAINER(frame), hbox); label = gtk_label_new(_("Determine file type:")); gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); om = gtk_option_menu_new(); gtk_box_pack_start(GTK_BOX(hbox), om, TRUE, TRUE, 0); menu = gtk_item_factory_get_widget(playlistwin_save_menu, "<Save>"); gtk_option_menu_set_menu(GTK_OPTION_MENU(om), menu); gtk_box_pack_start(GTK_BOX(GTK_FILE_SELECTION(filesel)->action_area), frame, TRUE, TRUE, 0); gtk_widget_show_all(filesel);}static void playlistwin_save_type_cb(gpointer cb_data, guint action, GtkWidget * w){ playlistwin_save_type = action;}static void playlistwin_popup_handler(int item){ switch (item) { /* Add button */ case ADD_URL: playlistwin_show_add_url_window(); break; case ADD_DIR: playlistwin_show_dirbrowser(); break; case ADD_FILE: playlistwin_show_filebrowser(); break; /* Sub Button */ case SUB_MISC: playlistwin_show_sub_misc_menu(); break; case SUB_ALL: playlist_clear(); mainwin_clear_song_info(); mainwin_set_info_text(); break; case SUB_CROP: playlist_delete(TRUE); break; case SUB_SELECTED: playlist_delete(FALSE); break; /* Select button */ case SEL_INV: playlistwin_inverse_selection(); break; case SEL_ZERO: playlistwin_select_none(); break; case SEL_ALL: playlistwin_select_all(); break; /* Misc button */ case MISC_SORT: { int x, y; GtkItemFactory *f; playlistwin_set_sensitive_sortmenu(); gdk_window_get_pointer(NULL, &x, &y, NULL); f = GTK_ITEM_FACTORY(playlistwin_sort_menu); util_item_factory_popup(f, x, y, 1, GDK_CURRENT_TIME); break; } case MISC_FILEINFO: playlistwin_fileinfo(); break; case MISC_MISCOPTS: break; /* Playlist button */ case PLIST_NEW: playlist_clear(); mainwin_clear_song_info(); mainwin_set_info_text(); break; case PLIST_SAVE: playlistwin_show_save_filesel(); break; case PLIST_LOAD: playlistwin_show_load_filesel(); break; }}static gboolean inside_sensitive_widgets(int x, int y){ return (inside_widget(x, y, playlistwin_list) || inside_widget(x, y, playlistwin_slider) || inside_widget(x, y, playlistwin_close) || inside_widget(x, y, playlistwin_shade) || inside_widget(x, y, playlistwin_time_min) || inside_widget(x, y, playlistwin_time_sec) || inside_widget(x, y, playlistwin_info) || inside_widget(x, y, playlistwin_vis) || inside_widget(x, y, playlistwin_srew) || inside_widget(x, y, playlistwin_splay) || inside_widget(x, y, playlistwin_spause) || inside_widget(x, y, playlistwin_sstop) || inside_widget(x, y, playlistwin_sfwd) || inside_widget(x, y, playlistwin_seject) || inside_widget(x, y, playlistwin_sscroll_up) || inside_widget(x, y, playlistwin_sscroll_down));}#define REGION_L(x1,x2,y1,y2) \(event->x >= (x1) && event->x < (x2) && \ event->y >= cfg.playlist_height - (y1) && \ event->y < cfg.playlist_height - (y2))#define REGION_R(x1,x2,y1,y2) \(event->x >= cfg.playlist_width - (x1) && \ event->x < cfg.playlist_width - (x2) && \ event->y >= cfg.playlist_height - (y1) && \ event->y < cfg.playlist_height - (y2))static void playlistwin_press(GtkWidget * widget, GdkEventButton * event, gpointer callback_data){ gboolean grab = TRUE; int xpos, ypos; dock_get_widget_pos(playlistwin, &xpos, &ypos); if (event->button == 1 && !cfg.show_wm_decorations && ((!cfg.playlist_shaded && event->x > cfg.playlist_width - 20 && event->y > cfg.playlist_height - 20) || (cfg.playlist_shaded && event->x >= cfg.playlist_width - 31 && event->x < cfg.playlist_width - 22))) { if (hint_move_resize_available()) { hint_move_resize(playlistwin, event->x_root, event->y_root, FALSE); grab = FALSE; } else { playlistwin_resizing = TRUE; playlistwin_resize_x = cfg.playlist_width - event->x; playlistwin_resize_y = cfg.playlist_height - event->y; playlistwin_raise(); } } else if (event->button == 1 && REGION_L(12, 37, 29, 11)) { int nx[] = {0, 0, 0}, ny[] = {111, 130, 149}; int sx[] = {23, 23, 23}, sy[] = {111, 130, 149}; int barx = 48, bary = 111; playlist_popup(xpos + 12, ypos + cfg.playlist_height - (3 * 18) - 11, 3, nx, ny, sx, sy, barx, bary, ADD_URL, playlistwin_popup_handler); grab = FALSE; } else if (event->button == 1 && REGION_L(41, 66, 29, 11)) { int nx[] = {54, 54, 54, 54}, ny[] = {168, 111, 130, 149}; int sx[] = {77, 77, 77, 77}, sy[] = {168, 111, 130, 149}; int barx = 100, bary = 111; playlist_popup(xpos + 41, ypos + cfg.playlist_height - (4 * 18) - 11, 4, nx, ny, sx, sy, barx, bary, SUB_MISC, playlistwin_popup_handler); grab = FALSE; } else if (event->button == 1 && REGION_L(70, 95, 29, 11)) { int nx[] = {104, 104, 104}, ny[] = {111, 130, 149}; int sx[] = {127, 127, 127}, sy[] = {111, 130, 149}; int barx = 150, bary = 111; playlist_popup(xpos + 70, ypos + cfg.playlist_height - (3 * 18) - 11, 3, nx, ny, sx, sy, barx, bary, SEL_INV, playlistwin_popup_handler); grab = FALSE; } else if (event->button == 1 && REGION_L(99, 124, 29, 11)) { int nx[] = {154, 154, 154}, ny[] = {111, 130, 149}; int sx[] = {177, 177, 177}, sy[] = {111, 130, 149}; int barx = 200, bary = 111; playlist_popup(xpos + 99, ypos + cfg.playlist_height - (3 * 18) - 11, 3, nx, ny, sx, sy, barx, bary, MISC_SORT, playlistwin_popup_handler); grab = FALSE; } else if (event->button == 1 && REGION_R(46, 23, 29, 11)) { int nx[] = {204, 204, 204}, ny[] = {111, 130, 149}; int sx[] = {227, 227, 227}, sy[] = {111, 130, 149}; int barx = 250, bary = 111; playlist_popup(xpos + cfg.playlist_width - 46, ypos + cfg.playlist_height - (3 * 18) - 11, 3, nx, ny, sx, sy, barx, bary, PLIST_NEW, playlistwin_popup_handler); grab = FALSE; } else if (event->button == 1 && REGION_R(82, 54, 15, 9)) { if (cfg.timer_mode == TIMER_ELAPSED) cfg.timer_mode = TIMER_REMAINING; else cfg.timer_mode = TIMER_ELAPSED; } else if (event->button == 2 && (event->type == GDK_BUTTON_PRESS) && inside_widget(event->x, event->y, playlistwin_list)) { gtk_selection_convert(widget, GDK_SELECTION_PRIMARY, GDK_TARGET_STRING, event->time); } else if (cfg.playlist_width >= 350 && REGION_R(223, 151, 26, 10)) { if (event->button == 1) { cfg.vis_type++; if (cfg.vis_type > VIS_OFF) cfg.vis_type = VIS_ANALYZER; mainwin_vis_set_type(cfg.vis_type); } else if (event->button == 3) { int mx, my; GdkModifierType modmask; gdk_window_get_pointer(NULL, &mx, &my, &modmask); util_item_factory_popup(mainwin_vis_menu, mx, my, 3, event->time); grab = FALSE; } } else if (event->button == 1 && event->type == GDK_BUTTON_PRESS && !inside_sensitive_widgets(event->x, event->y) && (cfg.easy_move || event->y < 14)) { if (hint_move_resize_available()) { hint_move_resize(playlistwin, event->x_root, event->y_root, TRUE); grab = FALSE; } else { gdk_window_raise(playlistwin->window); dock_move_press(dock_window_list, playlistwin, event, FALSE); } } else if (event->button == 1 && event->type == GDK_2BUTTON_PRESS && !inside_sensitive_widgets(event->x, event->y) && event->y < 14) { playlistwin_set_shade(!cfg.playlist_shaded); if(dock_is_moving(playlistwin)) dock_move_release(playlistwin); } else if (event->button == 3 && !(inside_widget(event->x, event->y, playlistwin_list) || (event->y >= cfg.playlist_height - 29 && event->y < cfg.playlist_height - 11 && ((event->x >= 12 && event->x < 37) || (event->x >= 41 && event->x < 66) || (event->x >= 70 && event->x < 95) || (event->x >= 99 && event->x < 124) || (event->x >= cfg.playlist_width - 46 && event->x < cfg.playlist_width - 23))))) { /* * Pop up the main menu a few pixels down to avoid * anything to be selected initially. */ util_item_factory_popup(mainwin_general_menu, event->x_root, event->y_root + 2, 3, event->time); grab = FALSE; } else if (event->button == 3 && inside_widget(event->x, event->y, playlistwin_list)) { int pos, sensitive;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -