Statistics
| Revision:

root / trunk / client / gui / auto_shutdown.c @ 1921

History | View | Annotate | Download (2.1 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
static gboolean autoshutdown_enabled = FALSE;
22

                
23
gboolean        perform_shutdown(void);
24

                
25
static void
26
tool_button_clicked(GtkToolItem *item, gpointer data)
27
{
28
    if (autoshutdown_enabled) {
29
        autoshutdown_enabled = FALSE;
30
        //gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), _("Enable automatic shutdown"));
31
    } else {
32
        autoshutdown_enabled = TRUE;
33
        //gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), _("Disable automatic shutdown"));
34
    }
35
}
36

                
37
static void
38
all_downloads_completed(NntpgrabGlue *obj, gpointer data)
39
{
40
    g_print("all downloads completed\n");
41

                
42
    if (autoshutdown_enabled) {
43
        nntpgrab_utils_perform_shutdown();
44
        g_idle_add((GSourceFunc) gtk_main_quit, NULL);
45
    }
46
}
47

                
48
void
49
autoshutdown_initialize(void)
50
{
51
    if (!nntpgrab_glue_get_is_standalone(glue)) {
52
        return;
53
    }
54

                
55
    GtkWidget *toolbarMain = nntpgrab_gui_base_get_widget("toolbarMain");
56
    GtkToolItem *item = gtk_toggle_tool_button_new();
57
    gtk_tool_button_set_label(GTK_TOOL_BUTTON(item), _("Automatic shutdown"));
58
    gtk_tool_button_set_stock_id(GTK_TOOL_BUTTON(item), "gtk-disconnect");
59
    gtk_widget_show(GTK_WIDGET(item));
60

                
61
    gtk_toolbar_insert(GTK_TOOLBAR(toolbarMain), item, -1);
62

                
63
    g_signal_connect(item, "clicked", G_CALLBACK(tool_button_clicked), NULL);
64
    g_signal_connect(glue, "all_downloads_completed", G_CALLBACK(all_downloads_completed), NULL);
65
}
66