Statistics
| Revision:

root / trunk / client / gui / config_par2.c @ 1850

History | View | Annotate | Download (5.3 KB)

1
/* 
2
    Copyright (C) 2005-2010  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 "gui.h"
20

                
21
G_MODULE_EXPORT void
22
on_chkEnablePAR2Repair_toggled(GtkToggleButton *caller, gpointer data)
23
{
24
    NGConfigOpts opts = nntpgrab_glue_config_get_opts(glue);
25
    gboolean state = gtk_toggle_button_get_active(caller);
26

                
27
    if (opts.enable_par2_repair != state) {
28
        opts.enable_par2_repair = state;
29
    }
30

                
31
    nntpgrab_glue_config_set_opts(glue, opts);
32
}
33

                
34
G_MODULE_EXPORT void
35
on_chkEnableIntelligentPAR2Downloading_toggled(GtkToggleButton *caller, gpointer data)
36
{
37
    NGConfigOpts opts = nntpgrab_glue_config_get_opts(glue);
38
    gboolean state = gtk_toggle_button_get_active(caller);
39

                
40
    if (opts.enable_intelligent_par2_downloading != state) {
41
        opts.enable_intelligent_par2_downloading = state;
42
    }
43

                
44
    nntpgrab_glue_config_set_opts(glue, opts);
45
}
46

                
47
G_MODULE_EXPORT void
48
on_chkEnableAutoUnpack_toggled(GtkToggleButton *caller, gpointer data)
49
{
50
    NGConfigOpts opts = nntpgrab_glue_config_get_opts(glue);
51
    gboolean state = gtk_toggle_button_get_active(caller);
52

                
53
    if (opts.enable_auto_unpack != state) {
54
        opts.enable_auto_unpack = state;
55
    }
56

                
57
    nntpgrab_glue_config_set_opts(glue, opts);
58
 }
59

                
60
G_MODULE_EXPORT void
61
on_chkRemoveFilesAfterRepair_toggled(GtkToggleButton *caller, gpointer data)
62
{
63
    NGConfigOpts opts = nntpgrab_glue_config_get_opts(glue);
64
    gboolean state = gtk_toggle_button_get_active(caller);
65

                
66
    if (opts.auto_remove_files_after_repair != state) {
67
        opts.auto_remove_files_after_repair = state;
68
        nntpgrab_glue_config_set_opts(glue, opts);
69
    }
70
}
71

                
72
G_MODULE_EXPORT void
73
on_chkRemoveFilesAfterUnpack_toggled(GtkToggleButton *caller, gpointer data)
74
{
75
    NGConfigOpts opts = nntpgrab_glue_config_get_opts(glue);
76
    gboolean state = gtk_toggle_button_get_active(caller);
77

                
78
    if (opts.auto_remove_files_after_unpack != state) {
79
        opts.auto_remove_files_after_unpack = state;
80
        nntpgrab_glue_config_set_opts(glue, opts);
81
    }
82
}
83

                
84
static void
85
config_changed(NntpgrabGlue *obj, gpointer data)
86
{
87
    GtkWidget *chkEnablePAR2Repair = nntpgrab_gui_base_get_widget("chkEnablePAR2Repair");
88
    GtkWidget *chkEnableIntelligentPAR2Downloading = nntpgrab_gui_base_get_widget("chkEnableIntelligentPAR2Downloading");
89
    GtkWidget *chkEnableAutoUnpack = nntpgrab_gui_base_get_widget("chkEnableAutoUnpack");
90
    GtkWidget *chkRemoveFilesAfterRepair = nntpgrab_gui_base_get_widget("chkRemoveFilesAfterRepair");
91
    GtkWidget *chkRemoveFilesAfterUnpack = nntpgrab_gui_base_get_widget("chkRemoveFilesAfterUnpack");
92
    NGConfigOpts opts = nntpgrab_glue_config_get_opts(glue);
93

                
94
    g_signal_handlers_block_by_func (G_OBJECT (chkEnablePAR2Repair), G_CALLBACK (on_chkEnablePAR2Repair_toggled), NULL);
95
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkEnablePAR2Repair), opts.enable_par2_repair);
96
    g_signal_handlers_unblock_by_func (G_OBJECT (chkEnablePAR2Repair), G_CALLBACK (on_chkEnablePAR2Repair_toggled), NULL);
97

                
98
    g_signal_handlers_block_by_func (G_OBJECT (chkEnableIntelligentPAR2Downloading), G_CALLBACK (on_chkEnableIntelligentPAR2Downloading_toggled), NULL);
99
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkEnableIntelligentPAR2Downloading), opts.enable_intelligent_par2_downloading);
100
    g_signal_handlers_unblock_by_func (G_OBJECT (chkEnableIntelligentPAR2Downloading), G_CALLBACK (on_chkEnableIntelligentPAR2Downloading_toggled), NULL);
101

                
102
    g_signal_handlers_block_by_func (G_OBJECT (chkEnableAutoUnpack), G_CALLBACK (on_chkEnableAutoUnpack_toggled), NULL);
103
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkEnableAutoUnpack), opts.enable_auto_unpack);
104
    g_signal_handlers_unblock_by_func (G_OBJECT (chkEnableAutoUnpack), G_CALLBACK (on_chkEnableAutoUnpack_toggled), NULL);
105

                
106
    g_signal_handlers_block_by_func (G_OBJECT (chkRemoveFilesAfterRepair), G_CALLBACK (on_chkRemoveFilesAfterRepair_toggled), NULL);
107
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkRemoveFilesAfterRepair), opts.auto_remove_files_after_repair);
108
    g_signal_handlers_unblock_by_func (G_OBJECT (chkRemoveFilesAfterRepair), G_CALLBACK (on_chkRemoveFilesAfterRepair_toggled), NULL);
109

                
110
    g_signal_handlers_block_by_func (G_OBJECT (chkRemoveFilesAfterUnpack), G_CALLBACK (on_chkRemoveFilesAfterUnpack_toggled), NULL);
111
    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(chkRemoveFilesAfterUnpack), opts.auto_remove_files_after_unpack);
112
    g_signal_handlers_unblock_by_func (G_OBJECT (chkRemoveFilesAfterUnpack), G_CALLBACK (on_chkRemoveFilesAfterUnpack_toggled), NULL);
113
}
114

                
115
void
116
config_par2_initialize()
117
{
118
    nntpgrab_glue_signal_connect(glue, "config_changed", NG_CALLBACK(config_changed), NULL);
119
    config_changed(glue, NULL);
120
}