gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r12386 - in gnunet-gtk: contrib src


From: gnunet
Subject: [GNUnet-SVN] r12386 - in gnunet-gtk: contrib src
Date: Thu, 29 Jul 2010 00:08:38 +0200

Author: grothoff
Date: 2010-07-29 00:08:38 +0200 (Thu, 29 Jul 2010)
New Revision: 12386

Modified:
   gnunet-gtk/contrib/publish-directory-dialog.glade
   gnunet-gtk/contrib/publish-file-dialog.glade
   gnunet-gtk/src/edit_publish_dialog.c
   gnunet-gtk/src/gnunet-gtk.c
   gnunet-gtk/src/main_window_file_publish.c
Log:
new features

Modified: gnunet-gtk/contrib/publish-directory-dialog.glade
===================================================================
--- gnunet-gtk/contrib/publish-directory-dialog.glade   2010-07-28 20:19:39 UTC 
(rev 12385)
+++ gnunet-gtk/contrib/publish-directory-dialog.glade   2010-07-28 22:08:38 UTC 
(rev 12386)
@@ -2,20 +2,156 @@
 <interface>
   <requires lib="gtk+" version="2.20"/>
   <!-- interface-naming-policy project-wide -->
+  <object class="GtkAdjustment" id="anonymity_adjustment">
+    <property name="upper">10000000</property>
+    <property name="value">1</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
   <object class="GtkFileChooserDialog" 
id="GNUNET_GTK_publish_directory_dialog">
     <property name="can_default">True</property>
     <property name="border_width">5</property>
     <property name="type_hint">normal</property>
     <property name="has_separator">False</property>
-    <property name="select_multiple">True</property>
     <property name="action">select-folder</property>
     <property name="create_folders">False</property>
+    <property name="select_multiple">True</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox2">
         <property name="visible">True</property>
         <property name="spacing">2</property>
         <child>
-          <placeholder/>
+          <object class="GtkVBox" id="vbox1">
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkHBox" id="hbox1">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkCheckButton" 
id="GNUNET_GTK_publish_directory_dialog_do_index_checkbutton">
+                    <property name="label" translatable="yes">Index 
files</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="active">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="padding">20</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <object class="GtkLabel" 
id="GNUNET_GTK_publish_directory_dialog_priority_label">
+                    <property name="visible">True</property>
+                    <property name="label" 
translatable="yes">Priority:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="padding">13</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSpinButton" 
id="GNUNET_GTK_publish_directory_dialog_priority_spin_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="invisible_char">•</property>
+                    <property name="adjustment">priority_adjustment</property>
+                    <property name="numeric">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="padding">20</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkHBox" id="hbox2">
+                <property name="visible">True</property>
+                <child>
+                  <object class="GtkLabel" 
id="GNUNET_GTK_publish_directory_dialog_expiration_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Expires 
in:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="padding">20</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBox" 
id="GNUNET_GTK_publish_directory_dialog_expiration_combo_box">
+                    <property name="visible">True</property>
+                    <property name="active">0</property>
+                    <property 
name="model">GNUNET_GTK_publish_directory_dialog_expiration_list_store</property>
+                    <child>
+                      <object class="GtkCellRendererText" 
id="GNUNET_GTK_publish_directory_dialog_expiration_box_time_renderer"/>
+                      <attributes>
+                        <attribute name="text">0</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="padding">5</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <object class="GtkLabel" 
id="GNUNET_GTK_publish_directory_dialog_anonymity_label">
+                    <property name="visible">True</property>
+                    <property name="label" 
translatable="yes">Anonymity:</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="padding">5</property>
+                    <property name="position">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSpinButton" 
id="GNUNET_GTK_publish_directory_dialog_anonymity_spin_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="invisible_char">•</property>
+                    <property name="adjustment">anonymity_adjustment</property>
+                    <property name="numeric">True</property>
+                    <signal name="value-changed" 
handler="GNUNET_GTK_anonymity_spin_button_value_changed_cb" swapped="no"/>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="padding">20</property>
+                    <property name="position">4</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">2</property>
+          </packing>
         </child>
         <child internal-child="action_area">
           <object class="GtkHButtonBox" id="dialog-action_area3">
