diff options
author | Christian Grothoff <christian@grothoff.org> | 2012-12-03 10:08:28 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2012-12-03 10:08:28 +0000 |
commit | 6e9c8986a5f173e30a47071a0969fb61a0fc560d (patch) | |
tree | fca876e40c205b6f562bca331343959d9b45c4b0 | |
parent | a90965ca3f0c11d154e87113f507bec7ea556972 (diff) | |
download | gnunet-gtk-6e9c8986a5f173e30a47071a0969fb61a0fc560d.tar.gz gnunet-gtk-6e9c8986a5f173e30a47071a0969fb61a0fc560d.zip |
-more cleanup, getting ready for edit dialogs
-rw-r--r-- | src/setup/gnunet-setup-gns.c | 65 |
1 files changed, 45 insertions, 20 deletions
diff --git a/src/setup/gnunet-setup-gns.c b/src/setup/gnunet-setup-gns.c index 551ea74c..d359796b 100644 --- a/src/setup/gnunet-setup-gns.c +++ b/src/setup/gnunet-setup-gns.c | |||
@@ -1100,8 +1100,34 @@ remove_records_by_path (const gchar *path) | |||
1100 | static void | 1100 | static void |
1101 | edit_selected_row (int old_record_in_namestore) | 1101 | edit_selected_row (int old_record_in_namestore) |
1102 | { | 1102 | { |
1103 | // FIXME | 1103 | GtkTreeSelection *sel; |
1104 | GtkTreeIter it; | ||
1105 | gchar *n_name; | ||
1106 | gint n_type; | ||
1107 | gboolean n_public; | ||
1108 | guint64 n_exp_time; | ||
1109 | gboolean n_is_relative; | ||
1110 | gchar *n_value; | ||
1111 | |||
1112 | sel = gtk_tree_view_get_selection (tv); | ||
1113 | if (! gtk_tree_selection_get_selected (sel, NULL, &it)) | ||
1114 | { | ||
1115 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1116 | "No row selected\n"); | ||
1117 | return; | ||
1118 | } | ||
1119 | gtk_tree_model_get (tm, &it, | ||
1120 | GNS_TREESTORE_COL_NAME, &n_name, | ||
1121 | GNS_TREESTORE_COL_RECORD_TYPE, &n_type, | ||
1122 | GNS_TREESTORE_COL_IS_PUBLIC, &n_public, | ||
1123 | GNS_TREESTORE_COL_EXP_TIME, &n_exp_time, | ||
1124 | GNS_TREESTORE_COL_EXP_TIME_IS_REL, &n_is_relative, | ||
1125 | GNS_TREESTORE_COL_VAL_AS_STR, &n_value, | ||
1126 | -1); | ||
1127 | // FIXME - implement... | ||
1104 | GNUNET_break (0); | 1128 | GNUNET_break (0); |
1129 | g_free (n_name); | ||
1130 | g_free (n_value); | ||
1105 | } | 1131 | } |
1106 | 1132 | ||
1107 | 1133 | ||
@@ -1340,22 +1366,21 @@ GNUNET_setup_gns_name_cellrenderertext_edited_cb (GtkCellRendererText *renderer, | |||
1340 | static gboolean | 1366 | static gboolean |
1341 | create_popup_menu () | 1367 | create_popup_menu () |
1342 | { | 1368 | { |
1343 | GtkTreeModel *tm; | ||
1344 | GtkTreeIter it; | 1369 | GtkTreeIter it; |
1345 | GtkMenu *popup; | 1370 | GtkMenu *popup; |
1346 | GtkTreeSelection * ts; | 1371 | GtkTreeSelection *sel; |
1347 | 1372 | ||
1348 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1373 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1349 | "Considering creating popup menu...\n"); | 1374 | "Considering creating popup menu...\n"); |
1350 | ts = gtk_tree_view_get_selection (tv); | 1375 | sel = gtk_tree_view_get_selection (tv); |
1351 | if (! gtk_tree_selection_get_selected (ts, &tm, &it)) | 1376 | if (! gtk_tree_selection_get_selected (sel, NULL, &it)) |
1352 | { | 1377 | { |
1353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1378 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1354 | "No row selected\n"); | 1379 | "No row selected\n"); |
1355 | return FALSE; | 1380 | return FALSE; |
1356 | } | 1381 | } |
1357 | popup = GTK_MENU (GNUNET_SETUP_get_object ("GNUNET_setup_gns_delete_popup_menu")); | 1382 | popup = GTK_MENU (GNUNET_SETUP_get_object ("GNUNET_setup_gns_delete_popup_menu")); |
1358 | gtk_widget_show_all (GTK_WIDGET(popup)); | 1383 | gtk_widget_show_all (GTK_WIDGET (popup)); |
1359 | gtk_menu_popup (popup, NULL, NULL, NULL, NULL, 0, 0); | 1384 | gtk_menu_popup (popup, NULL, NULL, NULL, NULL, 0, 0); |
1360 | return TRUE; | 1385 | return TRUE; |
1361 | } | 1386 | } |
@@ -1386,15 +1411,16 @@ static void | |||
1386 | delete_selected_row () | 1411 | delete_selected_row () |
1387 | { | 1412 | { |
1388 | GtkTreeIter it; | 1413 | GtkTreeIter it; |
1389 | GtkTreeModel *tm; | 1414 | GtkTreeSelection *sel; |
1390 | GtkTreeSelection * ts; | ||
1391 | int not_dummy; | 1415 | int not_dummy; |
1392 | char *path; | 1416 | char *path; |
1393 | 1417 | ||
1394 | ts = gtk_tree_view_get_selection(tv); | 1418 | sel = gtk_tree_view_get_selection(tv); |
1395 | if (! gtk_tree_selection_get_selected (ts, &tm, &it)) | 1419 | if (! gtk_tree_selection_get_selected (sel, NULL, &it)) |
1396 | return; /* nothing selected */ | 1420 | return; /* nothing selected */ |
1397 | gtk_tree_model_get(tm, &it, GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, -1); | 1421 | gtk_tree_model_get (tm, &it, |
1422 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, | ||
1423 | -1); | ||
1398 | if (GNUNET_NO == not_dummy) | 1424 | if (GNUNET_NO == not_dummy) |
1399 | return; /* do not delete the dummy line */ | 1425 | return; /* do not delete the dummy line */ |
1400 | path = gtk_tree_model_get_string_from_iter (tm, &it); | 1426 | path = gtk_tree_model_get_string_from_iter (tm, &it); |
@@ -1437,7 +1463,7 @@ GNUNET_setup_calendar_dialog_response_cb (GtkDialog *dialog, | |||
1437 | GtkTreeIter it; | 1463 | GtkTreeIter it; |
1438 | GtkTreeIter parent; | 1464 | GtkTreeIter parent; |
1439 | GtkCellRendererText *renderer; | 1465 | GtkCellRendererText *renderer; |
1440 | GtkTreeSelection * ts; | 1466 | GtkTreeSelection *sel; |
1441 | gboolean has_parent; | 1467 | gboolean has_parent; |
1442 | char *path; | 1468 | char *path; |
1443 | int not_dummy; | 1469 | int not_dummy; |
@@ -1464,8 +1490,8 @@ GNUNET_setup_calendar_dialog_response_cb (GtkDialog *dialog, | |||
1464 | GNUNET_STRINGS_fancy_time_to_absolute (fancydate, | 1490 | GNUNET_STRINGS_fancy_time_to_absolute (fancydate, |
1465 | &atime)); | 1491 | &atime)); |
1466 | gndate = GNUNET_STRINGS_absolute_time_to_string (atime); | 1492 | gndate = GNUNET_STRINGS_absolute_time_to_string (atime); |
1467 | ts = gtk_tree_view_get_selection(tv); | 1493 | sel = gtk_tree_view_get_selection (tv); |
1468 | if (gtk_tree_selection_get_selected (ts, &tm, &it)) | 1494 | if (gtk_tree_selection_get_selected (sel, NULL, &it)) |
1469 | { | 1495 | { |
1470 | gtk_tree_model_get (tm, &it, | 1496 | gtk_tree_model_get (tm, &it, |
1471 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, | 1497 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, |
@@ -1504,7 +1530,7 @@ GNUNET_setup_gns_popup_cal_button_activate_cb (GtkWidget *widget, | |||
1504 | { | 1530 | { |
1505 | GtkBuilder *builder; | 1531 | GtkBuilder *builder; |
1506 | GtkWindow *dialog; | 1532 | GtkWindow *dialog; |
1507 | GtkTreeSelection * tsel; | 1533 | GtkTreeSelection *sel; |
1508 | gboolean has_parent; | 1534 | gboolean has_parent; |
1509 | int not_dummy; | 1535 | int not_dummy; |
1510 | guint64 et; | 1536 | guint64 et; |
@@ -1515,8 +1541,8 @@ GNUNET_setup_gns_popup_cal_button_activate_cb (GtkWidget *widget, | |||
1515 | time_t tp; | 1541 | time_t tp; |
1516 | struct tm *ymd; | 1542 | struct tm *ymd; |
1517 | 1543 | ||
1518 | tsel = gtk_tree_view_get_selection(tv); | 1544 | sel = gtk_tree_view_get_selection (tv); |
1519 | if (! gtk_tree_selection_get_selected (tsel, &tm, &it)) | 1545 | if (! gtk_tree_selection_get_selected (sel, NULL, &it)) |
1520 | return; | 1546 | return; |
1521 | gtk_tree_model_get (tm, &it, | 1547 | gtk_tree_model_get (tm, &it, |
1522 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, | 1548 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, ¬_dummy, |
@@ -1884,7 +1910,6 @@ zone_iteration_proc (void *cls, | |||
1884 | GNUNET_free (type_str); | 1910 | GNUNET_free (type_str); |
1885 | GNUNET_free (val); | 1911 | GNUNET_free (val); |
1886 | } | 1912 | } |
1887 | |||
1888 | GNUNET_NAMESTORE_zone_iterator_next (zc_ctx->it); | 1913 | GNUNET_NAMESTORE_zone_iterator_next (zc_ctx->it); |
1889 | } | 1914 | } |
1890 | 1915 | ||
@@ -1933,7 +1958,6 @@ zone_key_loaded_callback (void *cls, | |||
1933 | gtk_label_set_markup (GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_label")), | 1958 | gtk_label_set_markup (GTK_LABEL (GNUNET_SETUP_get_object ("GNUNET_setup_gns_zone_label")), |
1934 | label); | 1959 | label); |
1935 | g_free (label); | 1960 | g_free (label); |
1936 | /* Load zone from namestore! */ | ||
1937 | /* Append a top level row and leave it empty */ | 1961 | /* Append a top level row and leave it empty */ |
1938 | gtk_tree_store_insert_with_values (ts, &toplevel, NULL, 0, | 1962 | gtk_tree_store_insert_with_values (ts, &toplevel, NULL, 0, |
1939 | GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR), | 1963 | GNS_TREESTORE_COL_NAME, _(NEW_NAME_STR), |
@@ -1942,6 +1966,7 @@ zone_key_loaded_callback (void *cls, | |||
1942 | GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE, | 1966 | GNS_TREESTORE_COL_IS_RECORD_ROW, FALSE, |
1943 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE, | 1967 | GNS_TREESTORE_COL_NOT_DUMMY_ROW, FALSE, |
1944 | -1); | 1968 | -1); |
1969 | /* Load zone from namestore! */ | ||
1945 | zc_ctx->zone = zone; | 1970 | zc_ctx->zone = zone; |
1946 | zc_ctx->it = GNUNET_NAMESTORE_zone_iteration_start (namestore, &zone, | 1971 | zc_ctx->it = GNUNET_NAMESTORE_zone_iteration_start (namestore, &zone, |
1947 | GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION, | 1972 | GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION, |
@@ -2093,7 +2118,7 @@ GNUNET_SETUP_gns_init () | |||
2093 | } | 2118 | } |
2094 | ts = GTK_TREE_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_treestore")); | 2119 | ts = GTK_TREE_STORE (GNUNET_SETUP_get_object ("GNUNET_setup_gns_treestore")); |
2095 | tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_treeview")); | 2120 | tv = GTK_TREE_VIEW (GNUNET_SETUP_get_object ("GNUNET_setup_gns_main_treeview")); |
2096 | tm = GTK_TREE_MODEL(ts); | 2121 | tm = GTK_TREE_MODEL (ts); |
2097 | load_zone ("ZONEKEY"); | 2122 | load_zone ("ZONEKEY"); |
2098 | } | 2123 | } |
2099 | 2124 | ||