Esempio n. 1
0
void ShowPlayList( void )
{
 if ( PlayList ) gtkActive( PlayList );
  else PlayList=create_PlayList();

 if ( old_path && *old_path )
  {
   char         * currentdir = strdup( old_path );
   char         * tpath,* pos;
   GtkCTreeNode * node,* nextnode;
   gboolean       leaf;
   tpath=strdup( "/" );
   pos=strtok( currentdir,"/" );
   node=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),NULL,"/",compare_func );
   do
    {
     char * tpathnew = g_strconcat( tpath,pos,"/",NULL );
     free( tpath ); tpath=tpathnew;
     nextnode=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),node,tpath,compare_func );
     if ( !nextnode ) break;
     node=nextnode;
     pos=strtok( NULL,"/" );
     gtk_ctree_get_node_info( GTK_CTREE( CTDirTree ),node,NULL,NULL,NULL,NULL,NULL,NULL,&leaf,NULL );
     if ( !leaf && pos ) gtk_ctree_expand( GTK_CTREE( CTDirTree ),node );
      else
       {
        DirNodeType * DirNode;
        gtk_ctree_select( GTK_CTREE( CTDirTree ),node );
	DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( CTDirTree ),node );
	current_path=DirNode->path;
        scan_dir( DirNode->path );
        if ( CLFileSelected ) free( CLFileSelected ); CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) );
	break;
       }
    } while( pos );
   free( tpath );
   free( currentdir );
  }
  else gtk_ctree_select( GTK_CTREE( CTDirTree ),parent );

 gtk_clist_freeze( GTK_CLIST( CLSelected ) );
 gtk_clist_clear( GTK_CLIST( CLSelected ) );
 if ( plList )
  {
   plItem * next = plList;
   while ( next || next->next )
    {
     char * text[1][3]; text[0][2]="";
     text[0][0]=next->name;
     text[0][1]=next->path;
     gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
     NrOfSelected++;
     if ( next->next ) next=next->next; else break;
    }
   CLListSelected=calloc( 1,NrOfSelected * sizeof( int ) );
  }
 gtk_clist_thaw( GTK_CLIST( CLSelected ) );

 gtk_widget_show( PlayList );
}
Esempio n. 2
0
File: xqf-ui.c Progetto: IR4T4/xqf
void source_ctree_show_node_status (GtkWidget *ctree, struct master *m) {
	GtkCTreeNode *node;
	struct pixmap *pix = NULL;
	int is_leaf;
	int expanded;

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

	if (m->isgroup || m == favorites) {
		pix = games[m->type].pix;
	}
	else {
		pix = &server_status[m->state];
	}

	gtk_ctree_get_node_info (GTK_CTREE (ctree), node, NULL, NULL, NULL, NULL, NULL, NULL, &is_leaf, &expanded);

	gtk_ctree_set_node_info (GTK_CTREE (ctree), node, _(m->name), 4,
			(pix)? pix->pix : NULL, (pix)? pix->mask : NULL,
			(pix)? pix->pix : NULL, (pix)? pix->mask : NULL,
			is_leaf, expanded);
}
Esempio n. 3
0
File: xqf-ui.c Progetto: IR4T4/xqf
void ui_done (void) {
	GtkCTreeNode *node;
	char cfgkey[128];
	int expanded;
	GSList *list;
	struct master *m;

	save_cwidget_geometry (GTK_WIDGET (server_clist), &server_clist_def);
	save_cwidget_geometry (GTK_WIDGET (player_clist), &player_clist_def);
	save_cwidget_geometry (GTK_WIDGET (srvinf_ctree), &srvinf_clist_def);

	config_push_prefix ("/" CONFIG_FILE "/Main Window Geometry/");

	config_set_int ("height", main_window->allocation.height);
	config_set_int ("width", main_window->allocation.width);
	config_set_int ("pane1", GTK_PANED (pane1_widget)->child1->allocation.width);
	config_set_int ("pane2", GTK_PANED (pane2_widget)->child1->allocation.height);
	config_set_int ("pane3", GTK_PANED (pane3_widget)->child1->allocation.width);

	config_pop_prefix ();

	config_clean_section ("/" CONFIG_FILE "/Source Tree");

	for (list = master_groups; list; list = list->next) {
		m = (struct master *) list->data;
		if (m->isgroup) {
			node = gtk_ctree_find_by_row_data (GTK_CTREE (source_ctree), NULL, m);
			if (node) {
				gtk_ctree_get_node_info (GTK_CTREE (source_ctree), node,
						NULL, NULL, NULL, NULL, NULL, NULL, NULL, &expanded);
				if (!expanded) {
					g_snprintf (cfgkey, 128, "/" CONFIG_FILE "/Source Tree/%s node collapsed=false", m->name);
					config_set_bool (cfgkey, TRUE - expanded);
				}
			}
		}
	}
}
Esempio n. 4
0
int
clip_GTK_CTREENODEGETTEXT(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);
	gint nColumns;
	CHECKCWID(cctree,GTK_IS_CTREE);
	CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cnode,cnode->type==GTK_TYPE_CTREE_NODE);
	CHECKOPT(3,NUMERIC_t);
	nColumns = GTK_CLIST(cctree->widget)->columns;
	if (_clip_parinfo(cm,3)==UNDEF_t) column = 1;
	if (column==1)
	{
		gchar **text = calloc(nColumns, sizeof(gchar*));

		if (gtk_ctree_get_node_info (GTK_CTREE(cctree->widget),
			GTK_CTREE_NODE(cnode->object), text, 0,0,0,0,0,0,0))
		LOCALE_TO_UTF(*text);
		_clip_retc(cm, text[column-1]);
		FREE_TEXT(*text);
		free(text);
	}
	else
	{
		gchar *text;
		gtk_ctree_node_get_text(GTK_CTREE(cctree->widget),
			GTK_CTREE_NODE(cnode->object), column-1, &text);
		LOCALE_FROM_UTF(text);
		if (text) _clip_retc(cm, text);
		FREE_TEXT(text);
	}
	return 0;
