Пример #1
0
Файл: gui.c Проект: hrl/AVL
void gui_sns_people_delete(void *pass, int call_type) {
    GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
    GtkTreeIter iter;
    GtkTreeModel *model;
    gpointer *self;
    gint type;

    if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
        /* check */
        gtk_tree_model_get(model, &iter, 0, &self, -1);
        gtk_tree_model_get(model, &iter, 1, &type, -1);
        if(self == NULL || type != TYPE_PEOPLE) return gui_show_message("请先选择用户", GTK_MESSAGE_INFO);

        GtkWidget **question_dialog = (GtkWidget **)malloc(sizeof(GtkWidget *)*(1));
        question_dialog = gui_create_message_dialog(window, "确定要删除吗?", GTK_MESSAGE_QUESTION, question_dialog);
        gtk_widget_show_all(question_dialog[0]);

        if(gtk_dialog_run(GTK_DIALOG(question_dialog[0])) == GTK_RESPONSE_YES) {
            gtk_tree_model_get(model, &iter, 0, &self, -1);
            int result;
            result = people_del(SNS, ((People**)&self));
            if(result != PEOPLE_OP_SUCCESS) gui_show_message("删除失败", GTK_MESSAGE_ERROR);
            sns_changed = 1;
        }
        gtk_widget_destroy(GTK_WIDGET(question_dialog[0]));
        free(question_dialog);
    } else {
        return gui_show_message("请先选择用户", GTK_MESSAGE_INFO);
    }

    _gui_call_last_func();
}
Пример #2
0
Файл: gui.c Проект: hrl/AVL
int _gui_sns_people_dialog(void *self) {
    /*
     * create a people create/edit dialog, do some input check, then apply create/edit to param `self`
     *
     * */
    People **people=(People**)self;
    int rws=1;
    char title[100];
    char argi[rws*2+1][100];

    if(people == NULL) {
        strcpy(title, "新建用户");
        strcpy(argi[rws+1], "");
    } else {
        strcpy(title, "编辑用户");
        strcpy(argi[rws+1], (*people)->name);
    }
    strcpy(argi[0], title);
    strcpy(argi[1], "用户名");

    GtkWidget **dialog_result = (GtkWidget **)malloc(sizeof(GtkWidget *)*(rws*2+2));
    dialog_result = gui_create_edit_dialog(window, rws, argi, dialog_result);
    gtk_widget_show_all(dialog_result[0]);

    char validate_message[100];
    validate_message[0] = '\0';
    int result;
    GtkEntryBuffer *buffer;
    char name[100];
    while(gtk_dialog_run(GTK_DIALOG(dialog_result[0])) == GTK_RESPONSE_ACCEPT) {
        validate_message[0] = '\0';

        buffer = gtk_entry_get_buffer(GTK_ENTRY(dialog_result[2*1+1]));
        if(gtk_entry_buffer_get_length(buffer) >= 100) {
            strcpy(validate_message, "用户名过长");
        } else {
            strcpy(name, gtk_entry_buffer_get_text(buffer));
        }

        if(validate_message[0] != '\0') {
            gui_show_message(validate_message, GTK_MESSAGE_WARNING);
            continue;
        }

        if(people == NULL) {
            People *_people_tmp=NULL;
            people = &_people_tmp;
            result = people_init(SNS, people, name, 0, 0);
        } else {
            strcpy((*people)->name, name);
            result = PEOPLE_OP_SUCCESS;
        }
        break;
    }

    gtk_widget_destroy(GTK_WIDGET(dialog_result[0]));
    free(dialog_result);

    return result;
}
Пример #3
0
Файл: gui.c Проект: hrl/AVL
void gui_sns_people_c_tags(void *pass, int call_type) {
    People *people=NULL;
    _gui_sns_people_get_selection(&people);
    if(people != NULL) {
        People *target=NULL;
        int result;
        result = _gui_sns_get_people_by_id_dialog("查看共同爱好", &target);
        if(result != SNS_OP_SUCCESS || target == NULL) return gui_show_message("获取用户失败", GTK_MESSAGE_WARNING);

        Set *target_set=NULL;
        result = people_common_tags(people, target, &target_set);
        if(result != SNS_OP_SUCCESS || target_set == NULL) return gui_show_message("获取共同爱好列表失败", GTK_MESSAGE_WARNING);

        last_func = gui_sns_people_c_tags;
        _gui_clean_column();
        _gui_sns_tag_common_show(target_set);
    }
}
Пример #4
0
Файл: gui.c Проект: hrl/AVL
void _gui_sns_tag_get_selection(Tag **tag) {
    GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
    GtkTreeIter iter;
    GtkTreeModel *model;
    gpointer *self;
    gint type;

    if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
        /* check */
        gtk_tree_model_get(model, &iter, 0, &self, -1);
        gtk_tree_model_get(model, &iter, 1, &type, -1);
        if(self == NULL || type != TYPE_TAG) return gui_show_message("请先选择爱好", GTK_MESSAGE_INFO);

        *tag = (Tag*)self;
    } else {
        gui_show_message("请先选择爱好", GTK_MESSAGE_INFO);
    }
}
Пример #5
0
Файл: gui.c Проект: hrl/AVL
int _gui_sns_tag_dialog(void *self) {
    Tag **tag = (Tag **) self;
    int rws = 1;
    char title[100];
    char argi[rws * 2 + 1][100];

    if (tag == NULL) {
        strcpy(title, "新建爱好");
        strcpy(argi[rws + 1], "");
    } else {
        strcpy(title, "编辑爱好");
        strcpy(argi[rws + 1], (*tag)->name);
    }
    strcpy(argi[0], title);
    strcpy(argi[1], "爱好名");

    GtkWidget **dialog_result = (GtkWidget **) malloc(sizeof(GtkWidget *) * (rws * 2 + 2));
    dialog_result = gui_create_edit_dialog(window, rws, argi, dialog_result);
    gtk_widget_show_all(dialog_result[0]);

    char validate_message[100];
    validate_message[0] = '\0';
    int result;
    GtkEntryBuffer *buffer;
    char name[100];
    while (gtk_dialog_run(GTK_DIALOG(dialog_result[0])) == GTK_RESPONSE_ACCEPT) {
        validate_message[0] = '\0';

        buffer = gtk_entry_get_buffer(GTK_ENTRY(dialog_result[2 * 1 + 1]));
        if (gtk_entry_buffer_get_length(buffer) >= 100) {
            strcpy(validate_message, "爱好名过长");
        } else {
            strcpy(name, gtk_entry_buffer_get_text(buffer));
        }

        if (validate_message[0] != '\0') {
            gui_show_message(validate_message, GTK_MESSAGE_WARNING);
            continue;
        }

        if (tag == NULL) {
            Tag *_tag_tmp = NULL;
            tag = &_tag_tmp;
            result = tag_init(SNS, tag, name, 0, 0);
        } else {
            strcpy((*tag)->name, name);
            result = PEOPLE_OP_SUCCESS;
        }
        break;
    }

    gtk_widget_destroy(GTK_WIDGET(dialog_result[0]));
    free(dialog_result);

    return result;
}
Пример #6
0
Файл: gui.c Проект: hrl/AVL
void gui_sns_people_untag(void *pass, int call_type) {
    People *people=NULL;
    _gui_sns_people_get_selection(&people);
    Tag *target=NULL;
    if(people != NULL) {
        int result;
        int has_tag;
        result = _gui_sns_get_tag_by_id_dialog("取消爱好", &target);
        if(result != SNS_OP_SUCCESS) return gui_show_message("操作失败", GTK_MESSAGE_WARNING);
        result = people_has_tag(people, target, &has_tag);
        if(result != SNS_OP_SUCCESS) return gui_show_message("操作失败", GTK_MESSAGE_WARNING);
        if(has_tag == 0) return gui_show_message("无此爱好", GTK_MESSAGE_WARNING);
        result = people_untag(people, target);
        if(result != SNS_OP_SUCCESS) return gui_show_message("操作失败", GTK_MESSAGE_WARNING);
        sns_changed = 1;
    }

    _gui_call_last_func();
}
Пример #7
0
Файл: gui.c Проект: hrl/AVL
void gui_sns_people_friend(void *pass, int call_type) {
    People *people=NULL;
    _gui_sns_people_get_selection(&people);
    People *target=NULL;
    if(people != NULL) {
        int result;
        int has_friend;
        result = _gui_sns_get_people_by_id_dialog("添加新好友", &target);
        if(result != SNS_OP_SUCCESS) return gui_show_message("操作失败", GTK_MESSAGE_WARNING);
        result = people_has_friend(people, target, &has_friend);
        if(result != SNS_OP_SUCCESS) return gui_show_message("操作失败", GTK_MESSAGE_WARNING);
        if(has_friend == 1) return gui_show_message("已是好友", GTK_MESSAGE_WARNING);
        result = people_friend(people, target);
        if(result != SNS_OP_SUCCESS) return gui_show_message("操作失败", GTK_MESSAGE_WARNING);
        sns_changed = 1;
    }

    _gui_call_last_func();
}
Пример #8
0
Файл: gui.c Проект: hrl/AVL
void _gui_sns_people_get_selection(People **people) {
    /*
     * get the selected people
     *
     * */
    GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
    GtkTreeIter iter;
    GtkTreeModel *model;
    gpointer *self;
    gint type;

    if(gtk_tree_selection_get_selected(selection, &model, &iter)) {
        /* check */
        gtk_tree_model_get(model, &iter, 0, &self, -1);
        gtk_tree_model_get(model, &iter, 1, &type, -1);
        if(self == NULL || type != TYPE_PEOPLE) return gui_show_message("请先选择用户", GTK_MESSAGE_INFO);

        *people = (People*)self;
    } else {
        gui_show_message("请先选择用户", GTK_MESSAGE_INFO);
    }
}
Пример #9
0
Файл: gui.c Проект: hrl/AVL
void gui_sns_people_e_friends(void *pass, int call_type) {
    People *people=NULL;
    _gui_sns_people_get_selection(&people);
    if(people != NULL) {
        int result;
        Set *target_set=NULL;
        result = people_extend_friends(people, &target_set);
        if(result != SNS_OP_SUCCESS || target_set == NULL) return gui_show_message("获取二度好友列表失败", GTK_MESSAGE_WARNING);

        last_func = gui_sns_people_e_friends;
        _gui_clean_column();
        _gui_sns_people_common_show(target_set);
    }
}
Пример #10
0
Файл: gui.c Проект: hrl/AVL
int _gui_sns_get_tag_by_id_dialog(char *messages, Tag **result_tag) {
    /*
     * create a dialog to get tag by input id
     *
     * */
    int rws=1;
    char title[100];
    char argi[rws*2+1][100];

    strcpy(title, messages);
    strcpy(argi[0], title);
    strcpy(argi[1], "爱好ID");
    strcpy(argi[rws+1], "");

    GtkWidget **dialog_result = (GtkWidget **)malloc(sizeof(GtkWidget *)*(rws*2+2));
    dialog_result = gui_create_edit_dialog(window, rws, argi, dialog_result);
    gtk_widget_show_all(dialog_result[0]);

    char validate_message[100];
    validate_message[0] = '\0';
    int result;
    GtkEntryBuffer *buffer;
    char id_string[10];
    int id;
    while(gtk_dialog_run(GTK_DIALOG(dialog_result[0])) == GTK_RESPONSE_ACCEPT) {
        validate_message[0] = '\0';

        buffer = gtk_entry_get_buffer(GTK_ENTRY(dialog_result[2*1+1]));
        if(gtk_entry_buffer_get_length(buffer) >= 10) {
            strcpy(validate_message, "爱好ID过长");
        } else {
            strcpy(id_string, gtk_entry_buffer_get_text(buffer));
            id = atoi(id_string);
        }

        if(validate_message[0] != '\0') {
            gui_show_message(validate_message, GTK_MESSAGE_WARNING);
            continue;
        }

        result = sns_search_tag(SNS, id, result_tag);
        break;
    }

    gtk_widget_destroy(GTK_WIDGET(dialog_result[0]));
    free(dialog_result);

    return result;
}
Пример #11
0
Файл: gui.c Проект: hrl/AVL
void gui_sns_file_save(void *pass, int call_type) {
    /*
     * create a file "save" dialog
     *
     * */
    if(sns_filename == NULL) {
        return _gui_sns_file_save_as(pass, call_type);
    }
    int result;
    result = sns_json_file_write(SNS, sns_filename);
    if(result != SNS_OP_SUCCESS) {
        gui_show_message("文件保存失败", GTK_MESSAGE_ERROR);
    } else {
        sns_changed = 0;
    }
}
Пример #12
0
Файл: gui.c Проект: hrl/AVL
void _gui_sns_file_save_as(void *pass, int call_type) {
    /*
     * create a file "save as" dialog
     *
     * */
    sns_filename=_gui_file_choose(FILE_CHOOSE_SAVE);
    if(sns_filename != NULL) {
        int result;
        result = sns_json_file_write(SNS, sns_filename);
        if(result != SNS_OP_SUCCESS) {
            gui_show_message("文件保存失败", GTK_MESSAGE_ERROR);
        } else {
            sns_changed = 0;
        }
    }
}
Пример #13
0
Файл: gui.c Проект: hrl/AVL
void gui_sns_file_load(void *pass, int call_type) {
    /*
     * load SNS data from file
     *
     * */
    gui_save_confirmation();
    sns_filename=_gui_file_choose(FILE_CHOOSE_OPEN);
    if(sns_filename != NULL) {
        gui_clean_var();
        int result;
        result = sns_json_file_read(&SNS, sns_filename);
        if(result != SNS_OP_SUCCESS) {
            gui_clean_var();
            gui_show_message("文件损坏", GTK_MESSAGE_ERROR);
        }
        _gui_clean_column();
    }
}
Пример #14
0
Файл: gui.c Проект: hrl/AVL
void _gui_sns_tag_common_show(Set *tag_set) {
    /*
     * show tags' information
     *
     * */
    GtkListStore *liststore=NULL;
    _gui_create_list_store(&liststore, TAG_ALL);

    _Gui_sns_pipe *_pipe=NULL;
    _gui_sns_pipe_init(&_pipe);
    _pipe->liststore = &liststore;

    int result;
    result = set_map(tag_set, _pipe, _gui_sns_tag_insert_into_column);
    if(result != GUI_OP_SUCCESS) gui_show_message("查询失败", GTK_MESSAGE_WARNING);

    gtk_tree_view_set_model(treeview, GTK_TREE_MODEL(liststore));
    _gui_create_column(TAG_ALL);

    _gui_sns_pipe_del(&_pipe);
}
Пример #15
0
void
com_irontec_evosugar(void *ep, EMPopupTargetSelect *t) {

   CamelException ex = {0};


   gchar *folder_name =  camel_folder_get_name(t->folder);
   gboolean folder_is_sent = FALSE;
   BREAKPOINT;
   gui.gtkBuilder = gtk_builder_new();
   gtk_builder_set_translation_domain(gui.gtkBuilder, GETTEXT_PACKAGE);
   gtk_builder_add_from_file(gui.gtkBuilder, g_build_filename(PLUGIN_INSTALL_DIR, UI_FILE, NULL), NULL);


   gui.entry_search = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "entrySearch"));
   gui.button_search = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "buttonSearch"));
   gui.radio_button_from = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "radiobuttonFrom"));
   gui.radio_button_to = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "radiobuttonTo"));
   gui.button_submit = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "buttonAddToSugarCRM"));

   gui.entry_subject_edit = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "entryEditSubject"));

   BREAKPOINT;
   g_signal_connect(gui.button_search, "clicked",
         G_CALLBACK(on_button_search_clicked), GTK_ENTRY(gui.entry_search));
   g_signal_connect(gui.button_submit, "clicked",
         G_CALLBACK(on_button_AddToSugarCRM_clicked), NULL);

   scrm_session.id = scrm_login(gconf_get_username(), gconf_get_password(), gconf_get_server());

   if ((g_strcmp0(folder_name, "Sent") == 0) || (g_strcmp0(folder_name, _("Sent")) == 0) ) {
      folder_is_sent = TRUE;
   }

   if (scrm_session.id == NULL || g_strcmp0(scrm_session.id, "-1") == 0) {
      gui_show_message(_("SugarCRM"), _("Unable to connect: check your connection and settings please."));
   } else {


      BREAKPOINT;

      msg = camel_folder_get_message(t->folder, t->uids->pdata[0], &ex);
      util_get_msg_body(msg, &msg_body);

      if (msg == NULL) {
         camel_exception_clear(&ex);
         return;
      }
      BREAKPOINT;

      subject = camel_mime_message_get_subject(msg);
      gtk_entry_set_text(gui.entry_subject_edit, subject);

      gui.body_text_view = gtk_builder_get_object(gui.gtkBuilder, "bodyTextView");
      model.body_text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gui.body_text_view));

      gtk_text_buffer_set_text(model.body_text_buffer, msg_body, -1);

      from = camel_mime_message_get_from(msg);
      to = camel_mime_message_get_recipients(msg, CAMEL_RECIPIENT_TYPE_TO);

      BREAKPOINT;
      msg_date = camel_mime_message_get_date(msg, NULL);
      camel_internet_address_get(from, 0, &from_name, &from_addr);
      camel_internet_address_get(to, 0, &to_name, &to_addr);
      g_signal_connect(gui.radio_button_from, "pressed",
            G_CALLBACK(on_radio_group_search_changed), from_addr);

      gchar *to_search = to_addr;


      g_signal_connect(gui.radio_button_to, "pressed",
            G_CALLBACK(on_radio_group_search_changed), to_search);
      if (folder_is_sent) {
         gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gui.radio_button_to),TRUE);
      }

      BREAKPOINT;

      GtkWidget *content_box = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "vboxContents"));
      GtkWidget *frame_attach = GTK_WIDGET(gtk_builder_get_object(gui.gtkBuilder, "frameAttach"));

      if (folder_is_sent) {
         gtk_entry_set_text(gui.entry_search, to_addr);
      } else {
         gtk_entry_set_text(gui.entry_search, from_addr);
      }

      GtkScrolledWindow *scrolledwindow = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL));
      gtk_scrolled_window_set_policy(scrolledwindow,
            GTK_POLICY_AUTOMATIC,
            GTK_POLICY_AUTOMATIC);
      GtkScrolledWindow *scrolledwindow2 = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL));
      gtk_scrolled_window_set_policy(scrolledwindow2,
            GTK_POLICY_AUTOMATIC,
            GTK_POLICY_AUTOMATIC);



      BREAKPOINT;
      gtk_container_add(GTK_CONTAINER(content_box), scrolledwindow);
      gtk_container_add(GTK_CONTAINER(frame_attach), scrolledwindow2);
      BREAKPOINT;
      gui.treeview_search = gtk_tree_view_new();
      gui.treeview_attach = gtk_tree_view_new();


      add_columns_search(GTK_TREE_VIEW(gui.treeview_search));
      add_columns_attachment(GTK_TREE_VIEW(gui.treeview_attach));
      model.model_attach = util_get_msg_attachments(msg);


      //gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), model_search);
      BREAKPOINT;
      //g_object_unref (G_OBJECT (model_search));

      gtk_builder_connect_signals(gui.gtkBuilder, NULL);
      gtk_tree_view_set_model(GTK_TREE_VIEW(gui.treeview_attach), model.model_attach);
      gtk_container_add(scrolledwindow, gui.treeview_search);
      gtk_container_add(scrolledwindow2, gui.treeview_attach);

      gui.mainwin =
         GTK_WIDGET(gtk_builder_get_object
               (gui.gtkBuilder, "addToSugarCRMwindow"));


      /*
       * Show the application window
       */
      gtk_widget_show_all(gui.mainwin);

      //trigger
      on_button_search_clicked(NULL, gui.entry_search);
      if (DEBUG_ON) {
         //g_mem_profile ();
      }

   } // end-else comprobar conexion
}