diff options
Diffstat (limited to 'src/fs/gnunet-fs-gtk-main_window_file_publish.c')
-rw-r--r-- | src/fs/gnunet-fs-gtk-main_window_file_publish.c | 145 |
1 files changed, 85 insertions, 60 deletions
diff --git a/src/fs/gnunet-fs-gtk-main_window_file_publish.c b/src/fs/gnunet-fs-gtk-main_window_file_publish.c index 72915041..74e7cf5f 100644 --- a/src/fs/gnunet-fs-gtk-main_window_file_publish.c +++ b/src/fs/gnunet-fs-gtk-main_window_file_publish.c | |||
@@ -278,7 +278,6 @@ add_file_at_iter (gpointer data, const char *filename, const struct GNUNET_FS_Bl | |||
278 | } | 278 | } |
279 | 279 | ||
280 | 280 | ||
281 | |||
282 | /** | 281 | /** |
283 | * Add an empty directory to the tree model. | 282 | * Add an empty directory to the tree model. |
284 | * | 283 | * |
@@ -873,7 +872,6 @@ move_entry (gpointer data, GtkTreeModel * tm, GtkTreeIter * old, GtkTreeIter * n | |||
873 | GtkBuilder *builder; | 872 | GtkBuilder *builder; |
874 | 873 | ||
875 | builder = GTK_BUILDER (data); | 874 | builder = GTK_BUILDER (data); |
876 | |||
877 | gtk_tree_model_get (tm, old, 0, &fsf, 1, &do_index, 2, &short_fn, 3, | 875 | gtk_tree_model_get (tm, old, 0, &fsf, 1, &do_index, 2, &short_fn, 3, |
878 | &anonymity_level, 4, &priority, 5, &fip, -1); | 876 | &anonymity_level, 4, &priority, 5, &fip, -1); |
879 | gtk_tree_store_set (GTK_TREE_STORE (tm), newpos, 0, fsf, 1, do_index, 2, | 877 | gtk_tree_store_set (GTK_TREE_STORE (tm), newpos, 0, fsf, 1, do_index, 2, |
@@ -926,20 +924,21 @@ move_entry (gpointer data, GtkTreeModel * tm, GtkTreeIter * old, GtkTreeIter * n | |||
926 | update_selectivity (data); | 924 | update_selectivity (data); |
927 | } | 925 | } |
928 | 926 | ||
927 | |||
929 | /** | 928 | /** |
930 | * User has changed the "current" identifier for the content in | 929 | * User has changed the "current" identifier for the content in |
931 | * the GtkTreeView. Update the model. | 930 | * the GtkTreeView. Update the model. |
932 | */ | 931 | */ |
933 | void GNUNET_GTK_master_publish_dialog_pseudonym_updates_renderer_edited_cb | 932 | void |
934 | (GtkCellRendererText * renderer, gchar * cpath, gchar * new_text, | 933 | GNUNET_GTK_master_publish_dialog_pseudonym_updates_renderer_edited_cb (GtkCellRendererText * renderer, |
935 | gpointer user_data) | 934 | gchar * cpath, gchar * new_text, |
935 | gpointer user_data) | ||
936 | { | 936 | { |
937 | GtkTreeIter iter; | 937 | GtkTreeIter iter; |
938 | GtkTreeStore *ts; | 938 | GtkTreeStore *ts; |
939 | GtkBuilder *builder; | 939 | GtkBuilder *builder; |
940 | 940 | ||
941 | builder = GTK_BUILDER (user_data); | 941 | builder = GTK_BUILDER (user_data); |
942 | |||
943 | ts = GTK_TREE_STORE (gtk_builder_get_object | 942 | ts = GTK_TREE_STORE (gtk_builder_get_object |
944 | (builder, "GNUNET_GTK_pseudonym_tree_store")); | 943 | (builder, "GNUNET_GTK_pseudonym_tree_store")); |
945 | 944 | ||
@@ -958,16 +957,16 @@ void GNUNET_GTK_master_publish_dialog_pseudonym_updates_renderer_edited_cb | |||
958 | * User has changed the "current" identifier for the content in | 957 | * User has changed the "current" identifier for the content in |
959 | * the GtkTreeView. Update the model. | 958 | * the GtkTreeView. Update the model. |
960 | */ | 959 | */ |
961 | void GNUNET_GTK_master_publish_dialog_pseudonym_identifier_renderer_edited_cb | 960 | void |
962 | (GtkCellRendererText * renderer, gchar * cpath, gchar * new_text, | 961 | GNUNET_GTK_master_publish_dialog_pseudonym_identifier_renderer_edited_cb (GtkCellRendererText * renderer, |
963 | gpointer user_data) | 962 | gchar * cpath, gchar * new_text, |
963 | gpointer user_data) | ||
964 | { | 964 | { |
965 | GtkTreeIter iter; | 965 | GtkTreeIter iter; |
966 | GtkTreeStore *ts; | 966 | GtkTreeStore *ts; |
967 | GtkBuilder *builder; | 967 | GtkBuilder *builder; |
968 | 968 | ||
969 | builder = GTK_BUILDER (user_data); | 969 | builder = GTK_BUILDER (user_data); |
970 | |||
971 | ts = GTK_TREE_STORE (gtk_builder_get_object | 970 | ts = GTK_TREE_STORE (gtk_builder_get_object |
972 | (builder, "GNUNET_GTK_pseudonym_tree_store")); | 971 | (builder, "GNUNET_GTK_pseudonym_tree_store")); |
973 | 972 | ||
@@ -1228,35 +1227,48 @@ GNUNET_GTK_master_publish_dialog_add_button_clicked_cb (GtkWidget * dummy, | |||
1228 | gtk_window_present (GTK_WINDOW (ad)); | 1227 | gtk_window_present (GTK_WINDOW (ad)); |
1229 | } | 1228 | } |
1230 | 1229 | ||
1231 | struct edit_pub_cb_args | 1230 | |
1231 | struct EditPublishContext | ||
1232 | { | 1232 | { |
1233 | GtkTreeModel *tm; | 1233 | GtkTreeModel *tm; |
1234 | GtkTreeIter iter; | 1234 | GtkTreeIter iter; |
1235 | /* FIXME: this indirection madness is not really required any longer. | ||
1236 | * we only need to pass over *tm and iter, everything else can be | ||
1237 | * copied. | ||
1238 | */ | ||
1239 | gchar *short_fn; | ||
1240 | struct GNUNET_FS_FileInformation *fip; | ||
1241 | int do_index; | ||
1242 | guint anonymity_level; | ||
1243 | guint priority; | ||
1244 | }; | 1235 | }; |
1245 | 1236 | ||
1246 | void | 1237 | |
1247 | master_publish_edit_publish_dialog_cb (gpointer cls, int *do_index, char **short_fn, | 1238 | /** |
1248 | guint * anonymity_level, guint * priority, gchar *root, | 1239 | * Function called when the edit publish dialog has been closed. |
1249 | struct GNUNET_FS_FileInformation *fip, gint ret) | 1240 | * |
1241 | * @param cls closure | ||
1242 | * @param do_index index flag set? | ||
1243 | * @param short_fn short filename | ||
1244 | * @param anonymity_level anonymity degree chosen for publishing | ||
1245 | * @param priority replication setting (rename!) | ||
1246 | * @param root always NULL here | ||
1247 | * @param ret GTK_RESPONSE_OK if the dialog was closed with "OK" | ||
1248 | */ | ||
1249 | static void | ||
1250 | master_publish_edit_publish_dialog_cb (gpointer cls, | ||
1251 | int do_index, | ||
1252 | const char *short_fn, | ||
1253 | uint32_t anonymity_level, | ||
1254 | uint32_t priority, | ||
1255 | const char *root, | ||
1256 | gint ret) | ||
1250 | { | 1257 | { |
1251 | struct edit_pub_cb_args *cbargs = (struct edit_pub_cb_args *) cls; | 1258 | struct EditPublishContext *cbargs = cls; |
1259 | |||
1260 | GNUNET_assert (NULL == root); | ||
1252 | if (ret == GTK_RESPONSE_OK) | 1261 | if (ret == GTK_RESPONSE_OK) |
1253 | gtk_tree_store_set (GTK_TREE_STORE (cbargs->tm), &cbargs->iter, | 1262 | gtk_tree_store_set (GTK_TREE_STORE (cbargs->tm), &cbargs->iter, |
1254 | 1, *do_index, 2, *short_fn, 3, *anonymity_level, 4, *priority, -1); | 1263 | 1, do_index, |
1255 | g_free (root); | 1264 | 2, short_fn, |
1256 | g_free (short_fn); | 1265 | 3, (guint) anonymity_level, |
1257 | g_free (cbargs); | 1266 | 4, (guint) priority, |
1267 | -1); | ||
1268 | GNUNET_free (cbargs); | ||
1258 | } | 1269 | } |
1259 | 1270 | ||
1271 | |||
1260 | void | 1272 | void |
1261 | GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | 1273 | GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, |
1262 | gpointer data) | 1274 | gpointer data) |
@@ -1264,36 +1276,47 @@ GNUNET_GTK_master_publish_dialog_edit_button_clicked_cb (GtkWidget * dummy, | |||
1264 | GtkTreeView *tv; | 1276 | GtkTreeView *tv; |
1265 | GtkTreeModel *tm; | 1277 | GtkTreeModel *tm; |
1266 | GtkTreeSelection *sel; | 1278 | GtkTreeSelection *sel; |
1267 | struct edit_pub_cb_args *cbargs; | 1279 | struct EditPublishContext *cbargs; |
1268 | GtkBuilder *builder; | 1280 | GtkBuilder *builder; |
1269 | GtkWindow *master_pubdialog; | 1281 | GtkWindow *master_pubdialog; |
1282 | gint do_index; | ||
1283 | char *short_fn; | ||
1284 | guint anonymity_level; | ||
1285 | guint priority; | ||
1286 | struct GNUNET_FS_FileInformation *fip; | ||
1270 | 1287 | ||
1271 | builder = GTK_BUILDER (data); | 1288 | builder = GTK_BUILDER (data); |
1272 | |||
1273 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1289 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1274 | (builder, | 1290 | (builder, |
1275 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1291 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
1276 | 1292 | ||
1277 | cbargs = g_new0 (struct edit_pub_cb_args, 1); | 1293 | cbargs = GNUNET_malloc (sizeof (struct EditPublishContext)); |
1278 | cbargs->tm = gtk_tree_view_get_model (tv); | 1294 | cbargs->tm = gtk_tree_view_get_model (tv); |
1279 | |||
1280 | master_pubdialog = GTK_WINDOW (gtk_builder_get_object (builder, | 1295 | master_pubdialog = GTK_WINDOW (gtk_builder_get_object (builder, |
1281 | "GNUNET_GTK_master_publish_dialog")); | 1296 | "GNUNET_GTK_master_publish_dialog")); |
1282 | sel = gtk_tree_view_get_selection (tv); | 1297 | sel = gtk_tree_view_get_selection (tv); |
1283 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &cbargs->iter)) | 1298 | if (TRUE != gtk_tree_selection_get_selected (sel, &tm, &cbargs->iter)) |
1284 | { | 1299 | { |
1285 | GNUNET_break (0); | 1300 | GNUNET_break (0); |
1286 | g_free (cbargs); | 1301 | GNUNET_free (cbargs); |
1287 | return; | 1302 | return; |
1288 | } | 1303 | } |
1289 | 1304 | ||
1290 | gtk_tree_model_get (tm, &cbargs->iter, 1, &cbargs->do_index, 2, | 1305 | gtk_tree_model_get (tm, &cbargs->iter, |
1291 | &cbargs->short_fn, 3, &cbargs->anonymity_level, 4, &cbargs->priority, | 1306 | 1, &do_index, |
1292 | 5, &cbargs->fip, -1); | 1307 | 2, &short_fn, |
1293 | 1308 | 3, &anonymity_level, | |
1294 | GNUNET_FS_GTK_edit_publish_dialog (builder, master_pubdialog, &cbargs->do_index, | 1309 | 4, &priority, |
1295 | &cbargs->short_fn, &cbargs->anonymity_level, &cbargs->priority, | 1310 | 5, &fip, |
1296 | cbargs->fip, TRUE, &master_publish_edit_publish_dialog_cb, cbargs); | 1311 | -1); |
1312 | /* FIXME: shouldn't this use a fresh builder? */ | ||
1313 | GNUNET_FS_GTK_edit_publish_dialog (builder, master_pubdialog, | ||
1314 | do_index, | ||
1315 | short_fn, | ||
1316 | (uint32_t) anonymity_level, | ||
1317 | (uint32_t) priority, | ||
1318 | fip, | ||
1319 | TRUE, &master_publish_edit_publish_dialog_cb, cbargs); | ||
1297 | } | 1320 | } |
1298 | 1321 | ||
1299 | 1322 | ||
@@ -1320,7 +1343,6 @@ free_fi_row_reference (void *cls, struct GNUNET_FS_FileInformation *fi, | |||
1320 | } | 1343 | } |
1321 | 1344 | ||
1322 | 1345 | ||
1323 | |||
1324 | void | 1346 | void |
1325 | GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, | 1347 | GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, |
1326 | gpointer data) | 1348 | gpointer data) |
@@ -1333,7 +1355,6 @@ GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, | |||
1333 | GtkBuilder *builder; | 1355 | GtkBuilder *builder; |
1334 | 1356 | ||
1335 | builder = GTK_BUILDER (data); | 1357 | builder = GTK_BUILDER (data); |
1336 | |||
1337 | tv = GTK_TREE_VIEW (gtk_builder_get_object | 1358 | tv = GTK_TREE_VIEW (gtk_builder_get_object |
1338 | (builder, | 1359 | (builder, |
1339 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); | 1360 | "GNUNET_GTK_master_publish_dialog_file_information_tree_view")); |
@@ -1349,9 +1370,10 @@ GNUNET_GTK_master_publish_dialog_delete_button_clicked_cb (GtkWidget * dummy, | |||
1349 | update_selectivity (data); | 1370 | update_selectivity (data); |
1350 | } | 1371 | } |
1351 | 1372 | ||
1373 | |||
1352 | void | 1374 | void |
1353 | GNUNET_GTK_publish_directory_dialog_response_cb (GtkDialog *dialog, | 1375 | GNUNET_GTK_publish_directory_dialog_response_cb (GtkDialog *dialog, |
1354 | gint response_id, gpointer user_data) | 1376 | gint response_id, gpointer user_data) |
1355 | { | 1377 | { |
1356 | char *filename; | 1378 | char *filename; |
1357 | int do_index; | 1379 | int do_index; |
@@ -1361,10 +1383,8 @@ GNUNET_GTK_publish_directory_dialog_response_cb (GtkDialog *dialog, | |||
1361 | GtkBuilder *builder; | 1383 | GtkBuilder *builder; |
1362 | 1384 | ||
1363 | builder = GTK_BUILDER (user_data); | 1385 | builder = GTK_BUILDER (user_data); |
1364 | |||
1365 | ad = GTK_WIDGET (gtk_builder_get_object (builder, | 1386 | ad = GTK_WIDGET (gtk_builder_get_object (builder, |
1366 | "GNUNET_GTK_publish_directory_dialog")); | 1387 | "GNUNET_GTK_publish_directory_dialog")); |
1367 | |||
1368 | if (response_id == -5) | 1388 | if (response_id == -5) |
1369 | { | 1389 | { |
1370 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); | 1390 | filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (ad)); |
@@ -1637,9 +1657,10 @@ free_file_information_tree_store (GtkTreeModel * tm, GtkTreeIter * iter) | |||
1637 | } | 1657 | } |
1638 | } | 1658 | } |
1639 | 1659 | ||
1660 | |||
1640 | void | 1661 | void |
1641 | GNUNET_GTK_master_publish_dialog_realize_cb (GtkWidget *widget, | 1662 | GNUNET_GTK_master_publish_dialog_realize_cb (GtkWidget *widget, |
1642 | gpointer user_data) | 1663 | gpointer user_data) |
1643 | { | 1664 | { |
1644 | GtkTreeView *tv; | 1665 | GtkTreeView *tv; |
1645 | GtkTreeSelection *sel; | 1666 | GtkTreeSelection *sel; |
@@ -1661,7 +1682,8 @@ GNUNET_GTK_master_publish_dialog_realize_cb (GtkWidget *widget, | |||
1661 | G_CALLBACK (selection_changed_cb), user_data); | 1682 | G_CALLBACK (selection_changed_cb), user_data); |
1662 | } | 1683 | } |
1663 | 1684 | ||
1664 | void | 1685 | |
1686 | static void | ||
1665 | hide_master_publish_dialog (gpointer user_data, gint ret) | 1687 | hide_master_publish_dialog (gpointer user_data, gint ret) |
1666 | { | 1688 | { |
1667 | GtkTreeView *tv, *ptv; | 1689 | GtkTreeView *tv, *ptv; |
@@ -1673,11 +1695,11 @@ hide_master_publish_dialog (gpointer user_data, gint ret) | |||
1673 | gchar *namespace_uid; | 1695 | gchar *namespace_uid; |
1674 | struct GNUNET_FS_FileInformation *fi; | 1696 | struct GNUNET_FS_FileInformation *fi; |
1675 | GtkWidget *ad; | 1697 | GtkWidget *ad; |
1676 | GtkBuilder *builder = GTK_BUILDER (user_data); | 1698 | GtkBuilder *builder; |
1677 | 1699 | ||
1700 | builder = GTK_BUILDER (user_data); | ||
1678 | ad = GTK_WIDGET (gtk_builder_get_object | 1701 | ad = GTK_WIDGET (gtk_builder_get_object |
1679 | (builder, "GNUNET_GTK_master_publish_dialog")); | 1702 | (builder, "GNUNET_GTK_master_publish_dialog")); |
1680 | |||
1681 | ptv = GTK_TREE_VIEW (gtk_builder_get_object | 1703 | ptv = GTK_TREE_VIEW (gtk_builder_get_object |
1682 | (builder, | 1704 | (builder, |
1683 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); | 1705 | "GNUNET_GTK_master_publish_dialog_pseudonym_tree_view")); |
@@ -1732,35 +1754,40 @@ hide_master_publish_dialog (gpointer user_data, gint ret) | |||
1732 | } | 1754 | } |
1733 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); | 1755 | while (TRUE == gtk_tree_model_iter_next (tm, &iter)); |
1734 | gtk_tree_store_clear (GTK_TREE_STORE (tm)); | 1756 | gtk_tree_store_clear (GTK_TREE_STORE (tm)); |
1735 | |||
1736 | gtk_widget_hide (ad); | 1757 | gtk_widget_hide (ad); |
1758 | /* FIXME: doesn't this leak everything (builder + window)? | ||
1759 | I think we need to unref the builder here! */ | ||
1737 | } | 1760 | } |
1738 | 1761 | ||
1762 | |||
1739 | void | 1763 | void |
1740 | GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton *button, | 1764 | GNUNET_GTK_master_publish_dialog_execute_button_clicked_cb (GtkButton *button, |
1741 | gpointer user_data) | 1765 | gpointer user_data) |
1742 | { | 1766 | { |
1743 | hide_master_publish_dialog (user_data, GTK_RESPONSE_OK); | 1767 | hide_master_publish_dialog (user_data, GTK_RESPONSE_OK); |
1744 | } | 1768 | } |
1745 | 1769 | ||
1770 | |||
1746 | void | 1771 | void |
1747 | GNUNET_GTK_master_publish_dialog_cancel_button_clicked_cb (GtkButton *button, | 1772 | GNUNET_GTK_master_publish_dialog_cancel_button_clicked_cb (GtkButton *button, |
1748 | gpointer user_data) | 1773 | gpointer user_data) |
1749 | { | 1774 | { |
1750 | hide_master_publish_dialog (user_data, GTK_RESPONSE_CANCEL); | 1775 | hide_master_publish_dialog (user_data, GTK_RESPONSE_CANCEL); |
1751 | } | 1776 | } |
1752 | 1777 | ||
1778 | |||
1753 | gboolean | 1779 | gboolean |
1754 | GNUNET_GTK_master_publish_dialog_delete_event_cb (GtkWidget *widget, | 1780 | GNUNET_GTK_master_publish_dialog_delete_event_cb (GtkWidget *widget, |
1755 | GdkEvent *event, gpointer user_data) | 1781 | GdkEvent *event, gpointer user_data) |
1756 | { | 1782 | { |
1757 | hide_master_publish_dialog (user_data, GTK_RESPONSE_CANCEL); | 1783 | hide_master_publish_dialog (user_data, GTK_RESPONSE_CANCEL); |
1758 | return TRUE; | 1784 | return TRUE; |
1759 | } | 1785 | } |
1760 | 1786 | ||
1787 | |||
1761 | void | 1788 | void |
1762 | GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog *dialog, | 1789 | GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog *dialog, |
1763 | gint response_id, gpointer user_data) | 1790 | gint response_id, gpointer user_data) |
1764 | { | 1791 | { |
1765 | char *filename; | 1792 | char *filename; |
1766 | struct GNUNET_FS_BlockOptions bo; | 1793 | struct GNUNET_FS_BlockOptions bo; |
@@ -1802,6 +1829,7 @@ GNUNET_GTK_publish_file_dialog_response_cb (GtkDialog *dialog, | |||
1802 | gtk_widget_hide (ad); | 1829 | gtk_widget_hide (ad); |
1803 | } | 1830 | } |
1804 | 1831 | ||
1832 | |||
1805 | /** | 1833 | /** |
1806 | */ | 1834 | */ |
1807 | void | 1835 | void |
@@ -1812,10 +1840,8 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer data) | |||
1812 | GtkBuilder *builder; | 1840 | GtkBuilder *builder; |
1813 | 1841 | ||
1814 | builder = GTK_BUILDER (data); | 1842 | builder = GTK_BUILDER (data); |
1815 | |||
1816 | ad = GTK_WIDGET (gtk_builder_get_object | 1843 | ad = GTK_WIDGET (gtk_builder_get_object |
1817 | (builder, "GNUNET_GTK_master_publish_dialog")); | 1844 | (builder, "GNUNET_GTK_master_publish_dialog")); |
1818 | |||
1819 | if (!gtk_widget_get_visible (ad)) | 1845 | if (!gtk_widget_get_visible (ad)) |
1820 | { | 1846 | { |
1821 | ts = GTK_TREE_STORE (gtk_builder_get_object (builder, | 1847 | ts = GTK_TREE_STORE (gtk_builder_get_object (builder, |
@@ -1823,7 +1849,6 @@ GNUNET_GTK_main_menu_file_publish_activate_cb (GtkWidget * dummy, gpointer data) | |||
1823 | GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (), | 1849 | GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (), |
1824 | &add_namespace_to_ts, ts); | 1850 | &add_namespace_to_ts, ts); |
1825 | } | 1851 | } |
1826 | |||
1827 | gtk_window_present (GTK_WINDOW (ad)); | 1852 | gtk_window_present (GTK_WINDOW (ad)); |
1828 | } | 1853 | } |
1829 | 1854 | ||