<commit_before>//
// Created by hrl on 9/22/15.
//

#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <cJSON.h>
#include <gtk/gtk.h>
#include "sns_functions.h"
#include "gui_functions.h"
#include "sns_structs.h"
#include "gui_structs.h"
#include "sns_defines.h"
#include "gui_defines.h"

void build_UI() {
    GtkBuilder *builder = NULL;
    GError *error = NULL;
    builder = gtk_builder_new();
    if (!gtk_builder_add_from_file(builder, UI_FILE, &error)) {
        g_warning("%s", error->message);
        g_free(error);
        exit(1);
    }

    /* Get objects */
    /* Main window */
    window = GTK_WINDOW(gtk_builder_get_object(builder, "window"));
    treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
    /* -SNS menu */
    /* --SNS file menu */
    GtkWidget *menu_sns_file_new = GTK_WIDGET(gtk_builder_get_object(builder, "sns_file_new"));
    GtkWidget *menu_sns_file_load = GTK_WIDGET(gtk_builder_get_object(builder, "sns_file_load"));
    GtkWidget *menu_sns_file_save = GTK_WIDGET(gtk_builder_get_object(builder, "sns_file_save"));
    /* --SNS people menu */
    GtkWidget *menu_sns_people_new = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_new"));
    GtkWidget *menu_sns_people_all = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_all"));
    GtkWidget *menu_sns_people_follow = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_follow"));
    GtkWidget *menu_sns_people_friend = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_friend"));
    GtkWidget *menu_sns_people_tag = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_tag"));
    GtkWidget *menu_sns_people_unfollow = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_unfollow"));
    GtkWidget *menu_sns_people_unfriend = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_unfriend"));
    GtkWidget *menu_sns_people_untag = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_untag"));
    GtkWidget *menu_sns_people_followings = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_followings"));
    GtkWidget *menu_sns_people_followers = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_followers"));
    GtkWidget *menu_sns_people_friends = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_friends"));
    GtkWidget *menu_sns_people_tags = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_tags"));
    GtkWidget *menu_sns_people_c_followings = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_c_followings"));
    GtkWidget *menu_sns_people_c_followers = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_c_followers"));
    GtkWidget *menu_sns_people_e_friends = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_e_friends"));
    GtkWidget *menu_sns_people_c_tags = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_c_tags"));
    GtkWidget *menu_sns_people_delete = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_delete"));
    /* --SNS tag menu */
    GtkWidget *menu_sns_tag_new = GTK_WIDGET(gtk_builder_get_object(builder, "sns_tag_new"));
    GtkWidget *menu_sns_tag_all = GTK_WIDGET(gtk_builder_get_object(builder, "sns_tag_all"));
    GtkWidget *menu_sns_tag_delete = GTK_WIDGET(gtk_builder_get_object(builder, "sns_tag_delete"));
    /* -Other menu */
    GtkWidget *menu_other_about = GTK_WIDGET(gtk_builder_get_object(builder, "other_about"));
    GtkWidget *menu_other_quit = GTK_WIDGET(gtk_builder_get_object(builder, "other_quit"));
    /* End Get objects */

    /* Connect signals */
    /* Main window */
    g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(gui_other_quit), NULL);
    /* -SNS menu */
    /* --SNS file menu */
    g_signal_connect(G_OBJECT(menu_sns_file_new), "activate", G_CALLBACK(gui_sns_file_new), NULL);
    g_signal_connect(G_OBJECT(menu_sns_file_load), "activate", G_CALLBACK(gui_sns_file_load), NULL);
    g_signal_connect(G_OBJECT(menu_sns_file_save), "activate", G_CALLBACK(gui_sns_file_save), NULL);
    /* --SNS people menu */
    g_signal_connect(G_OBJECT(menu_sns_people_new), "activate", G_CALLBACK(gui_sns_people_new), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_all), "activate", G_CALLBACK(gui_sns_people_all), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_follow), "activate", G_CALLBACK(gui_sns_people_follow), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_friend), "activate", G_CALLBACK(gui_sns_people_friend), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_tag), "activate", G_CALLBACK(gui_sns_people_tag), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_unfollow), "activate", G_CALLBACK(gui_sns_people_unfollow), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_unfriend), "activate", G_CALLBACK(gui_sns_people_unfriend), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_untag), "activate", G_CALLBACK(gui_sns_people_untag), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_followings), "activate", G_CALLBACK(gui_sns_people_followings), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_followers), "activate", G_CALLBACK(gui_sns_people_followers), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_friends), "activate", G_CALLBACK(gui_sns_people_friends), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_tags), "activate", G_CALLBACK(gui_sns_people_tags), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_c_followings), "activate", G_CALLBACK(gui_sns_people_c_followings), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_c_followers), "activate", G_CALLBACK(gui_sns_people_c_followers), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_e_friends), "activate", G_CALLBACK(gui_sns_people_e_friends), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_c_tags), "activate", G_CALLBACK(gui_sns_people_c_tags), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_delete), "activate", G_CALLBACK(gui_sns_people_delete), NULL);
    /* --SNS tag menu */
    g_signal_connect(G_OBJECT(menu_sns_tag_new), "activate", G_CALLBACK(gui_sns_tag_new), NULL);
    g_signal_connect(G_OBJECT(menu_sns_tag_all), "activate", G_CALLBACK(gui_sns_tag_all), NULL);
    g_signal_connect(G_OBJECT(menu_sns_tag_delete), "activate", G_CALLBACK(gui_sns_tag_delete), NULL);
    /* -Other menu */
    g_signal_connect(G_OBJECT(menu_other_about), "activate", G_CALLBACK(gui_other_about), NULL);
    g_signal_connect(G_OBJECT(menu_other_quit), "activate", G_CALLBACK(gui_other_quit), NULL);

    /* End Connect signals */

    /* Destroy builder */
    g_object_unref(G_OBJECT(builder));

    /* Show window */
    gtk_widget_show_all(GTK_WIDGET(window));
}