@@ -66,4 +202,18 @@
       <action-widget 
response="-5">GNUNET_GTK_publish_directory_dialog_ok_button</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkListStore" 
id="GNUNET_GTK_publish_directory_dialog_expiration_list_store">
+    <columns>
+      <!-- column-name human_readable_time -->
+      <column type="gchararray"/>
+      <!-- column-name time_in_ms -->
+      <column type="guint64"/>
+    </columns>
+  </object>
+  <object class="GtkAdjustment" id="priority_adjustment">
+    <property name="upper">100000000</property>
+    <property name="value">1000</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
 </interface>

Modified: gnunet-gtk/contrib/publish-file-dialog.glade
===================================================================
--- gnunet-gtk/contrib/publish-file-dialog.glade        2010-07-28 20:19:39 UTC 
(rev 12385)
+++ gnunet-gtk/contrib/publish-file-dialog.glade        2010-07-28 22:08:38 UTC 
(rev 12386)
@@ -2,26 +2,6 @@
 <interface>
   <requires lib="gtk+" version="2.20"/>
   <!-- interface-naming-policy project-wide -->
-  <object class="GtkAdjustment" id="anonymity_adjustment">
-    <property name="upper">10000000</property>
-    <property name="value">1</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
-  <object class="GtkListStore" 
id="GNUNET_GTK_publish_file_dialog_expiration_list_store">
-    <columns>
-      <!-- column-name human_readable_time -->
-      <column type="gchararray"/>
-      <!-- column-name time_in_ms -->
-      <column type="guint64"/>
-    </columns>
-  </object>
-  <object class="GtkAdjustment" id="priority_adjustment">
-    <property name="upper">100000000</property>
-    <property name="value">1000</property>
-    <property name="step_increment">1</property>
-    <property name="page_increment">10</property>
-  </object>
   <object class="GtkFileChooserDialog" id="GNUNET_GTK_publish_file_dialog">
     <property name="can_default">True</property>
     <property name="border_width">5</property>
@@ -216,4 +196,24 @@
       <action-widget 
response="-5">GNUNET_GTK_publish_file_dialog_ok_button</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkAdjustment" id="priority_adjustment">
+    <property name="upper">100000000</property>
+    <property name="value">1000</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
+  <object class="GtkListStore" 
id="GNUNET_GTK_publish_file_dialog_expiration_list_store">
+    <columns>
+      <!-- column-name human_readable_time -->
+      <column type="gchararray"/>
+      <!-- column-name time_in_ms -->
+      <column type="guint64"/>
+    </columns>
+  </object>
+  <object class="GtkAdjustment" id="anonymity_adjustment">
+    <property name="upper">10000000</property>
+    <property name="value">1</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
 </interface>

Modified: gnunet-gtk/src/edit_publish_dialog.c
===================================================================
--- gnunet-gtk/src/edit_publish_dialog.c        2010-07-28 20:19:39 UTC (rev 
12385)
+++ gnunet-gtk/src/edit_publish_dialog.c        2010-07-28 22:08:38 UTC (rev 
12386)
@@ -644,6 +644,16 @@
       GNUNET_break (0);
       return;
     }
