1 /* 2 * Copyright 2011 kubtek <kubtek@mail.com> 3 * 4 * This file is part of StarDict. 5 * 6 * StarDict is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * StarDict is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with StarDict. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef __SD_DICT_MANAGE_DLG_H__ 21 #define __SD_DICT_MANAGE_DLG_H__ 22 23 #include <gtk/gtk.h> 24 25 class DictManageDlg; 26 27 class NetworkAddDlg { 28 private: 29 DictManageDlg *dictdlg; 30 GtkTreeStore *model; 31 GtkWidget *treeview; 32 static void on_network_adddlg_add_button_clicked(GtkWidget *widget, NetworkAddDlg *oNetworkAddDlg); 33 static void on_network_adddlg_info_button_clicked(GtkWidget *widget, NetworkAddDlg *oNetworkAddDlg); 34 static gboolean on_button_press(GtkWidget * widget, GdkEventButton * event, NetworkAddDlg *oNetworkAddDlg); 35 static void on_row_expanded(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, NetworkAddDlg *oNetworkAddDlg); 36 public: 37 GtkWidget *window; 38 NetworkAddDlg(DictManageDlg *dlg); 39 void Show(GtkWindow *parent_win); 40 void network_getdirinfo(const char *xml); 41 }; 42 43 class DictManageDlg { 44 private: 45 GtkWidget *dict_list_button; 46 GtkWidget *manage_button; 47 GtkWidget *tree_dict_button; 48 GtkWidget *notebook; 49 GtkWidget *button_notebook; 50 GtkWidget *download_hbox; 51 GtkWidget *info_label; 52 GtkWidget *upgrade_label; 53 GtkWidget *upgrade_eventbox; 54 GtkWidget *popup_menu; 55 GtkWidget *dict_list_treeview; 56 GtkTreeModel *dict_list_tree_model; 57 GtkWidget *dictmanage_treeview; 58 GtkTreeModel *dictmanage_tree_model; 59 GtkWidget *treedict_treeview; 60 GtkTreeModel *treedict_tree_model; 61 GtkWidget *network_treeview; 62 GtkTreeModel *network_tree_model; 63 GtkWindow *parent_win; 64 GdkPixbuf *dicts_icon, *tree_dicts_icon; 65 NetworkAddDlg *network_add_dlg; 66 int max_dict_count; 67 int user_level; 68 std::string upgrade_url; 69 bool network_dictmask_changed; 70 bool dictmanage_list_changed; 71 bool dictmanage_config_changed; 72 73 enum TDictTree { DictTree_DictList, DictTree_TreeDict, DictTree_NetworkDict }; 74 static GtkTreeModel* create_tree_model(TDictTree dicttree); 75 GtkWidget *create_dict_tree(TDictTree dicttree); 76 static GtkTreeModel* create_dictmanage_tree_model(); 77 GtkWidget *create_dictmanage_tree(); 78 79 GtkWidget *create_buttons(); 80 GtkWidget *create_dictmanage_buttons(); 81 GtkWidget *create_network_buttons(); 82 83 void write_treedict_order_list(); 84 void ChangeNetworkDictMask(); 85 void SaveDictManageList(); 86 void SaveDictManageConfig(); 87 void show_dict_info(); 88 89 void show_add_group_dialog(GtkTreeIter *iter); 90 void show_delete_group_dialog(GtkTreeIter *iter); 91 void show_delete_subgroup_dialog(GtkTreeIter *iter); 92 void show_add_dict_dialog(GtkTreeIter *iter); 93 94 static void on_dict_list_button_toggled(GtkToggleButton *button, DictManageDlg *oDictManageDlg); 95 static void on_manage_button_toggled(GtkToggleButton *button, DictManageDlg *oDictManageDlg); 96 static void on_tree_dict_button_toggled(GtkToggleButton *button, DictManageDlg *oDictManageDlg); 97 static void on_network_button_toggled(GtkToggleButton *button, DictManageDlg *oDictManageDlg); 98 static void on_download_eventbox_clicked(GtkWidget *widget, GdkEventButton *event, DictManageDlg *oDictManageDlg); 99 static void on_upgrade_eventbox_clicked(GtkWidget *widget, GdkEventButton *event, DictManageDlg *oDictManageDlg); 100 101 static void on_popup_menu_show_info_activate(GtkMenuItem *menuitem, DictManageDlg *oDictManageDlg); 102 static void on_popup_menu_select_all_activate(GtkMenuItem *menuitem, DictManageDlg *oDictManageDlg); 103 static void on_popup_menu_unselect_all_activate(GtkMenuItem *menuitem, DictManageDlg *oDictManageDlg); 104 105 static gboolean on_dictlist_treeview_button_press(GtkWidget * widget, GdkEventButton *event, DictManageDlg *oDictManageDlg); 106 static gboolean on_dicttree_and_manage_treeview_button_press(GtkWidget * widget, GdkEventButton *event, DictManageDlg *oDictManageDlg); 107 static gboolean on_network_treeview_button_press(GtkWidget * widget, GdkEventButton *event, DictManageDlg *oDictManageDlg); 108 static void response_handler (GtkDialog *dialog, gint res_id, DictManageDlg *oDictManageDlg); 109 static void on_network_add_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 110 static void on_network_remove_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 111 static void on_move_top_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 112 static void on_move_bottom_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 113 static void on_move_up_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 114 static void on_move_down_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 115 static void on_dictmanage_add_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 116 static void on_dictmanage_delete_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 117 static void on_dictmanage_info_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 118 static void on_dictmanage_move_top_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 119 static void on_dictmanage_move_bottom_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 120 static void on_dictmanage_move_up_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 121 static void on_dictmanage_move_down_button_clicked(GtkWidget *widget, DictManageDlg *oDictManageDlg); 122 static void on_group_name_cell_edited(GtkCellRendererText *cell, const gchar *path_string, const gchar *new_text, DictManageDlg *oDictManageDlg); 123 static void on_dictmanage_enable_toggled (GtkCellRendererToggle *cell, gchar *path_str, DictManageDlg *oDictManageDlg); 124 static void on_treedict_enable_toggled (GtkCellRendererToggle *cell, gchar *path_str, DictManageDlg *oDictManageDlg); 125 static void on_dict_list_dict_name_column_clicked(GtkTreeViewColumn *treeviewcolumn, DictManageDlg *oDictManageDlg); 126 static void on_treedict_dict_name_column_clicked(GtkTreeViewColumn *treeviewcolumn, DictManageDlg *oDictManageDlg); 127 static void on_network_dict_name_column_clicked(GtkTreeViewColumn *treeviewcolumn, DictManageDlg *oDictManageDlg); 128 129 static void drag_data_received_cb(GtkWidget *widget, GdkDragContext *ctx, guint x, guint y, GtkSelectionData *sd, guint info, guint t, DictManageDlg *oDictManageDlg); 130 static void drag_data_get_cb(GtkWidget *widget, GdkDragContext *ctx, GtkSelectionData *data, guint info, guint time, DictManageDlg *oDictManageDlg); 131 static void dictmanage_drag_data_received_cb(GtkWidget *widget, GdkDragContext *ctx, guint x, guint y, GtkSelectionData *sd, guint info, guint t, DictManageDlg *oDictManageDlg); 132 133 public: 134 GtkWidget *window; 135 136 DictManageDlg(GtkWindow *parent_win, GdkPixbuf *dicts_icon, GdkPixbuf *tree_dicts_icon); 137 bool Show(bool &dictmanage_config_changed_); 138 void Close(); 139 void network_getdictmask(const char *xml); 140 void network_getadinfo(const char *xml); 141 void network_dirinfo(const char *xml); 142 void network_dictinfo(const char *xml); 143 void network_maxdictcount(int count); 144 145 friend class NetworkAddDlg; 146 }; 147 148 #endif 149