Exemplo n.º 1
0
Arquivo: xqf-ui.c Projeto: IR4T4/xqf
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);
}
Exemplo n.º 2
0
Arquivo: xqf-ui.c Projeto: IR4T4/xqf
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);
				}
			}
		}
	}
}
Exemplo n.º 3
0
static void icon_selected (MimeView *mimeview, gint num, MimeInfo *partinfo)
{
	GtkCTreeNode *node;
	node = gtk_ctree_find_by_row_data(GTK_CTREE(mimeview->ctree), NULL, partinfo);
	if (node)
		gtk_ctree_select(GTK_CTREE(mimeview->ctree), node);
}		
Exemplo n.º 4
0
Arquivo: xqf-ui.c Projeto: IR4T4/xqf
//static void source_ctree_remove_master_group (GtkWidget *ctree,
void source_ctree_remove_master_group (GtkWidget *ctree, struct master *m) {
	GtkCTreeNode *node;

	if (!m->isgroup)
		return;

	node = gtk_ctree_find_by_row_data (GTK_CTREE (ctree), NULL, m);
	if (node) {
		gtk_ctree_remove_node (GTK_CTREE (ctree), node);
	}
}
Exemplo n.º 5
0
Arquivo: xqf-ui.c Projeto: IR4T4/xqf
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);
}
Exemplo n.º 6
0
Arquivo: xqf-ui.c Projeto: IR4T4/xqf
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);
}
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 );
}
Exemplo n.º 8
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;
    }
}
Exemplo n.º 9
0
Arquivo: xqf-ui.c Projeto: IR4T4/xqf
void source_ctree_delete_master (GtkWidget *ctree, struct master *m) {
	GtkCTreeNode *node;
	struct master *group;

	node = gtk_ctree_find_by_row_data (GTK_CTREE (ctree), NULL, m);
	if (!node)
		return;

	gtk_ctree_remove_node (GTK_CTREE (ctree), node);

	/* Remove empty master group from the tree */

	if (m->type != UNKNOWN_SERVER) {
		group = (struct master *) g_slist_nth_data (master_groups, m->type);
		if (group && (group->masters == NULL || (g_slist_length (group->masters) == 1 && group->masters->data == m))) {
			source_ctree_remove_master_group (ctree, group);
		}
	}
}
Exemplo n.º 10
0
Arquivo: xqf-ui.c Projeto: 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);
}
Exemplo n.º 11
0
Arquivo: xqf-ui.c Projeto: 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);
				}
			}
		}
	}
}
Exemplo n.º 12
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;
  }
}