static void plCTree( GtkCTree * ctree,GtkCTreeNode * parent_node,gpointer user_data )
{
 GtkCTreeNode  * node;
 DirNodeType   * DirNode;
 gchar 		   * text, * name = NULL;
 gchar 		   * dummy = "dummy";
 int     	 	 subdir = 1;
 DIR   		   * dir = NULL;
 struct dirent * dirent;
 gchar  	   * path;
 struct 		 stat statbuf;

 DirNode=gtk_ctree_node_get_row_data( ctree,parent_node );
 if ( !DirNode->scaned )
  {
   DirNode->scaned=1; current_path=DirNode->path;
   gtk_clist_freeze( GTK_CLIST( ctree ) );
   node=gtk_ctree_find_by_row_data( ctree,parent_node,NULL );
   gtk_ctree_remove_node( ctree,node );

   if ( (dir=opendir( DirNode->path ) ) )
    {
     while( (dirent=readdir( dir )) )
      {
       path=calloc( 1,strlen( DirNode->path ) + strlen( dirent->d_name ) + 2 );
       if ( !strcmp( current_path,"/" ) ) sprintf( path,"/%s",dirent->d_name );
	else sprintf( path,"%s/%s",current_path,dirent->d_name );
       text=dirent->d_name;
       g_free( name );
       name=g_filename_to_utf8( text, -1, NULL, NULL, NULL );

       if ( stat( path,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) && dirent->d_name[0] != '.' )
	{
	 DirNode=malloc( sizeof( DirNodeType ) ); DirNode->scaned=0; DirNode->path=strdup( path );
	 subdir=check_for_subdir( path );
	 node=gtk_ctree_insert_node( ctree,parent_node,NULL,(name ? &name : &text ),4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE );
	 gtk_ctree_node_set_row_data_full( ctree,node,DirNode,NULL );
	 if ( subdir ) node=gtk_ctree_insert_node( ctree,node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE );
	}
       free( path ); path=NULL;
      }
     closedir( dir );
    }

   gtk_ctree_sort_node( ctree,parent_node );
   gtk_clist_thaw( GTK_CLIST( ctree ) );
  }

  g_free( name );
}
Exemple #2
0
void source_ctree_add_master (GtkWidget *ctree, struct master *m) {
	GtkCTreeNode *node;
	GtkCTreeNode *parent = NULL;
	struct master *group = NULL;

	if (m->isgroup)
		return;

	// If set to display only configured games, and game is not configured,
	// and it's not the 'Favorites' master, just return so the display
	// isn't updated with the game type and masters.
	if (!(games[m->type].cmd) && default_show_only_configured_games && m != favorites)
		return;

	if (m->type != UNKNOWN_SERVER) {
		group = (struct master *) g_slist_nth_data (master_groups, m->type);
		source_ctree_enable_master_group (ctree, group, TRUE);
	}

	node = gtk_ctree_find_by_row_data (GTK_CTREE (ctree), NULL, m);

	if (!node) {
		if (group) {
			parent = gtk_ctree_find_by_row_data (GTK_CTREE (ctree), NULL, group);
		}
		node = gtk_ctree_insert_node (GTK_CTREE (ctree), parent, NULL, NULL, 4, NULL, NULL, NULL, NULL, TRUE, FALSE);
		gtk_ctree_node_set_row_data (GTK_CTREE (ctree), node, m);
	}
	source_ctree_show_node_status (ctree, m);
}
Exemple #3
0
static GtkCTreeNode *mimeview_append_part(MimeView *mimeview,
					  MimeInfo *partinfo,
					  GtkCTreeNode *parent)
{
	GtkCTree *ctree = GTK_CTREE(mimeview->ctree);
	GtkCTreeNode *node;
	static gchar content_type[64];
	gchar *str[N_MIMEVIEW_COLS];

	if (partinfo->type != MIMETYPE_UNKNOWN && partinfo->subtype) {
		g_snprintf(content_type, 64, "%s/%s", procmime_get_media_type_str(partinfo->type), partinfo->subtype);
	} else {
		g_snprintf(content_type, 64, "UNKNOWN");
	}

	str[COL_MIMETYPE] = content_type;
	str[COL_SIZE] = to_human_readable(partinfo->length);
	if (prefs_common.attach_desc)
		str[COL_NAME] = (gchar *) get_part_description(partinfo);
	else
		str[COL_NAME] = (gchar *) get_part_name(partinfo);

	node = gtk_ctree_insert_node(ctree, parent, NULL, str, 0,
				     NULL, NULL, NULL, NULL,
				     FALSE, TRUE);
	gtk_ctree_node_set_row_data(ctree, node, partinfo);

	return node;
}
Exemple #4
0
void
gftpui_add_file_to_transfer (gftp_transfer * tdata, GList * curfle)
{
  gftpui_common_curtrans_data * transdata;
  char *text[2];
  gftp_file * fle;

  fle = curfle->data;
  text[0] = gftpui_gtk_get_utf8_file_pos (fle);

  if (fle->transfer_action == GFTP_TRANS_ACTION_SKIP)
    text[1] = _("Skipped");
  else
    text[1] = _("Waiting...");

  fle->user_data = gtk_ctree_insert_node (GTK_CTREE (dlwdw),
                                          tdata->user_data, NULL, text, 5,
                                          NULL, NULL, NULL, NULL,
                                          FALSE, FALSE);
  transdata = g_malloc0 (sizeof (*transdata));
  transdata->transfer = tdata;
  transdata->curfle = curfle;

  gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), fle->user_data, transdata);
}
Exemple #5
0
static void fill_source_ctree (GtkWidget *ctree) {
	GSList *list;
	GSList *list2;
	GtkCTreeNode *node;
	GtkCTreeNode *parent;
	struct master *group;
	struct master *m;

	source_ctree_add_master (ctree, favorites);

	for (list = master_groups; list; list = list->next) {
		group = (struct master *) list->data;
		if (group->masters) {
			// If set to display only configured games, and game is not configured,
			// don't update the display with the master.
			if (games[group->type].cmd || !default_show_only_configured_games) {
				source_ctree_enable_master_group (ctree, group, FALSE);
				parent = gtk_ctree_find_by_row_data (GTK_CTREE (ctree), NULL, group);

				for (list2 = group->masters; list2; list2 = list2->next) {
					m = (struct master *) list2->data;
					node = gtk_ctree_insert_node (GTK_CTREE (ctree), parent, NULL, NULL, 4, NULL, NULL, NULL, NULL, TRUE, FALSE);
					gtk_ctree_node_set_row_data (GTK_CTREE (ctree), node, m);
					source_ctree_show_node_status (ctree, m);
				}
			}
		}
	}
}
Exemple #6
0
void variable_ctree_add_var(GtkCTree *ctree, gchar *name, v5d_var_info *vinfo)
{
    GtkCTreeNode *node;
    gchar *nstr[1];
    nstr[0] = name;
    node = gtk_ctree_insert_node(ctree,NULL,NULL,nstr,0,NULL,NULL,NULL,NULL,1,0);
    gtk_ctree_node_set_row_data(ctree,node,(gpointer) vinfo);
}
Exemple #7
0
static void expand_cb(GtkWidget * widget, GtkCTreeNode * parent_node)
{
    DIR *dir;
    struct dirent *dirent;
    gchar *path, *text, *dummy = "dummy";
    struct stat statbuf;
    GtkCTreeNode *node, *sub_node;
    DirNode *parent_dirnode, *dirnode;
    gboolean has_subdir = FALSE;

    parent_dirnode = gtk_ctree_node_get_row_data(GTK_CTREE(widget), parent_node);
    if (!parent_dirnode->scanned)
    {
        gtk_clist_freeze(GTK_CLIST(widget));
        node = gtk_ctree_find_by_row_data(GTK_CTREE(widget), parent_node, NULL);
        gtk_ctree_remove_node(GTK_CTREE(widget), node);
        if ((dir = opendir(parent_dirnode->path)) != NULL)
        {
            while ((dirent = readdir(dir)) != NULL)
            {
                path = g_strconcat(parent_dirnode->path, dirent->d_name, NULL);
                if (stat(path, &statbuf) != -1 && S_ISDIR(statbuf.st_mode) && dirent->d_name[0] != '.')
                {
                    dirnode = g_malloc0(sizeof (DirNode));
                    dirnode->path = g_strconcat(path, "/", NULL);
                    text = dirent->d_name;
                    if (check_for_subdir(dirnode->path))
                        has_subdir = TRUE;
                    else
                        has_subdir = FALSE;
                    node = gtk_ctree_insert_node(GTK_CTREE(widget), parent_node, NULL, &text, 4, folder_pixmap, folder_mask, ofolder_pixmap, ofolder_mask, !has_subdir, FALSE);
                    gtk_ctree_node_set_row_data_full(GTK_CTREE(widget), node, dirnode, destroy_cb);
                    if (has_subdir)
                        sub_node = gtk_ctree_insert_node(GTK_CTREE(widget), node, NULL, &dummy, 4, NULL, NULL, NULL, NULL, FALSE, FALSE);
                }
                g_free(path);
            }
            closedir(dir);
            gtk_ctree_sort_node(GTK_CTREE(widget), parent_node);
        }
        gtk_clist_thaw(GTK_CLIST(widget));
        parent_dirnode->scanned = TRUE;
    }
}
Exemple #8
0
int add_a_site_to_the_tree(struct site *a_site, gint operation) 
{
    struct ctree_attachment *info_to_add;
    gchar *tmp, *node_label[1];
    
    tmp = getAppropriateTreeLabel(a_site);
    node_label[0] = tmp;
    
    site_item = gtk_ctree_insert_node(GTK_CTREE(the_tree), NULL, NULL, node_label,
				      0, NULL, NULL, NULL, NULL, FALSE, FALSE);
    g_free (tmp);
    
    info_to_add = malloc(sizeof(struct ctree_attachment));
    info_to_add->file_or_site = IS_A_SITE;
    info_to_add->info_struct = (void *) a_site;
    gtk_ctree_node_set_row_data(GTK_CTREE(the_tree), site_item,
				(gpointer) info_to_add);

    /* Read site info */
   if (site_readfiles(a_site) != SITE_OK)
     /* We effectively have no info file, so just read the stored state. */
     site_read_local_state(a_site);

    /* Catchup or init, if that's required */
    if (operation == 1)
      {
	  site_initialize(a_site);
	  printf("Initialised site\n");
      }
    else if (operation == 2)
      {
	  site_catchup(a_site);
	  printf("Caught-up new site.\n");
      }
/* As far as I can tell, this doesn't need to be done. 
 * Not sure why it's in here*/
    site_write_stored_state(a_site);
    
    
    if (operation != 3)
      {
	  gtk_clist_freeze(GTK_CLIST(the_tree));
	  populate_site_node(GTK_CTREE_NODE(site_item), a_site);
	  gtk_clist_thaw(GTK_CLIST(the_tree));
      }
    
    return 0;
}
Exemple #9
0
static void source_ctree_enable_master_group (GtkWidget *ctree, struct master *m, int expand) {
	GtkCTreeNode *node;
	GtkCTreeNode *sibling = NULL;
	char cfgkey[128];
	GSList *list;
	int expanded;

	if (!m->isgroup)
		return;

	node = gtk_ctree_find_by_row_data (GTK_CTREE (ctree), NULL, m);

	if (node != NULL) {
		if (expand)
			gtk_ctree_expand (GTK_CTREE (ctree), node);
		return;
	}

	g_snprintf (cfgkey, 128, "/" CONFIG_FILE "/Source Tree/%s node collapsed=false", m->name);

	if (expand)
		config_set_bool (cfgkey, expanded = TRUE);
	else
		expanded = TRUE - config_get_bool (cfgkey);

	/* Find the place to insert new master group */

	list = g_slist_nth (master_groups, m->type);
	if (list)
		list = list->next;

	while (!sibling && list) {
		sibling = gtk_ctree_find_by_row_data (GTK_CTREE (ctree), NULL, (struct master *) list->data);
		list = list->next;
	}

	node = gtk_ctree_insert_node (GTK_CTREE (ctree), NULL, sibling, NULL, 4, NULL, NULL, NULL, NULL, FALSE, expanded);
	gtk_ctree_node_set_row_data (GTK_CTREE (ctree), node, m);
	source_ctree_show_node_status (ctree, m);
}
Exemple #10
0
GtkWidget *create_dir_browser(gchar * title, gchar * current_path, GtkSelectionMode mode, void (*handler) (gchar *))
{
    GtkWidget *window, *scroll_win, *tree, *vbox, *bbox, *ok, *cancel,
              *sep;
    gchar *root_text = "/", *node_text = "dummy";
    gchar *currentdir, *pos, *tpath, *tpathnew;
    GtkCTreeNode *root_node, *node, *nextnode;
    DirNode *dirnode;
    gboolean leaf;

#ifdef _GTK2
    window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    gtk_window_set_modal(GTK_WINDOW(window), TRUE);
//	gtk_window_set_decorated(GTK_WINDOW(window), TRUE);
#else
    window = gtk_window_new(GTK_WINDOW_DIALOG);
#endif
    gtk_window_set_title(GTK_WINDOW(window), title);
    gtk_container_border_width(GTK_CONTAINER(window), 10);

    vbox = gtk_vbox_new(FALSE, 10);
    gtk_container_add(GTK_CONTAINER(window), vbox);

    scroll_win = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll_win), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
    gtk_widget_set_usize(scroll_win, 250, 200);
    gtk_box_pack_start(GTK_BOX(vbox), scroll_win, TRUE, TRUE, 0);
    gtk_widget_show(scroll_win);

    gtk_widget_realize(window);
    if (!folder_pixmap)
    {
        folder_pixmap = gdk_pixmap_create_from_xpm_d(window->window, &folder_mask, NULL, folder);
        ofolder_pixmap = gdk_pixmap_create_from_xpm_d(window->window, &ofolder_mask, NULL, ofolder);
    }

    tree = gtk_ctree_new(1, 0);
    gtk_clist_set_column_auto_resize(GTK_CLIST(tree), 0, TRUE);
    gtk_clist_set_selection_mode(GTK_CLIST(tree), mode);
    gtk_ctree_set_line_style(GTK_CTREE(tree), GTK_CTREE_LINES_DOTTED);
    gtk_signal_connect(GTK_OBJECT(tree), "tree_expand", GTK_SIGNAL_FUNC(expand_cb), NULL);
    gtk_signal_connect(GTK_OBJECT(tree), "select_row", GTK_SIGNAL_FUNC(select_row_cb), NULL);
    gtk_container_add(GTK_CONTAINER(scroll_win), tree);
    gtk_object_set_user_data(GTK_OBJECT(tree), (gpointer) handler);

    root_node = gtk_ctree_insert_node(GTK_CTREE(tree), NULL, NULL, &root_text, 4, folder_pixmap, folder_mask, ofolder_pixmap, ofolder_mask, FALSE, FALSE);
    dirnode = g_malloc0(sizeof (DirNode));
    dirnode->path = g_strdup("/");
    gtk_ctree_node_set_row_data_full(GTK_CTREE(tree), root_node, dirnode, destroy_cb);
    node = gtk_ctree_insert_node(GTK_CTREE(tree), root_node, NULL, &node_text, 4, NULL, NULL, NULL, NULL, TRUE, TRUE);
    gtk_ctree_expand(GTK_CTREE(tree), root_node);
    gtk_widget_show(tree);

    sep = gtk_hseparator_new();
    gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0);
    gtk_widget_show(sep);

    bbox = gtk_hbutton_box_new();
    gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
    gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);

    ok = gtk_button_new_with_label(tr("Ok"));
    gtk_object_set_user_data(GTK_OBJECT(ok), window);
    GTK_WIDGET_SET_FLAGS(ok, GTK_CAN_DEFAULT);
    gtk_window_set_default(GTK_WINDOW(window), ok);
    gtk_box_pack_start(GTK_BOX(bbox), ok, TRUE, TRUE, 0);
    gtk_signal_connect(GTK_OBJECT(ok), "clicked", GTK_SIGNAL_FUNC(ok_clicked), tree);
    gtk_widget_show(ok);

    cancel = gtk_button_new_with_label(tr("Cancel"));
    GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
    gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
    gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window));
    gtk_widget_show(cancel);

    gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
    gtk_widget_show(bbox);
    gtk_widget_show(vbox);

    if (current_path && *current_path)
    {
        currentdir = g_strdup(current_path);
        tpath = g_strdup("/");
        pos = strtok(currentdir, "/");
        node = gtk_ctree_find_by_row_data_custom(GTK_CTREE(tree), NULL, "/", filetreeent_compare_func);
        do
        {
            tpathnew = g_strconcat(tpath, pos, "/", NULL);
            g_free(tpath);
            tpath = tpathnew;
            nextnode = gtk_ctree_find_by_row_data_custom(GTK_CTREE(tree), node, tpath, filetreeent_compare_func);
            if (!nextnode)
                break;
            node = nextnode;
            pos = strtok(NULL, "/");
            gtk_ctree_get_node_info(GTK_CTREE(tree), node, NULL, NULL, NULL, NULL, NULL, NULL, &leaf, NULL);
            if (!leaf && pos)
                gtk_ctree_expand(GTK_CTREE(tree), node);
            else
            {
                gtk_ctree_select(GTK_CTREE(tree), node);
                break;
            }
        }
        while (pos);
        g_free(tpath);
        g_free(currentdir);
    }
    else
        gtk_ctree_select(GTK_CTREE(tree), root_node);

    return window;
}
Exemple #11
0
static GtkCTreeNode *maketree_nodes(GtkCTreeNode *subtree, struct tree *t2, GtkCTreeNode *sibling, int mode)
{
char *tmp, *tmp2, *tmp3;
gchar *text [1];
GdkDrawable *pxm, *msk;

if(t2->t_which >= 0)
	{
        if(GLOBALS->facs[t2->t_which]->vec_root)
        	{
                if(GLOBALS->autocoalesce)
                	{
                        if(GLOBALS->facs[t2->t_which]->vec_root!=GLOBALS->facs[t2->t_which])
                        	{
				return(NULL);
                                }

                        tmp2=makename_chain(GLOBALS->facs[t2->t_which]);
                        tmp3=leastsig_hiername(tmp2);
                        tmp=wave_alloca(strlen(tmp3)+4);
                        strcpy(tmp,   "[] ");
                        strcpy(tmp+3, tmp3);
                        free_2(tmp2);
                        }
                        else
                        {
                        tmp=wave_alloca(strlen(t2->name)+4);
                        strcpy(tmp,   "[] ");
                        strcpy(tmp+3, t2->name);
                        }
		}
                else
                {
                tmp=t2->name;
                }
	}
        else
        {
	if(t2->t_which == WAVE_T_WHICH_UNDEFINED_COMPNAME)
		{
        	tmp=t2->name;
		}
		else
		{
		int thidx = -t2->t_which + WAVE_T_WHICH_COMPNAME_START;
		if((thidx >= 0) && (thidx < GLOBALS->comp_name_serial))
			{
			char *sc = GLOBALS->comp_name_idx[thidx];
			int tlen = strlen(t2->name) + 2 + 1 + strlen(sc) + 1 + 1;
			tmp = wave_alloca(tlen);
			if(!GLOBALS->is_vhdl_component_format)
				{
				sprintf(tmp, "%s  (%s)", t2->name, sc);
				}
			else
				{
				sprintf(tmp, "%s  : %s", t2->name, sc);
				}
			}
			else
			{
	        	tmp=t2->name;	/* should never get a value out of range here! */
			}
		}
        }

text[0]=tmp;
switch(mode)
	{
	case MAKETREE_FLATTEN:
		if(t2->child)
			{
		        sibling = gtk_ctree_insert_node (GLOBALS->ctree_main, subtree, sibling, text, 3,
                	                       NULL, NULL, NULL, NULL,
                	                       FALSE, FALSE);
			gtk_ctree_node_set_row_data(GLOBALS->ctree_main, sibling, t2);
			maketree(sibling, t2->child);
			}
			else
			{
		        sibling = gtk_ctree_insert_node (GLOBALS->ctree_main, subtree, sibling, text, 3,
                	                       NULL, NULL, NULL, NULL,
                	                       TRUE, FALSE);
			gtk_ctree_node_set_row_data(GLOBALS->ctree_main, sibling, t2);
			}
		break;

	default:
		switch(t2->kind)
			{
   			case TREE_VCD_ST_MODULE:	pxm = GLOBALS->hiericon_module_pixmap; msk = GLOBALS->hiericon_module_mask; break;
   			case TREE_VCD_ST_TASK:		pxm = GLOBALS->hiericon_task_pixmap; msk = GLOBALS->hiericon_task_mask; break;
   			case TREE_VCD_ST_FUNCTION:	pxm = GLOBALS->hiericon_function_pixmap; msk = GLOBALS->hiericon_function_mask; break;
   			case TREE_VCD_ST_BEGIN:		pxm = GLOBALS->hiericon_begin_pixmap; msk = GLOBALS->hiericon_begin_mask; break;
   			case TREE_VCD_ST_FORK:		pxm = GLOBALS->hiericon_fork_pixmap; msk = GLOBALS->hiericon_fork_mask; break;
			case TREE_VCD_ST_GENERATE:	pxm = GLOBALS->hiericon_generatefor_pixmap; msk = GLOBALS->hiericon_generatefor_mask; break; /* same as TREE_VHDL_ST_GENFOR */
			case TREE_VCD_ST_STRUCT:	pxm = GLOBALS->hiericon_block_pixmap; msk = GLOBALS->hiericon_block_mask; break; /* same as TREE_VHDL_ST_BLOCK */
			case TREE_VCD_ST_UNION:		pxm = GLOBALS->hiericon_instance_pixmap; msk = GLOBALS->hiericon_instance_mask; break; /* same as TREE_VHDL_ST_INSTANCE */
			case TREE_VCD_ST_CLASS:		pxm = GLOBALS->hiericon_class_pixmap; msk = GLOBALS->hiericon_class_mask; break;
			case TREE_VCD_ST_INTERFACE:	pxm = GLOBALS->hiericon_interface_pixmap; msk = GLOBALS->hiericon_interface_mask; break;
			case TREE_VCD_ST_PACKAGE:	pxm = GLOBALS->hiericon_svpackage_pixmap; msk = GLOBALS->hiericon_svpackage_mask; break;
			case TREE_VCD_ST_PROGRAM:	pxm = GLOBALS->hiericon_program_pixmap; msk = GLOBALS->hiericon_program_mask; break;

			case TREE_VHDL_ST_DESIGN:	pxm = GLOBALS->hiericon_design_pixmap; msk = GLOBALS->hiericon_design_mask; break;
			case TREE_VHDL_ST_BLOCK:	pxm = GLOBALS->hiericon_block_pixmap; msk = GLOBALS->hiericon_block_mask; break;
			case TREE_VHDL_ST_GENIF:	pxm = GLOBALS->hiericon_generateif_pixmap; msk = GLOBALS->hiericon_generateif_mask; break;
			case TREE_VHDL_ST_GENFOR:	pxm = GLOBALS->hiericon_generatefor_pixmap; msk = GLOBALS->hiericon_generatefor_mask; break;
			case TREE_VHDL_ST_INSTANCE:	pxm = GLOBALS->hiericon_instance_pixmap; msk = GLOBALS->hiericon_instance_mask; break;
			case TREE_VHDL_ST_PACKAGE:	pxm = GLOBALS->hiericon_package_pixmap; msk = GLOBALS->hiericon_package_mask; break;

			case TREE_VHDL_ST_SIGNAL:	pxm = GLOBALS->hiericon_signal_pixmap; msk = GLOBALS->hiericon_signal_mask; break;
			case TREE_VHDL_ST_PORTIN:	pxm = GLOBALS->hiericon_portin_pixmap; msk = GLOBALS->hiericon_portin_mask; break;
			case TREE_VHDL_ST_PORTOUT:	pxm = GLOBALS->hiericon_portout_pixmap; msk = GLOBALS->hiericon_portout_mask; break;
			case TREE_VHDL_ST_PORTINOUT:	pxm = GLOBALS->hiericon_portinout_pixmap; msk = GLOBALS->hiericon_portinout_mask; break;
			case TREE_VHDL_ST_BUFFER:	pxm = GLOBALS->hiericon_buffer_pixmap; msk = GLOBALS->hiericon_buffer_mask; break;
			case TREE_VHDL_ST_LINKAGE:	pxm = GLOBALS->hiericon_linkage_pixmap; msk = GLOBALS->hiericon_linkage_mask; break;

   			case TREE_VHDL_ST_ARCHITECTURE:	pxm = GLOBALS->hiericon_module_pixmap; msk = GLOBALS->hiericon_module_mask; break; /* same as TREE_VCD_ST_MODULE */
   			case TREE_VHDL_ST_FUNCTION:	pxm = GLOBALS->hiericon_function_pixmap; msk = GLOBALS->hiericon_function_mask; break; /* same as TREE_VCD_ST_FUNCTION */
   			case TREE_VHDL_ST_PROCESS:	pxm = GLOBALS->hiericon_task_pixmap; msk = GLOBALS->hiericon_task_mask; break; /* same as TREE_VCD_ST_TASK */
			case TREE_VHDL_ST_PROCEDURE:	pxm = GLOBALS->hiericon_class_pixmap; msk = GLOBALS->hiericon_class_mask; break; /* same as TREE_VCD_ST_CLASS */
			case TREE_VHDL_ST_RECORD:	pxm = GLOBALS->hiericon_record_pixmap; msk = GLOBALS->hiericon_record_mask; break;
			case TREE_VHDL_ST_GENERATE:	pxm = GLOBALS->hiericon_generate_pixmap; msk = GLOBALS->hiericon_generate_mask; break;

			default:			pxm = msk = NULL; break;
			}

	        sibling = gtk_ctree_insert_node (GLOBALS->ctree_main, subtree, sibling, text, 3,
               	                       pxm, msk, pxm, msk,
               	                       (mode==MAKETREE_LEAF), FALSE);
		gtk_ctree_node_set_row_data(GLOBALS->ctree_main, sibling, t2);
		break;
	}

return(sibling);
}
Exemple #12
0
/*
 * Create a node that will contain all sampled symbol information.
 */
