Пример #1
0
gboolean getNode(GtkTreeModel *model,GtkTreePath *path,GtkTreeIter *iter,gpointer data)
{
	char*	name=NULL;
	char*	thispath=NULL;
	bool	retval=false;

	thispath=gtk_tree_path_to_string(path);
	if(node!=NULL && thispath!=NULL)
		{
			if((strlen(thispath)<strlen(node)) || (strcmp(thispath,node)==0))
				{
					debugFree(&thispath);
					return(false);
				}
		}

	gtk_tree_model_get(model,iter,COLUMN_FILENAME,&name,-1);
	if(name!=NULL)
		{
			if(strcmp(name,(char*)data)==0)
				{
					debugFree(&node);
					node=gtk_tree_path_to_string(path);
					gtk_tree_view_expand_row((GtkTreeView*)treeview,path,false);
					retval=true;
				}
			debugFree(&name);
		}
	debugFree(&thispath);
	return(retval);
}
Пример #2
0
void
tabu_playlist_remove_selection (TabuPlaylist *playlist)
{
  GtkTreeModel *store;
  GtkTreeIter iter;
  GtkTreePath *path;
  GList *selected;
  GList *references = NULL;
  GtkTreeSelection *selection;
  
  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (TABU_PLAYLIST (playlist)->tree_view));

  selected = gtk_tree_selection_get_selected_rows ( selection, &store );
  while (selected != NULL)
  {
    references = g_list_append ( references, gtk_tree_row_reference_new (store, selected->data));
    selected = g_list_next ( selected );
  }

  references = g_list_first (references);
  while (references != NULL)
  {
    path = gtk_tree_row_reference_get_path (references->data);

    if (tabu_backend_is_playing())
    {
      GtkTreePath *song_path = gtk_tree_row_reference_get_path (TABU_PLAYLIST (playlist)->reference);
  
      if (!strcmp(gtk_tree_path_to_string(path),gtk_tree_path_to_string(song_path)))
      {
        tabu_backend_stop();        
        TABU_PLAYLIST(playlist)->reference = NULL;
      }     
    }

    /* ok, now remove the song from the playlist */
    if (gtk_tree_model_get_iter (GTK_TREE_MODEL (store), &iter, path))
    {
      gtk_list_store_remove (GTK_LIST_STORE (store), &iter );    
    }
    
    gtk_tree_path_free (path);    
    references = g_list_next ( references );
  }

  g_list_foreach (references, (GFunc)gtk_tree_row_reference_free, NULL);
  g_list_free (references);

  g_list_foreach (selected, (GFunc) gtk_tree_path_free, NULL);
  g_list_free (selected);
}
Пример #3
0
static void
tree_selection_changed_cb (GtkTreeSelection *selection, gpointer data)
{
  StatisticViewerData *statistic_viewer_data = (StatisticViewerData*)data;
  GtkTreeIter iter;
  GtkTreeModel *model = GTK_TREE_MODEL(statistic_viewer_data->store_m);
  gchar *event;
  GtkTextBuffer* buf;
  gchar * str;
  GtkTreePath * path;
  GtkTextIter   text_iter;
  LttvAttribute * stats;

  if (gtk_tree_selection_get_selected (selection, &model, &iter))
    {
      gtk_tree_model_get (model, &iter, NAME_COLUMN, &event, -1);

      path = gtk_tree_model_get_path(GTK_TREE_MODEL(model),&iter);
      str = gtk_tree_path_to_string (path);
      stats = (LttvAttribute*)g_hash_table_lookup (statistic_viewer_data->statistic_hash,str);
      g_free(str);
      
      buf =  gtk_text_view_get_buffer((GtkTextView*)statistic_viewer_data->text_v);
      gtk_text_buffer_set_text(buf,"Statistic for  '", -1);
      gtk_text_buffer_get_end_iter(buf, &text_iter);
      gtk_text_buffer_insert(buf, &text_iter, event, strlen(event));      
      gtk_text_buffer_get_end_iter(buf, &text_iter);
      gtk_text_buffer_insert(buf, &text_iter, "' :\n\n",5);
      
      show_statistic(statistic_viewer_data, stats, buf);

      g_free (event);
    }
}
void SludgeProjectManager::on_remove_file_clicked()
{
	GList * selectedRows;
	GtkTreeIter iter;
	GtkTreePath *path;
	GtkTreeModel *model;
	gchar *indexStr;
	int index;

	if (! askAQuestion("Remove files?", "Do you want to remove the selected files from the project? (They will not be deleted from the disk.)")) {
		return;
	}

	selectedRows = gtk_tree_selection_get_selected_rows(filesSelection, &model);

	for (int j = g_list_length(selectedRows) - 1; j >= 0; j--)
	{
		path = gtk_tree_model_sort_convert_path_to_child_path(
					GTK_TREE_MODEL_SORT(model),
					(GtkTreePath *)g_list_nth(selectedRows, j)->data);

		indexStr = gtk_tree_path_to_string(path);
		index = atoi(indexStr);
        g_free(indexStr);

		removeFileFromList(index, fileList, &fileListNum);
		setFileChanged();

		gtk_tree_model_get_iter(GTK_TREE_MODEL(filesListStore), &iter, path);
		gtk_list_store_remove(filesListStore, &iter);
    }
	g_list_foreach(selectedRows, (GFunc) gtk_tree_path_free, NULL);
	g_list_free(selectedRows);
}
Пример #5
0
static void _lib_keywords_drag_data_get_callback(GtkWidget *w,
    GdkDragContext *dctx,
    GtkSelectionData *data,
    guint info,
    guint time,
    gpointer user_data)
{
  dt_lib_module_t *self = (dt_lib_module_t *)user_data;
  dt_lib_keywords_t *d = (dt_lib_keywords_t*)self->data;

  /* get iter of item to drag to ssetup drag data */
  GtkTreeIter iter;
  GtkTreeModel *model = NULL;
  GtkTreeSelection *s = gtk_tree_view_get_selection(d->view);

  if (gtk_tree_selection_get_selected(s,&model,&iter))
  {

    /* get tree path as string out of iter into selection data */
    GtkTreePath *path = NULL;
    path = gtk_tree_model_get_path(model,&iter);
    gchar *sp = gtk_tree_path_to_string(path);

    gtk_selection_data_set(data,data->target, 8, (const guchar *)sp, strlen(sp));
  }

}
Пример #6
0
/*****************************************************************************************
 *  Add a FileInfo to the parent node to the proper position.
 *  tree_path is the tree path of the parent node.
 * 
 ****************************************************************************************/