err:
	return 1;
}
Esempio n. 5
0
/* Get information corresponding to a node. Any of the return parameters can be null. */
int
clip_GTK_CTREENODEGETNODEINFO(ClipMachine * cm)
{
	C_widget   *cctree = _fetch_cw_arg(cm);
	C_object    *cnode = _fetch_cobject(cm,_clip_spar(cm,2));
	ClipVar    *minfo = RETPTR(cm);
	guint8     spacing;
	C_widget  *cclosed;
	C_widget  *copened;
	gboolean   is_leaf;
	gboolean  expanded;
	GdkPixmap *pxm_closed=NULL, *pxm_opened=NULL;
	GdkBitmap *mask_closed=NULL, *mask_opened=NULL;
	long i;
	gchar * * text;
	long ncolumns;

	CHECKCWID(cctree,GTK_IS_CTREE);
	CHECKOPT2(2,MAP_t,NUMERIC_t); CHECKCOBJOPT(cnode,cnode->type==GTK_TYPE_CTREE_NODE);

	ncolumns = GTK_CLIST(cctree->widget)->columns;
	text = calloc(ncolumns, sizeof(gchar*));
	if (gtk_ctree_get_node_info(GTK_CTREE(cctree->widget),
		GTK_CTREE_NODE(cnode->object),text,&spacing,&pxm_closed,&mask_closed,
		&pxm_opened,&mask_opened,&is_leaf,&expanded))
	{
		ClipVar *a = NEW(ClipVar);
		ClipVar cv;
		cv.t.type = CHARACTER_t;

		_clip_array(cm, a, 1, &ncolumns);

		for (i=0; i<ncolumns; i++)
		{
			gtk_ctree_node_get_text(GTK_CTREE(cctree->widget),
				GTK_CTREE_NODE(cnode->object), i, text);
#ifdef OS_CYGWIN
			cv.s.str.buf = _clip_locale_from_utf8(text[0]);
			cv.s.str.len = strlen(cv.s.str.buf);
#else
			cv.s.str.len = strlen(text[0]);
			cv.s.str.buf = (gchar*)calloc(1, cv.s.str.len+1);
			strcpy(cv.s.str.buf, text[0]);
#endif
			_clip_aset(cm, a, &cv, 1, &i);
			_clip_destroy(cm,&cv);
		}

		memset(minfo,0,sizeof(*minfo)); _clip_map(cm,minfo);

		if (pxm_closed)
		{
			cclosed = _list_get_cwidget_by_data(cm,pxm_closed);
			if (!cclosed) cclosed = _register_widget(cm,gtk_pixmap_new(pxm_closed,mask_closed),NULL);
			if (cclosed) _clip_madd(cm, minfo, HASH_PIXMAPCLOSED,&cclosed->obj);
		}

		if (pxm_opened)
		{
			copened = _list_get_cwidget_by_data(cm,pxm_opened);
			if (!copened) copened = _register_widget(cm,gtk_pixmap_new(pxm_opened,mask_opened),NULL);
			if (copened) _clip_madd(cm, minfo, HASH_PIXMAPOPENED,&copened->obj);
		}

		_clip_madd(cm, minfo, HASH_TEXT, a);

		_clip_mputn(cm, minfo, HASH_SPACING, spacing);
		_clip_mputl(cm, minfo, HASH_ISLEAF, is_leaf);
		_clip_mputl(cm, minfo, HASH_EXPANDED, expanded);
		free(a);
	}
	if (text) free(text);

	return 0;
err:
	return 1;
}
Esempio n. 6
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;
}