+  if (GNUNET_FS_file_information_is_directory (fip))
+    {
+      /* indexing does not apply to directories */
+      gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                   
"GNUNET_GTK_edit_file_information_index_check_button")));
+      gtk_widget_hide (GTK_WIDGET (gtk_builder_get_object (builder,
+                                                                  
"GNUNET_GTK_edit_file_information_index_label")));
+      
+    }
+
   ad = GTK_WIDGET (gtk_builder_get_object (builder,
                                           
"GNUNET_GTK_edit_file_information_dialog"));
   ls = GTK_LIST_STORE (gtk_builder_get_object (builder,

Modified: gnunet-gtk/src/gnunet-gtk.c
===================================================================
--- gnunet-gtk/src/gnunet-gtk.c 2010-07-28 20:19:39 UTC (rev 12385)
+++ gnunet-gtk/src/gnunet-gtk.c 2010-07-28 22:08:38 UTC (rev 12386)
@@ -363,9 +363,8 @@
   ret = gtk_builder_new ();
   gtk_builder_set_translation_domain (ret, "gnunet-gtk");
   GNUNET_asprintf (&glade_path,
-                  "%s/%s/%s",
+                  "%s%s",
                   GNUNET_GTK_get_data_dir (),
-                  PACKAGE_NAME,
                   filename);
   error = NULL;
   if (0 == gtk_builder_add_from_file (ret, glade_path, &error))

Modified: gnunet-gtk/src/main_window_file_publish.c
===================================================================
--- gnunet-gtk/src/main_window_file_publish.c   2010-07-28 20:19:39 UTC (rev 
12385)
+++ gnunet-gtk/src/main_window_file_publish.c   2010-07-28 22:08:38 UTC (rev 
12386)
@@ -179,7 +179,7 @@
 add_file_at_iter (const char *filename,
                  uint32_t anonymity_level,
                  uint32_t priority,
-                 struct GNUNET_TIME_Relative expiration,
+                 struct GNUNET_TIME_Absolute expiration,
                  int do_index,
                  GtkTreeIter *iter)
 {
@@ -240,7 +240,7 @@
                                                    do_index,
                                                    anonymity_level,
                                                    priority,
-                                                   
GNUNET_TIME_relative_to_absolute (expiration));
+                                                   expiration);
   GNUNET_CONTAINER_meta_data_destroy (meta);
   GNUNET_FS_uri_destroy (ksk_uri);
   file_size_fancy = GNUNET_STRINGS_byte_size_fancy (file_size);
@@ -260,24 +260,24 @@
 
 /**
  * Add an empty directory to the tree model.
- * FIXME: consider opening a dialog to get
- * anonymity, priority and expiration prior
- * to calling this function (currently we
- * use default values for those).
  *
  * @param name name for the directory
  * @param iter parent entry, or NULL for top-level addition
+ * @param pos iterator to set to the location of the new element
  */
 static void
 create_dir_at_iter (const char *name,
-                   GtkTreeIter *iter)
+                   uint32_t anonymity,
+                   uint32_t priority,
+                   struct GNUNET_TIME_Absolute expiration,
+                   GtkTreeIter *iter,
+                   GtkTreeIter *pos)
 {
   struct GNUNET_FS_FileInformation *fi;
   GtkTreeRowReference *row_reference;
   GtkTreePath *path;
   struct GNUNET_CONTAINER_MetaData *meta;
   GtkTreeStore *ts;
-  GtkTreeIter pos;
 
   ts = GTK_TREE_STORE (gtk_builder_get_object (master_builder,
                                               
"GNUNET_GTK_file_sharing_publishing_tree_store"));
@@ -291,11 +291,11 @@
                                     name,
                                     strlen(name)+1);
   gtk_tree_store_insert_before (ts,
-                               &pos,
+                               pos,
                                iter,
                                NULL);
   path = gtk_tree_model_get_path (GTK_TREE_MODEL (ts),
-                                 &pos);
+                                 pos);
   row_reference = gtk_tree_row_reference_new (GTK_TREE_MODEL (ts),
                                              path);
   gtk_tree_path_free (path);
@@ -303,21 +303,32 @@
                                                          row_reference,
                                                          NULL,
                                                          meta,
-                                                         1 /* anonymity */, 
1000 /* priority */,
-                                                         
GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS));
+                                                         anonymity,
+                                                         priority,
+                                                         expiration);
   GNUNET_CONTAINER_meta_data_destroy (meta);
-  gtk_tree_store_set (ts, &pos,
+  gtk_tree_store_set (ts, pos,
                      0, "0",
                      1, (gboolean) GNUNET_NO,
                      2, name,
-                     3, (guint) 1 /* anonymity */,
-                     4, (guint) 1000 /* priority */,
+                     3, (guint) anonymity,
+                     4, (guint) priority,
                      5, fi,
                      -1);
   update_selectivity ();
 }
 
 