GList *fm_dir_tree_model_insert_file_info (FmDirTreeModel *dir_tree_model, GList *parent_node,
                                           GtkTreePath *tree_path, FmFileInfo *file_info)
{
    FmDirTreeItem *parent_item = (FmDirTreeItem*) parent_node->data;
    
    FmDirTreeItem *dir_tree_item = fm_dir_tree_item_new (dir_tree_model, parent_node, file_info);

    // Don't show hidden files...
    if (!dir_tree_model->show_hidden && file_info->path->name[0] == '.')
    {
        parent_item->hidden_children = g_list_prepend (parent_item->hidden_children, dir_tree_item);
        return parent_item->hidden_children;
    }
    
    // Don't show links...
    if (!dir_tree_model->show_symlinks && fm_file_info_is_symlink (file_info))
    {
        parent_item->hidden_children = g_list_prepend (parent_item->hidden_children, dir_tree_item);
        return parent_item->hidden_children;
    }
    
    GList *item_list = fm_dir_tree_model_insert_sorted (dir_tree_model, parent_node, tree_path, dir_tree_item);
    
    char *tmp_path = gtk_tree_path_to_string (tree_path);
    TREEVIEW_DEBUG ("TREEVIEW_DEBUG: fm_dir_tree_model_insert_file_info: file = %s\t index = %d\n\n",
                    fm_file_info_get_name (file_info), file_info->sorting_index);
    g_free (tmp_path);
    
    return item_list;
}
Пример #7
0
/******************************************************************************
* gtk_ListStoreInsert(list, position, ncol, val, ....) -->path_string
******************************************************************************/
int
clip_GTK_LISTSTOREINSERT(ClipMachine * cm)
{

	C_object *cslist = _fetch_co_arg(cm);
        gint    position = _clip_parni(cm, 2);
        GtkTreeIter iter;
        GtkTreePath *path;
        gchar *path_string;

        CHECKARG2(1, MAP_t, NUMERIC_t); CHECKCOBJ(cslist, GTK_IS_LIST_STORE(cslist->object));
        CHECKARG(2, NUMERIC_t);

	gtk_list_store_insert(GTK_LIST_STORE(cslist->object), &iter, position);

        __list_store_set(cm, &iter, 3);

        path = gtk_tree_model_get_path(GTK_TREE_MODEL(GTK_LIST_STORE(cslist->object)),
        	&iter);

        path_string = gtk_tree_path_to_string(path);

        _clip_retc(cm, path_string);

	g_free(path_string);

	return 0;
err:
	return 1;
}
Пример #8
0
/*
 * Convert a model/owner pair into a gtk_tree_model_path.  This
 * routine should only be called from the file
 * gnc-tree-view-owner.c.
 */
