gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r19564 - in gnunet-gtk: contrib src/fs


From: gnunet
Subject: [GNUnet-SVN] r19564 - in gnunet-gtk: contrib src/fs
Date: Tue, 31 Jan 2012 12:02:18 +0100

Author: grothoff
Date: 2012-01-31 12:02:18 +0100 (Tue, 31 Jan 2012)
New Revision: 19564

Modified:
   gnunet-gtk/contrib/gnunet_fs_gtk_progress_dialog.glade
   gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c
Log:
-misc bugfixes to progress dialog for publishing

Modified: gnunet-gtk/contrib/gnunet_fs_gtk_progress_dialog.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_progress_dialog.glade      2012-01-31 
08:25:37 UTC (rev 19563)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_progress_dialog.glade      2012-01-31 
11:02:18 UTC (rev 19564)
@@ -1,19 +1,18 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0"?>
 <interface>
   <requires lib="gtk+" version="2.20"/>
   <!-- interface-naming-policy project-wide -->
   <object class="GtkWindow" id="GNUNET_FS_GTK_progress_dialog">
-    <property name="can_focus">False</property>
     <property name="border_width">2</property>
     <property name="window_position">center-on-parent</property>
     <property name="default_width">800</property>
     <property name="default_height">600</property>
     <property name="destroy_with_parent">True</property>
-    <signal name="delete-event" 
handler="GNUNET_FS_GTK_progress_dialog_delete_event_cb" swapped="no"/>
+    <signal name="delete_event" 
handler="GNUNET_FS_GTK_progress_dialog_delete_event_cb"/>
     <child>
       <object class="GtkVBox" id="GNUNET_FS_GTK_progress_dialog_main_vbox">
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">2</property>
         <child>
           <object class="GtkScrolledWindow" 
id="GNUNET_FS_GTK_progress_dialog_scrolled_window">
@@ -37,15 +36,12 @@
             </child>
           </object>
           <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
             <property name="position">0</property>
           </packing>
         </child>
         <child>
           <object class="GtkProgressBar" 
id="GNUNET_FS_GTK_progress_dialog_progressbar">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
             <property name="activity_mode">True</property>
           </object>
           <packing>
@@ -57,43 +53,23 @@
         <child>
           <object class="GtkHBox" 
id="GNUNET_FS_GTK_progress_dialog_buttons_hbox">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
             <property name="spacing">2</property>
             <child>
               <placeholder/>
             </child>
             <child>
-              <object class="GtkButton" 
id="GNUNET_FS_GTK_progress_dialog_ok_button">
-                <property name="label">gtk-ok</property>
-                <property name="use_action_appearance">False</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-                <signal name="clicked" 
handler="GNUNET_FS_GTK_progress_dialog_ok_button_clicked_cb" swapped="no"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="pack_type">end</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkButton" 
id="GNUNET_FS_GTK_progress_dialog_cancel_button">
                 <property name="label">gtk-cancel</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_stock">True</property>
-                <signal name="clicked" 
handler="GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb" swapped="no"/>
+                <signal name="clicked" 
handler="GNUNET_FS_GTK_progress_dialog_cancel_button_clicked_cb"/>
               </object>
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="pack_type">end</property>
-                <property name="position">2</property>
+                <property name="position">1</property>
               </packing>
             </child>
           </object>
@@ -106,12 +82,7 @@
       </object>
     </child>
   </object>
-  <object class="GtkSizeGroup" 
id="GNUNET_FS_GTK_progress_dialog_buttons_sizegroup">
-    <widgets>
-      <widget name="GNUNET_FS_GTK_progress_dialog_ok_button"/>
-      <widget name="GNUNET_FS_GTK_progress_dialog_cancel_button"/>
-    </widgets>
-  </object>
+  <object class="GtkSizeGroup" 
id="GNUNET_FS_GTK_progress_dialog_buttons_sizegroup"/>
   <object class="GtkTextBuffer" id="GNUNET_FS_GTK_progress_dialog_textbuffer"/>
   <object class="GtkAdjustment" 
id="GNUNET_FS_GTK_progress_dialog_textview_horizontal_adjustment">
     <property name="upper">100</property>

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c  2012-01-31 
08:25:37 UTC (rev 19563)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-main_window_file_publish.c  2012-01-31 
11:02:18 UTC (rev 19564)
@@ -86,6 +86,9 @@
   GtkTextView *progress_dialog_textview;
   GtkTextBuffer *progress_dialog_textbuffer;
   GtkTextMark *progress_dialog_textmark;
+
+  unsigned int done;
+  unsigned int total;
 };
 
 void
@@ -821,8 +824,11 @@
     GNUNET_CONTAINER_meta_data_delete (item->meta,
                                       EXTRACTOR_METATYPE_MIMETYPE, NULL, 0);
     GNUNET_FS_meta_data_make_directory (item->meta);