+struct AddDirContext
+{
+  GtkTreeIter *parent;
+  uint32_t anonymity_level;
+  uint32_t priority;
+  struct GNUNET_TIME_Absolute expiration;
+  int do_index;
+};
+
+
 /**
  * Add a directory to the tree model.
  *
@@ -326,10 +337,80 @@
  */
 static void
 add_dir_at_iter (const char *filename,
+                uint32_t anonymity_level,
+                uint32_t priority,
+                struct GNUNET_TIME_Absolute expiration,
+                int do_index,
+                GtkTreeIter *iter);
+
+
+/**
+ * Function called by the directory iterator to
+ * (recursively) add all of the files in the
+ * directory to the tree.
+ */
+static int
+scan_cb (void *cls,
+        const char *filename)
+{
+  struct AddDirContext *adc = cls;
+
+  add_dir_at_iter (filename, 
+                  adc->anonymity_level,
+                  adc->priority,
+                  adc->expiration,
+                  adc->do_index,
+                  adc->parent);
+  return GNUNET_OK;
+}
+
+
+/**
+ * Add a directory to the tree model.
+ *
+ * @param filename directory name to add
+ * @param iter parent entry, or NULL for top-level addition
+ */
+static void
+add_dir_at_iter (const char *filename,
+                uint32_t anonymity_level,
+                uint32_t priority,
+                struct GNUNET_TIME_Absolute expiration,
+                int do_index,
                 GtkTreeIter *iter)
 {
-  GNUNET_break (0);
-  update_selectivity ();
+  struct stat sbuf;
+  struct AddDirContext scan_ctx;
+  GtkTreeIter pos;
+
+  fprintf (stderr, "Adding %s\n", filename);
+  if (0 != STAT (filename, &sbuf))
+    return;
+  if (S_ISDIR (sbuf.st_mode))
+    {
+      create_dir_at_iter (filename, 
+                         anonymity_level,
+                         priority,
+                         expiration,
+                         iter, &pos);
+      scan_ctx.parent = &pos;
+      scan_ctx.anonymity_level = anonymity_level;
+      scan_ctx.priority = priority;
+      scan_ctx.expiration = expiration;
+      scan_ctx.do_index = do_index;
+      GNUNET_DISK_directory_scan (filename,
+                                 &scan_cb,
+                                 &scan_ctx);      
+    }
+  else
+    {
+      add_file_at_iter (filename,
+                       anonymity_level,
+                       priority,
+                       expiration,
+                       do_index,
+                       iter);
+    }
 }
 
 
@@ -648,18 +729,32 @@
   GtkTreeView *tv;
   GtkTreeSelection *sel;
   GtkTreeIter iter;
+  GtkTreeIter pos;
 
   tv = GTK_TREE_VIEW (gtk_builder_get_object (master_builder,
                                              
"GNUNET_GTK_master_publish_dialog_file_information_tree_view"));
   sel = gtk_tree_view_get_selection (tv);
+  /* FIXME: consider opening a dialog to get
+   * anonymity, priority and expiration prior
+   * to calling this function (currently we
+   * use default values for those).
+   */
   if (TRUE != gtk_tree_selection_get_selected (sel,
                                               NULL,
                                               &iter))
     {
-      create_dir_at_iter ("unnamed/", NULL);
+      create_dir_at_iter ("unnamed/", 
+                         1 /* anonymity */,
+                         1000 /* priority */,
+                         GNUNET_TIME_relative_to_absolute 
(GNUNET_TIME_UNIT_YEARS) /* expiration */,
+                         NULL, &pos);
       return;
     }
-  create_dir_at_iter ("unnamed/", &iter);
+  create_dir_at_iter ("unnamed/",
+                     1 /* anonymity */,
+                     1000 /* priority */,
+                     GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_YEARS) 
/* expiration */,
+                     &iter, &pos);
 }
 
 
@@ -670,19 +765,21 @@
 };
 
 
