root / trunk / client / gui / config.c @ 1790
History | View | Annotate | Download (5.2 KB)
| 1 |
/*
|
|---|---|
| 2 |
Copyright (C) 2005-2009 Erik van Pienbroek |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or modify |
| 5 |
it under the terms of the GNU General Public License as published by |
| 6 |
the Free Software Foundation; either version 2 of the License, or |
| 7 |
(at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 |
*/ |
| 18 |
|
| 19 |
#include |
| 20 |
#include "gui.h" |
| 21 |
#include "config_gui.h" |
| 22 |
|
| 23 |
void config_servers_initialize();
|
| 24 |
void config_folders_update_folders(void); |
| 25 |
void config_folders_initialize();
|
| 26 |
void config_par2_initialize();
|
| 27 |
void config_notifications_initialize();
|
| 28 |
void config_nzbcreator_initialize();
|
| 29 |
void config_autoimport_initialize();
|
| 30 |
void config_autoimport_update_folders(void); |
| 31 |
void config_plugins_initialize();
|
| 32 |
|
| 33 |
static void |
| 34 |
on_cat_selection_changed(GtkTreeSelection *selection, gpointer data) |
| 35 |
{
|
| 36 |
GtkTreeIter iter; |
| 37 |
GtkTreeModel *model = NULL;
|
| 38 |
GtkWidget *widget = NULL;
|
| 39 |
GtkWidget *notebookConfigCats = nntpgrab_gui_base_get_widget("notebookConfigCats");
|
| 40 |
int pagenum;
|
| 41 |
char *label = NULL; |
| 42 |
|
| 43 |
g_return_if_fail(gtk_tree_selection_count_selected_rows(selection) != 0);
|
| 44 |
|
| 45 |
g_assert(gtk_tree_selection_get_selected(selection, &model, &iter)); |
| 46 |
|
| 47 |
gtk_tree_model_get(model, &iter, 0, &label, 1, &widget, -1); |
| 48 |
|
| 49 |
pagenum = gtk_notebook_page_num(GTK_NOTEBOOK(notebookConfigCats), GTK_WIDGET(widget)); |
| 50 |
gtk_notebook_set_current_page(GTK_NOTEBOOK(notebookConfigCats), pagenum); |
| 51 |
|
| 52 |
if (!strcmp(label, _("Download folders"))) { |
| 53 |
config_folders_update_folders(); |
| 54 |
} |
| 55 |
|
| 56 |
if (!strcmp(label, _("Auto NZB import"))) { |
| 57 |
config_autoimport_update_folders(); |
| 58 |
} |
| 59 |
|
| 60 |
g_free(label); |
| 61 |
} |
| 62 |
|
| 63 |
void
|
| 64 |
config_initialize() |
| 65 |
{
|
| 66 |
GtkWidget *treeConfigCats = nntpgrab_gui_base_get_widget("treeConfigCats");
|
| 67 |
GtkTreeSelection *selection; |
| 68 |
GtkListStore *store; |
| 69 |
GtkCellRenderer *cellRenderer; |
| 70 |
GtkTreeIter iter; |
| 71 |
GtkWidget *vboxServers; |
| 72 |
GtkWidget *hboxFolders; |
| 73 |
#ifdef HAVE_LIBNOTIFY
|
| 74 |
GtkWidget *vboxNotifications; |
| 75 |
#endif
|
| 76 |
GtkWidget *vboxPAR2; |
| 77 |
GtkWidget *vboxDisplay; |
| 78 |
#if 0
|
| 79 |
GtkWidget *vboxNZBCreator; |
| 80 |
#endif |
| 81 |
GtkWidget *vboxAutoImport; |
| 82 |
GtkWidget *hboxPlugins; |
| 83 |
|
| 84 |
config_servers_initialize(); |
| 85 |
config_folders_initialize(); |
| 86 |
config_par2_initialize(); |
| 87 |
config_notifications_initialize(); |
| 88 |
config_nzbcreator_initialize(); |
| 89 |
#if GLIB_CHECK_VERSION(2,16,0) |
| 90 |
config_autoimport_initialize(); |
| 91 |
#endif
|
| 92 |
config_plugins_initialize(); |
| 93 |
|
| 94 |
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeConfigCats)); |
| 95 |
gtk_tree_selection_set_mode(selection, GTK_SELECTION_BROWSE); |
| 96 |
|
| 97 |
cellRenderer = gtk_cell_renderer_text_new(); |
| 98 |
gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeConfigCats), -1, _("Category"), cellRenderer, "text", 0, NULL); |
| 99 |
|
| 100 |
store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_OBJECT);
|
| 101 |
|
| 102 |
gtk_tree_view_set_model(GTK_TREE_VIEW(treeConfigCats), GTK_TREE_MODEL(store)); |
| 103 |
|
| 104 |
gtk_tree_view_set_enable_search(GTK_TREE_VIEW(treeConfigCats), FALSE); |
| 105 |
|
| 106 |
g_signal_connect(selection, "changed", G_CALLBACK(on_cat_selection_changed), NULL); |
| 107 |
|
| 108 |
vboxServers = nntpgrab_gui_base_get_widget("vboxServers");
|
| 109 |
hboxFolders = nntpgrab_gui_base_get_widget("hboxFolders");
|
| 110 |
#ifdef HAVE_LIBNOTIFY
|
| 111 |
vboxNotifications = nntpgrab_gui_base_get_widget("vboxNotifications");
|
| 112 |
#endif
|
| 113 |
vboxPAR2 = nntpgrab_gui_base_get_widget("vboxPAR2");
|
| 114 |
vboxDisplay = nntpgrab_gui_base_get_widget("vboxDisplay");
|
| 115 |
#if 0
|
| 116 |
vboxNZBCreator = nntpgrab_gui_base_get_widget("vboxNZBCreator");
|
| 117 |
#endif |
| 118 |
#if GLIB_CHECK_VERSION(2,16,0) |
| 119 |
vboxAutoImport = nntpgrab_gui_base_get_widget("vboxAutoImport");
|
| 120 |
#endif
|
| 121 |
hboxPlugins = nntpgrab_gui_base_get_widget("hboxPlugins");
|
| 122 |
|
| 123 |
gtk_list_store_clear(store); |
| 124 |
|
| 125 |
gtk_list_store_append(store, &iter); |
| 126 |
gtk_list_store_set(store, &iter, 0, _("Servers"), 1, vboxServers, -1); |
| 127 |
gtk_tree_selection_select_iter(selection, &iter); |
| 128 |
|
| 129 |
gtk_list_store_append(store, &iter); |
| 130 |
gtk_list_store_set(store, &iter, 0, _("Download folders"), 1, hboxFolders, -1); |
| 131 |
|
| 132 |
#ifdef HAVE_LIBNOTIFY
|
| 133 |
gtk_list_store_append(store, &iter); |
| 134 |
gtk_list_store_set(store, &iter, 0, _("Notifications"), 1, vboxNotifications, -1); |
| 135 |
#endif
|
| 136 |
|
| 137 |
gtk_list_store_append(store, &iter); |
| 138 |
gtk_list_store_set(store, &iter, 0, _("PAR2 handling"), 1, vboxPAR2, -1); |
| 139 |
|
| 140 |
gtk_list_store_append(store, &iter); |
| 141 |
gtk_list_store_set(store, &iter, 0, _("Display settings"), 1, vboxDisplay, -1); |
| 142 |
|
| 143 |
#if 0
|
| 144 |
gtk_list_store_append(store, &iter); |
| 145 |
gtk_list_store_set(store, &iter, 0, _("Online Search"), 1, vboxNZBCreator, -1);
|
| 146 |
#endif |
| 147 |
|
| 148 |
#if GLIB_CHECK_VERSION(2,16,0) |
| 149 |
/* GDirectoryMonitor isn't available yet for OSX */
|
| 150 |
#ifndef __APPLE__
|
| 151 |
gtk_list_store_append(store, &iter); |
| 152 |
gtk_list_store_set(store, &iter, 0, _("Auto NZB import"), 1, vboxAutoImport, -1); |
| 153 |
#endif
|
| 154 |
#endif
|
| 155 |
|
| 156 |
gtk_list_store_append(store, &iter); |
| 157 |
gtk_list_store_set(store, &iter, 0, _("Plugins"), 1, hboxPlugins, -1); |
| 158 |
} |
| 159 |
|
NNTPGrab