static void
gdisp_createSymbolNode(Kernel_T     *kernel,
		       GtkWidget    *parent,
		       GtkWidget    *tree,
		       GtkCTreeNode *sampledSymbolNode,
		       Symbol_T     *symbol)
{

  GtkCTreeNode *iNode                       = (GtkCTreeNode*)NULL;
  GList        *iExtInfoItem                = (GList*)NULL;
  Pixmap_T     *pPixmap                     = (Pixmap_T*)NULL;
  gchar        *iNames [GD_TREE_NB_COLUMNS] = { (gchar*)NULL,  (gchar*)NULL };
  gchar         iInfo  [128];
  gchar         iMin   [128];
  gchar         iMax   [128];

  /*
   * The name of the node is the name of the symbol.
   */
  iNames[0] = symbol->sInfo.name;
  iNames[1] = iInfo;
  if (symbol->sInfo.dimension == 1) {
    sprintf(iNames[1],
	    "Type %s",
	    gdisp_getTypeAsString(symbol));
  }
  else {
    sprintf(iNames[1],
	    "Type %s [%d]",
	    gdisp_getTypeAsString(symbol),
	    symbol->sInfo.dimension);
  }

  symbol->sNode = gtk_ctree_insert_node(GTK_CTREE(tree),
					sampledSymbolNode,
					(GtkCTreeNode*)NULL, /* no sibling */
					iNames,
					GD_TREE_SPACING,
					(GdkPixmap*)NULL,
					(GdkBitmap*)NULL,
					(GdkPixmap*)NULL,
					(GdkBitmap*)NULL,
					FALSE, /* is a leave  */
					FALSE); /* is expanded */

  gtk_ctree_node_set_row_data(GTK_CTREE(tree),
			      symbol->sNode,
			      (gpointer)symbol);

  /*
   * Insert information node : PERIOD.
   */
  iNames[0] = "Period";
  iNames[1] = iInfo;
  sprintf(iNames[1],"%d",symbol->sInfo.period);

  iNode = gtk_ctree_insert_node(GTK_CTREE(tree),
				symbol->sNode, /* symbol node is the parent */
				(GtkCTreeNode*)NULL, /* no sibling node */
				iNames,
				GD_TREE_SPACING,
				(GdkPixmap*)NULL,
				(GdkBitmap*)NULL,
				(GdkPixmap*)NULL,
				(GdkBitmap*)NULL,
				TRUE,   /* is a leave  */
				FALSE); /* is expanded */

  gtk_ctree_node_set_selectable(GTK_CTREE(tree),
				iNode,
				FALSE); /* not selectable */


  /*
   * Insert information node : PHASE.
   */
  iNames[0] = "Phase";
  iNames[1] = iInfo;
  sprintf(iNames[1],"%d",symbol->sInfo.phase);

  iNode = gtk_ctree_insert_node(GTK_CTREE(tree),
				symbol->sNode, /* symbol node is the parent */
				(GtkCTreeNode*)NULL, /* no sibling node */
				iNames,
				GD_TREE_SPACING,
				(GdkPixmap*)NULL,
				(GdkBitmap*)NULL,
				(GdkPixmap*)NULL,
				(GdkBitmap*)NULL,
				TRUE,   /* is a leave  */
				FALSE); /* is expanded */

  gtk_ctree_node_set_selectable(GTK_CTREE(tree),
				iNode,
				FALSE); /* not selectable */


  /*
   * Insert information node : RANGE.
   */
  iNames[0] = "Range";
  iNames[1] = iInfo;
  if (symbol->sMinimum > (- G_MAXDOUBLE)) {
    sprintf(iMin,"%f",symbol->sMinimum);
  }
  else {
    sprintf(iMin,"n/a");
  }
  if (symbol->sMaximum < (+ G_MAXDOUBLE)) {
    sprintf(iMax,"%f",symbol->sMaximum);
  }
  else {
    sprintf(iMax,"n/a");
  }
  sprintf(iNames[1],"[ %s .. %s ]",iMin,iMax);

  iNode = gtk_ctree_insert_node(GTK_CTREE(tree),
				symbol->sNode, /* symbol node is the parent */
				(GtkCTreeNode*)NULL, /* no sibling node */
				iNames,
				GD_TREE_SPACING,
				(GdkPixmap*)NULL,
				(GdkBitmap*)NULL,
				(GdkPixmap*)NULL,
				(GdkBitmap*)NULL,
				TRUE,   /* is a leave  */
				FALSE); /* is expanded */

  gtk_ctree_node_set_selectable(GTK_CTREE(tree),
				iNode,
				FALSE); /* not selectable */


  /*
   * Insert information node : REFERENCE.
   */
  iNames[0] = "Reference";
  iNames[1] = iInfo;
  sprintf(iNames[1],"%d",symbol->sReference);

  iNode = gtk_ctree_insert_node(GTK_CTREE(tree),
				symbol->sNode, /* symbol node is the parent */
				(GtkCTreeNode*)NULL, /* no sibling node */
				iNames,
				GD_TREE_SPACING,
				(GdkPixmap*)NULL,
				(GdkBitmap*)NULL,
				(GdkPixmap*)NULL,
				(GdkBitmap*)NULL,
				TRUE,   /* is a leave  */
				FALSE); /* is expanded */

  gtk_ctree_node_set_selectable(GTK_CTREE(tree),
				iNode,
				FALSE); /* not selectable */

  gtk_ctree_node_set_row_data(GTK_CTREE(tree),
			      iNode,
			      (gpointer)"sReference");


  /*
   * Insert extended information.
   */
  pPixmap = gdisp_getPixmapById(kernel,
				GD_PIX_info,
				parent);

  iExtInfoItem = g_list_first(symbol->sExtInfoList);
  while (iExtInfoItem != (GList*)NULL) {

    iNames[0] = ((gchar**)(iExtInfoItem->data))[0];
    iNames[1] = ((gchar**)(iExtInfoItem->data))[1];

    iNode = gtk_ctree_insert_node(GTK_CTREE(tree),
				  symbol->sNode, /* the parent */
				  (GtkCTreeNode*)NULL, /* no sibling node */
				  iNames,
				  GD_TREE_SPACING,
				  pPixmap->pixmap,
				  pPixmap->mask,
				  pPixmap->pixmap,
				  pPixmap->mask,
				  TRUE,   /* is a leave  */
				  FALSE); /* is expanded */

    gtk_ctree_node_set_selectable(GTK_CTREE(tree),
				  iNode,
				  FALSE); /* not selectable */

    iExtInfoItem = g_list_next(iExtInfoItem);

  }

}
Exemple #13
0
/*
 * Create a node that will contain all provider information.
 */