GtkTreePath *
gnc_tree_model_owner_get_path_from_owner (GncTreeModelOwner *model,
        GncOwner *owner)
{
    GtkTreeIter tree_iter;
    GtkTreePath *tree_path;

    ENTER("model %p, owner %p", model, owner);
    gnc_leave_return_val_if_fail (GNC_IS_TREE_MODEL_OWNER (model), NULL);
    gnc_leave_return_val_if_fail (owner != NULL, NULL);

    if (!gnc_tree_model_owner_get_iter_from_owner (model, owner,
            &tree_iter))
    {
        LEAVE("no iter");
        return NULL;
    }

    tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
    if (tree_path)
    {
        gchar *path_string = gtk_tree_path_to_string(tree_path);
        LEAVE("path (2) %s", path_string);
        g_free(path_string);
    }
    else
    {
        LEAVE("no path");
    }
    return tree_path;
}
Пример #9
0
int
clip_GTK_LISTSTOREAPPEND(ClipMachine * cm)
{
	C_object *cslist = _fetch_co_arg(cm);
        GtkTreeIter iter;
        GtkTreePath *path;
        gchar *path_string;

        CHECKCOBJ(cslist, GTK_IS_LIST_STORE(cslist->object));


        gtk_list_store_append(GTK_LIST_STORE(cslist->object), &iter);

	__list_store_set(cm, &iter, 2);

        path = gtk_tree_model_get_path(GTK_TREE_MODEL(GTK_LIST_STORE(cslist->object)),
        	&iter);

        path_string = gtk_tree_path_to_string(path);

        _clip_retc(cm, path_string);


	g_free(path_string);

	return 0;
err:
	return 1;
}
Пример #10
0
/* Given a drop path retrieved by gtk_tree_view_get_dest_row_at_pos, this function
 * determines whether dropping a bookmark item at the specified path is allow.
 * If dropping is not allowed, this function tries to choose an alternative position
 * for the bookmark item and modified the tree path @tp passed into this function. */
static gboolean get_bookmark_drag_dest(FmPlacesView* view, GtkTreePath** tp, GtkTreeViewDropPosition* pos)
{
    gboolean ret = TRUE;
    if(*tp)
    {
        /* if the drop site is below the separator (in the bookmark area) */
        if(fm_places_model_path_is_bookmark(FM_PLACES_MODEL(model), *tp))
        {
            /* we cannot drop into a item */
            if(*pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE ||
               *pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER)
                ret = FALSE;
            else
                ret = TRUE;
        }
        else /* the drop site is above the separator (in the places area containing volumes) */
        {
            const GtkTreePath* sep = fm_places_model_get_separator_path(FM_PLACES_MODEL(model));
            /* set drop site at the first bookmark item */
            gtk_tree_path_get_indices(*tp)[0] = gtk_tree_path_get_indices(sep)[0] + 1;
            *pos = GTK_TREE_VIEW_DROP_BEFORE;
            ret = TRUE;
        }
    }
    else
    {
        /* drop at end of the bookmarks list instead */
        *tp = gtk_tree_path_new_from_indices(gtk_tree_model_iter_n_children(GTK_TREE_MODEL(model), NULL) - 1, -1);
        *pos = GTK_TREE_VIEW_DROP_AFTER;
        ret = TRUE;
    }
    g_debug("path: %s", gtk_tree_path_to_string(*tp));
    return ret;
}
Пример #11
0
/**
 * trace_view_get_selected_row - return the selected row
 * @treeview: The tree view
 *
 * Returns the selected row number (or -1 if none is selected)
 */
