#include #include #include #include #include "playlist.h" #include "notebook/notebook.h" #include "notebook/collection.h" #include "gui.h" #include "playbox.h" #include "statusbox.h" #include "misc.h" #include "coverart_wizard.h" #include "menus.h" #include "audio/audio.h" #include "notify.h" #include "amatory.h" #include "firststart.h" #include "vgtk.h" #include #include #ifdef HAVE_LIBNOTIFY #include extern NotifyNotification *gnotify; #endif GUI_SESSION gui; #define SETTLE_TIME 15 GUI_HOTKEY default_hotkeys[] = { { "z",0,0,on_prev_clicked }, { "x",0,0,on_play_clicked }, { "c",0,0,on_pause_toggled }, { "v",0,0,on_stop_clicked }, { "b",0,0,on_next_clicked }, {NULL} }; static void on_quit(GtkWidget *widget, gpointer data){ GUI_SESSION *g = data; printf("quit button says bye\n"); /* Save playlist */ playlist_save_session(); gtk_main_quit(); g->amatory->audio_session->AUDIO_stop(g->amatory->audio_session); AMATORY_shutdown(g->amatory); #ifdef HAVE_LIBNOTIFY notify_notification_close(gnotify,NULL); notify_uninit (); #endif /* just to make valgrind happier */ //g_object_unref(g->collection_filter); // gtk_tree_path_free(g->active_path); } static gboolean on_gui_configure_event(GtkWidget *window, GdkEventConfigure *event, GtkWidget *box){ gint h=0,w=0; if(event->type == GDK_CONFIGURE){ gdk_window_get_geometry(window->window,NULL,NULL,&w,&h,NULL); gtk_widget_set_size_request (box,w,h); } return FALSE; } int CM_event_id = 0; static gboolean collection_change_done(gpointer data){ printf("Collection Changes are DONE!\n"); LIBRARY_factor_VA(); repopulate_collection(); CM_event_id = 0; return FALSE; } static void on_collection_change(GFileMonitor *monitor,GFile *file,GFile *other_file, GFileMonitorEvent event_type,gpointer user_data){ char *path=NULL; char *base = NULL, *dir = NULL; path = g_file_get_path(file); printf("collection_monitor: %s\n",path); switch(event_type){ case G_FILE_MONITOR_EVENT_CHANGED: printf("CM: Ignoring EVENT CHANGED\n"); /* Ignore printf("CM: Changed\n"); */ break; case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT: base = strdup(basename(path)); free(path); path = g_file_get_path(file); dir = strdup(dirname(path)); printf("CM: Change Done: dir=%s,base=%s\n",dir,base); LIBRARY_update_file(gui.amatory->audio_session,dir,base); if(CM_event_id == 0){ CM_event_id = gdk_threads_add_timeout_seconds(SETTLE_TIME, collection_change_done,NULL); }else{ g_source_remove(CM_event_id); CM_event_id = gdk_threads_add_timeout_seconds(SETTLE_TIME, collection_change_done,NULL); } break; case G_FILE_MONITOR_EVENT_DELETED: printf("CM: Deleted\n"); if(g_file_query_file_type(file,G_FILE_QUERY_INFO_NONE,NULL) != G_FILE_TYPE_DIRECTORY){ base = strdup(basename(path)); free(path); path = g_file_get_path(file); dir = strdup(dirname(path)); LIBRARY_delete_tag(dir,base); }else{ g_file_monitor_cancel(monitor); LIBRARY_delete_tag(path,NULL); } break; case G_FILE_MONITOR_EVENT_CREATED: printf("CM: Created\n"); if(g_file_query_file_type(file,G_FILE_QUERY_INFO_NONE,NULL) == G_FILE_TYPE_DIRECTORY){ printf("CM: Adding new file monitor directory\n"); vg_file_monitor_directory(path, on_collection_change); LIBRARY_quick_dir_scanfs(gui.amatory->audio_session,path); if(CM_event_id == 0){ CM_event_id = gdk_threads_add_timeout_seconds(SETTLE_TIME, collection_change_done,NULL); }else{ g_source_remove(CM_event_id); CM_event_id = gdk_threads_add_timeout_seconds(SETTLE_TIME, collection_change_done,NULL); } } break; case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED: printf("CM: Ignoring Attribute Changed\n"); /* Ignore printf("CM: Attribute Changed\n"); */ break; default: printf("Unahndled event = %i\n",event_type); } g_free(path); } static void *deploy_file_monitors(void *args){ char **paths= NULL; long long size; int i; size = LIBRARY_get_paths(&paths); for(i=0;imax_keypermod;j++){ if(modmap->modifiermap[i * modmap->max_keypermod + j] == XKeysymToKeycode(d, XK_Control_L )){ super_mask = 1<window,TRUE); // gdk_window_set_keep_below(gui.content_view->window,TRUE); g_signal_connect(main_notebook,"switch-page", G_CALLBACK(on_switch_page),NULL); pthread_create(&key_press_tid,NULL,global_key_press,NULL); gtk_main(); printf("After Main\n"); gdk_threads_leave(); return 0; }