[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r18803 - in gnunet-gtk: contrib src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r18803 - in gnunet-gtk: contrib src/fs |
Date: |
Sat, 24 Dec 2011 22:46:49 +0100 |
Author: grothoff
Date: 2011-12-24 22:46:49 +0100 (Sat, 24 Dec 2011)
New Revision: 18803
Modified:
gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade
gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
Log:
-LRN: make publication type selector do something - #2028
Modified: gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade 2011-12-24 21:43:31 UTC
(rev 18802)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade 2011-12-24 21:46:49 UTC
(rev 18803)
@@ -61,11 +61,12 @@
</packing>
</child>
<child>
- <object class="GtkComboBox"
id="_GNUNET_GTK_edit_publication_type_combo">
+ <object class="GtkComboBox"
id="GNUNET_GTK_edit_publication_type_combo">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property
name="model">GNUNET_GTK_publication_types_liststore</property>
<property name="active">0</property>
+ <signal name="changed"
handler="GNUNET_GTK_edit_publication_type_combo_changed_cb" swapped="no"/>
<child>
<object class="GtkCellRendererText"
id="cellrenderertext2"/>
<attributes>
@@ -2165,12 +2166,12 @@
<columns>
<!-- column-name Type -->
<column type="gint"/>
- <!-- column-name Type1 -->
+ <!-- column-name Type_name -->
<column type="gchararray"/>
</columns>
<data>
<row>
- <col id="0">-1</col>
+ <col id="0">0</col>
<col id="1" translatable="yes">Generic</col>
</row>
<row>
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.c 2011-12-24
21:43:31 UTC (rev 18802)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk-edit_publish_dialog.c 2011-12-24
21:46:49 UTC (rev 18803)
@@ -30,6 +30,60 @@
#define PUBSTATE "edit-publication-state"
+#include "metatypes.c"
+
+void change_metatypes (GtkBuilder *builder, gint code)
+{
+ GtkListStore *metatypes_list;
+ gint pub_type = 0, i;
+ gint pubtype_count = 0;
+ gint max_type;
+ GtkTreeIter iter;
+ metatypes_list = GTK_LIST_STORE (gtk_builder_get_object (builder,
+ "GNUNET_GTK_publication_metadata_types_liststore"));
+
+ for (pub_type = 0; types[pub_type] != NULL; pub_type++)
+ pubtype_count += 1;
+
+ if (code < pubtype_count)
+ pub_type = code;
+ else
+ pub_type = 0;
+
+ gtk_list_store_clear (metatypes_list);
+ max_type = EXTRACTOR_metatype_get_max ();
+ for (i = 0; types[pub_type][i] != EXTRACTOR_METATYPE_RESERVED; i++)
+ {
+ if (types[pub_type][i] < max_type && types[pub_type][i] > 0)
+ gtk_list_store_insert_with_values (metatypes_list, &iter, G_MAXINT,
+ 0, types[pub_type][i],
+ 1, EXTRACTOR_METAFORMAT_UTF8,
+ 2, EXTRACTOR_metatype_to_string (types[pub_type][i]),
+ 3, EXTRACTOR_metatype_to_description (types[pub_type][i]), -1);
+ }
+}
+
+void
+GNUNET_GTK_edit_publication_type_combo_changed_cb (GtkComboBox *widget,
+ gpointer user_data)
+{
+ GtkTreeIter iter;
+ GtkBuilder *builder;
+ GtkListStore *pubtypes_list;
+ gint code;
+
+ if (!gtk_combo_box_get_active_iter (widget, &iter))
+ return;
+ builder = GTK_BUILDER (user_data);
+
+ pubtypes_list = GTK_LIST_STORE (gtk_builder_get_object (builder,
+ "GNUNET_GTK_publication_types_liststore"));
+
+ gtk_tree_model_get (GTK_TREE_MODEL (pubtypes_list), &iter, 0, &code, -1);
+
+ change_metatypes (builder, code);
+}
+
struct EditPublicationState
{
int do_index;
@@ -105,16 +159,10 @@
gpointer user_data)
{
GtkBuilder *builder;
- GtkListStore *metatypes_list;
- GtkTreeIter iter;
GtkTreeView *tv;
GtkTreeSelection *sel;
- guint type;
- guint max_type;
builder = GTK_BUILDER (user_data);
- metatypes_list = GTK_LIST_STORE (gtk_builder_get_object (builder,
- "GNUNET_GTK_publication_metadata_types_liststore"));
tv = GTK_TREE_VIEW (gtk_builder_get_object (builder,
"GNUNET_GTK_edit_publication_metadata_tree_view"));
@@ -127,14 +175,6 @@
sel = gtk_tree_view_get_selection (tv);
g_signal_connect (G_OBJECT (sel), "changed",
G_CALLBACK (keywords_selection_changed_cb), builder);
-
- max_type = EXTRACTOR_metatype_get_max ();
- for (type = 1; type < max_type - 1; type++)
- gtk_list_store_insert_with_values (metatypes_list, &iter, G_MAXINT,
- 0, type,
- 1, EXTRACTOR_METAFORMAT_UTF8,
- 2, EXTRACTOR_metatype_to_string (type),
- 3, EXTRACTOR_metatype_to_description (type), -1);
}
@@ -1036,6 +1076,10 @@
GtkEntry *entry;
GtkWidget *ok;
struct EditPublicationState *state;
+ GtkListStore *pubtypes_list;
+ GtkComboBox *pubtypes_combo;
+ GtkTreeIter iter;
+ gint code;
GNUNET_FS_GTK_setup_expiration_year_adjustment (builder);
if (GNUNET_FS_file_information_is_directory (fip))
@@ -1067,6 +1111,19 @@
"GNUNET_GTK_edit_publication_window"));
gtk_window_set_title (GTK_WINDOW (dialog), short_fn);
+ pubtypes_list = GTK_LIST_STORE (gtk_builder_get_object (builder,
+ "GNUNET_GTK_publication_types_liststore"));
+ pubtypes_combo = GTK_COMBO_BOX (gtk_builder_get_object (builder,
+ "GNUNET_GTK_edit_publication_type_combo"));
+
+ if (gtk_combo_box_get_active_iter (pubtypes_combo, &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (pubtypes_list), &iter, 0, &code, -1);
+ change_metatypes (builder, 0);
+ }
+ else
+ gtk_combo_box_set_active (pubtypes_combo, 0);
+
state = GNUNET_malloc (sizeof (struct EditPublicationState));
state->do_index = do_index;
if (NULL != short_fn)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r18803 - in gnunet-gtk: contrib src/fs,
gnunet <=