static void
gdisp_createProviderNode(Kernel_T      *kernel,
			 GtkWidget     *parent,
			 GtkWidget     *tree,
			 Provider_T    *provider,
			 GtkCTreeNode **providerNode,
			 GtkCTreeNode **sampledSymbolNode)
{

  gchar        *pNames [GD_TREE_NB_COLUMNS] = { (gchar*)NULL,  (gchar*)NULL };
  GtkCTreeNode *iNode                       = (GtkCTreeNode*)NULL;
  GtkCTreeNode *sNode                       = (GtkCTreeNode*)NULL;
  Pixmap_T     *pPixmap                     = (Pixmap_T*)NULL;

  /*
   * The name of the node is the URL of the provider.
   * Get back provider pixmap according to its identity.
   */
  pNames[0] = provider->pUrl->str;

  pPixmap = gdisp_getProviderIdPixmap(kernel,
				      parent,
				      provider->pIdentity);

  provider->pNode = gtk_ctree_insert_node(GTK_CTREE(tree),
					  (GtkCTreeNode*)NULL, /* parent  */
					  (GtkCTreeNode*)NULL, /* sibling */
					  pNames,
					  GD_TREE_SPACING,
					  pPixmap->pixmap,
					  pPixmap->mask,
					  pPixmap->pixmap,
					  pPixmap->mask,
					  FALSE, /* is a leave  */
					  TRUE); /* is expanded */

  gtk_ctree_node_set_row_data(GTK_CTREE(tree),
			      provider->pNode,
			      (gpointer)provider);

  gtk_ctree_node_set_selectable(GTK_CTREE(tree),
				provider->pNode,
				FALSE); /* not selectable */

  /*
   * Insert information node.
   */
  pNames[0] = "Information";

  pPixmap = gdisp_getPixmapById(kernel,
				GD_PIX_info,
				parent);

  iNode = gtk_ctree_insert_node(GTK_CTREE(tree),
				provider->pNode, /* provider is the parent */
				(GtkCTreeNode*)NULL, /* no sibling node */
				pNames,
				GD_TREE_SPACING,
				pPixmap->pixmap,
				pPixmap->mask,
				pPixmap->pixmap,
				pPixmap->mask,
  /* FIXME for the moment */    TRUE, /* is a leave  */
				FALSE); /* is expanded */

  gtk_ctree_node_set_selectable(GTK_CTREE(tree),
				iNode,
				FALSE); /* not selectable */

  /*
   * Insert sampled symbol node.
   */
  pNames[0] = "Sampled Symbols";
  sNode = gtk_ctree_insert_node(GTK_CTREE(tree),
				provider->pNode, /* provider is the parent */
				(GtkCTreeNode*)NULL, /* no sibling node */
				pNames,
				GD_TREE_SPACING,
				kernel->widgets.collapsedNodePixmap->pixmap,
				kernel->widgets.collapsedNodePixmap->mask,
				kernel->widgets.expandedNodePixmap->pixmap,
				kernel->widgets.expandedNodePixmap->mask,
				FALSE, /* is a leave  */
				FALSE); /* is expanded */

  gtk_ctree_node_set_row_data(GTK_CTREE(tree),
			      sNode,
			      (gpointer)"sAnchor");

  gtk_ctree_node_set_text(GTK_CTREE(tree),
			  sNode,
			  0, /* column */
			  pNames[0]);

  gtk_ctree_node_set_selectable(GTK_CTREE(tree),
				sNode,
				FALSE); /* not selectable */

  if (gdisp_getProviderNumber(kernel) == 1) {

    /*
     * Expand that node if there is only one provider.
     */
    gtk_ctree_expand(GTK_CTREE(tree),sNode);

  }

  /*
   * Return.
   */
  *providerNode      = provider->pNode;
  *sampledSymbolNode = sNode;

}
GtkWidget * create_PlayList( void )
{
  GtkWidget 	* vbox1;
  GtkWidget 	* hbox1;
  GtkWidget 	* scrolledwindow1;
  GtkWidget 	* vbox2;
  GtkWidget 	* scrolledwindow2;
  GtkWidget 	* scrolledwindow3;
  GtkWidget 	* hbuttonbox1;
  GtkAccelGroup * accel_group;
  GdkColor 	  transparent = { 0,0,0,0 };
  gchar 	* root = "/";
  gchar 	* dummy = "dummy";
  DirNodeType 	* DirNode;

  accel_group=gtk_accel_group_new();

  PlayList=gtk_window_new( GTK_WINDOW_TOPLEVEL );
  gtk_object_set_data( GTK_OBJECT( PlayList ),"PlayList",PlayList );
  gtk_widget_set_usize( PlayList,512,384 );
  gtk_window_set_title( GTK_WINDOW( PlayList ),MSGTR_PlayList );
  gtk_window_set_position( GTK_WINDOW( PlayList ),GTK_WIN_POS_CENTER );
//  gtk_window_set_policy( GTK_WINDOW( PlayList ),FALSE,FALSE,FALSE );
  gtk_window_set_wmclass( GTK_WINDOW( PlayList ),"Playlist","MPlayer" );

  gtk_widget_realize( PlayList );
  gtkAddIcon( PlayList );

  vbox1=AddVBox( AddDialogFrame( PlayList ),0 );
  hbox1=AddHBox( NULL,1 );
   gtk_box_pack_start( GTK_BOX( vbox1 ),hbox1,TRUE,TRUE,0 );

  scrolledwindow1=gtk_scrolled_window_new( NULL,NULL );
  gtk_widget_show( scrolledwindow1 );
  gtk_container_add( GTK_CONTAINER(
    AddFrame( NULL,0,hbox1,1 ) ),scrolledwindow1 );
  gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC );

  CTDirTree=gtk_ctree_new( 1,0 );
  gtk_signal_connect( GTK_OBJECT( CTDirTree ),"tree_expand",GTK_SIGNAL_FUNC( plCTree ),(void*)0 );
  gtk_signal_connect( GTK_OBJECT( CTDirTree ),"select_row",GTK_SIGNAL_FUNC( plCTRow ),(void *)0 );
  gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),CTDirTree );
  gtk_clist_set_column_auto_resize( GTK_CLIST( CTDirTree ),0,TRUE );
  gtk_clist_set_column_width( GTK_CLIST( CTDirTree ),0,80 );
  gtk_clist_set_selection_mode( GTK_CLIST( CTDirTree ),GTK_SELECTION_SINGLE );
  gtk_ctree_set_line_style( GTK_CTREE( CTDirTree ),GTK_CTREE_LINES_SOLID );
  gtk_clist_column_titles_show( GTK_CLIST( CTDirTree ) );
  gtk_clist_set_shadow_type( GTK_CLIST( CTDirTree ),GTK_SHADOW_NONE );

  if ( !pxOpenedBook ) pxOpenedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msOpenedBook,&transparent,(gchar **)dir2_xpm );
  if ( !pxClosedBook ) pxClosedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msClosedBook,&transparent,(gchar **)open2_xpm );

  parent=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),NULL,NULL,&root,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,FALSE,FALSE );
  DirNode=malloc( sizeof( DirNodeType ) );
  DirNode->scaned=0; DirNode->path=strdup( root );
  gtk_ctree_node_set_row_data_full(GTK_CTREE( CTDirTree ),parent,DirNode,NULL );
  sibling=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),parent,NULL,&dummy,4,NULL,NULL,NULL,NULL,TRUE,TRUE );
  gtk_ctree_expand( GTK_CTREE( CTDirTree ),parent );
  gtk_widget_show( CTDirTree );

  if ( fsHistory[0] ) old_path = g_filename_from_utf8( fsHistory[0], -1, NULL, NULL, NULL );

  gtk_clist_set_column_widget( GTK_CLIST( CTDirTree ),0,
    AddLabel( MSGTR_PLAYLIST_DirectoryTree,NULL ) );

  gtk_clist_column_title_passive( GTK_CLIST( CTDirTree ),0 );

  vbox2=AddVBox(
    AddFrame( NULL,1,hbox1,1 ),0 );

  scrolledwindow2=gtk_scrolled_window_new( NULL,NULL );
  gtk_widget_show( scrolledwindow2 );
  gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow2,TRUE,TRUE,0 );
  gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow2 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC );

  CLFiles=gtk_clist_new( 1 );
  gtk_widget_show( CLFiles );
  gtk_container_add( GTK_CONTAINER( scrolledwindow2 ),CLFiles );
  gtk_clist_set_column_width( GTK_CLIST( CLFiles ),0,80 );
  gtk_clist_set_selection_mode( GTK_CLIST( CLFiles ),GTK_SELECTION_EXTENDED );
  gtk_clist_column_titles_show( GTK_CLIST( CLFiles ) );
  gtk_clist_set_shadow_type( GTK_CLIST( CLFiles ),GTK_SHADOW_NONE );

  gtk_clist_set_column_widget( GTK_CLIST( CLFiles ),0,
    AddLabel( MSGTR_PLAYLIST_Files,NULL ) );

  gtk_clist_column_title_passive( GTK_CLIST( CLFiles ),0 );

  AddHSeparator( vbox2 );

  scrolledwindow3=gtk_scrolled_window_new( NULL,NULL );
  gtk_widget_show( scrolledwindow3 );
  gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow3,TRUE,TRUE,0 );
  gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow3 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC );

  CLSelected=gtk_clist_new( 2 );
  gtk_widget_show( CLSelected );
  gtk_container_add( GTK_CONTAINER( scrolledwindow3 ),CLSelected );
  gtk_clist_set_column_width( GTK_CLIST( CLSelected ),0,295 );
  gtk_clist_set_column_width( GTK_CLIST( CLSelected ),1,295 );
  gtk_clist_set_selection_mode( GTK_CLIST( CLSelected ),GTK_SELECTION_MULTIPLE );
  gtk_clist_column_titles_show( GTK_CLIST( CLSelected ) );
  gtk_clist_set_shadow_type( GTK_CLIST( CLSelected ),GTK_SHADOW_NONE );

  gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),0,
    AddLabel( MSGTR_PLAYLIST_Selected,NULL ) );

  gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),1,
    AddLabel( MSGTR_PLAYLIST_Path,NULL ) );

  gtk_clist_column_title_passive( GTK_CLIST( CLSelected ),0 );

  AddHSeparator( vbox1 );

  hbuttonbox1=AddHButtonBox( vbox1 );
    gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END );
    gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 );

  Add=AddButton( MSGTR_Add,hbuttonbox1 );
  Remove=AddButton( MSGTR_Remove,hbuttonbox1 );
  Ok=AddButton( MSGTR_Ok,hbuttonbox1 );
  Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 );

  gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE );

  gtk_signal_connect( GTK_OBJECT( PlayList ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&PlayList );

  gtk_signal_connect( GTK_OBJECT( CLFiles ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void *)0 );
  gtk_signal_connect( GTK_OBJECT( CLFiles ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void *)0 );
  gtk_signal_connect( GTK_OBJECT( CLFiles ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)0 );
  gtk_signal_connect( GTK_OBJECT( CLFiles ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)0 );
  sigSel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void*)1 );
  sigUnsel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void*)1 );
  sigEvent=gtk_signal_connect( GTK_OBJECT( CLSelected ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)1 );
  gtk_signal_connect( GTK_OBJECT( CLSelected ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)1 );

  gtk_signal_connect( GTK_OBJECT( Add ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)3 );
  gtk_signal_connect( GTK_OBJECT( Add ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)3 );
  gtk_signal_connect( GTK_OBJECT( Remove ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)2 );
  gtk_signal_connect( GTK_OBJECT( Remove ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)2 );
  gtk_signal_connect( GTK_OBJECT( Ok ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)1 );
  gtk_signal_connect( GTK_OBJECT( Ok ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)1 );
  gtk_signal_connect( GTK_OBJECT( Cancel ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)0 );
  gtk_signal_connect( GTK_OBJECT( Cancel ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)0 );

  gtk_window_add_accel_group( GTK_WINDOW( PlayList ),accel_group );

  return PlayList;
}
Exemple #15
0
static void
tree_expand_node (DirTree * dt, GtkCTreeNode * node, gboolean expand)
{
    GtkCTreeNode *child;
    DirTreeNode *parent_node;
    DirTreeNode *child_node;
    DIR    *dir;
    struct stat stat_buff;
    struct dirent *entry;
    gboolean has_subdirs, has_link, has_access;
    char   *old_path;
    char   *subdir = "?";
    char   *file_name;
    GtkWidget *top = gtk_widget_get_toplevel (GTK_WIDGET (dt));
    old_path = g_get_current_dir ();

    if (!old_path)
	return;

    parent_node = gtk_ctree_node_get_row_data (GTK_CTREE (dt), node);

    if (chdir (parent_node->path))
    {
	g_free (old_path);
	return;
    }

    dir = opendir (".");

    if (!dir)
    {
	chdir (old_path);
	g_free (old_path);
	return;
    }

    dirtree_set_cursor (top, GDK_WATCH);

    gtk_clist_freeze (GTK_CLIST (dt));

    tree_collapse (GTK_CTREE (dt), node);

    child = NULL;

    while ((entry = readdir (dir)))
    {
	if (!stat (entry->d_name, &stat_buff) && S_ISDIR (stat_buff.st_mode)
	    && tree_is_dotfile (entry->d_name, dt->show_dotfile))
	{
	    child_node = g_malloc0 (sizeof (DirTreeNode));

	    child_node->path =
		g_strconcat (parent_node->path, "/", entry->d_name, NULL);

	    has_link = islink (entry->d_name);
	    has_access = access (entry->d_name, X_OK);

	    file_name = entry->d_name;

	    if (has_access)
	    {
		child = gtk_ctree_insert_node (GTK_CTREE (dt),
					       node, child,
					       &file_name,
					       CTREE_SPACING,
					       lckfolder_pixmap,
					       lckfolder_mask, NULL,
					       NULL, 1, 0);
		has_subdirs = FALSE;
	    }
	    else if (!strcmp (entry->d_name, "."))
	    {
		child = gtk_ctree_insert_node (GTK_CTREE (dt),
					       node, child,
					       &file_name,
					       CTREE_SPACING,
					       gofolder_pixmap,
					       gofolder_mask, NULL,
					       NULL, 1, 0);

		has_subdirs = FALSE;
	    }
	    else if (!strcmp (entry->d_name, ".."))
	    {
		child = gtk_ctree_insert_node (GTK_CTREE (dt),
					       node, child,
					       &file_name,
					       CTREE_SPACING,
					       upfolder_pixmap,
					       upfolder_mask, NULL,
					       NULL, 1, 0);

		has_subdirs = FALSE;
	    }
	    else
	    {
		if (dt->check_dir)
		{
		    if (dt->check_hlinks)
		    {
			if (stat_buff.st_nlink == 2 && dt->show_dotfile)
			    has_subdirs = TRUE;
			else if (stat_buff.st_nlink > 2)
			    has_subdirs = TRUE;
			else if (stat_buff.st_nlink == 1)
			    has_subdirs =
				tree_is_subdirs (entry->d_name,
						 dt->show_dotfile);
			else
			    has_subdirs = FALSE;
		    }
		    else
			has_subdirs =
			    tree_is_subdirs (entry->d_name, dt->show_dotfile);

		}
		else
		    has_subdirs = TRUE;

		if (access (entry->d_name, X_OK) != 0)
		{
		    has_subdirs = FALSE;
		}

		if (has_link)
		    child = gtk_ctree_insert_node (GTK_CTREE (dt),
						   node, child,
						   &file_name,
						   CTREE_SPACING,
						   lfolder_pixmap,
						   lfolder_mask,
						   lofolder_pixmap,
						   lofolder_mask,
						   !has_subdirs, 0);
		else
		    child = gtk_ctree_insert_node (GTK_CTREE (dt),
						   node, child,
						   &file_name,
						   CTREE_SPACING,
						   folder_pixmap,
						   folder_mask,
						   ofolder_pixmap,
						   ofolder_mask,
						   !has_subdirs, 0);
	    }

	    if (child)
	    {
		gtk_ctree_node_set_row_data_full (GTK_CTREE (dt), child,
						  child_node,
						  dirtree_destroy_tree);

		if (has_subdirs)
		    gtk_ctree_insert_node (GTK_CTREE (dt),
					   child, NULL,
					   &subdir,
					   CTREE_SPACING,
					   NULL, NULL, NULL, NULL, 0, 0);
	    }
	}

	if (dt->check_events)
	    while (gtk_events_pending ())
		gtk_main_iteration ();
    }

    closedir (dir);

    chdir (old_path);
    g_free (old_path);

    gtk_ctree_sort_node (GTK_CTREE (dt), node);

    if (expand == TRUE)
	gtk_ctree_expand (GTK_CTREE (dt), node);

    gtk_clist_thaw (GTK_CLIST (dt));

    dirtree_set_cursor (top, -1);
}
Exemple #16
0
static void
show_transfer (gftp_transfer * tdata)
{
  GdkPixmap * closedir_pixmap, * opendir_pixmap;
  GdkBitmap * closedir_bitmap, * opendir_bitmap;
  gftpui_common_curtrans_data * transdata;
  gftp_file * tempfle;
  GList * templist;
  char *text[2];

  gftp_get_pixmap (dlwdw, "open_dir.xpm", &opendir_pixmap, &opendir_bitmap);
  gftp_get_pixmap (dlwdw, "dir.xpm", &closedir_pixmap, &closedir_bitmap);

  text[0] = tdata->fromreq->hostname;
  text[1] = _("Waiting...");
  tdata->user_data = gtk_ctree_insert_node (GTK_CTREE (dlwdw), NULL, NULL, 
                                       text, 5,
                                       closedir_pixmap, closedir_bitmap, 
                                       opendir_pixmap, opendir_bitmap, 
                                       FALSE, 
                                       tdata->numdirs + tdata->numfiles < 50);
  transdata = g_malloc0 (sizeof (*transdata));
  transdata->transfer = tdata;
  transdata->curfle = NULL;
  gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tdata->user_data, transdata);
  tdata->show = 0;
  tdata->curfle = tdata->updfle = tdata->files;

  tdata->total_bytes = 0;
  for (templist = tdata->files; templist != NULL; templist = templist->next)
    {
      tempfle = templist->data;

      text[0] = gftpui_gtk_get_utf8_file_pos (tempfle);
      if (tempfle->transfer_action == GFTP_TRANS_ACTION_SKIP)
        text[1] = _("Skipped");
      else
        {
          tdata->total_bytes += tempfle->size;
          text[1] = _("Waiting...");
        }

      tempfle->user_data = gtk_ctree_insert_node (GTK_CTREE (dlwdw), 
                                             tdata->user_data, 
                                             NULL, text, 5, NULL, NULL, NULL, 
                                             NULL, FALSE, FALSE);
      transdata = g_malloc0 (sizeof (*transdata));
      transdata->transfer = tdata;
      transdata->curfle = templist;
      gtk_ctree_node_set_row_data (GTK_CTREE (dlwdw), tempfle->user_data, 
                                   transdata);
    }

  if (!tdata->toreq->stopable && gftp_need_password (tdata->toreq))
    {
      tdata->toreq->stopable = 1;
      MakeEditDialog (_("Enter Password"),
		      _("Please enter your password for this site"), NULL, 0,
		      NULL, gftp_dialog_button_connect, 
                      get_trans_password, tdata->toreq,
		      cancel_get_trans_password, tdata);
    }

  if (!tdata->fromreq->stopable && gftp_need_password (tdata->fromreq))
    {
      tdata->fromreq->stopable = 1;
      MakeEditDialog (_("Enter Password"),
		      _("Please enter your password for this site"), NULL, 0,
		      NULL, gftp_dialog_button_connect, 
                      get_trans_password, tdata->fromreq,
		      cancel_get_trans_password, tdata);
    }
}
Exemple #17
0
static void 
expand_tree(GtkCTree *ctree,GtkCTreeNode *parent_node, gpointer data)
{
  DIR *dir;
  struct dirent *dirent;
  gchar *path,*text,*dummy="dummy";
  struct stat statbuf;
  GtkCTreeNode *node,*sub_node;
  GtkDirTreeNode *parent_dirnode,*dirnode;
  gboolean has_subdir=FALSE;
  gboolean show_hidden;
  gboolean stat_subdirs=TRUE;
  gboolean can_open_subdir;
  GtkDirTree *dir_tree;
  GtkWidget *widget;

  widget = GTK_WIDGET(ctree);
  dir_tree = GTK_DIR_TREE(widget);
  show_hidden = dir_tree->show_hidden;

  parent_dirnode=gtk_ctree_node_get_row_data(GTK_CTREE(widget),parent_node);

  if(parent_dirnode->path == dir_tree->local_hostname) return;

  if(!parent_dirnode->scanned)
  {
    gtk_clist_freeze(GTK_CLIST(widget));
    node=gtk_ctree_find_by_row_data(GTK_CTREE(widget),parent_node,NULL);
    gtk_ctree_remove_node(GTK_CTREE(widget),node);
    if((dir=opendir(parent_dirnode->path))!=NULL)
    {
      if(!check_dir_extra(parent_dirnode->path,&statbuf,&stat_subdirs))
      {
        closedir(dir);
        gtk_clist_thaw(GTK_CLIST(widget));
        return;
      }
      while((dirent=readdir(dir))!=NULL)
      {
        path=g_strconcat(parent_dirnode->path,dirent->d_name,NULL);
        if (stat_subdirs)
        {
          if(0!=stat(path,&statbuf))
          {
            g_free(path);
            continue;
          }
        }
        if(((!stat_subdirs)&&accept_dirname(dirent->d_name,show_hidden)) ||
           (S_ISDIR(statbuf.st_mode)&&accept_dirname(dirent->d_name,show_hidden)))
        {
          DIR *dir_sub;
          dirnode=g_malloc0(sizeof(GtkDirTreeNode));
          dirnode->path=g_strconcat(path,G_DIR_SEPARATOR_S,NULL);
          text=dirent->d_name;
          if (stat_subdirs)
          {
            if(check_for_subdir(dirnode->path,show_hidden))
               has_subdir=TRUE;
            else
               has_subdir=FALSE;
            dir_sub = opendir(dirnode->path);
            if( dir_sub != NULL )
            {
              closedir(dir_sub);
              can_open_subdir=TRUE;
            }
            else
            {
              can_open_subdir=FALSE;
            }
          }
          else
          {
            has_subdir=TRUE;
            can_open_subdir=TRUE;
          }

          if(can_open_subdir)
          {
             node=gtk_ctree_insert_node(GTK_CTREE(widget),parent_node,NULL,&text,4,dir_tree->folder,dir_tree->folder_mask,dir_tree->ofolder,dir_tree->ofolder_mask,!has_subdir,FALSE);
          }
          else
          {
             node=gtk_ctree_insert_node(GTK_CTREE(widget),parent_node,NULL,&text,4,dir_tree->dennied,dir_tree->dennied_mask,dir_tree->dennied,dir_tree->dennied_mask,!has_subdir,FALSE);
          }

          gtk_ctree_node_set_row_data_full(GTK_CTREE(widget),node,dirnode,destroy_tree);
          if(has_subdir)
                  sub_node=gtk_ctree_insert_node(GTK_CTREE(widget),node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE);
        }
        g_free(path);
      }
      closedir(dir);
      gtk_ctree_sort_node(GTK_CTREE(widget),parent_node);
    }
    gtk_clist_thaw(GTK_CLIST(widget));
    parent_dirnode->scanned=TRUE;
  }
}
Exemple #18
0
static void
gtk_dir_tree_init (GtkDirTree *dir_tree)
{
  GtkCTreeNode *root_node,*mypc_node,*node;
  GtkDirTreeNode *dirnode;
  gchar *root_text=G_DIR_SEPARATOR_S,*node_text="dummy";
  gchar localhost[MAXHOSTNAMELEN];
  GtkWidget *widget;
  GdkColormap *colormap;
#ifdef G_OS_WIN32
  gchar  drives[128];
  gchar* drive;
#endif

  widget = GTK_WIDGET(dir_tree);
  colormap = gdk_colormap_get_system();

  dir_tree->show_hidden = TRUE;

  /* Get the local hostname. */
#ifndef G_OS_WIN32
  if ((gethostname (localhost, MAXHOSTNAMELEN) != 0) &&
      (getdomainname (localhost, MAXHOSTNAMELEN) != 0))
    strcpy (localhost, "LocalHost");
#else
    strcpy (localhost, "My PC");
#endif

  dir_tree->local_hostname = g_strdup(localhost);

  gtk_ctree_construct(GTK_CTREE(dir_tree), 1, 0, NULL);
  gtk_clist_set_row_height (GTK_CLIST (dir_tree), 18);

  dir_tree->my_pc=gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap,
                                                       &dir_tree->my_pc_mask,
                                                       NULL,mypc_xpm);
  dir_tree->folder=gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap,
                                                       &dir_tree->folder_mask,
                                                       NULL,folder_xpm);
  dir_tree->ofolder=gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap,
                                                        &dir_tree->ofolder_mask,
                                                        NULL,ofolder_xpm);
  dir_tree->dennied=gdk_pixmap_colormap_create_from_xpm_d(NULL, colormap,
                                                        &dir_tree->dennied_mask,
                                                        NULL,dennied_xpm);

  gtk_clist_set_column_auto_resize(GTK_CLIST(dir_tree),0,TRUE);
  gtk_clist_set_selection_mode(GTK_CLIST(dir_tree),GTK_SELECTION_SINGLE);
  gtk_ctree_set_line_style(GTK_CTREE(dir_tree),GTK_CTREE_LINES_DOTTED);
  
  gtk_signal_connect(GTK_OBJECT(dir_tree),"tree_expand",GTK_SIGNAL_FUNC(expand_tree), NULL);

  mypc_node=gtk_ctree_insert_node(GTK_CTREE(dir_tree),NULL,NULL,&dir_tree->local_hostname,4,dir_tree->my_pc,dir_tree->my_pc_mask,dir_tree->my_pc,dir_tree->my_pc_mask,FALSE,FALSE);

  dirnode=g_malloc0(sizeof(GtkDirTreeNode));
  dirnode->path = dir_tree->local_hostname;
  gtk_ctree_node_set_row_data_full(GTK_CTREE(dir_tree),mypc_node,dirnode,destroy_tree);

