197
200
/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
202
void ui_tag_listview_toggle_to_filter(GtkTreeView *treeview, Filter *filter)
209
DB( g_print("(ui_tag_listview) toggle_to_filter\n") );
211
model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
212
//selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_tag));
213
valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
218
gtk_tree_model_get (model, &iter,
219
LST_DEFTAG_TOGGLE, &toggled,
220
LST_DEFTAG_DATAS, &tagitem,
223
DB( g_print(" get tag k:%3d = %d (%s)\n", tagitem->key, toggled, tagitem->name) );
224
da_flt_status_tag_set(filter, tagitem->key, toggled);
226
//tagitem->flt_select = toggled;
228
/* Make iter point to the next row in the list store */
229
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
201
235
ui_tag_listview_toggled_cb (GtkCellRendererToggle *cell,
221
255
gtk_tree_path_free (path);
259
ui_tag_listview_quick_select(GtkTreeView *treeview, const gchar *uri)
265
gint qselect = hb_clicklabel_to_int(uri);
267
DB( g_print("(ui_acc_listview) quick select\n") );
270
DB( g_print(" comboboxlink '%s' %d\n", uri, qselect) );
272
model = gtk_tree_view_get_model(GTK_TREE_VIEW(treeview));
273
valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter);
278
case HB_LIST_QUICK_SELECT_ALL:
279
gtk_list_store_set (GTK_LIST_STORE (model), &iter, LST_DEFTAG_TOGGLE, TRUE, -1);
281
case HB_LIST_QUICK_SELECT_NONE:
282
gtk_list_store_set (GTK_LIST_STORE (model), &iter, LST_DEFTAG_TOGGLE, FALSE, -1);
284
case HB_LIST_QUICK_SELECT_INVERT:
285
gtk_tree_model_get (model, &iter, LST_DEFTAG_TOGGLE, &toggle, -1);
287
gtk_list_store_set (GTK_LIST_STORE (model), &iter, LST_DEFTAG_TOGGLE, toggle, -1);
290
valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter);
225
296
ui_tag_listview_compare_func (GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata)
253
321
gtk_tree_model_get(model, iter, LST_DEFTAG_DATAS, &entry, -1);
254
if(entry->name == NULL)
255
name = _("(none)"); // can never occurs !
323
name = _("(no tag)");
257
325
name = entry->name;
260
string = g_strdup_printf ("[%d] %s", entry->key, name );
261
g_object_set(renderer, "text", string, NULL);
264
g_object_set(renderer, "text", name, NULL);
327
g_object_set(renderer, "text", name, NULL);
333
ui_tag_listview_cell_data_function_debugkey (GtkTreeViewColumn *col, GtkCellRenderer *renderer, GtkTreeModel *model, GtkTreeIter *iter, gpointer user_data)
338
gtk_tree_model_get(model, iter, LST_DEFTAG_DATAS, &item, -1);
339
string = g_strdup_printf ("[%d]", item->key );
340
g_object_set(renderer, "text", string, NULL);
562
ui_tag_manage_dialog_load_csv( GtkWidget *widget, gpointer user_data)
564
struct ui_tag_manage_dialog_data *data = user_data;
565
gchar *filename = NULL;
568
//data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(GTK_WIDGET(widget), GTK_TYPE_WINDOW)), "inst_data");
570
DB( g_print("(ui_tag_manage_dialog) load csv - data %p\n", data) );
572
if( ui_file_chooser_csv(GTK_WINDOW(data->dialog), GTK_FILE_CHOOSER_ACTION_OPEN, &filename, NULL) == TRUE )
574
DB( g_print(" + filename is %s\n", filename) );
576
if( !tag_load_csv(filename, &error) )
578
ui_dialog_msg_infoerror(GTK_WINDOW(data->dialog), GTK_MESSAGE_ERROR,
579
_("File format error"),
580
_("The CSV file must contains the exact numbers of column,\nseparated by a semi-colon, please see the help for more details.")
585
ui_tag_listview_populate(data->LV_tag, 0);
591
ui_tag_manage_dialog_save_csv( GtkWidget *widget, gpointer user_data)
593
struct ui_tag_manage_dialog_data *data = user_data;
594
gchar *filename = NULL;
596
DB( g_print("(ui_tag_manage_dialog) save csv\n") );
598
//data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
600
if( ui_file_chooser_csv(GTK_WINDOW(data->dialog), GTK_FILE_CHOOSER_ACTION_SAVE, &filename, NULL) == TRUE )
602
DB( g_print(" + filename is %s\n", filename) );
604
tag_save_csv(filename);
474
612
* ui_tag_manage_dialog_add:
706
model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_tag));
707
gtk_list_store_clear (GTK_LIST_STORE(model));
709
844
dsttagkey = ui_tag_combobox_get_key(GTK_COMBO_BOX_TEXT(getwidget));
711
tag_move(srctag->key, dsttagkey);
713
newtag = da_tag_get(dsttagkey);
715
//#1771720: update count
716
newtag->usage_count += srctag->usage_count;
717
srctag->usage_count = 0;
719
// add the new tagee to listview
721
ui_tag_listview_add(GTK_TREE_VIEW(data->LV_tag), newtag);
723
// delete the old tagee
724
if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(togglebutton)) )
846
//do nothing if src = dst...
847
if( srctag->key != dsttagkey )
726
DB( g_print(" -> delete %d '%s'\n", srctag->key, srctag->name ) );
728
ui_tag_listview_remove_selected(GTK_TREE_VIEW(data->LV_tag));
729
da_tag_delete(srctag->key);
849
model = gtk_tree_view_get_model(GTK_TREE_VIEW(data->LV_tag));
850
gtk_list_store_clear (GTK_LIST_STORE(model));
852
DB( g_print(" -> move cat to %d (subcat=%d)\n", dstcatkey, dosubcat) );
854
tag_move(srctag->key, dsttagkey);
856
newtag = da_tag_get(dsttagkey);
858
//#1771720: update count
859
newtag->usage_count += srctag->usage_count;
860
srctag->usage_count = 0;
862
// add the new tag to listview
864
ui_tag_listview_add(GTK_TREE_VIEW(data->LV_tag), newtag);
866
// delete the old tag
867
if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(togglebutton)) )
869
DB( g_print(" -> delete %d '%s'\n", srctag->key, srctag->name ) );
871
ui_tag_listview_remove_selected(GTK_TREE_VIEW(data->LV_tag));
872
da_tag_delete(srctag->key);
877
ui_tag_listview_populate(data->LV_tag, 0);
735
ui_tag_listview_populate(data->LV_tag, 0);
738
881
// cleanup and destroy
739
882
gtk_widget_destroy (dialog);
989
static void ui_tag_manage_setup(struct ui_tag_manage_dialog_data *data)
992
DB( g_print("\n[ui-tag] setup\n") );
994
DB( g_print(" init data\n") );
997
DB( g_print(" populate\n") );
999
ui_tag_listview_populate(data->LV_tag, 0);
1002
//DB( g_print(" set widgets default\n") );
1004
DB( g_print(" connect widgets signals\n") );
1006
g_object_bind_property (data->BT_add, "active", data->RE_addreveal, "reveal-child", G_BINDING_BIDIRECTIONAL);
1008
g_signal_connect (G_OBJECT (data->ST_name), "activate", G_CALLBACK (ui_tag_manage_dialog_add), NULL);
1009
g_signal_connect(G_OBJECT(data->ST_name), "insert-text", G_CALLBACK(ui_tag_manage_filter_text_handler), NULL);
1011
g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_tag)), "changed", G_CALLBACK (ui_tag_manage_dialog_selection), NULL);
1012
g_signal_connect (GTK_TREE_VIEW(data->LV_tag), "row-activated", G_CALLBACK (ui_tag_manage_dialog_onRowActivated), NULL);
1014
g_signal_connect (G_OBJECT (data->BT_edit), "clicked", G_CALLBACK (ui_tag_manage_dialog_edit), NULL);
1015
g_signal_connect (G_OBJECT (data->BT_merge), "clicked", G_CALLBACK (ui_tag_manage_dialog_merge), NULL);
1016
g_signal_connect (G_OBJECT (data->BT_delete), "clicked", G_CALLBACK (ui_tag_manage_dialog_delete), NULL);
1022
ui_tag_manage_mapped (GtkWidget *widget, GdkEvent *event, gpointer user_data)
1024
struct ui_tag_manage_dialog_data *data;
1026
data = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), "inst_data");
1028
DB( g_print("\n(ui_tag_manage_mapped)\n") );
1030
ui_tag_manage_setup(data);
1031
ui_tag_manage_dialog_update(data->LV_tag, NULL);
847
1037
GtkWidget *ui_tag_manage_dialog (void)
849
1039
struct ui_tag_manage_dialog_data *data;
850
1040
GtkWidget *dialog, *content, *mainvbox, *box, *bbox, *tbar, *treeview, *scrollwin, *table, *addreveal;
1041
GtkWidget *menu, *menuitem, *widget, *image;
851
1042
GtkToolItem *toolitem;
852
1043
gint w, h, dw, dh, row;
904
1092
//test headerbar
905
1093
//content = gtk_dialog_get_header_bar(GTK_DIALOG (dialog));
1095
menu = gtk_menu_new ();
1096
gtk_widget_set_halign (menu, GTK_ALIGN_END);
1098
menuitem = gtk_menu_item_new_with_mnemonic (_("_Import CSV"));
1099
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
1100
g_signal_connect (G_OBJECT (menuitem), "activate", G_CALLBACK (ui_tag_manage_dialog_load_csv), data);
1102
menuitem = gtk_menu_item_new_with_mnemonic (_("E_xport CSV"));
1103
gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
1104
g_signal_connect (G_OBJECT (menuitem), "activate", G_CALLBACK (ui_tag_manage_dialog_save_csv), data);
1106
//menuitem = gtk_separator_menu_item_new();
1107
//gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
1109
//menuitem = gtk_menu_item_new_with_mnemonic (_("_Delete unused"));
1110
//gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
1111
//g_signal_connect (G_OBJECT (menuitem), "activate", G_CALLBACK (ui_pay_manage_dialog_delete_unused), data);
1113
gtk_widget_show_all (menu);
1115
widget = gtk_menu_button_new();
1116
image = gtk_image_new_from_icon_name (ICONNAME_HB_BUTTON_MENU, GTK_ICON_SIZE_MENU);
1117
g_object_set (widget, "image", image, "popup", GTK_MENU(menu), NULL);
1118
gtk_widget_set_halign (widget, GTK_ALIGN_END);
1119
gtk_box_pack_end(GTK_BOX (bbox), widget, FALSE, FALSE, 0);
1120
//gtk_header_bar_pack_end(GTK_HEADER_BAR (content), widget);
909
1124
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
931
1146
gtk_container_add (GTK_CONTAINER(toolitem), bbox);
932
1147
gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
934
data->BT_add = make_image_toggle_button(ICONNAME_LIST_ADD, _("Add"));
935
gtk_container_add (GTK_CONTAINER (bbox), data->BT_add);
938
data->BT_edit = make_image_button(ICONNAME_LIST_EDIT, _("Edit"));
939
gtk_container_add (GTK_CONTAINER (bbox), data->BT_edit);
941
data->BT_merge = make_image_button(ICONNAME_HB_LIST_MERGE, _("Move/Merge"));
942
gtk_container_add (GTK_CONTAINER (bbox), data->BT_merge);
944
data->BT_delete = make_image_button(ICONNAME_LIST_DELETE, _("Delete"));
945
gtk_container_add (GTK_CONTAINER (bbox), data->BT_delete);
1149
data->BT_add = make_image_toggle_button(ICONNAME_LIST_ADD, _("Add"));
1150
gtk_container_add (GTK_CONTAINER (bbox), data->BT_add);
1152
data->BT_delete = make_image_button(ICONNAME_LIST_DELETE, _("Delete"));
1153
gtk_container_add (GTK_CONTAINER (bbox), data->BT_delete);
1155
toolitem = gtk_separator_tool_item_new ();
1156
//gtk_tool_item_set_expand (toolitem, TRUE);
1157
gtk_separator_tool_item_set_draw(GTK_SEPARATOR_TOOL_ITEM(toolitem), FALSE);
1158
gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
1160
bbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
1161
toolitem = gtk_tool_item_new();
1162
gtk_container_add (GTK_CONTAINER(toolitem), bbox);
1163
gtk_toolbar_insert(GTK_TOOLBAR(tbar), GTK_TOOL_ITEM(toolitem), -1);
1165
data->BT_edit = make_image_button(ICONNAME_LIST_EDIT, _("Edit"));
1166
gtk_container_add (GTK_CONTAINER (bbox), data->BT_edit);
1168
data->BT_merge = make_image_button(ICONNAME_HB_LIST_MERGE, _("Move/Merge"));
1169
gtk_container_add (GTK_CONTAINER (bbox), data->BT_merge);
948
1172
addreveal = gtk_revealer_new ();
1173
data->RE_addreveal = addreveal;
949
1174
gtk_grid_attach (GTK_GRID (table), addreveal, 0, row, 2, 1);
950
1175
data->ST_name = gtk_entry_new ();
951
1176
gtk_entry_set_placeholder_text(GTK_ENTRY(data->ST_name), _("new tag") );
952
1177
gtk_widget_set_hexpand (data->ST_name, TRUE);
953
1178
gtk_container_add(GTK_CONTAINER(addreveal), data->ST_name);
957
//connect all our signals
958
g_object_bind_property (data->BT_add, "active", addreveal, "reveal-child", G_BINDING_BIDIRECTIONAL);
960
g_signal_connect (G_OBJECT (data->ST_name), "activate", G_CALLBACK (ui_tag_manage_dialog_add), NULL);
961
g_signal_connect(G_OBJECT(data->ST_name), "insert-text", G_CALLBACK(ui_tag_manage_filter_text_handler), NULL);
963
g_signal_connect (gtk_tree_view_get_selection(GTK_TREE_VIEW(data->LV_tag)), "changed", G_CALLBACK (ui_tag_manage_dialog_selection), NULL);
964
g_signal_connect (GTK_TREE_VIEW(data->LV_tag), "row-activated", G_CALLBACK (ui_tag_manage_dialog_onRowActivated), NULL);
966
g_signal_connect (G_OBJECT (data->BT_edit), "clicked", G_CALLBACK (ui_tag_manage_dialog_edit), NULL);
967
g_signal_connect (G_OBJECT (data->BT_merge), "clicked", G_CALLBACK (ui_tag_manage_dialog_merge), NULL);
968
g_signal_connect (G_OBJECT (data->BT_delete), "clicked", G_CALLBACK (ui_tag_manage_dialog_delete), NULL);
970
//setup, init and show dialog
972
ui_tag_listview_populate(data->LV_tag, 0);
973
ui_tag_manage_dialog_update(data->LV_tag, NULL);
1181
// connect dialog signals
1182
g_signal_connect (dialog, "destroy", G_CALLBACK (gtk_widget_destroyed), &dialog);
1183
g_signal_connect (dialog, "map-event", G_CALLBACK (ui_tag_manage_mapped), &dialog);
1185
// show & run dialog
1186
DB( g_print(" run dialog\n") );
975
1187
gtk_widget_show_all (dialog);
978
gint result = gtk_dialog_run (GTK_DIALOG (dialog));
982
case GTK_RESPONSE_ACCEPT:
983
//do_application_specific_something ();
986
//do_nothing_since_dialog_was_cancelled ();
1189
// wait for the user
1190
gtk_dialog_run (GTK_DIALOG (dialog));
990
1192
// cleanup and destroy
991
1193
GLOBALS->changes_count += data->change;