gint trace_view_get_selected_row(GtkWidget *treeview)
{
	GtkTreeView *tree = GTK_TREE_VIEW(treeview);
	GtkTreeSelection *selection;
	GtkTreeModel *model;
	GtkTreePath *path;
	gchar *spath;
	GList *glist;
	gint row;

	model = gtk_tree_view_get_model(tree);
	if (!model)
		return -1;

	selection = gtk_tree_view_get_selection(tree);
	glist = gtk_tree_selection_get_selected_rows(selection, &model);
	if (!glist)
		return -1;

	/* Only one row may be selected */
	path = glist->data;
	spath = gtk_tree_path_to_string(path);
	row = atoi(spath);
	g_free(spath);

	gtk_tree_path_free(path);
	g_list_free(glist);

	return row;
}
Пример #12
0
void print_tree_selection(GtkTreeModel *model,
                          GtkTreePath *path,
                          GtkTreeIter *iter,
                          gpointer data)
{
    gint columns = gtk_tree_model_get_n_columns(model);

    // Print the path of the selection
    g_printf("\t%s", gtk_tree_path_to_string(path));

    // Print all the text columns
    for (gint i = 0; i < columns; ++i) {
        GValue value = {0};
        GValue str_value = {0};

        gtk_tree_model_get_value(model, iter, i, &value);
        g_value_init(&str_value, G_TYPE_STRING);
        if (g_value_type_transformable(G_VALUE_TYPE(&value), G_TYPE_STRING)) {
            g_value_transform(&value, &str_value);
            g_printf("\t%s", g_value_get_string(&str_value));
        }

        g_value_unset(&value);
    }
}
Пример #13
0
void saa_tree_view_row_activated(SaaTreeView * tv, GtkTreePath * path, GtkTreeViewColumn * column, gpointer user_data) {
	gchar * spath = gtk_tree_path_to_string(path);
	gchar ** splited = g_strsplit(spath, ":", -1);
	int ind1, ind2;

	g_return_if_fail(splited[1]);

	ind1 = atoi(splited[0]);
	ind2 = atoi(splited[1]);
	g_free(spath);
	g_strfreev(splited);

	//g_debug("row_activated %d %d", ind1, ind2);

	switch(ind1) {
	case 0:
		g_signal_emit (G_OBJECT (tv), tree_view_signals[VERTEX_SELECTED_SIGNAL], 0, tv->visuel->solide->lesSommets[ind2]);
		break;
	case 1:
		g_signal_emit (G_OBJECT (tv), tree_view_signals[EDGE_SELECTED_SIGNAL], 0, tv->visuel->solide->lesAretes[ind2]);
		break;
	case 2:
		g_signal_emit (G_OBJECT (tv), tree_view_signals[WING_SELECTED_SIGNAL], 0, tv->visuel->solide->lesAiles[ind2]);
		break;
	}
}
Пример #14
0
static void ListView_activate(GtkTreeView* treeView, GtkTreePath* path, GtkTreeViewColumn* column, ListView* self) {
  char* pathname = gtk_tree_path_to_string(path);
  unsigned selection = decimal(pathname);
  g_free(pathname);
  self->state.selection = selection;
  if(self->onActivate) self->onActivate();
}
Пример #15
0
static void open_dir(GtkTreeView       *tree_view,
		     GtkTreePath       *path,
		     GtkTreeViewColumn *column,
		     gpointer	       user_data)
{
	GtkTreeIter iter;
	GtkTreeModel *model;
	char *dir, *url;

	model = gtk_tree_view_get_model(tree_view);

	if (!gtk_tree_model_get_iter(model, &iter, path)) {
		char *p;
		p = gtk_tree_path_to_string(path);
		g_warning("Cannot get iter for path '%s'\n", p);
		g_free(p);
		return;
	}

	gtk_tree_model_get(model, &iter, DISK_DIR, &dir, -1);

	url = g_strdup_printf("file://%s", dir);

	GError* error = 0;
	if (!g_app_info_launch_default_for_uri(url, NULL, &error)) {
		g_warning("Cannot open '%s' : %s\n", url, error->message);
		g_error_free(error);
	}

	g_free(url);
	g_free(dir);
}
Пример #16
0
gboolean GN_tree_view_get_selected(int ARI, ei_x_buff *XBUF, char *B, int *I){
  GtkTreeView *tv;
  GtkTreeSelection *selection;
  GtkTreeModel *model;
  gchar* path;

  if ( ! gn_check_arity(XBUF, 1, ARI) )
    return FALSE;
  if ( ! gn_get_arg_object(XBUF, B, I, GTK_TYPE_TREE_VIEW, (GObject**)&tv) )
    return FALSE;

  model = gtk_tree_view_get_model(tv);
  selection = gtk_tree_view_get_selection(tv);

  GList* list = gtk_tree_selection_get_selected_rows(selection, &model);

  gn_wrap_reply("ok", XBUF);

  while ( list ) {
    path = gtk_tree_path_to_string( (GtkTreePath*) list->data);
    g_assert( ! ei_x_encode_list_header(XBUF, 1) );
    g_assert( ! ei_x_encode_string(XBUF, path) );
    g_free(path);
    list = list->next;
  }
  g_list_free(list);
  g_assert( ! ei_x_encode_empty_list(XBUF));
  return TRUE;
}
Пример #17
0
gboolean replay_message_tree_set_recv_event(ReplayMessageTree *self,
                                         GtkTreeIter *iter,
                                         GtkTreePath *recv_list_path)
{
  ReplayMessageTreePrivate *priv;
  ReplayMessageTreeEntry *entry;

  g_return_val_if_fail(REPLAY_IS_MESSAGE_TREE(self), FALSE);

  priv = self->priv;

  g_return_val_if_fail(priv->stamp == iter->stamp, FALSE);

  entry = (ReplayMessageTreeEntry *)(iter->user_data);

  if (recv_list_path &&
      (entry->recv_iter_set =
       gtk_tree_model_get_iter(GTK_TREE_MODEL(priv->event_store),
                               &(entry->recv_list_iter),
                               recv_list_path)))
  {
    gchar *path_string = gtk_tree_path_to_string(recv_list_path);
    g_hash_table_insert(priv->path_table,
                        path_string,
                        entry);
  }
  return entry->recv_iter_set;
}
Пример #18
0
static VALUE
rg_to_str(VALUE self)
{
    gchar* s = gtk_tree_path_to_string(_SELF(self));
    VALUE result = CSTR2RVAL(s);
    g_free(s);
    return result;
}
Пример #19
0
/*#
    @method to_string GtkTreePath
    @brief Generates a string representation of the path.
    @return a string

    This string is a ':' separated list of numbers.
    For example, "4:10:0:3" would be an acceptable return value for this string.
 */