-    GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME,
-        GNUNET_NO);
+    if (NULL == item->ksk_uri)
+      item->ksk_uri = GNUNET_FS_uri_ksk_create (GNUNET_FS_DIRECTORY_MIME, 
NULL);
+    else
+      GNUNET_FS_uri_ksk_add_keyword (item->ksk_uri, GNUNET_FS_DIRECTORY_MIME,
+                                    GNUNET_NO);
     fi = GNUNET_FS_file_information_create_empty_directory (
         GNUNET_FS_GTK_get_fs_handle (), row_reference, item->ksk_uri,
         item->meta, &adcc->directory_scan_bo, item->filename);
@@ -834,8 +840,6 @@
         item->ksk_uri, item->meta, adcc->directory_scan_do_index,
         &adcc->directory_scan_bo);
   }
-  GNUNET_CONTAINER_meta_data_destroy (item->meta);
-  GNUNET_FS_uri_destroy (item->ksk_uri);
   if (item->is_directory)
     file_size_fancy = GNUNET_strdup (MARKER_DIR_FILE_SIZE);
   else
@@ -850,8 +854,6 @@
       6, (guint64) adcc->directory_scan_bo.expiration_time.abs_value,
       7, (guint) adcc->directory_scan_bo.replication_level, -1);
   GNUNET_free (file_size_fancy);
-  GNUNET_free (item->short_filename);
-  GNUNET_free (item->filename);
 }
 
 
@@ -877,7 +879,7 @@
     sibling_iter = &last_added;
     if (item->is_directory) 
       add_share_items_to_treestore (adcc,
-                                   item,
+                                   item->children_head,
                                    sibling_iter);
   }
 }
@@ -929,36 +931,58 @@
 {
   struct AddDirClientContext *adcc = cls;
   char *s;
+  gdouble fraction;
 
   gtk_progress_bar_pulse (adcc->progress_dialog_bar);
   switch (reason)
   {
   case GNUNET_FS_DIRSCANNER_FILE_START:
-    if (filename != NULL)
+    GNUNET_assert (filename != NULL);
+    if (is_directory)
     {
-      if (is_directory)
-       GNUNET_asprintf (&s, _("Scanning directory `%s'.\n"), filename);
-      else
-       GNUNET_asprintf (&s, _("Scanning file `%s'.\n"), filename);
+      GNUNET_asprintf (&s, _("Scanning directory `%s'.\n"), filename);
       insert_progress_dialog_text (adcc, s);
       GNUNET_free (s);
     }
+    else
+      adcc->total++;    
     break;
   case GNUNET_FS_DIRSCANNER_FILE_IGNORED:
-    if (filename != NULL)
-    {
-      GNUNET_asprintf (&s,
-                      _("Failed to scan `%s', because it does not exist.\n"),
-                      filename);
-      insert_progress_dialog_text (adcc, s);
-      GNUNET_free (s);
-    }
+    GNUNET_assert (filename != NULL);
+    GNUNET_asprintf (&s,
+                    _("Failed to scan `%s' (access error). Skipping.\n"),
+                    filename);
+    insert_progress_dialog_text (adcc, s);
+    GNUNET_free (s);    
     break;
   case GNUNET_FS_DIRSCANNER_ALL_COUNTED:
-    // FIXME...
+    fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total;
+    GNUNET_asprintf (&s, "%u/%u (%3f%%)", 
+                    adcc->done,
+                    adcc->total,
+                    100.0 * fraction);
+    gtk_progress_bar_set_text (adcc->progress_dialog_bar,
+                              s);    
+    GNUNET_free (s);
+    gtk_progress_bar_set_fraction (adcc->progress_dialog_bar,
+                                  fraction);
     break;
   case GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED:
-    // FIXME...
+    GNUNET_asprintf (&s, _("Processed file `%s'.\n"), filename);
+    insert_progress_dialog_text (adcc, s);
+    GNUNET_free (s);
+    adcc->done++;
+    GNUNET_assert (adcc->done <= adcc->total);
+    fraction = (adcc->total == 0) ? 1.0 : (1.0 * adcc->done) / adcc->total;
+    GNUNET_asprintf (&s, "%u/%u (%3f%%)", 
+                    adcc->done,
+                    adcc->total,
+                    100.0 * fraction);
+    gtk_progress_bar_set_text (adcc->progress_dialog_bar,
+                              s);    
+    GNUNET_free (s);
+    gtk_progress_bar_set_fraction (adcc->progress_dialog_bar,
+                                  fraction);
     break;
   case GNUNET_FS_DIRSCANNER_INTERNAL_ERROR:
     insert_progress_dialog_text (adcc, _("Operation failed (press cancel)\n"));
@@ -1026,6 +1050,7 @@
       &iter, FALSE);
 
   gtk_window_set_transient_for (GTK_WINDOW (adcc->progress_dialog), 
adcc->ctx->master_pubdialog);
+  gtk_window_set_title (GTK_WINDOW (adcc->progress_dialog), filename);
   gtk_window_present (GTK_WINDOW (adcc->progress_dialog));
 
   update_selectivity (ctx);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]