/* Basic function */
void clean_var(){
    sns_del(&SNS);
    SNS = NULL;
}

GtkWidget** gui_create_message_dialog(GtkWindow *fwindow, char *messages, GtkMessageType type, GtkWidget **dialog_response){
    GtkButtonsType buttons = GTK_BUTTONS_OK;
    switch(type){
        case GTK_MESSAGE_ERROR: buttons = GTK_BUTTONS_OK; break;
        case GTK_MESSAGE_WARNING: buttons = GTK_BUTTONS_OK; break;
        case GTK_MESSAGE_QUESTION: buttons = GTK_BUTTONS_YES_NO; break;
        case GTK_MESSAGE_INFO:break;
        case GTK_MESSAGE_OTHER:break;
    }

    GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;

    dialog_response[0] = GTK_WIDGET(gtk_message_dialog_new(
        fwindow,
        flags,
        type,
        buttons,
        messages
    ));

    return dialog_response;
}

GtkWidget** gui_create_edit_dialog(GtkWindow *fwindow, int rws, char argi[][100], GtkWidget **dialog_response){
    GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;<commit_msg>gui: add clean_column<commit_after>//
// Created by hrl on 9/22/15.
//

#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <cJSON.h>
#include <gtk/gtk.h>
#include "sns_functions.h"
#include "gui_functions.h"
#include "sns_structs.h"
#include "gui_structs.h"
#include "sns_defines.h"
#include "gui_defines.h"

void build_UI() {
    GtkBuilder *builder = NULL;
    GError *error = NULL;
    builder = gtk_builder_new();
    if (!gtk_builder_add_from_file(builder, UI_FILE, &error)) {
        g_warning("%s", error->message);
        g_free(error);
        exit(1);
    }

    /* Get objects */
    /* Main window */
    window = GTK_WINDOW(gtk_builder_get_object(builder, "window"));
    treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview"));
    /* -SNS menu */
    /* --SNS file menu */
    GtkWidget *menu_sns_file_new = GTK_WIDGET(gtk_builder_get_object(builder, "sns_file_new"));
    GtkWidget *menu_sns_file_load = GTK_WIDGET(gtk_builder_get_object(builder, "sns_file_load"));
    GtkWidget *menu_sns_file_save = GTK_WIDGET(gtk_builder_get_object(builder, "sns_file_save"));
    /* --SNS people menu */
    GtkWidget *menu_sns_people_new = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_new"));
    GtkWidget *menu_sns_people_all = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_all"));
    GtkWidget *menu_sns_people_follow = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_follow"));
    GtkWidget *menu_sns_people_friend = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_friend"));
    GtkWidget *menu_sns_people_tag = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_tag"));
    GtkWidget *menu_sns_people_unfollow = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_unfollow"));
    GtkWidget *menu_sns_people_unfriend = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_unfriend"));
    GtkWidget *menu_sns_people_untag = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_untag"));
    GtkWidget *menu_sns_people_followings = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_followings"));
    GtkWidget *menu_sns_people_followers = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_followers"));
    GtkWidget *menu_sns_people_friends = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_friends"));
    GtkWidget *menu_sns_people_tags = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_tags"));
    GtkWidget *menu_sns_people_c_followings = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_c_followings"));
    GtkWidget *menu_sns_people_c_followers = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_c_followers"));
    GtkWidget *menu_sns_people_e_friends = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_e_friends"));
    GtkWidget *menu_sns_people_c_tags = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_c_tags"));
    GtkWidget *menu_sns_people_delete = GTK_WIDGET(gtk_builder_get_object(builder, "sns_people_delete"));
    /* --SNS tag menu */
    GtkWidget *menu_sns_tag_new = GTK_WIDGET(gtk_builder_get_object(builder, "sns_tag_new"));
    GtkWidget *menu_sns_tag_all = GTK_WIDGET(gtk_builder_get_object(builder, "sns_tag_all"));
    GtkWidget *menu_sns_tag_delete = GTK_WIDGET(gtk_builder_get_object(builder, "sns_tag_delete"));
    /* -Other menu */
    GtkWidget *menu_other_about = GTK_WIDGET(gtk_builder_get_object(builder, "other_about"));
    GtkWidget *menu_other_quit = GTK_WIDGET(gtk_builder_get_object(builder, "other_quit"));
    /* End Get objects */

    /* Connect signals */
    /* Main window */
    g_signal_connect(G_OBJECT(window), "delete-event", G_CALLBACK(gui_other_quit), NULL);
    /* -SNS menu */
    /* --SNS file menu */
    g_signal_connect(G_OBJECT(menu_sns_file_new), "activate", G_CALLBACK(gui_sns_file_new), NULL);
    g_signal_connect(G_OBJECT(menu_sns_file_load), "activate", G_CALLBACK(gui_sns_file_load), NULL);
    g_signal_connect(G_OBJECT(menu_sns_file_save), "activate", G_CALLBACK(gui_sns_file_save), NULL);
    /* --SNS people menu */
    g_signal_connect(G_OBJECT(menu_sns_people_new), "activate", G_CALLBACK(gui_sns_people_new), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_all), "activate", G_CALLBACK(gui_sns_people_all), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_follow), "activate", G_CALLBACK(gui_sns_people_follow), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_friend), "activate", G_CALLBACK(gui_sns_people_friend), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_tag), "activate", G_CALLBACK(gui_sns_people_tag), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_unfollow), "activate", G_CALLBACK(gui_sns_people_unfollow), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_unfriend), "activate", G_CALLBACK(gui_sns_people_unfriend), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_untag), "activate", G_CALLBACK(gui_sns_people_untag), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_followings), "activate", G_CALLBACK(gui_sns_people_followings), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_followers), "activate", G_CALLBACK(gui_sns_people_followers), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_friends), "activate", G_CALLBACK(gui_sns_people_friends), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_tags), "activate", G_CALLBACK(gui_sns_people_tags), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_c_followings), "activate", G_CALLBACK(gui_sns_people_c_followings), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_c_followers), "activate", G_CALLBACK(gui_sns_people_c_followers), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_e_friends), "activate", G_CALLBACK(gui_sns_people_e_friends), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_c_tags), "activate", G_CALLBACK(gui_sns_people_c_tags), NULL);
    g_signal_connect(G_OBJECT(menu_sns_people_delete), "activate", G_CALLBACK(gui_sns_people_delete), NULL);
    /* --SNS tag menu */
    g_signal_connect(G_OBJECT(menu_sns_tag_new), "activate", G_CALLBACK(gui_sns_tag_new), NULL);
    g_signal_connect(G_OBJECT(menu_sns_tag_all), "activate", G_CALLBACK(gui_sns_tag_all), NULL);
    g_signal_connect(G_OBJECT(menu_sns_tag_delete), "activate", G_CALLBACK(gui_sns_tag_delete), NULL);
    /* -Other menu */
    g_signal_connect(G_OBJECT(menu_other_about), "activate", G_CALLBACK(gui_other_about), NULL);
    g_signal_connect(G_OBJECT(menu_other_quit), "activate", G_CALLBACK(gui_other_quit), NULL);

    /* End Connect signals */

    /* Destroy builder */
    g_object_unref(G_OBJECT(builder));

    /* Show window */
    gtk_widget_show_all(GTK_WIDGET(window));
}