#ifndef G_OS_WIN32
  root_node=gtk_ctree_insert_node(GTK_CTREE(dir_tree),mypc_node,NULL,&root_text,4,dir_tree->folder,dir_tree->folder_mask,dir_tree->ofolder,dir_tree->ofolder_mask,FALSE,FALSE);

  dirnode=g_malloc0(sizeof(GtkDirTreeNode));
  dirnode->path=g_strdup(G_DIR_SEPARATOR_S);
  gtk_ctree_node_set_row_data_full(GTK_CTREE(dir_tree),root_node,dirnode,destroy_tree);
  node=gtk_ctree_insert_node(GTK_CTREE(dir_tree),root_node,NULL,&node_text,4,NULL,NULL,NULL,NULL,TRUE,TRUE);
  gtk_ctree_expand(GTK_CTREE(dir_tree),mypc_node);

  gtk_ctree_select(GTK_CTREE(dir_tree),root_node);
#else
  /* On Windoze there isn't one unique root directory "/" but instead
   * there are logical drives a:, c: ... . Insert them into the dir_tree.
   */

  /* Get the Drives string */
  GetLogicalDriveStrings(sizeof(drives), drives);
  drive = drives;
  /* add an entry for every existing drive */
  while (*drive != '\0')
  {
    root_node=gtk_ctree_insert_node(GTK_CTREE(dir_tree),mypc_node,NULL,&drive,4,dir_tree->folder,dir_tree->folder_mask,dir_tree->ofolder,dir_tree->ofolder_mask,FALSE,FALSE);

    dirnode = g_malloc0(sizeof(GtkDirTreeNode));
    dirnode->path = g_strdup(drive);
    gtk_ctree_node_set_row_data_full(GTK_CTREE(dir_tree),root_node,dirnode,destroy_tree);
    node=gtk_ctree_insert_node(GTK_CTREE(dir_tree),root_node,NULL,&node_text, 4,NULL,NULL,NULL,NULL,TRUE,TRUE);
    drive += (strlen(drive) + 1);
  }

  gtk_ctree_expand(GTK_CTREE(dir_tree),mypc_node);
  gtk_ctree_select(GTK_CTREE(dir_tree),mypc_node);
