diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2010-04-25 17:54:24 +0200 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2010-04-25 17:54:24 +0200 |
commit | 8eadc6efa274a28848ca586d69055ee1953a2e49 (patch) | |
tree | df97ebf6221f0477ab573f619458ed4df16b98a4 | |
parent | cedb4ed9779e56e14f14fbd108a2bcfe9bb24080 (diff) |
Added support for creating child tags in the tag dialog.
-rw-r--r-- | tags.ui | 21 | ||||
-rw-r--r-- | window_tag.c | 33 |
2 files changed, 49 insertions, 5 deletions
@@ -55,6 +55,21 @@ </packing> </child> <child> + <object class="GtkButton" id="addchildbtn"> + <property name="label" translatable="yes">Add _Child</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_underline">True</property> + <signal name="clicked" handler="on_tags_addchildbtn_clicked"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> <object class="GtkButton" id="rembtn"> <property name="label">gtk-remove</property> <property name="visible">True</property> @@ -66,7 +81,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">1</property> + <property name="position">2</property> </packing> </child> <child> @@ -81,7 +96,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">2</property> + <property name="position">3</property> </packing> </child> <child> @@ -97,7 +112,7 @@ <packing> <property name="expand">False</property> <property name="fill">False</property> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> </object> diff --git a/window_tag.c b/window_tag.c index 35c814b..52db1ad 100644 --- a/window_tag.c +++ b/window_tag.c @@ -99,6 +99,8 @@ static void tagview_create_model(GtkTreeView *tagview, gpointer user_data) { g_array_free(walltag_single, TRUE); } g_array_free(walltags, TRUE); + + gtk_tree_view_expand_all(tagview); } static void tagview_init(GtkTreeView *tagview, gpointer user_data) { @@ -124,8 +126,6 @@ static void tagview_init(GtkTreeView *tagview, gpointer user_data) { gtk_tree_view_column_add_attribute(col2, renderer, "text", 2); tagview_create_model(tagview, user_data); - - gtk_tree_view_expand_all(tagview); } void on_tags_addbtn_clicked(GtkButton *button, gpointer user_data) { @@ -146,6 +146,35 @@ void on_tags_addbtn_clicked(GtkButton *button, gpointer user_data) { gtk_widget_destroy(GTK_WIDGET(dialog)); } +void on_tags_addchildbtn_clicked(GtkButton *button, gpointer user_data) { + struct tagdialog_data_t *data; + GtkDialog *dialog; + gchar *s; + GtkTreeSelection *selection; + GtkTreeModel *model; + GtkTreeIter iter; + struct tag_t *tag; + + data = user_data; + selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->tagview)); + if(!gtk_tree_selection_get_selected(selection, &model, &iter)) { + return; + } + + tag_model_get_tag_record(GTK_TREE_MODEL(model), &iter, &tag); + + dialog = text_input_dialog_new(data->dialog, "Enter the name of the new tag:"); + if(gtk_dialog_run(dialog) == GTK_RESPONSE_OK) { + s = text_input_dialog_get_text(GTK_WIDGET(dialog)); + if(db_add_tag(s, tag->id)) + tagview_create_model(GTK_TREE_VIEW(data->tagview), user_data); + else + g_warning("Failed to add tag \"%s\"\n", s); + g_free(s); + } + gtk_widget_destroy(GTK_WIDGET(dialog)); +} + void on_tags_rembtn_clicked(GtkButton *button, gpointer user_data) { GtkWidget *dialog; struct tagdialog_data_t *data; |