FALCON_FUNC TreePath::to_string( VMARG )
{
    NO_ARGS
    MYSELF;
    gchar* s = gtk_tree_path_to_string( self->getTreePath() );
    vm->retval( UTF8String( s ) );
    g_free( s );
}
Пример #20
0
void collapseRow(GtkTreeView* treeview,GtkTreeIter* iter,GtkTreePath* path,gpointer user_data)
{
	char*	pathstring=gtk_tree_path_to_string(path);

	if(strcmp(pathstring,"0")==0)
		flag=false;
	debugFree(&pathstring);
}
Пример #21
0
gboolean table_check_func (GtkTreeModel *model, GtkTreePath *path,
                           GtkTreeIter *iter, gpointer user_data)
{
  gchar *description, *icon, *params;
  gchar *tree_path_str;
  gboolean has_child;
  gint depth;

  gtk_tree_model_get (model, iter,
                      COL_DESCRIPTION, &description,
                      COL_ICONNAME, &icon,
                      COL_PARAMS, &params,
                      -1);

  tree_path_str = gtk_tree_path_to_string(path);

  has_child = gtk_tree_model_iter_has_child (model, iter);
  depth = gtk_tree_path_get_depth (path) - 1;

  gv.app_errno = 0;
  strcpy (gv.app_errno_str, "");

  if (depth + 1 >= MAX_RECURSION)
  {
    g_print ("maximum menu recursion reached! -> %d\n", MAX_RECURSION);
    return TRUE;
  }

  if (depth > 0)
  {
    if (has_child)
    {
      /* some checks for submenus */
      if (!strcmp (params, ""))
      {
        gv.app_errno = AE_EMPTY_SUBMENU;
        strncpy (gv.app_errno_str, tree_path_str, APP_ERRNO_STR_LEN);

        return TRUE;
      }
    }
    else
    {
      /* some checks for entries */
    }
  }
  else
  {
    /* check for root node */
  }

  g_free(tree_path_str);
  g_free(description);
  g_free(icon);
  g_free(params);

  return FALSE;
}
Пример #22
0
static void
row_changed (GtkTreeModel *tree_model,
             GtkTreePath  *path,
             GtkTreeIter  *iter,
             gpointer      user_data)
{
	_terminal_debug_print (TERMINAL_DEBUG_ACCELS,
	                       "ROW-CHANGED [%s]\n", gtk_tree_path_to_string (path) /* leak */);
}
Пример #23
0
static void
log_operation_for_path (GtkTreePath *path,
                        const char  *operation_name)
{
  char *path_string;

  path_string = path ? gtk_tree_path_to_string (path) : g_strdup ("");

  g_printerr ("%10s %s\n", operation_name, path_string);

  g_free (path_string);
}
Пример #24
0
static void
test_position (GtkTreeView *tree_view,
	       GtkTreePath *path,
	       gboolean     use_align,
	       gdouble      row_align)
{
	gint pos;
	gchar *path_str;
	GdkRectangle rect;
	GtkTreeModel *model;
	gint row_start;

	/* Get the location of the path we scrolled to */
	gtk_tree_view_get_background_area (GTK_TREE_VIEW (tree_view),
					   path, NULL, &rect);

	row_start = get_row_start_for_index (GTK_TREE_VIEW (tree_view),
					     gtk_tree_path_get_indices (path)[0]);

	/* Ugh */
	pos = get_pos_from_path (GTK_TREE_VIEW (tree_view),
				 path, rect.height,
			         gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (tree_view)));

	/* This is only tested for during test_single() */
	model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
	if (gtk_tree_model_iter_n_children (model, NULL) == 1) {
                GtkAllocation allocation;
		GtkTreePath *tmppath;

		/* Test nothing is dangling at the bottom; read
		 * description for test_single() for more information.
		 */

		/* FIXME: hardcoded width */
                gtk_widget_get_allocation (GTK_WIDGET (tree_view), &allocation);
		if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (tree_view), 0, allocation.height - 30, &tmppath, NULL, NULL, NULL)) {
			g_assert_not_reached ();
			gtk_tree_path_free (tmppath);
		}
	}

	path_str = gtk_tree_path_to_string (path);
	if (use_align) {
		assert_position_with_align (tree_view, pos, rect.y,
                                            row_start, rect.height, row_align);
	} else {
		assert_position_without_align (tree_view, row_start, rect.height);
	}

	g_free (path_str);
}
Пример #25
0
/******************************************************************************
* gtk_TreeStoreInsertAfter(tree, parent_path_string/NULL, sibling_path_string/NULL, ncol, val, ....)-->path_string
******************************************************************************/
int
clip_GTK_TREESTOREINSERTAFTER(ClipMachine * ClipMachineMemory)
{

   C_object *cstree = _fetch_co_arg(ClipMachineMemory);

   gchar    *parent = _clip_parc(ClipMachineMemory, 2);

   gchar    *sibling = _clip_parc(ClipMachineMemory, 3);

   GtkTreeIter iter;

   GtkTreeIter parentiter;

   GtkTreeIter siblingiter;

   GtkTreePath *path;

   gchar    *path_string;

   CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType);
   CHECKCOBJ(cstree, GTK_IS_TREE_STORE(cstree->object));
   CHECKOPT(2, CHARACTER_type_of_ClipVarType);
   CHECKOPT(3, CHARACTER_type_of_ClipVarType);

   if (parent)
      gtk_tree_model_get_iter(GTK_TREE_MODEL(GTK_TREE_STORE(cstree->object)),
			      &parentiter, gtk_tree_path_new_from_string(parent));

   if (sibling)
      gtk_tree_model_get_iter(GTK_TREE_MODEL(GTK_TREE_STORE(cstree->object)),
			      &siblingiter, gtk_tree_path_new_from_string(sibling));

   gtk_tree_store_insert_after(GTK_TREE_STORE(cstree->object), &iter,
			       (parent ? &parentiter : NULL), (sibling ? &siblingiter : NULL));

   __tree_store_set(ClipMachineMemory, &iter, 4);

   path = gtk_tree_model_get_path(GTK_TREE_MODEL(GTK_TREE_STORE(cstree->object)), &iter);

   path_string = gtk_tree_path_to_string(path);

   _clip_retc(ClipMachineMemory, path_string);

   g_free(path_string);

   return 0;
 err:
   return 1;
}
Пример #26
0
/**
 * called when we begin a drag,
 * find what cell was under the cursor and change it
 *
 * \param tree_view
 * \param drag_context
 * \param null
 *
 * \return FALSE
 * */
