summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tags.ui21
-rw-r--r--window_tag.c33
2 files changed, 49 insertions, 5 deletions
diff --git a/tags.ui b/tags.ui
index 66c7f8c..6faf4de 100644
--- a/tags.ui
+++ b/tags.ui
@@ -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;