예제 #1
0
static gboolean
clist_row_is_selected(GtkCList *clist, int row)
{
	const GList *node;

	g_return_val_if_fail(clist, FALSE);
	g_return_val_if_fail(row >= 0, FALSE);
	g_return_val_if_fail(row < clist->rows, FALSE);

	node = g_list_nth(clist->row_list, row);
	g_return_val_if_fail(node, FALSE);

	return GTK_STATE_SELECTED == GTK_CLIST_ROW(node)->state;
}
static int
find_row (const char *name)
{
  GList *tmp_list = GTK_CLIST (settings_clist)->row_list;
  int index = 0;
  
  while (tmp_list)
    {
      GtkCListRow *row = GTK_CLIST_ROW (tmp_list);

      if (strcmp (row->data, name) == 0)
	return index;
	
      tmp_list = tmp_list->next;
      index++;
    }

  return -1;
}
예제 #3
0
void FileSelector::AddEvent()
{
    GtkFileSelection *gfile = GTK_FILE_SELECTION(filesel);
    char *raw_path = NULL;
    GList *row = GTK_CLIST(gfile->file_list)->row_list;
    gint rownum = 0;
    gint sub_rnum = 0;
    char *temp, *path_temp;

    char *rawtext = gtk_entry_get_text(GTK_ENTRY(gfile->selection_entry));
    if (!strncasecmp("http://", rawtext, 7) ||
        !strncasecmp("rtp://", rawtext, 6)) {
        returnpath = strdup_new(rawtext);
        gtk_widget_destroy(GTK_WIDGET(gfile));
        ok = true;
        done = true;

        return;
    }

    returnpath = gtk_file_selection_get_filename(gfile);
    path_temp = strdup(returnpath.c_str());
    raw_path = 	gtk_entry_get_text(GTK_ENTRY(gfile->selection_entry));
    char *tempdir = strrchr(path_temp, '/');
    strncpy(old_path,path_temp,PATH_MAX);
    if (!tempdir) {
        strcpy(path_temp, "./");
        path_temp = (char *)realloc(path_temp, strlen(path_temp) + 1);
    }
    else
        tempdir[0] = '\0';
    if(row){
	while (row) {
    	    if (GTK_CLIST_ROW(row)->state == GTK_STATE_SELECTED) {
        	if (gtk_clist_get_cell_type(GTK_CLIST(gfile->file_list), rownum, 0)
            	    == GTK_CELL_TEXT) {
            	    gtk_clist_get_text(GTK_CLIST(gfile->file_list), rownum, 0, &temp);
		    if (!strcmp(temp, raw_path))
                	goto next_iter;
		    returnpath += "\n";
            	    returnpath += path_temp;
            	    returnpath += "/";
            	    returnpath += temp;
        	}
    	    }
	    next_iter:
    	    rownum++;
    	    row = g_list_next(row);
	}
    } 
    else {
	char subdirs[PATH_MAX];
	strncpy(subdirs,old_path,PATH_MAX);
	returnpath="";
	returnpath = recursive_path(subdirs, returnpath,&sub_rnum);
    }
    rownum += sub_rnum;
    gtk_widget_destroy(GTK_WIDGET(gfile));
    free(path_temp);

    ok = true;
    done = true;
}