+static struct ListValue list_values[] =
+  {
+    { gettext_noop ("1 year"), 1000LL * 60 * 60 * 24 * 365 },
+    { gettext_noop ("1 month"), 1000LL * 60 * 60 * 24 * 30 },
+    { gettext_noop ("1 day"), 1000LL * 60 * 60 * 24 },
+    { gettext_noop ("1 hour"), 1000LL * 60 * 60 },
+    { gettext_noop ("1 minute"), 1000LL * 60 },
+    { NULL, 0}
+  };
+
+
 void
 GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, 
                                                        gpointer data)
 {
-  static struct ListValue list_values[] =
-    {
-      { gettext_noop ("1 year"), 1000LL * 60 * 60 * 24 * 365 },
-      { gettext_noop ("1 month"), 1000LL * 60 * 60 * 24 * 30 },
-      { gettext_noop ("1 day"), 1000LL * 60 * 60 * 24 },
-      { gettext_noop ("1 hour"), 1000LL * 60 * 60 },
-      { gettext_noop ("1 minute"), 1000LL * 60 },
-      { NULL, 0}
-    };
   GtkWidget *ad;
   GtkBuilder *builder;
   char *filename;
@@ -734,7 +831,8 @@
   gtk_combo_box_get_active_iter (cb, &iter);
   gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 1, &exp.value, -1);
   add_file_at_iter (filename, anonymity,
-                   priority, exp, do_index, 
+                   priority, 
+                   GNUNET_TIME_relative_to_absolute (exp), do_index, 
                    NULL);
   gtk_widget_destroy (ad);
   g_object_unref (G_OBJECT (builder));
@@ -860,6 +958,14 @@
   GtkWidget *ad;
   GtkBuilder *builder;
   char *filename;
+  uint32_t anonymity;
+  uint32_t priority;
+  struct GNUNET_TIME_Relative exp;
+  int do_index;
+  GtkComboBox *cb;
+  GtkListStore *ls;
+  GtkTreeIter iter;
+  int i;
 
   builder = GNUNET_GTK_get_new_builder ("publish-directory-dialog.glade");
   if (builder == NULL)
@@ -869,6 +975,22 @@
     }
   ad = GTK_WIDGET (gtk_builder_get_object (builder,
                                           
"GNUNET_GTK_publish_directory_dialog"));
+  cb = GTK_COMBO_BOX (gtk_builder_get_object (builder,
+                                          
"GNUNET_GTK_publish_directory_dialog_expiration_combo_box"));
+
+  ls = GTK_LIST_STORE (gtk_builder_get_object (builder,
+                                              
"GNUNET_GTK_publish_directory_dialog_expiration_list_store"));
+  i = 0;
+  while (list_values[i].text != NULL)
+    {
+      gtk_list_store_insert_before (ls, &iter, NULL);
+      gtk_list_store_set (ls, &iter, 
+                         0, gettext (list_values[i].text), 
+                         1, list_values[i].value,
+                         -1);
+      i++;
+    }  
+
   if (GTK_RESPONSE_OK != gtk_dialog_run (GTK_DIALOG (ad)))
     {
       gtk_widget_destroy (ad);
@@ -876,10 +998,21 @@
       return;
     }
   filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(ad));
-  add_dir_at_iter (filename, NULL);
-  GNUNET_break (0);
+  anonymity = gtk_spin_button_get_value (GTK_SPIN_BUTTON 
(gtk_builder_get_object (builder,
+                                                                               
   "GNUNET_GTK_publish_directory_dialog_anonymity_spin_button")));
+  priority = gtk_spin_button_get_value (GTK_SPIN_BUTTON 
(gtk_builder_get_object (builder,
+                                                                               
  "GNUNET_GTK_publish_directory_dialog_priority_spin_button")));
+  do_index = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(gtk_builder_get_object (builder,
+                                                                               
      "GNUNET_GTK_publish_directory_dialog_do_index_checkbutton")));
+  gtk_combo_box_get_active_iter (cb, &iter);
+  gtk_tree_model_get (GTK_TREE_MODEL (ls), &iter, 1, &exp.value, -1);
   gtk_widget_destroy (ad);
   g_object_unref (G_OBJECT (builder));
+  /* FIXME: open progress dialog here... */
+  add_dir_at_iter (filename, anonymity, priority, 
+                  GNUNET_TIME_relative_to_absolute (exp),
+                  do_index,
+                  NULL);
   g_free (filename);
   update_selectivity ();
 }




reply via email to

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