1 /* 2 category.h 3 4 5 6 2003 Plus Huang 7 */ 8 9 #ifndef __CATEGORY_H 10 #define __CATEGORY_H 11 12 #include <glib.h> 13 #include "category_setting.h" 14 #include "download_list_view.h" 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 // 21 // ProxySetting 22 // | 23 // `--DownloadSetting 24 // | 25 // `--CategorySetting 26 // | 27 // `-- Category 28 // 29 30 #define CATEGORY(o) ((Category*)(o)) 31 #define CATEGORY_TAG "category" 32 33 #define CATEGORY_WAITING_STORE_TAG "waiting_store" 34 #define CATEGORY_COMPLETED_STORE_TAG "completed_store" 35 #define CATEGORY_RECYCLED_STORE_TAG "recycled_store" 36 37 typedef struct _Category Category; 38 39 struct _Category { 40 CategorySetting setting; 41 42 // iter in CategoryStore.list_store 43 // iter in CategoryStore.tree_store 44 gpointer category_store; 45 GtkTreeIter iter_list_store; 46 GtkTreeIter iter_tree_store; 47 gboolean valid; 48 49 GStaticRecMutex mutex; 50 gpointer thread_list; 51 gint n_thread; 52 gint reference_count; 53 54 DownloadListView waiting_view; 55 DownloadListView completed_view; 56 DownloadListView recycled_view; 57 DownloadStore waiting_store; 58 DownloadStore completed_store; 59 DownloadStore recycled_store; 60 }; 61 62 enum CATEGORY_CHILDREN { 63 CATEGORY_WAITING, 64 CATEGORY_COMPLETED, 65 CATEGORY_RECYCLED, 66 CATEGORY_ALL 67 }; 68 69 Category* category_new (); 70 Category* category_new_from_setting (CategorySetting* cd); 71 72 void category_ref (Category* ca); 73 void category_unref (Category* ca); 74 75 void category_apply_setting (Category* ca); 76 // call this when CATEGORY_COL_STATE or other display data changed 77 void category_changed_with_children (Category* ca, gint flag_child); 78 #define category_changed(ca) category_changed_with_children(ca, CATEGORY_ALL) 79 80 #define category_lock(cate) g_static_rec_mutex_lock (&(cate)->mutex) 81 #define category_unlock(cate) g_static_rec_mutex_unlock (&(cate)->mutex) 82 83 // thread manager for Category 84 gint category_thread_count_request (Category* ca); 85 gboolean category_thread_activate (Category* ca); 86 void category_thread_destroy (Category* ca); 87 void category_thread_stop (Category* category); 88 void category_thread_remove (Category* category, 89 gpointer thread); 90 void category_thread_add (Category* category, 91 gpointer thread); 92 93 #define category_thread_is_active(cate) ((cate)->n_thread) 94 95 // xml 96 void category_write_xml (Category* category, 97 FILE* file, int level); 98 99 #ifdef __cplusplus 100 } 101 #endif 102 103 #endif // End of __CATEGORY_H 104