gboolean gsb_form_config_drag_begin ( GtkWidget *tree_view,
				      GdkDragContext *drag_context,
				      gpointer null )
{
    gint x, y;
    GtkTreePath *path;
    GtkTreeViewColumn *tree_column;
    GdkWindow *drawable;
    GdkRectangle rectangle;
    GdkPixbuf *pixbuf_cursor;

    /* get the cell coord */
    gdk_window_get_pointer ( gtk_tree_view_get_bin_window ( GTK_TREE_VIEW ( tree_view )),
			     &x,
			     &y,
			     FALSE );
    gtk_tree_view_get_path_at_pos ( GTK_TREE_VIEW ( tree_view ),
				    x,
				    y,
				    &path,
				    &tree_column,
				    NULL, NULL );

    if ( !path
	 ||
	 !tree_column )
	return FALSE;

    start_drag_column = g_list_index ( gtk_tree_view_get_columns ( GTK_TREE_VIEW ( tree_view )),
				       tree_column );
    start_drag_row = utils_str_atoi ( gtk_tree_path_to_string ( path ));

    /* draw the new cursor */
    drawable = gtk_tree_view_get_bin_window (GTK_TREE_VIEW ( tree_view ));
    gtk_tree_view_get_cell_area ( GTK_TREE_VIEW ( tree_view ),
				  path,
				  tree_column,
				  &rectangle );
    pixbuf_cursor = gdk_pixbuf_get_from_drawable ( NULL,
						   GDK_DRAWABLE (drawable),
						   gdk_colormap_get_system (),
						   rectangle.x, rectangle.y,
						   0, 0,
						   rectangle.width, rectangle.height );
    gtk_drag_source_set_icon_pixbuf ( tree_view,
				      pixbuf_cursor );
    g_object_unref (pixbuf_cursor);

    return FALSE;
}
Пример #27
0
static char*
set_row_data (GtkTreeStore *store, char *path, char *parent, const char *attribute, const char *value)
{
	GtkTreeIter iter;
	gchar *utf_attribute = NULL;
	gchar *utf_value = NULL;
	gboolean iter_valid = FALSE;

	if (!attribute) return NULL;

	if (path != NULL) {
		iter_valid = gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store), &iter, path);
	}

	if (!iter_valid) {
		GtkTreePath *tree_path;
		GtkTreeIter parent_iter;
		gboolean parent_valid = FALSE;

		if (parent != NULL) {
			parent_valid = gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (store),
									    &parent_iter,
									    parent);
		}

		gtk_tree_store_append (store, &iter, parent_valid ? &parent_iter : NULL);

		if (path == NULL) {
			tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);

			if (tree_path != NULL) {
				path = gtk_tree_path_to_string (tree_path);
				gtk_tree_path_free (tree_path);
			}
		}
	}

	utf_attribute = eog_util_make_valid_utf8 (attribute);

	gtk_tree_store_set (store, &iter, MODEL_COLUMN_ATTRIBUTE, utf_attribute, -1);
	g_free (utf_attribute);

	if (value != NULL) {
		utf_value = eog_util_make_valid_utf8 (value);
		gtk_tree_store_set (store, &iter, MODEL_COLUMN_VALUE, utf_value, -1);
		g_free (utf_value);
	}

	return path;
}
Пример #28
0
static void item_deleted_cb (GtkTreeModel *tree_model, GtkTreePath *path, PhidiasItemsGeo *item)
{
	gchar *str;
	ClutterActor *marker;

	str = gtk_tree_path_to_string (path);
	marker = g_hash_table_lookup (item->priv->markers, str);

	if (marker != NULL) {
		champlain_marker_layer_remove_marker (item->priv->current_layer, CHAMPLAIN_MARKER (marker));
		g_hash_table_remove (item->priv->markers, str);
	}

	g_free (str);
}
Пример #29
0
Файл: nemu.c Проект: wareya/gzrt
/* Get currently selected row */
static int
nc_cur_row ( void )
{
    GtkTreeModel * m = gtk_tree_view_get_model( view );
    GList * l = gtk_tree_selection_get_selected_rows( _sel, &m );
    char * b;
    int ret;
    if( !l ) return -1;
    b = gtk_tree_path_to_string(l->data);
    if( !b ) return -1;
    ret = atoi( b );
    g_free( b );
    g_list_free( l );
    return ret;
}
Пример #30
0
void NedMidiRecordConfigDialog::OnClose(GtkDialog *dialog, gint result, gpointer data) {
	NedMidiRecordConfigDialog *midi_record_dialog = (NedMidiRecordConfigDialog *) data;
	int i;
	GtkTreeSelection* selection;
	GList *selected_rows;
	switch (result) {
		case GTK_RESPONSE_ACCEPT:
			midi_record_dialog->m_state = TRUE;
		break;
		default:
			midi_record_dialog->m_state = FALSE;
			gtk_widget_destroy (GTK_WIDGET(dialog));
			return;
		break;
	}
	midi_record_dialog->m_num = (int) gtk_spin_button_get_value(GTK_SPIN_BUTTON(midi_record_dialog->m_numerator));
	switch (gtk_combo_box_get_active(GTK_COMBO_BOX(midi_record_dialog->m_denominator))) {
		case 0: midi_record_dialog->m_denom = 2; break;
		case 1: midi_record_dialog->m_denom = 4; break;
		case 2: midi_record_dialog->m_denom = 8; break;
		default: midi_record_dialog->m_denom = 16; break;
	}
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(midi_record_dialog->m_instrument_list));
	selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
	if ( g_list_length(selected_rows) > 0) {
		GtkTreePath *path = (GtkTreePath *) g_list_first(selected_rows)->data;
		char *tp = gtk_tree_path_to_string(path);
		if (sscanf(tp, "%d", &(midi_record_dialog->m_pgm)) != 1) {
			NedResource::Abort("NedMidiRecordConfigDialog::OnClose: error reading tree path(1)");
		}
	}
	else {
		midi_record_dialog->m_pgm = 0;
	}
	midi_record_dialog->m_triplet = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_record_dialog->m_with_triplet_button));
	midi_record_dialog->m_f_piano = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_record_dialog->m_force_piano_button));
	midi_record_dialog->m_dnt_split = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(midi_record_dialog->m_dont_split_button));
	midi_record_dialog->m_tempo_inverse = (int) (100000.0 * gtk_range_get_value(GTK_RANGE(midi_record_dialog->m_tempo_scale)) / 60.0);
	midi_record_dialog->m_metro_volume = (int) gtk_range_get_value(GTK_RANGE(midi_record_dialog->m_metro_volume_scale));
	midi_record_dialog->m_keysig = 0;
	for (i = 0; i < 13; i++) {
		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (midi_record_dialog->m_sig_radio_buttons[i]))) {
			midi_record_dialog->m_keysig = i - 6;
		}
	}
	gtk_widget_destroy (GTK_WIDGET(dialog));
}