#endif

}
Exemple #19
0
GtkCTreeNode *add_file(char *name, struct site_file *a_file,
		       GtkCTreeNode * parent)
{
/* External icons */
/* dir is closed, dir2 is open */
    extern GdkPixmap *dir, *dir_new, *dir_changed, *dir_del;
    extern GdkPixmap *dir2, *dir2_new, *dir2_changed, *dir2_del;
    extern GdkPixmap *xsitecopy_file, *xsitecopy_file_new, *xsitecopy_file_changed, *xsitecopy_file_del, *xsitecopy_file_moved;
    extern GdkPixmap *symbolic_link, *symbolic_link_new, *symbolic_link_changed, *symbolic_link_del;

    /* Bitmaps */
    extern GdkBitmap *dir_map, *dir_new_map, *dir_changed_map, *dir_del_map;
    extern GdkBitmap *dir2_map, *dir2_new_map, *dir2_changed_map, *dir2_del_map;
    extern GdkBitmap *xsitecopy_file_map, *xsitecopy_file_new_map, *xsitecopy_file_changed_map, *xsitecopy_file_del_map, *xsitecopy_file_moved_map;
    extern GdkBitmap *symbolic_link_map, *symbolic_link_new_map, *symbolic_link_changed_map, *symbolic_link_del_map;

    
    GtkCTreeNode *file_im_adding;
    struct ctree_attachment *file_info_to_add;
    gchar *node_label[1];
    GdkPixmap *image, *image2 = NULL;
    GdkBitmap *mask, *mask2 = NULL;

    file_info_to_add = g_malloc0(sizeof(struct ctree_attachment));
    file_info_to_add->file_or_site = IS_A_FILE;
    /* Pointer to this file */
    file_info_to_add->info_struct = (gpointer) a_file;

    
    /* Check if this file is a symbolic_link or directory */
        
    if (a_file->type == file_link)
      {
	  if (a_file->diff != file_unchanged) 
	    {
		if (a_file->diff == file_changed)
		  {
		      image = symbolic_link_changed;
		      mask = symbolic_link_changed_map;
		  } 
		else if (a_file->diff == file_deleted)
		  {
		      image = symbolic_link_del;
		      mask = symbolic_link_del_map;
		  }
		else 
		  {
		      image = symbolic_link_new;
		      mask = symbolic_link_new_map;
		  }
	    }
	  else 
	    {
		image = symbolic_link; mask = symbolic_link_map;
	    }
      }
    
    /* Check if it's actually a directory */
    else if (a_file->type == file_dir) 
      {
	  if (a_file->diff != file_unchanged) 
	    {
		if (a_file->diff == file_changed)
		  {
		      image = dir_changed;
		      mask = dir_changed_map;
		      image2 = dir2_changed;
		      mask2 = dir2_changed_map;
		  } 
		else if (a_file->diff == file_deleted)
		  {
		      image = dir_del;
		      mask = dir_del_map;
		      image2 = dir2_del;
		      mask2 = dir2_del_map;
		  }
		else 
		  {
		      image = dir_new;
		      mask = dir_new_map;
		      image2 = dir2_new;
		      mask2 = dir2_new_map;
		  }
	    }
	  else 
	    {
		image = dir; mask = dir_map;
		image2 = dir2; mask2 = dir2_map;
	    }
      }

    else
      {
	  
	  /* Set the image of this new file depending upon file status */
	  if (a_file->diff != file_unchanged) 
	    {
		if (a_file->diff == file_changed)
		  {
		      image = xsitecopy_file_changed;
		      mask = xsitecopy_file_changed_map;
		  } 
		else if (a_file->diff == file_deleted)
		  {
		      image = xsitecopy_file_del;
		      mask = xsitecopy_file_del_map;
		  }
		else if (a_file->diff == file_moved)
		  {
		      image = xsitecopy_file_moved;
		      mask = xsitecopy_file_moved_map;
		  }
		else 
		  {
		      image = xsitecopy_file_new;
		      mask = xsitecopy_file_new_map;
		  }
	    }
	  else 
	    {
		image = xsitecopy_file;
		mask = xsitecopy_file_map;
	    }
      }
    
    /* Set the node's text label accordingly */
    node_label[0] = name;

    /* Add the node */
    file_im_adding = gtk_ctree_insert_node(GTK_CTREE(the_tree),
					   GTK_CTREE_NODE(parent),
					   NULL, node_label, 3,
					   image,
					   mask,
					   a_file->type == file_dir ? image2 : image,
					   a_file->type == file_dir ? mask2 : mask,
					   FALSE, FALSE);
    gtk_ctree_node_set_row_data(GTK_CTREE(the_tree), file_im_adding,
				(gpointer) file_info_to_add);
    return file_im_adding;
}
Exemple #20
0
void
set_mboxlist ()
{
    int x;
    mboxs **mboxlist;
    GtkCTree *tree;
    char *read, *unread, *marked, *all;

    mboxlist = (mboxs **) db_read_mboxlist ();
    tree = GTK_CTREE (lookup_widget (gems, "mailboxlist"));
    all = strdup ("all");
    read = strdup ("read");
    unread = strdup ("unread");
    marked = strdup ("marked");

    gtk_clist_freeze (&GTK_CTREE (tree)->clist);
    gtk_clist_clear (&GTK_CTREE (tree)->clist);

    x = 0;
    if(mboxlist) {
	while (mboxlist[x] != NULL)
	{
	    GtkCTreeNode *node, *n;
	    char *text;

	    text = mboxlist[x]->name;
	    node =
		gtk_ctree_insert_node (tree, NULL, NULL, &text, 5, NULL,
			NULL, NULL, NULL, FALSE, FALSE);
	    gtk_ctree_node_set_row_data (tree, node,
		    new_mboxview (mboxlist[x],
			default_mboxlistbehavior));
	    n = gtk_ctree_insert_node (tree, node, NULL, &all, 5, NULL, NULL,
		    NULL, NULL, TRUE, TRUE);
	    gtk_ctree_node_set_row_data (tree, n,
		    new_mboxview (mboxlist[x], DB_ALL));
	    n = gtk_ctree_insert_node (tree, node, NULL, &unread, 5, NULL, NULL,
		    NULL, NULL, TRUE, TRUE);
	    gtk_ctree_node_set_row_data (tree, n,
		    new_mboxview (mboxlist[x], DB_UNREAD));
	    n = gtk_ctree_insert_node (tree, node, NULL, &read, 5, NULL, NULL,
		    NULL, NULL, TRUE, TRUE);
	    gtk_ctree_node_set_row_data (tree, n,
		    new_mboxview (mboxlist[x], DB_READ));
	    n = gtk_ctree_insert_node (tree, node, NULL, &marked, 5, NULL, NULL,
		    NULL, NULL, TRUE, TRUE);
	    gtk_ctree_node_set_row_data (tree, n,
		    new_mboxview (mboxlist[x], DB_MARKED));

	    x++;
	}
	free (mboxlist);
    }

    /*
     * gtk_ctree_select(GTK_CTREE (tree), select_node);
     */
    gtk_clist_thaw (&GTK_CTREE (tree)->clist);
    update_mboxlist (NULL);
    return;
}
Exemple #21
0
/* a mailbox was clicked 
 * TODO: this is called twice on keypress... up and down?
 */
