Commits

jjacky committed 9198c9c

- added indication of db to sync in tooltip (close #3)
- bumped version to 0.1.4

  • Participants
  • Parent commits 47e8753

Comments (0)

Files changed (5)

 }
 
 gboolean
-kalu_alpm_syncdbs (GError **error)
+kalu_alpm_syncdbs (gint *nb_dbs_synced, GError **error)
 {
     alpm_list_t     *sync_dbs   = NULL;
     alpm_list_t     *i;
 	}
     
     sync_dbs = alpm_option_get_syncdbs (alpm->handle);
+    *nb_dbs_synced = 0;
     for (i = sync_dbs; i; i = alpm_list_next (i))
     {
 		alpm_db_t *db = i->data;
 
-		ret = alpm_db_update (0, db);
-		if (ret < 0)
+        ret = alpm_db_update (0, db);
+        if (ret < 0)
         {
             g_set_error (error, KALU_ERROR, 1, "Failed to update %s: %s",
                 alpm_db_get_name (db), alpm_strerror (alpm_errno (alpm->handle)));
 		}
         else
         {
+            ++*nb_dbs_synced;
             debug ("%s was updated", alpm_db_get_name (db));
 		}
 	}
 kalu_alpm_load (const gchar *conffile, GError **error);
 
 gboolean
-kalu_alpm_syncdbs (GError **error);
+kalu_alpm_syncdbs (gint *nb_dbs_synced, GError **error);
 
 gboolean
 kalu_alpm_has_updates (alpm_list_t **packages, GError **error);
 
 #define _UNUSED_            __attribute__ ((unused)) 
 
-#define KALU_VERSION       "0.1.3"
+#define KALU_VERSION        "0.1.4"
 #define KALU_TAG            "Keeping Arch Linux Up-to-date"
 
 #define MAX_PATH            255
     guint       timeout;
     guint       timeout_icon;
     GDateTime  *last_check;
+    gint        nb_syncdbs;
     gint        nb_upgrades;
     gint        nb_watched;
     gint        nb_aur;
 
 void set_kalpm_busy (gboolean busy);
 void set_kalpm_nb (check_t type, gint nb);
+void set_kalpm_nb_syncdbs (gint nb);
 
 #endif /* _KALU_H */
 static void icon_popup_cb (GtkStatusIcon *icon, guint button, guint activate_time, gpointer data);
 static void free_config (void);
 
-static kalpm_state_t kalpm_state = { FALSE, 0, 0, NULL, 0, 0, 0, 0, 0 };
+static kalpm_state_t kalpm_state = { FALSE, 0, 0, NULL, 0, 0, 0, 0, 0, 0 };
 
 static void
 run_cmdline (const char *cmdline)
     alpm_list_t *packages, *aur_pkgs;
     gchar *xml_news;
     gboolean got_something =  FALSE;
+    gint nb_syncdbs     = -1;
     gint nb_upgrades    = -1;
     gint nb_watched     = -1;
     gint nb_aur         = -1;
         
         /* syncdbs only if needed */
         if (checks & (CHECK_UPGRADES | CHECK_WATCHED)
-            && !kalu_alpm_syncdbs (&error))
+            && !kalu_alpm_syncdbs (&nb_syncdbs, &error))
         {
             notify_error ("Unable to check for updates -- could not synchronize databases",
                 error->message);
         g_date_time_unref (kalpm_state.last_check);
     }
     kalpm_state.last_check = g_date_time_new_now_local ();
+    if (nb_syncdbs >= 0)
+    {
+        set_kalpm_nb_syncdbs (nb_syncdbs);
+    }
     if (nb_news >= 0)
     {
         set_kalpm_nb (CHECK_NEWS, nb_news);
         addstr ("ago");
     }
     
+    if (kalpm_state.nb_syncdbs > 0)
+    {
+        addstr ("\nsync possible for %d dbs", kalpm_state.nb_syncdbs);
+    }
+    
     if (kalpm_state.nb_news > 0)
     {
         addstr ("\n%d unread news", kalpm_state.nb_news);
     g_main_context_invoke (NULL, (GSourceFunc) set_status_icon, GINT_TO_POINTER (active));
 }
 
+inline void
+set_kalpm_nb_syncdbs (gint nb)
+{
+    kalpm_state.nb_syncdbs = nb;
+}
+
 static gboolean
 switch_status_icon (void)
 {
     
     gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (updater->pbar_main), 1);
     add_log (LOGTYPE_NORMAL, "Databases synchronized\n");
+    set_kalpm_nb_syncdbs (0);
     
     add_log (LOGTYPE_UNIMPORTANT, "Getting packages list\n");
     gtk_label_set_text (GTK_LABEL (updater->lbl_main), "Getting packages list...");