/* Basic function */
void clean_var(){
    sns_del(&SNS);
    SNS = NULL;
}

void clean_column(){
    int columns;
    GtkTreeViewColumn *column;
    columns = gtk_tree_view_get_n_columns(treeview);

    while(columns){
        column = gtk_tree_view_get_column(treeview, 0);
        gtk_tree_view_remove_column(treeview, column);
        columns--;
    }
}

GtkWidget** gui_create_message_dialog(GtkWindow *fwindow, char *messages, GtkMessageType type, GtkWidget **dialog_response){
    GtkButtonsType buttons = GTK_BUTTONS_OK;
    switch(type){
        case GTK_MESSAGE_ERROR: buttons = GTK_BUTTONS_OK; break;
        case GTK_MESSAGE_WARNING: buttons = GTK_BUTTONS_OK; break;
        case GTK_MESSAGE_QUESTION: buttons = GTK_BUTTONS_YES_NO; break;
        case GTK_MESSAGE_INFO:break;
        case GTK_MESSAGE_OTHER:break;
    }

    GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;

    dialog_response[0] = GTK_WIDGET(gtk_message_dialog_new(
        fwindow,
        flags,
        type,
        buttons,
        messages
    ));

    return dialog_response;
}

GtkWidget** gui_create_edit_dialog(GtkWindow *fwindow, int rws, char argi[][100], GtkWidget **dialog_response){
    GtkDialogFlags flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
{'fraction_non_alphanumeric': 0.11271230056613485, 'fraction_numerical': 0.0013510036026762738, 'mean_word_length': 6.487957610789981, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7157149', 'n_tokens_mistral': 5937, 'n_tokens_neox': 5864, 'n_words': 754}