void on_toolbar_next_clicked (GtkButton * UNUSED(button), gpointer UNUSED(user_data)) { GtkCTree *ctree; GtkCTreeNode *n; ctree = GTK_CTREE (lookup_widget (gems, "mailbox")); if (ctree->clist.rows == 0) return; n = gtk_ctree_node_nth (GTK_CTREE (ctree), (&(GTK_CTREE (ctree)->clist))->focus_row); gtk_ctree_unselect (GTK_CTREE (ctree), n); if ((&(GTK_CTREE (ctree)->clist))->focus_row < ((&(GTK_CTREE (ctree)->clist))->rows - 1)) (&(GTK_CTREE (ctree)->clist))->focus_row++; n = gtk_ctree_node_nth (GTK_CTREE (ctree), (&(GTK_CTREE (ctree)->clist))->focus_row); gtk_ctree_select (GTK_CTREE (ctree), n); if (gtk_ctree_node_is_visible (GTK_CTREE (ctree), n) != GTK_VISIBILITY_FULL) gtk_ctree_node_moveto (GTK_CTREE (ctree), n, 0, 1, 0); putmail (GTK_WIDGET (ctree)); return; }
/* Returns : True if the node is currently inside the bounds of the window. * Note that this function can return true even if the node is not viewable, * if the node's ancestor is visible. */ int clip_GTK_CTREENODEISVISIBLE (ClipMachine *cm) { C_widget *cctree = _fetch_cw_arg(cm); C_object *cnode = _fetch_cobject(cm,_clip_spar(cm,2)); CHECKCWID(cctree,GTK_IS_CTREE); CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cnode,cnode->type==GTK_TYPE_CTREE_NODE); _clip_retni(cm,gtk_ctree_node_is_visible (GTK_CTREE(cctree->widget), GTK_CTREE_NODE(cnode->object))); return 0; err: return 1; }
void source_ctree_select_source (struct master *m) { GtkCTreeNode *node; GtkVisibility vis; node = gtk_ctree_find_by_row_data (GTK_CTREE (source_ctree), NULL, m); gtk_ctree_unselect_recursive (GTK_CTREE (source_ctree), NULL); gtk_ctree_select (GTK_CTREE (source_ctree), node); vis = gtk_ctree_node_is_visible (GTK_CTREE (source_ctree), node); if (vis != GTK_VISIBILITY_FULL) gtk_ctree_node_moveto (GTK_CTREE (source_ctree), node, 0, 0.2, 0.0); }
gint gtk_dir_tree_open_dir(GtkDirTree *dir_tree, const gchar *path) { GtkCTreeNode *root_node, *node; GtkDirTreeNode *dir_node; DIR *dir; gchar *c; gchar *folder; gint nlen; gint new_path, new_node; gchar *text; gchar root[5], root1[5], root2[5], root3[5], root4[5]; gchar *aux_path, *real_path; if((dir=opendir(path)) == NULL) return FALSE; closedir(dir); /* GET ABSOLUTE PATH */ sprintf(root,"%s",G_DIR_SEPARATOR_S); sprintf(root1,"%s.",G_DIR_SEPARATOR_S); sprintf(root2,"%s..",G_DIR_SEPARATOR_S); sprintf(root3,"%s..%s",G_DIR_SEPARATOR_S,G_DIR_SEPARATOR_S); sprintf(root4,"%s.%s",G_DIR_SEPARATOR_S,G_DIR_SEPARATOR_S); if(path){ gint length; aux_path = g_strdup(path); length = strlen(aux_path); if(strcmp(aux_path + length - 2, root1) == 0){ if(length == 2) { g_free(aux_path); aux_path = g_strdup(root); } else { aux_path[length - 1] = '\0'; } } else if(strcmp(aux_path + length - 3, root2) == 0){ if(length == 3) { g_free(aux_path); aux_path = g_strdup(root); } else { gint i = length - 4; while(i >= 0){ if(aux_path[i] == root[0]){ aux_path[i+1] = '\0'; break; } i--; } } } else if(strcmp(aux_path + length - 4, root3) == 0){ if(length == 4) { g_free(aux_path); aux_path = g_strdup(root); } else { gint i = length - 5; while(i >= 0){ if(aux_path[i] == root[0]){ aux_path[i+1] = '\0'; break; } i--; } } } else if(strcmp(aux_path + length - 3, root4) == 0){ if(length == 3) { g_free(aux_path); aux_path = g_strdup(root); } else { aux_path[length - 2] = '\0'; } } } else aux_path = g_strdup(G_DIR_SEPARATOR_S); real_path = g_strdup(aux_path); g_free(aux_path); c = (gchar *)real_path; folder = NULL; nlen = 0; root_node = gtk_ctree_node_nth(GTK_CTREE(dir_tree), 1); gtk_ctree_expand(GTK_CTREE(dir_tree), root_node); new_path = FALSE; new_node = TRUE; while(*c != '\0' && *c != '\n' && c != NULL){ nlen++; folder = (char *)g_realloc(folder, (nlen+1)*sizeof(char)); folder[nlen-1] = *c; folder[nlen]='\0'; if(*c == G_DIR_SEPARATOR){ if(new_path){ node = GTK_CTREE_ROW(root_node)->children; while(node){ dir_node = gtk_ctree_node_get_row_data(GTK_CTREE(dir_tree), node); text = dir_node->path; if(strcmp(text, folder) == 0){ gtk_ctree_expand(GTK_CTREE(dir_tree), node); root_node = node; break; } node = GTK_CTREE_NODE_NEXT(node); } } else { new_path = TRUE; } new_node = FALSE; } else { new_node = TRUE; } c++; } if(new_node){ nlen++; folder = (char *)g_realloc(folder, (nlen+1)*sizeof(char)); folder[nlen-1] = G_DIR_SEPARATOR; folder[nlen]='\0'; node = GTK_CTREE_ROW(root_node)->children; while(node){ dir_node = gtk_ctree_node_get_row_data(GTK_CTREE(dir_tree), node); text = dir_node->path; if(strcmp(text, folder) == 0){ gtk_ctree_expand(GTK_CTREE(dir_tree), node); root_node = node; break; } node = GTK_CTREE_NODE_NEXT(node); } } g_free(folder); if (gtk_ctree_node_is_visible(GTK_CTREE(dir_tree), root_node) != GTK_VISIBILITY_FULL) { gtk_widget_map(GTK_WIDGET(dir_tree)); gtk_ctree_node_moveto(GTK_CTREE(dir_tree), root_node, 0, 0.5, 0.5); } gtk_ctree_select(GTK_CTREE(dir_tree), root_node); return TRUE; }