void tilp_local_update_applist(void) { GList *ptr; if (local.selection3 == NULL) return; if((options.calc_model == CALC_TI82) || (options.calc_model == CALC_TI85)) return; if(!remote.var_tree || !remote.app_tree) return; for(ptr = local.selection3; ptr; ptr = ptr->next) { FileEntry *fe = ptr->data; FlashContent *c = fe->content2; VarEntry ve; memset(&ve, 0, sizeof(ve)); strcpy(ve.name, c->name); ve.size = c->data_length; ve.type = tifiles_flash_type(calc_handle->model); ticalcs_dirlist_ve_add(remote.app_tree, &ve); } remote.memory.flash_used = ticalcs_dirlist_flash_used(remote.var_tree, remote.app_tree); }
static gboolean allow_selection(GtkTreeSelection * selection, GtkTreeModel * model, GtkTreePath * path, gboolean path_currently_selected, gpointer data) { GtkTreeIter iter; VarEntry *ve; (void)selection; (void)data; (void)path_currently_selected; gtk_tree_model_get_iter(model, &iter, path); gtk_tree_model_get(model, &iter, COLUMN_DATA, &ve, -1); if (ve == NULL) return FALSE; if (ve->type == tifiles_folder_type(GFMFile.model)) return FALSE; if(ve->type == tifiles_flash_type(GFMFile.model)) return FALSE; return TRUE; }
static void tree_selection_changed(GtkTreeSelection * selection, gpointer user_data) { GList *list; GtkTreeIter iter; GtkTreeModel *model; // destroy selection g_list_free(gfm_widget.sel1); g_list_free(gfm_widget.sel2); // create a new selection for (list = gtk_tree_selection_get_selected_rows(selection, &model); list != NULL; list = list->next) { GtkTreePath *path = list->data; VarEntry *ve; gtk_tree_model_get_iter(model, &iter, path); gtk_tree_model_get(model, &iter, COLUMN_DATA, &ve, -1); if (ve->type != tifiles_flash_type(GFMFile.model)) { gfm_widget.sel1 = g_list_append(gfm_widget.sel1, ve); } else { gfm_widget.sel2 = g_list_append(gfm_widget.sel2, ve); } } g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); g_list_free(list); }
/** * tifiles_build_filename: * @model: a calculator model. * @ve: a #VarEntry structure. * * Build a valid filename from folder name, variable name and variable type. * Example: real number x on TI89 in the 'main' folder will give 'main.x.89e'. * Note: this function is useable with FLASH apps, too (but you have to fill the #VarEntry structure yourself). * * Return value: a newly allocated string which must be freed when no longer used. **/ TIEXPORT2 char* TICALL tifiles_build_filename(CalcModel model, const VarEntry *ve) { char *filename; if (ve == NULL) { tifiles_critical("%s: an argument is NULL", __FUNCTION__); return NULL; } if(tifiles_calc_is_ti8x(model) || !strcmp(ve->folder, "") || (ve->type == tifiles_flash_type(model))) { char *part2; const char *part3; char *tmp; part2 = ticonv_varname_to_filename(model, ve->name, ve->type); part3 = tifiles_vartype2fext(model, ve->type); tmp = g_strconcat(part2, ".", part3, NULL); g_free(part2); filename = g_strdup(tmp); g_free(tmp); } else { char *part1; char *part2; const char *part3; char *tmp; part1 = ticonv_varname_to_filename(model, ve->folder, -1); part2 = ticonv_varname_to_filename(model, ve->name, ve->type); part3 = tifiles_vartype2fext(model, ve->type); tmp = g_strconcat(part1, ".", part2, ".", part3, NULL); g_free(part1); g_free(part2); filename = strdup(tmp); g_free(tmp); } return filename; }
static void get_selection (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { VarEntry *ve; (void)path; (void)data; gtk_tree_model_get(model, iter, COLUMN_DATA, &ve, -1); if (ve->type != tifiles_flash_type(GFMFile.model)) { gfm_widget.sel1 = g_list_append(gfm_widget.sel1, ve); } else { gfm_widget.sel2 = g_list_append(gfm_widget.sel2, ve); } }
static void tree_selection_changed(GtkTreeSelection * selection, gpointer user_data) { GList *list; GtkTreeIter iter; GtkTreeModel *model; GtkTreeSelection *sel; // destroy selection tilp_remote_selection_destroy(); // clear clist selection(one selection active at a time) sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(clist_wnd)); gtk_tree_selection_unselect_all(sel); // create a new selection for (list = gtk_tree_selection_get_selected_rows(selection, &model); list != NULL; list = list->next) { GtkTreePath *path = list->data; VarEntry *ve; gtk_tree_model_get_iter(model, &iter, path); gtk_tree_model_get(model, &iter, COLUMN_DATA, &ve, -1); if (ve->type != tifiles_flash_type(options.calc_model)) { remote.selection1 = g_list_append(remote.selection1, ve); } else { remote.selection2 = g_list_append(remote.selection2, ve); } } g_list_foreach(list, (GFunc)gtk_tree_path_free, NULL); g_list_free(list); }
GLADE_CB gboolean on_treeview1_button_press_event(GtkWidget * widget, GdkEventButton * event, gpointer user_data) { GtkTreeView *view = GTK_TREE_VIEW(gfm_widget.tree); GtkTreeModel *model = GTK_TREE_MODEL(tree); GtkTreePath *path; GtkTreeViewColumn *column; GtkTreeIter iter; VarEntry *ve; int col; gtk_tree_view_get_cursor(view, &path, &column); col = column2index(column); if (path == NULL) return FALSE; gtk_tree_model_get_iter(model, &iter, path); gtk_tree_model_get(model, &iter, COLUMN_DATA, &ve, -1); if (ve == NULL) return FALSE; if((event->type == GDK_2BUTTON_PRESS) && (col == COLUMN_ATTR)) { GdkPixbuf *pix1, *pix2, *pix3; pix1 = create_pixbuf("attr_none.xpm"); pix2 = create_pixbuf("attr_locked.xpm"); pix3 = create_pixbuf("attr_archived.xpm"); if(ve->type == tifiles_flash_type(GFMFile.model)) return FALSE; if(ve->attr == ATTRB_NONE) ve->attr = ATTRB_LOCKED; else if(ve->attr == ATTRB_LOCKED && tifiles_is_flash(GFMFile.model)) ve->attr = ATTRB_ARCHIVED; else if(ve->attr == ATTRB_LOCKED && !tifiles_is_flash(GFMFile.model)) ve->attr = ATTRB_NONE; else if(ve->attr == ATTRB_ARCHIVED) ve->attr = ATTRB_NONE; switch (ve->attr) { case ATTRB_NONE: gtk_tree_store_set(tree, &iter, COLUMN_ATTR, pix1, -1); break; case ATTRB_LOCKED: gtk_tree_store_set(tree, &iter, COLUMN_ATTR, pix2, -1); break; case ATTRB_ARCHIVED: gtk_tree_store_set(tree, &iter, COLUMN_ATTR, pix3, -1); break; default: break; } g_object_unref(pix1); g_object_unref(pix2); g_object_unref(pix3); labels_refresh(); } return FALSE; }