Beispiel #1
0
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;
}
Beispiel #2
0
static void
dirtree_expand (GtkCTree * tree, GtkCTreeNode * node)
{
    GtkAdjustment *h_adjustment;
    gfloat  row_align;

    DirTreeNode *dt_node;

    dt_node = gtk_ctree_node_get_row_data (tree, node);

    if (dt_node->scanned == FALSE)
    {
	tree_expand_node (DIRTREE (tree), node, FALSE);
	dt_node->scanned = TRUE;
    }

    if (parent_class->tree_expand)
	(*parent_class->tree_expand) (tree, node);

    h_adjustment = gtk_clist_get_hadjustment (GTK_CLIST (tree));

    if (h_adjustment && h_adjustment->upper != 0.0)
    {
	row_align =
	    (float) (tree->tree_indent * GTK_CTREE_ROW (node)->level) /
	    h_adjustment->upper;
	gtk_ctree_node_moveto (tree, node, tree->tree_column, 0, row_align);
    }
}
Beispiel #3
0
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);
}
Beispiel #4
0
/* This function makes the given column of the given node visible by scrolling. */
int
clip_GTK_CTREENODEMOVETO (ClipMachine *cm)
{
	C_widget   *cctree = _fetch_cw_arg(cm);
	C_object    *cnode = _fetch_cobject(cm,_clip_spar(cm,2));
	gint        column = _clip_parni(cm,3);
	gfloat   row_align = _clip_parnd(cm,4);
	gfloat   col_align = _clip_parnd(cm,5);
	CHECKCWID(cctree,GTK_IS_CTREE);
	CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cnode,cnode->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT(3,NUMERIC_t); CHECKOPT(4,NUMERIC_t); CHECKOPT(5,NUMERIC_t);
	if (_clip_parinfo(cm,3)==UNDEF_t) column = 1;
	gtk_ctree_node_moveto (GTK_CTREE(cctree->widget),
		GTK_CTREE_NODE(cnode->object), column-1, row_align, col_align);
	return 0;
err:
	return 1;
}
Beispiel #5
0
static void mimeview_selected(GtkCTree *ctree, GtkCTreeNode *node, gint column,
			      MimeView *mimeview)
{
	MimeInfo *partinfo;

	if (mimeview->opened == node) return;
	mimeview->opened = node;
	gtk_ctree_node_moveto(ctree, node, -1, 0.5, 0);

	partinfo = gtk_ctree_node_get_row_data(ctree, node);
	if (!partinfo) return;

	/* ungrab the mouse event */
	if (GTK_WIDGET_HAS_GRAB(ctree)) {
		gtk_grab_remove(GTK_WIDGET(ctree));
		if (gdk_pointer_is_grabbed())
			gdk_pointer_ungrab(GDK_CURRENT_TIME);
	}
	
	mimeview->textview->default_text = FALSE;

	update_signature_info(mimeview, partinfo);

	if (!mimeview_show_part(mimeview, partinfo)) {
		switch (partinfo->type) {
		case MIMETYPE_TEXT:
		case MIMETYPE_MESSAGE:
		case MIMETYPE_MULTIPART:
			mimeview_show_message_part(mimeview, partinfo);
		
			break;
		default:
			mimeview->textview->default_text = TRUE;	
			mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
			textview_show_mime_part(mimeview->textview, partinfo);
			break;
		}
	}
}
Beispiel #6
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;
}