void
on_mailboxlist_tree_select_row (GtkCTree * ctree,
    GList * UNUSED(node), gint UNUSED(column), gpointer UNUSED(user_data))
{
    GtkWidget *mailbox, *stat;
    GtkCTreeNode *n;
    GtkCList *clist;
    GtkWidget *appbar;
    gchar *text[3];
    synopsis **syn;
    int x = 0, mboxcount;
    mboxview *m;

    n = gtk_ctree_node_nth (ctree, (&(ctree->clist))->focus_row);
    m = (mboxview *) gtk_ctree_node_get_row_data (ctree, n);

    if (m == NULL)
    {
	printf (_("Bad mbox (null)\n"));
	exit (-1);
    }
    stat = lookup_widget (gems, "appbar1");
    mailbox = lookup_widget (gems, "mailbox");
    appbar = lookup_widget (gems, "appbar1");

    /*** TODO *** clear the mail things */
    putmail (NULL);

    gnome_appbar_push (GNOME_APPBAR (stat), _("Reading synopsis"));
    while (gtk_events_pending ())
	gtk_main_iteration ();
    syn = (synopsis **) db_read_synopsis (m->mailbox->id, m->status);
    gnome_appbar_pop (GNOME_APPBAR (stat));
    gnome_appbar_push (GNOME_APPBAR (stat), _("Displaying mailbox"));
    while (gtk_events_pending ())
	gtk_main_iteration ();

    clist = &GTK_CTREE (mailbox)->clist;

    gtk_clist_clear (clist);
    while (gtk_events_pending ())
	gtk_main_iteration ();

    gtk_clist_freeze (clist);

    if(syn) {
	mboxcount = 0;
	while (syn[mboxcount] != NULL)
	    mboxcount++;

	while (syn[x] != NULL)
	{
	    GtkCTreeNode *n;

	    text[0] = syn[x]->sender;
	    text[1] = syn[x]->date;
	    text[2] = syn[x]->subject;

	    n = gtk_ctree_insert_node (GTK_CTREE (mailbox), NULL, NULL, text, 5,
		    NULL, NULL, NULL, NULL, TRUE, TRUE);
	    gtk_ctree_node_set_row_data (GTK_CTREE (mailbox), n, syn[x]);

	    gnome_appbar_set_progress (GNOME_APPBAR (appbar),
		    (float)x / (float)mboxcount);
	    /*
	     * pump the status bar 
	     */
	    if (gtk_events_pending ())
		gtk_main_iteration ();

	    x++;
	}
	free (syn);
    }
    gtk_clist_set_sort_column (clist, 1);
    gtk_clist_set_sort_type (clist, GTK_SORT_ASCENDING);
    gtk_clist_sort (clist);
    gtk_clist_thaw (clist);
    update_mboxlist (NULL);
    gnome_appbar_set_progress (GNOME_APPBAR (appbar), 0.0);
    gnome_appbar_pop (GNOME_APPBAR (stat));

    /*
     * gtk_signal_handler_unblock(GTK_OBJECT(ctree), select_row);
     */

}
Exemple #22
0
/* Insert a new node to the tree. The position is specified through the
 * parent-sibling notation, as explained in the introduction above. */
