root / trunk / client / gui / notify.c @ 1853
History | View | Annotate | Download (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 | 
                  #include "config_gui.h"  | 
              
| 21 | 
                   | 
              
| 22 | 
                  #ifdef HAVE_LIBNOTIFY
                 | 
              
| 23 | 
                   | 
              
| 24 | 
                  #include  | 
              
| 25 | 
                   | 
              
| 26 | 
                  static void  | 
              
| 27 | 
                  file_state_changed (NntpgrabGlue *obj, const char *collection_name, const char *subject, const char *real_filename, NGTaskState old_state, NGTaskState new_state, guint64 file_size_remaining, guint64 total_size, guint64 total_size_remaining, gpointer data)  | 
              
| 28 | 
                  {
                 | 
              
| 29 | 
                      char *msg;
                 | 
              
| 30 | 
                  NotifyNotification *notification;  | 
              
| 31 | 
                  ConfigGUIOpts opts;  | 
              
| 32 | 
                   | 
              
| 33 | 
                  opts = config_gui_get_opts();  | 
              
| 34 | 
                   | 
              
| 35 | 
                      switch (new_state) {
                 | 
              
| 36 | 
                  case TASK_STATE_WAITING_FOR_DECODE:  | 
              
| 37 | 
                              if (!opts.show_notification_on_file_downloaded) {
                 | 
              
| 38 | 
                                  return;
                 | 
              
| 39 | 
                  }  | 
              
| 40 | 
                   | 
              
| 41 | 
                              msg = g_strdup_printf(_("All the parts belonging to the post with subject\n%s\nare now downloaded and will soon be decoded"), subject);
                 | 
              
| 42 | 
                  #ifdef HAVE_LIBNOTIFY_0_7
                 | 
              
| 43 | 
                  notification = notify_notification_new(_("File download done"), msg, NULL);  | 
              
| 44 | 
                  #else
                 | 
              
| 45 | 
                  notification = notify_notification_new(_("File download done"), msg, NULL, NULL);  | 
              
| 46 | 
                  #endif
                 | 
              
| 47 | 
                  g_free(msg);  | 
              
| 48 | 
                   | 
              
| 49 | 
                              break;
                 | 
              
| 50 | 
                   | 
              
| 51 | 
                  case TASK_STATE_FINISHED_COMPLETE:  | 
              
| 52 | 
                  case TASK_STATE_FINISHED_INCOMPLETE:  | 
              
| 53 | 
                              if (!opts.show_notification_on_file_decoded) {
                 | 
              
| 54 | 
                                  return;
                 | 
              
| 55 | 
                  }  | 
              
| 56 | 
                   | 
              
| 57 | 
                              msg = g_strdup_printf(_("The file belonging to the post with subject\n%s\nis now decoded"), subject);
                 | 
              
| 58 | 
                  #ifdef HAVE_LIBNOTIFY_0_7
                 | 
              
| 59 | 
                  notification = notify_notification_new(_("File decode done"), msg, NULL);  | 
              
| 60 | 
                  #else
                 | 
              
| 61 | 
                  notification = notify_notification_new(_("File decode done"), msg, NULL, NULL);  | 
              
| 62 | 
                  #endif
                 | 
              
| 63 | 
                  g_free(msg);  | 
              
| 64 | 
                   | 
              
| 65 | 
                              break;
                 | 
              
| 66 | 
                   | 
              
| 67 | 
                          default:
                 | 
              
| 68 | 
                              return;
                 | 
              
| 69 | 
                              break;
                 | 
              
| 70 | 
                  };  | 
              
| 71 | 
                   | 
              
| 72 | 
                      notify_notification_show(notification, NULL);
                 | 
              
| 73 | 
                  }  | 
              
| 74 | 
                   | 
              
| 75 | 
                  void
                 | 
              
| 76 | 
                  notify_initialize(void)
                 | 
              
| 77 | 
                  {
                 | 
              
| 78 | 
                      if (!notify_init(PACKAGE)) {
                 | 
              
| 79 | 
                          GtkWidget *windowMain = nntpgrab_gui_base_get_widget("windowMain");
                 | 
              
| 80 | 
                          nntpgrab_gui_base_dialog_show(windowMain, _("Libnotify could not be initialised.\nNotification bubbles will be disabled"), GTK_MESSAGE_ERROR, GTK_BUTTONS_OK);
                 | 
              
| 81 | 
                   | 
              
| 82 | 
                          return;
                 | 
              
| 83 | 
                  }  | 
              
| 84 | 
                   | 
              
| 85 | 
                  nntpgrab_glue_signal_connect(glue, "file_state_changed", NG_CALLBACK(file_state_changed), NULL);  | 
              
| 86 | 
                  }  | 
              
| 87 | 
                   | 
              
| 88 | 
                  #else /* HAVE_LIBNOTIFY */  | 
              
| 89 | 
                   | 
              
| 90 | 
                  void
                 | 
              
| 91 | 
                  notify_initialize(void)
                 | 
              
| 92 | 
                  {
                 | 
              
| 93 | 
                  }  | 
              
| 94 | 
                   | 
              
| 95 | 
                  #endif /* HAVE_LIBNOTIFY */  | 
              
NNTPGrab