int
clip_GTK_CTREEINSERTNODE(ClipMachine * cm)
{
	C_widget   *cctree = _fetch_cw_arg(cm);
	C_object  *cparent = _fetch_cobject(cm,_clip_spar(cm,2));
	C_object *csibling = _fetch_cobject(cm,_clip_spar(cm,3));
	ClipVar    *cvtext = _clip_spar(cm,4);
	guint8     spacing = _clip_parni(cm,5);
	C_widget  *cclosed = _fetch_cwidget(cm,_clip_spar(cm,6));
	C_widget  *copened = _fetch_cwidget(cm,_clip_spar(cm,7));
	gboolean   is_leaf = _clip_parl(cm,8);
	gboolean  expanded = _clip_parl(cm,9);
	GtkCTreeNode *new_node, *parent=NULL, *sibling=NULL;
	GdkPixmap *pxm_closed=NULL, *pxm_opened=NULL;
	GdkBitmap *mask_closed=NULL, *mask_opened=NULL;
	C_object *cnew_node;
	int i;
	gchar * * columns = NULL;
	int ncolumns;

	CHECKCWID(cctree,GTK_IS_CTREE);
	CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cparent,cparent->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT2(3,MAP_t,NUMERIC_t); CHECKCOBJOPT(csibling,csibling->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT2(4,ARRAY_t,CHARACTER_t); CHECKOPT(5,NUMERIC_t);
	CHECKOPT2(6,MAP_t,NUMERIC_t); CHECKCWIDOPT(cclosed,GTK_IS_PIXMAP);
	CHECKOPT2(7,MAP_t,NUMERIC_t); CHECKCWIDOPT(copened,GTK_IS_PIXMAP);
	CHECKOPT(8,LOGICAL_t); CHECKOPT(9,LOGICAL_t);

	if (cparent) parent = GTK_CTREE_NODE(cparent->object);
	if (csibling) sibling = GTK_CTREE_NODE(csibling->object);
	if (cclosed)
	{
		pxm_closed=GTK_PIXMAP(cclosed->widget)->pixmap;
		mask_closed=GTK_PIXMAP(cclosed->widget)->mask;
	}
	if (copened)
	{
		pxm_opened=GTK_PIXMAP(copened->widget)->pixmap;
		mask_opened=GTK_PIXMAP(copened->widget)->mask;
	}
	if (_clip_parinfo(cm,8)==UNDEF_t) is_leaf = TRUE;
	if (_clip_parinfo(cm,9)==UNDEF_t) expanded = FALSE;

	ncolumns = GTK_CLIST(cctree->widget)->columns;
	columns = (gchar**)calloc(sizeof(columns),ncolumns);
	for(i=0; i < ncolumns; i++ ) columns[i] = "";
	if (cvtext->t.type==ARRAY_t)
	{
		ClipArrVar *acol = (ClipArrVar*)_clip_vptr(cvtext);
		for(i=0; i < acol->count; i++ )
			if ( i < acol->count && acol->items[i].t.type == CHARACTER_t )
				{
				columns[i] = acol->items[i].s.str.buf;
				LOCALE_TO_UTF(columns[i]);
				}
	}
	if (cvtext->t.type==CHARACTER_t)
		{
		columns[0] = _clip_parc(cm,2);
		LOCALE_TO_UTF(columns[0]);
		}

	new_node = gtk_ctree_insert_node(GTK_CTREE(cctree->widget),
		parent,sibling,columns,spacing,pxm_closed,mask_closed,
		pxm_opened,mask_opened,is_leaf,expanded);
	if (new_node)
	{
		cnew_node = _register_object(cm,new_node,GTK_TYPE_CTREE_NODE,NULL,NULL);
		if (cnew_node) _clip_mclone(cm,RETPTR(cm),&cnew_node->obj);
		gtk_ctree_node_set_row_data_full(GTK_CTREE(cctree->widget),
			new_node,cnew_node,(GtkDestroyNotify)destroy_c_object);
	}

#ifdef OS_CYGWIN
	if (cvtext->t.type==ARRAY_t)
	{
		ClipArrVar *acol = (ClipArrVar*)_clip_vptr(cvtext);
		for(i=0; i < acol->count; i++ )
			if ( i < acol->count && acol->items[i].t.type == CHARACTER_t )
				FREE_TEXT(columns[i]);
	}
	if (cvtext->t.type==CHARACTER_t)
		FREE_TEXT(columns[0]);
#endif
	if (columns) free(columns);
	return 0;
err:
	return 1;
}
Exemple #23
0
GtkWidget *
dirtree_new (GtkWidget * win, const gchar * start_path, gboolean check_dir,
	     gboolean check_hlinks, gboolean show_dotfile, gint line_style,
	     gint expander_style)
{
    GtkWidget *widget;
    DirTree *dt;
    DirTreeNode *dt_node;
    GtkCTreeNode *node = NULL;
    char   *root = "/", *rp, *tmp;

    widget = gtk_type_new (dirtree_get_type ());

#ifndef USE_GTK2
    gtk_ctree_construct (GTK_CTREE (widget), 1, 0, NULL);
#endif

    dt = DIRTREE (widget);
    dt->collapse = FALSE;
    dt->check_dir = check_dir;
    dt->check_hlinks = check_hlinks;
    dt->show_dotfile = show_dotfile;
    dt->expander_style = expander_style;
    dt->line_style = line_style;
    dt->check_events = TRUE;

    lock = FALSE;

    gtk_clist_set_column_auto_resize (GTK_CLIST (dt), 0, TRUE);
    gtk_clist_set_selection_mode (GTK_CLIST (dt), GTK_SELECTION_BROWSE);
    gtk_clist_set_row_height (GTK_CLIST (dt), 18);
    gtk_ctree_set_expander_style (GTK_CTREE (dt), expander_style);
    gtk_ctree_set_line_style (GTK_CTREE (dt), line_style);

    folder_pixmap =
	gdk_pixmap_create_from_xpm_d (win->window, &folder_mask, NULL,
				      folder_xpm);
    ofolder_pixmap =
	gdk_pixmap_create_from_xpm_d (win->window, &ofolder_mask, NULL,
				      folder_open_xpm);
    lfolder_pixmap =
	gdk_pixmap_create_from_xpm_d (win->window, &lfolder_mask, NULL,
				      folder_link_xpm);
    lofolder_pixmap =
	gdk_pixmap_create_from_xpm_d (win->window, &lofolder_mask, NULL,
				      folder_link_open_xpm);
    lckfolder_pixmap =
	gdk_pixmap_create_from_xpm_d (win->window, &lckfolder_mask, NULL,
				      folder_lock_xpm);
    gofolder_pixmap =
	gdk_pixmap_create_from_xpm_d (win->window, &gofolder_mask, NULL,
				      folder_go_xpm);
    upfolder_pixmap =
	gdk_pixmap_create_from_xpm_d (win->window, &upfolder_mask, NULL,
				      folder_up_xpm);

    node = gtk_ctree_insert_node (GTK_CTREE (dt),
				  NULL, NULL,
				  &root, CTREE_SPACING,
				  folder_pixmap, folder_mask, ofolder_pixmap,
				  ofolder_mask, FALSE, TRUE);

    dt_node = g_malloc0 (sizeof (DirTreeNode));
    dt_node->path = g_strdup ("/");
    dt_node->scanned = TRUE;
    gtk_ctree_node_set_row_data_full (GTK_CTREE (dt), node, dt_node,
				      dirtree_destroy_tree);

    tree_expand_node (dt, node, FALSE);

    rp = g_strdup (start_path);
    tmp = strtok (rp, "/");

    while (tmp)
    {
	node = dirtree_find_file (dt, node, tmp);

	if (!node)
	    break;

	gtk_ctree_expand (GTK_CTREE (dt), node);
	gtk_ctree_select (GTK_CTREE (dt), node);
	GTK_CLIST (dt)->focus_row =
	    GTK_CLIST (dt)->rows - g_list_length ((GList *) node);

	tmp = strtok (NULL, "/");
    }

    g_free (rp);

    return widget;
}