// This callback is responsible for enabling/disabling the appropriate buttons depending on
// the contents of the selection
static void tree_view_selection_changed (GtkTreeSelection *sel, gpointer data)
  {
  bus_layout_D *dialog = (bus_layout_D *)data ;
  gboolean bSomethingSelected = FALSE ;
  gboolean bBusSelected = FALSE ;
  gboolean bSelectionIsFromBus = FALSE ;
  gboolean bFirstSelected = FALSE ;
  gboolean bLastSelected = FALSE ;
  gboolean bFirstBusSelected = TRUE ;
  gboolean bLastBusSelected = TRUE ;
  GtkTreePath *tpSelBus = NULL, *tp = NULL ;
  GtkTreeModel *tm = NULL ;
  int icChildren = -1, Nix ;

  tm = gtk_tree_view_get_model (gtk_tree_selection_get_tree_view (sel)) ;

  if ((bSelectionIsFromBus = (NULL != (tpSelBus = get_selection_bus (sel, &bSomethingSelected)))))
    if (!(bFirstSelected = bLastSelected = bBusSelected = whole_bus_selected_p (sel, tm, tpSelBus)))
      if ((icChildren = gtk_tree_model_path_n_children (tm, tpSelBus)) > 0)
        {
        gtk_tree_path_down (tp = gtk_tree_path_copy (tpSelBus)) ;
        bFirstSelected = gtk_tree_selection_path_is_selected (sel, tp) ;
        for (Nix = 1 ; Nix < icChildren ; Nix++) gtk_tree_path_next (tp) ;
        bLastSelected = gtk_tree_selection_path_is_selected (sel, tp) ;
        gtk_tree_path_free (tp) ;
        }

  if (bSelectionIsFromBus)
    determine_first_or_last_bus (tm, tpSelBus, &bFirstBusSelected, &bLastBusSelected) ;

  gtk_widget_set_sensitive (dialog->btnCreateBus, bSomethingSelected && !bBusSelected) ;
  gtk_widget_set_sensitive (dialog->btnDeleteBus, bSelectionIsFromBus) ;
  gtk_widget_set_sensitive (dialog->btnMoveBusUp, bSelectionIsFromBus && !bFirstBusSelected) ;
  gtk_widget_set_sensitive (dialog->btnMoveBusDown, bSelectionIsFromBus && !bLastBusSelected) ;
  gtk_widget_set_sensitive (dialog->btnMoveCellsUp, bSelectionIsFromBus && !bFirstSelected) ;
  gtk_widget_set_sensitive (dialog->btnMoveCellsDown, bSelectionIsFromBus && !bLastSelected) ;
  gtk_widget_set_sensitive (dialog->lblBusName, bSelectionIsFromBus) ;
  gtk_widget_set_sensitive (dialog->txtBusName, bSelectionIsFromBus) ;

  // Fill in the text box with the name of the bus
  if (bSelectionIsFromBus)
    {
    GtkTreeIter itr ;
    char *psz = NULL ;

    gtk_tree_model_get_iter (tm, &itr, tpSelBus) ;

    gtk_tree_model_get (tm, &itr, BUS_LAYOUT_MODEL_COLUMN_NAME, &psz, -1) ;

    g_signal_handlers_block_matched (G_OBJECT (dialog->txtBusName), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer)bus_name_changed, NULL) ;
    gtk_entry_set_text (GTK_ENTRY (dialog->txtBusName), psz) ;
    g_signal_handlers_unblock_matched (G_OBJECT (dialog->txtBusName), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer)bus_name_changed, NULL) ;

    g_free (psz) ;
    }

  if (NULL != (tp = g_object_get_data (G_OBJECT (gtk_tree_selection_get_tree_view (sel)), "tpBus")))
    gtk_tree_path_free (tp) ;
  g_object_set_data (G_OBJECT (gtk_tree_selection_get_tree_view (sel)), "tpBus", tpSelBus) ;
  }
Exemplo n.º 2
0
static void raise_bus_cell_position (GtkWidget *widget, gpointer data)
  {
  bus_layout_D *dialog = (bus_layout_D *)data ;
  GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tview)) ;
  GtkTreeModel *tm = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tview)) ;
  GtkTreePath *tpBus = g_object_get_data (G_OBJECT (dialog->tview), "tpBus") ;
  GtkTreePath *tpSrc = NULL, *tpDst = NULL ;
  int icChildren = -1, Nix ;

  if (NULL == tpBus) return ;
  if (0 == (icChildren = gtk_tree_model_path_n_children (tm, tpBus))) return ;

  gtk_tree_path_down (tpDst = gtk_tree_path_copy (tpBus)) ;
  gtk_tree_path_next (tpSrc = gtk_tree_path_copy (tpDst)) ;

  for (Nix = 1 ; Nix < icChildren ; Nix++)
    {
    if (gtk_tree_selection_path_is_selected (sel, tpSrc))
      {
      // swap the 2 rows
      swap_model_paths_contents (tm, tpSrc, tpDst) ;
      gtk_tree_selection_unselect_path (sel, tpSrc) ;
      gtk_tree_selection_select_path (sel, tpDst) ;
      }
    gtk_tree_path_next (tpSrc) ;
    gtk_tree_path_next (tpDst) ;
    }
  }
Exemplo n.º 3
0
/* Expand trees (and any subtrees they may have) whose ett_ shows them as
 * expanded.
 * Callers should block calls to expand_tree() to avoid useless recursion.
 */
static void
check_expand_trees(GtkTreeView *tree_view, GtkTreeModel *model, GtkTreePath *path,
                   GtkTreeIter *iter, gboolean scroll_it, gboolean expand_parent)
{
    /* code inspired by gtk_tree_model_foreach_helper */

    field_info *fi;

    do {
        GtkTreeIter child;

        if (gtk_tree_model_iter_children(model, &child, iter)) {
            gtk_tree_model_get(model, iter, 1, &fi, -1);

            if (tree_expanded(fi->tree_type)) {
                if (expand_parent)
                    gtk_tree_view_expand_row(tree_view, path, FALSE);

                if (scroll_it)
                     gtk_tree_view_scroll_to_cell(tree_view, path, NULL, TRUE, (prefs.gui_auto_scroll_percentage/100.0f), 0.0f);

                /* try to expand children only when parent is expanded */
                gtk_tree_path_down(path);
                check_expand_trees(tree_view, model, path, &child, scroll_it, TRUE);
                gtk_tree_path_up(path);
            }
        }

        gtk_tree_path_next(path);
    } while (gtk_tree_model_iter_next(model, iter));
}
Exemplo n.º 4
0
static void
test_bug111500_mixed (ScrollFixture *fixture,
		      gconstpointer  test_data)
{
	int i, len;
	GtkTreeStore *store;
	GtkTreeIter parent;
	GtkTreePath *path;

	g_test_bug ("111500");

	gtk_widget_show_all (fixture->window);

	/* Make sure all events have been processed and the window
	 * is visible.
	 */
	while (gtk_events_pending ())
		gtk_main_iteration ();

	/* Further prepare model */
	store = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (fixture->tree_view)));

	for (i = 0; i < 15; i++) {
		GtkTreeIter iter;

		gtk_tree_store_append (store, &iter, NULL);
		if (i % 2 == 0)
			gtk_tree_store_set (store, &iter, 0, "Other node", -1);
		else
			gtk_tree_store_set (store, &iter, 0, "Other\nnode", -1);
	}

	len = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (store), NULL);
	gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (store), &parent,
				       NULL, len - 1);

	for (i = 0; i < 5; i++) {
		GtkTreeIter iter;

		gtk_tree_store_append (store, &iter, &parent);
		if (i % 2 != 0)
			gtk_tree_store_set (store, &iter, 0, "Row", -1);
		else
			gtk_tree_store_set (store, &iter, 0, "Row\nRow", -1);
	}

	path = gtk_tree_path_new_from_indices (len - 1, -1);
	gtk_tree_view_expand_row (GTK_TREE_VIEW (fixture->tree_view),
				  path, FALSE);

	gtk_tree_path_down (path);

	scroll (fixture, path, FALSE, 0.5);
	gtk_tree_path_free (path);
}
Exemplo n.º 5
0
static void insert_event_with_parent(ReplayMessageTree *self,
                                     ReplayMessageTreeEntry *entry,
                                     ReplayMessageTreeEntry *parent)
{
  ReplayMessageTreePrivate *priv;

  priv = self->priv;

  entry->parent = parent;

  if (parent)
  {
    if (parent->last_child)
    {
      parent->last_child->next = entry;
      entry->prev = parent->last_child;
      /* create a tree path which is next after the one before us */
      entry->tree_path = gtk_tree_path_copy(entry->prev->tree_path);
      gtk_tree_path_next(entry->tree_path);
    }
    else
    {
      g_assert(parent->first_child == NULL);
      parent->first_child = entry;
      entry->parent = parent;
      /* create a tree path which is the first child of our parent */
      entry->tree_path = gtk_tree_path_copy(entry->parent->tree_path);
      gtk_tree_path_down(entry->tree_path);
    }
    parent->last_child = entry;
    parent->num_children++;
  }
  else
  {
    if (priv->last_child)
    {
      priv->last_child->next = entry;
      entry->prev = priv->last_child;
      /* create a tree path which is next after the one before us */
      entry->tree_path = gtk_tree_path_copy(entry->prev->tree_path);
      gtk_tree_path_next(entry->tree_path);
    }
    else
    {
      g_assert(priv->first_child == NULL);
      priv->first_child = entry;
      entry->parent = parent;
      /* create a tree path which is the first child of our parent */
      entry->tree_path = gtk_tree_path_new_first();
    }
    priv->last_child = entry;
    priv->num_children++;
  }
}
Exemplo n.º 6
0
char *gTreeRow::child()
{
	GtkTreePath* path;
	
	path = gtk_tree_model_get_path(GTK_TREE_MODEL(tree->store), dataiter);
	if (!path)
		return NULL;
	
	gtk_tree_path_down(path);
	return tree->pathToKey(path);
}
Exemplo n.º 7
0
/**
 * Expands to path
 * @param path to expand
 */
void
rs_dir_selector_expand_path(RSDirSelector *selector, const gchar *expand)
{
	GtkTreeView *view = GTK_TREE_VIEW(selector->view);
	GtkTreeModel *model = gtk_tree_view_get_model(view);
	GtkTreePath *path = gtk_tree_path_new_first();
	GtkTreeIter iter;
	gchar *filepath = NULL;
	GString *gs;

	if (g_path_is_absolute(expand)) 	
	{
		gs = g_string_new(expand);
	}
	else
	{
		gs = g_string_new(g_get_current_dir());
		g_string_append(gs, G_DIR_SEPARATOR_S);
		g_string_append(gs, expand);
	}

	g_string_append(gs, G_DIR_SEPARATOR_S);

	while (gtk_tree_model_get_iter(model, &iter, path))
	{
		gtk_tree_model_get(model, &iter, COL_PATH, &filepath, -1);

		if (filepath && g_str_has_prefix(gs->str, filepath))
		{
			gtk_tree_view_expand_row(GTK_TREE_VIEW(view), path, FALSE);
			gtk_tree_path_down(path);
		}
		else
		{
			gtk_tree_path_next(path);
		}
	}

	g_string_free(gs, TRUE);

	if (GTK_WIDGET_REALIZED(GTK_WIDGET(selector)))
		gtk_tree_view_scroll_to_cell(view, path, NULL, TRUE, 0.2, 0.0);
	else
	{
		/* Save this, realize() will catch it later */
		GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
		if (gtk_tree_model_get_iter(model, &iter, path))
			gtk_tree_selection_select_iter(selection, &iter);
	}

	gtk_tree_path_free(path);
}
Exemplo n.º 8
0
/* Refresh the page's available GtkTreeView.
 */
static gboolean
tp_find_icon(GArray * array, const gchar * icon)
{
    guint j;

    for (j = 0; j < array->len; j++) {
        if (strcmp(icon, g_array_index(array, BalsaToolbarEntry, j).icon) == 0)
            return TRUE;
    }
    return FALSE;
}

static void
#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
tp_page_refresh_available(ToolbarPage * page)
#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
tp_page_refresh_available(ToolbarPage * page, GActionMap * map)
#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
{
    GtkTreeSelection *selection =
        gtk_tree_view_get_selection(GTK_TREE_VIEW(page->available));
    GtkTreeModel *model;
    GtkTreeIter iter;
    GtkTreePath *path;
    GHashTable *legal = balsa_toolbar_model_get_legal(page->model);
    GArray *current = balsa_toolbar_model_get_current(page->model);
    int item;

    /* save currently selected path, or point path to the first row */
    if (gtk_tree_selection_get_selected(selection, &model, &iter))
        path = gtk_tree_model_get_path(model, &iter);
    else {
        path = gtk_tree_path_new();
        gtk_tree_path_down(path);
    }
    gtk_list_store_clear(GTK_LIST_STORE(model));

    for (item = 0; item < toolbar_button_count; item++) {
#ifdef BALSA_TOOLBAR_DEBUG_ACTIONS
        if (map) {
            if (item > 0) {
                gchar *action;

                action = g_hash_table_lookup(legal, toolbar_buttons[item].pixmap_id);
                if (action && !g_action_map_lookup_action(map, action))
                    g_print("undefined action: “%s”\n", action);
            }
        }
#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
        if (item > 0
            && (!g_hash_table_lookup(legal,
                                     toolbar_buttons[item].pixmap_id)
                || tp_find_icon(current, toolbar_buttons[item].pixmap_id)))
            continue;

        gtk_list_store_append(GTK_LIST_STORE(model), &iter);
        tp_store_set(GTK_LIST_STORE(model), &iter, item);
    }

    if (gtk_tree_model_get_iter(model, &iter, path)
        || gtk_tree_path_prev(path)) {
        gtk_tree_selection_select_path(selection, path);
        gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(page->available),
                                     path, NULL, FALSE, 0, 0);
    }
    gtk_tree_path_free(path);
}
Exemplo n.º 9
0
static void
move_up (int val)
{
    int i;
    GtkTreePath *path;
    GtkTreePath *tree_path;
    GtkTreeIter iter1;
    GtkTreeIter iter2;
    GtkTreeModel *model;

    model = gtk_tree_view_get_model (GTK_TREE_VIEW (main_gui.displayed_list));

    gtk_tree_view_get_cursor (GTK_TREE_VIEW (main_gui.displayed_list), &path, NULL);

    if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter1, path))
        return;

    for (i = 0; i < val; i++) {
        if (!gtk_tree_path_prev (path)) {
            if (!gtk_tree_path_up (path)) {
                break;
            } else {
                if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter1, path))
                    break;
            }
        } else {
            if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (main_gui.displayed_list), path)) {
                gtk_tree_path_down (path);
                gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter2, path);
                iter1 = iter2;
                while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter2)) {
                    iter1 = iter2;
                }
            } else {
                if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter1, path))
                    break;
            }
        }
    }

    tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter1);
    gtk_tree_view_set_cursor (GTK_TREE_VIEW (main_gui.displayed_list), tree_path, NULL, FALSE);
    gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (main_gui.displayed_list), tree_path, NULL, TRUE, 0.5, 0);
    gtk_tree_path_free (tree_path);

    gtk_widget_grab_focus (main_gui.displayed_list);

}
Exemplo n.º 10
0
static GList *get_bus_refs (GtkTreeModel *tm, GtkTreePath *tpBus)
  {
  int Nix, icChildren = -1 ;
  GList *llRefs = NULL ;
  GtkTreePath *tp = gtk_tree_path_copy (tpBus) ;

  icChildren = gtk_tree_model_path_n_children (tm, tp) ;
  gtk_tree_path_down (tp) ;

  for (Nix = 0 ; Nix < icChildren ; Nix++, gtk_tree_path_next (tp))
    llRefs = g_list_prepend (llRefs, gtk_tree_row_reference_new (tm, tp)) ;

  gtk_tree_path_free (tp) ;

  return llRefs ;
  }
Exemplo n.º 11
0
gboolean on_dir_tree_view_key_press( GtkWidget* view,
                                     GdkEventKey* evt,
                                     gpointer user_data )
{
    switch(evt->keyval) {
    case GDK_Left:
    case GDK_Right:
        break;
    default:
        return FALSE;
    }


    GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
    GtkTreeModel *model;
    GtkTreeIter iter;
    if(!gtk_tree_selection_get_selected(select, &model, &iter))
        return FALSE;

    GtkTreePath *path = gtk_tree_model_get_path(model, &iter);

    switch( evt->keyval ) {
    case GDK_Left:
        if(gtk_tree_view_row_expanded(GTK_TREE_VIEW(view), path)) {
            gtk_tree_view_collapse_row(GTK_TREE_VIEW(view), path);
        } else if(gtk_tree_path_up(path)) {
            gtk_tree_selection_select_path(select, path);
            gtk_tree_view_set_cursor(GTK_TREE_VIEW(view), path, NULL, FALSE);
        } else {
            return FALSE;
        }
        break;
    case GDK_Right:
        if(!gtk_tree_view_row_expanded(GTK_TREE_VIEW(view), path)) {
            gtk_tree_view_expand_row(GTK_TREE_VIEW(view), path, FALSE);
        } else {
            gtk_tree_path_down(path);
            gtk_tree_selection_select_path(select, path);
            gtk_tree_view_set_cursor(GTK_TREE_VIEW(view), path, NULL, FALSE);
        }
        break;
    }
    return TRUE;
}
Exemplo n.º 12
0
/* Refresh the page's current GtkTreeView.
 */
static void
tp_page_refresh_current(ToolbarPage * page)
{
    GtkTreeSelection *selection =
        gtk_tree_view_get_selection(GTK_TREE_VIEW(page->current));
    GtkTreeModel *model;
    GtkTreeIter iter;
    GtkTreePath *path;
    int item;
    GArray *current;
    guint j;

    /* save currently selected path, or point path to the first row */
    if (gtk_tree_selection_get_selected(selection, &model, &iter))
        path = gtk_tree_model_get_path(model, &iter);
    else {
        path = gtk_tree_path_new();
        gtk_tree_path_down(path);
    }
    gtk_list_store_clear(GTK_LIST_STORE(model));

    current = balsa_toolbar_model_get_current(page->model);
    for (j = 0; j < current->len; j++) {
        BalsaToolbarEntry *entry;

        entry = &g_array_index(current, BalsaToolbarEntry, j);
        item = get_toolbar_button_index(entry->icon);

        if (item < 0)
            continue;

        gtk_list_store_append(GTK_LIST_STORE(model), &iter);
        tp_store_set(GTK_LIST_STORE(model), &iter, item);
    }

    if (gtk_tree_model_get_iter(model, &iter, path)
        || gtk_tree_path_prev(path)) {
        gtk_tree_selection_select_path(selection, path);
        gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(page->current),
                                     path, NULL, FALSE, 0, 0);
    }
    gtk_tree_path_free(path);
}
Exemplo n.º 13
0
static void lower_bus_cell_position (GtkWidget *widget, gpointer data)
  {
  bus_layout_D *dialog = (bus_layout_D *)data ;
  GtkTreeSelection *sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->tview)) ;
  GtkTreeModel *tm = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tview)) ;
  GtkTreePath *tpBus = g_object_get_data (G_OBJECT (dialog->tview), "tpBus") ;
  GtkTreePath *tpSrc = NULL, *tpDst = NULL ;
  int icChildren = -1, Nix ;

  if (NULL == tpBus)
		{
		fprintf (stderr, "lower_bus_cell_position: tpBus == NULL !\n") ;
		return ;
		}
  if (0 == (icChildren = gtk_tree_model_path_n_children (tm, tpBus)))
		{
		fprintf (stderr, "lower_bus_cell_position: tpBus has no children O_o\n") ;
		return ;
		}

  gtk_tree_path_down (tpDst = gtk_tree_path_copy (tpBus)) ;
  for (Nix = 1 ; Nix < icChildren ; Nix++) gtk_tree_path_next (tpDst) ;
    // St00pid short-circuit if statement to suppress a warning.
    if (gtk_tree_path_prev (tpSrc = gtk_tree_path_copy (tpDst))) ;

  for (Nix = 1 ; Nix < icChildren ; Nix++)
    {
    if (gtk_tree_selection_path_is_selected (sel, tpSrc))
      {
      // swap the 2 rows
      swap_model_paths_contents (tm, tpSrc, tpDst) ;
      gtk_tree_selection_unselect_path (sel, tpSrc) ;
      gtk_tree_selection_select_path (sel, tpDst) ;
      }
    if (!gtk_tree_path_prev (tpSrc)) break ;
    if (!gtk_tree_path_prev (tpDst)) break ;
    }
  }
Exemplo n.º 14
0
static gboolean whole_bus_selected_p (GtkTreeSelection *sel, GtkTreeModel *tm, GtkTreePath *tpSelBus)
  {
  int Nix ;
  int icChildren = -1 ;
  GtkTreePath *tp = NULL ;

  icChildren = gtk_tree_model_path_n_children (tm, tpSelBus) ;

  if (icChildren > 0)
    {
    gtk_tree_path_down (tp = gtk_tree_path_copy (tpSelBus)) ;

    for (Nix = 0 ; Nix < icChildren ; Nix++, gtk_tree_path_next (tp))
      if (!gtk_tree_selection_path_is_selected (sel, tp))
        break ;

    gtk_tree_path_free (tp) ;

    return (Nix == icChildren) ;
    }
  fprintf (stderr, "What ?! The bus had 0 children ?!\n") ;
  return TRUE ;
  }
Exemplo n.º 15
0
gboolean on_dir_tree_view_key_press( GtkWidget* view,
                                     GdkEventKey* evt,
                                     PtkFileBrowser* browser )
{
    VFSFileInfo* file;
    GtkTreeModel *model;
    GtkTreeIter iter;
    GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
    
    if(!gtk_tree_selection_get_selected(select, &model, &iter))
        return FALSE;

    int keymod = ( evt->state & ( GDK_SHIFT_MASK | GDK_CONTROL_MASK |
            GDK_MOD1_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK | GDK_META_MASK ) );

    GtkTreePath *path = gtk_tree_model_get_path(model, &iter);

    switch( evt->keyval ) {
    case GDK_KEY_Left:
        if(gtk_tree_view_row_expanded(GTK_TREE_VIEW(view), path)) {
            gtk_tree_view_collapse_row(GTK_TREE_VIEW(view), path);
        } else if(gtk_tree_path_up(path)) {
            gtk_tree_selection_select_path(select, path);
            gtk_tree_view_set_cursor(GTK_TREE_VIEW(view), path, NULL, FALSE);
        } else {
            gtk_tree_path_free( path );
            return FALSE;
        }
        break;
    case GDK_KEY_Right:
        if(!gtk_tree_view_row_expanded(GTK_TREE_VIEW(view), path)) {
            gtk_tree_view_expand_row(GTK_TREE_VIEW(view), path, FALSE);
        } else {
            gtk_tree_path_down(path);
            gtk_tree_selection_select_path(select, path);
            gtk_tree_view_set_cursor(GTK_TREE_VIEW(view), path, NULL, FALSE);
        }
        break;
    case GDK_KEY_F10:
    case GDK_KEY_Menu:
        if ( evt->keyval == GDK_KEY_F10 && keymod != GDK_SHIFT_MASK )
        {
            gtk_tree_path_free( path );
            return FALSE;
        }

        char* dir_path = ptk_dir_tree_view_get_selected_dir(
                                        GTK_TREE_VIEW( view ) );
        if ( ptk_file_browser_chdir( browser, dir_path,
                                    PTK_FB_CHDIR_ADD_HISTORY ) )
        {
            /* show right-click menu
             * This simulates a right-click in the file list when
             * no files are selected (even if some are) since
             * actions are to be taken on the dir itself. */
            GtkWidget* popup = ptk_file_menu_new( NULL, browser,
                                                  NULL, NULL,
                                                  dir_path, NULL );
            if ( popup )
                gtk_menu_popup( GTK_MENU( popup ), NULL, NULL,
                            NULL, NULL, 3, 0 );
        }

        /* this old method operates on the wrong files
        gtk_tree_model_get( gtk_tree_view_get_model( GTK_TREE_VIEW( view ) ),
                            &iter,
                            COL_DIR_TREE_INFO,
                            &file, -1 );
        if ( file )
        {
            GtkWidget * popup;
            char* file_path;
            GList* sel_files;
            char* dir_name;
            file_path = ptk_dir_view_get_dir_path(
                    gtk_tree_view_get_model( GTK_TREE_VIEW( view ) ), &iter );

            sel_files = g_list_prepend( NULL, vfs_file_info_ref(file) );
            dir_name = g_path_get_dirname( file_path );
            popup = ptk_file_menu_new( NULL, browser,
                        file_path, file,
                        dir_name, sel_files );
            g_free( dir_name );
            g_free( file_path );
            if ( popup )
                gtk_menu_popup( GTK_MENU( popup ), NULL, NULL,
                            NULL, NULL, 3, evt->time );

            vfs_file_info_unref( file );
        }
        */
        break;
    default:
        gtk_tree_path_free( path );
        return FALSE;
    }
    gtk_tree_path_free( path );
    return TRUE;
}
Exemplo n.º 16
0
/*#
    @method down GtkTreePath
    @brief Moves path to point to the first child of the current path.
 */
FALCON_FUNC TreePath::down( VMARG )
{
    NO_ARGS
    MYSELF;
    gtk_tree_path_down( self->getTreePath() );
}
Exemplo n.º 17
0
// start helpers
static void swap_buses (GtkTreeModel *tm, GtkTreeSelection *sel, bus_layout_D *dialog, GtkTreePath *tpSrc, GtkTreePath *tpDst)
  {
  int Nix ;
  GtkTreeIter itr ;
  SWAP_BUSES_STRUCT src, dst ;
  SWAP_BUSES_STRUCT *min = NULL, *max = NULL ;
  EXP_ARRAY *ar_bSelSrc = NULL, *ar_bSelDst = NULL ;
  gboolean bDstExpanded = TRUE ;

  if (!gtk_tree_model_get_iter (tm, &(src.itr), tpSrc)) return ;
  src.tp = gtk_tree_path_copy (tpSrc) ;
  src.icChildren = gtk_tree_model_iter_n_children (tm, &(src.itr)) ;

  if (!gtk_tree_model_get_iter (tm, &(dst.itr), tpDst))
    {
    gtk_tree_path_free (src.tp) ;
    return ;
    }
  dst.tp = gtk_tree_path_copy (tpDst) ;
  dst.icChildren = gtk_tree_model_iter_n_children (tm, &(dst.itr)) ;

  if (dst.icChildren < src.icChildren)
    {
    min = &dst ;
    max = &src ;
    }
  else
    {
    min = &src ;
    max = &dst ;
    }

  bDstExpanded = gtk_tree_view_row_expanded (gtk_tree_selection_get_tree_view (sel), dst.tp) ;

  g_signal_handlers_block_matched (G_OBJECT (sel), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer)tree_view_selection_changed, NULL) ;

  for (Nix = 0 ; Nix < max->icChildren - min->icChildren ; Nix++)
    gtk_tree_store_append (GTK_TREE_STORE (tm), &itr, &(min->itr)) ;

  gtk_tree_path_down (src.tp) ;
  gtk_tree_path_down (dst.tp) ;

  ar_bSelSrc = exp_array_new (sizeof (gboolean), 1) ;
  ar_bSelDst = exp_array_new (sizeof (gboolean), 1) ;
  exp_array_1d_insert_vals (ar_bSelSrc, NULL, max->icChildren, 0) ;
  exp_array_1d_insert_vals (ar_bSelDst, NULL, max->icChildren, 0) ;

  for (Nix = 0 ; Nix < max->icChildren ; Nix++)
    {
    exp_array_index_1d (ar_bSelSrc, gboolean, Nix) =
      gtk_tree_selection_path_is_selected (sel, src.tp) ;
    exp_array_index_1d (ar_bSelDst, gboolean, Nix) =
      gtk_tree_selection_path_is_selected (sel, dst.tp) ;

    gtk_tree_path_next (src.tp) ;
    gtk_tree_path_next (dst.tp) ;
    }

  if (!gtk_tree_path_up (src.tp)) goto swap_buses_quit ;
  if (!gtk_tree_path_up (dst.tp)) goto swap_buses_quit ;
  gtk_tree_path_down (src.tp) ;
  gtk_tree_path_down (dst.tp) ;

  for (Nix = 0 ; Nix < max->icChildren ; Nix++)
    {
    if (exp_array_index_1d (ar_bSelDst, gboolean, Nix))
      gtk_tree_view_expand_to_path (gtk_tree_selection_get_tree_view (sel), src.tp) ;

    if (exp_array_index_1d (ar_bSelSrc, gboolean, Nix))
      gtk_tree_view_expand_to_path (gtk_tree_selection_get_tree_view (sel), dst.tp) ;

    gtk_tree_path_next (src.tp) ;
    gtk_tree_path_next (dst.tp) ;
    }

  if (!gtk_tree_path_up (src.tp)) goto swap_buses_quit ;
  if (!gtk_tree_path_up (dst.tp)) goto swap_buses_quit ;
  gtk_tree_path_down (src.tp) ;
  gtk_tree_path_down (dst.tp) ;

  for (Nix = 0 ; Nix < max->icChildren ; Nix++)
    {
    swap_model_paths_contents (tm, src.tp, dst.tp) ;
    gtk_tree_path_next (src.tp) ;
    gtk_tree_path_next (dst.tp) ;
    }

  if (!gtk_tree_path_up (src.tp)) goto swap_buses_quit ;
  if (!gtk_tree_path_up (dst.tp)) goto swap_buses_quit ;
  gtk_tree_path_down (src.tp) ;
  gtk_tree_path_down (dst.tp) ;

  for (Nix = 0 ; Nix < max->icChildren ; Nix++)
    {
    GTK_TREE_SELECTION_SET_PATH_SELECTED (sel, src.tp, exp_array_index_1d (ar_bSelDst, gboolean, Nix)) ;
    GTK_TREE_SELECTION_SET_PATH_SELECTED (sel, dst.tp, exp_array_index_1d (ar_bSelSrc, gboolean, Nix)) ;
    gtk_tree_path_next (src.tp) ;
    gtk_tree_path_next (dst.tp) ;
    }

  if (!gtk_tree_path_up (src.tp)) goto swap_buses_quit ;
  if (!gtk_tree_path_up (dst.tp)) goto swap_buses_quit ;

  swap_model_paths_contents (tm, src.tp, dst.tp) ;

  gtk_tree_path_down (src.tp) ;
  gtk_tree_path_down (dst.tp) ;

  for (Nix = 0 ; Nix < min->icChildren ; Nix++)
    gtk_tree_path_next (max->tp) ;
  if (gtk_tree_model_get_iter (tm, &itr, max->tp))
    while (gtk_tree_store_remove (GTK_TREE_STORE (tm), &itr)) ;

  if (!bDstExpanded)
    {
    for (Nix = 0 ; Nix < ar_bSelDst->icUsed ; Nix++)
      if (exp_array_index_1d (ar_bSelDst, gboolean, Nix))
        break ;

    if (Nix == ar_bSelDst->icUsed)
      if (gtk_tree_path_up (src.tp))
        gtk_tree_view_collapse_row (gtk_tree_selection_get_tree_view (sel), src.tp) ;
    }

swap_buses_quit:

  exp_array_free (ar_bSelSrc) ;
  exp_array_free (ar_bSelDst) ;
  gtk_tree_path_free (src.tp) ;
  gtk_tree_path_free (dst.tp) ;
  g_signal_handlers_unblock_matched (G_OBJECT (sel), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, (gpointer)tree_view_selection_changed, NULL) ;
  tree_view_selection_changed (sel, dialog) ;
  }
Exemplo n.º 18
0
// Implements the selection constraints for the available cells tree view
static gboolean select_cell_row_p (GtkTreeSelection *sel, GtkTreeModel *tm, GtkTreePath *tp, gboolean bSelStatus, gpointer data)
  {
  int Nix ;
  static gboolean bIgnore = FALSE ;
  int this_row_type = -1 ;
  GtkTreeIter itr ;

  if (bIgnore) return TRUE ;

  if (!gtk_tree_model_get_iter (tm, &itr, tp)) return FALSE ;

  gtk_tree_model_get (tm, &itr, BUS_LAYOUT_MODEL_COLUMN_TYPE, &this_row_type, -1) ;

  if (this_row_type & ROW_TYPE_BUS)
    {
    GtkTreePath *tpNew = NULL ;
    int icChildren = gtk_tree_model_iter_n_children (tm, &itr) ;
    int x, y ;
    GdkModifierType mask ;

    if (bSelStatus)
      {
      bIgnore = TRUE ;
      gtk_tree_selection_unselect_path (sel, tp) ;
      bIgnore = FALSE ;
      }

    gtk_tree_view_expand_row (gtk_tree_selection_get_tree_view (sel), tp, TRUE) ;

    if (icChildren > 0)
      {
      // I should be able to programmatically simulate a "click" event, because its meaning depends
      // on whether Ctrl or Shift are held down.  I should not have to reproduce that behaviour here,
      // because it may change in the future. I need to simulate a "click" event because I would like to
      // implement the following: Clicking on a bus is equivalent to clicking on all its inputs
      gdk_window_get_pointer (GTK_WIDGET (gtk_tree_selection_get_tree_view (sel))->window, &x, &y, &mask) ;

      gtk_tree_path_down (tpNew = gtk_tree_path_copy (tp)) ;

      bSelStatus = gtk_tree_selection_path_is_selected (sel, tpNew) ;

      for (Nix = 0 ; Nix < icChildren ; Nix++, gtk_tree_path_next (tpNew))
        if ((mask & GDK_CONTROL_MASK))
          {
          if (bSelStatus)
            gtk_tree_selection_unselect_path (sel, tpNew) ;
          else
            gtk_tree_selection_select_path (sel, tpNew) ;
          }
        else
          gtk_tree_selection_select_path (sel, tpNew) ;

      gtk_tree_path_free (tpNew) ;
      }
    return FALSE ;
    }
  else
  if (this_row_type & ROW_TYPE_CELL)
    {
    if (!bSelStatus)
      {
      DESELECT_DIFFERENT_CELLS_STRUCT ddcs = {NULL, 0} ;

      ddcs.sel = sel ;
      ddcs.row_type = this_row_type ;

      gtk_tree_selection_selected_foreach (sel, deselect_other_type_of_cells, &ddcs) ;
      }
    }

  return TRUE ;
  }
Exemplo n.º 19
0
static VALUE
rg_down_bang(VALUE self)
{
    gtk_tree_path_down(_SELF(self));
    return Qtrue;
}
Exemplo n.º 20
0
/* Test for GNOME bugzilla bug 359231 */
static void
test_bug359231 (void)
{
	int i;
	int height1, height2;
	GtkTreePath *path;
	GtkTreeIter iter, child;
	GtkTreeStore *store;
	GdkRectangle rect;
	ScrollFixture *fixture;

	/* See #359231. */
	g_test_bug ("359231");

	/* Create model (GtkTreeStore in this case) */
	store = gtk_tree_store_new (1, G_TYPE_STRING);

	gtk_tree_store_append (store, &iter, NULL);
	gtk_tree_store_set (store, &iter, 0, "Foo", -1);

	for (i = 0; i < 4; i++) {
		gtk_tree_store_append (store, &child, &iter);
		gtk_tree_store_set (store, &child, 0, "Two\nLines", -1);
	}
	
	fixture = g_new0 (ScrollFixture, 1);
	scroll_fixture_setup (fixture, GTK_TREE_MODEL (store), NULL);
	gtk_widget_show_all (fixture->window);

	while (gtk_events_pending ())
		gtk_main_iteration ();

	/* Prepend some rows at the top, expand */
	gtk_tree_store_prepend (store, &iter, NULL);
	gtk_tree_store_set (store, &iter, 0, "Foo", -1);

	gtk_tree_store_prepend (store, &child, &iter);
	gtk_tree_store_set (store, &child, 0, "Two\nLines", -1);

	gtk_tree_view_expand_all (GTK_TREE_VIEW (fixture->tree_view));

	while (gtk_events_pending ())
		gtk_main_iteration ();

	/* Test if height of row 0:0 is correct */
	path = gtk_tree_path_new_from_indices (0, -1);
	gtk_tree_view_get_background_area (GTK_TREE_VIEW (fixture->tree_view),
					   path, NULL, &rect);
	height1 = rect.height;

	gtk_tree_path_down (path);
	gtk_tree_view_get_background_area (GTK_TREE_VIEW (fixture->tree_view),
					   path, NULL, &rect);
	height2 = rect.height;
	gtk_tree_path_free (path);

	g_assert (height2 > height1);

	/* Clean up; the tear down also cleans up the model */
	scroll_fixture_teardown (fixture, NULL);
}
Exemplo n.º 21
0
static void DialogToBusLayout (bus_layout_D *dialog, BUS_LAYOUT *bus_layout)
  {
  GtkTreeModel *tm = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->tview)) ;
  int Nix ;
  int icTopLevel = gtk_tree_model_iter_n_children (tm, NULL), icCells = -1 ;
  GtkTreePath *tp = NULL, *tpCells = NULL ;
  GtkTreeIter itr ;
  int Nix1, idxCell = -1 ;
  int row_type ;
  EXP_ARRAY *cell_list = NULL ;
  BUS *bus ;

  // destroy all buses before adding the new ones
  for (Nix = bus_layout->buses->icUsed - 1 ; Nix > -1 ; Nix--)
    {
    exp_array_free (exp_array_index_1d (bus_layout->buses, BUS, Nix).cell_indices) ;
    g_free (exp_array_index_1d (bus_layout->buses, BUS, Nix).pszName) ;
    }
  exp_array_remove_vals (bus_layout->buses, 1, 0, bus_layout->buses->icUsed) ;

  // Since we've destroyed all buses, no cells are members of any bus any longer
  for (Nix = 0 ; Nix < bus_layout->inputs->icUsed ; Nix++)
    exp_array_index_1d (bus_layout->inputs, BUS_LAYOUT_CELL, Nix).bIsInBus = FALSE ;
  for (Nix = 0 ; Nix < bus_layout->outputs->icUsed ; Nix++)
    exp_array_index_1d (bus_layout->outputs, BUS_LAYOUT_CELL, Nix).bIsInBus = FALSE ;

  if (icTopLevel > 0)
    {
    tp = gtk_tree_path_new_first () ;
    for (Nix = 0 ; Nix < icTopLevel ; Nix++, gtk_tree_path_next (tp))
      {
      if (gtk_tree_model_get_iter (tm, &itr, tp))
        {
        gtk_tree_model_get (tm, &itr, BUS_LAYOUT_MODEL_COLUMN_TYPE, &row_type, -1) ;
        if (ROW_TYPE_BUS & row_type)
          {
          exp_array_1d_insert_vals (bus_layout->buses, NULL, 1, -1) ;
          bus = &(exp_array_index_1d (bus_layout->buses, BUS, bus_layout->buses->icUsed - 1)) ;
          gtk_tree_model_get (tm, &itr, BUS_LAYOUT_MODEL_COLUMN_NAME, &(bus->pszName), -1) ;
          if (ROW_TYPE_INPUT & row_type)
            {
            bus->bus_function = QCAD_CELL_INPUT ;
            cell_list = bus_layout->inputs ;
            }
          else
            {
            bus->bus_function = QCAD_CELL_OUTPUT ;
            cell_list = bus_layout->outputs ;
            }
          bus->cell_indices = exp_array_new (sizeof (int), 1) ;
          if ((icCells = gtk_tree_model_iter_n_children (tm, &itr)) > 0)
            {
            gtk_tree_path_down (tpCells = gtk_tree_path_copy (tp)) ;

            for (Nix1 = 0 ; Nix1 < icCells ; Nix1++, gtk_tree_path_next (tpCells))
              if (gtk_tree_model_get_iter (tm, &itr, tpCells))
                {
                gtk_tree_model_get (tm, &itr, BUS_LAYOUT_MODEL_COLUMN_INDEX, &idxCell, -1) ;
                exp_array_1d_insert_vals (bus->cell_indices, &idxCell, 1, -1) ;
                // Flag this cell in the master cell list as a member of some bus
                exp_array_index_1d (cell_list, BUS_LAYOUT_CELL, idxCell).bIsInBus = TRUE ;
                }
            gtk_tree_path_free (tpCells) ;
            }
          }
        }
      }
    gtk_tree_path_free (tp) ;
    }
  }
Exemplo n.º 22
0
bool
sc_navigate_index(girara_session_t* session, girara_argument_t* argument,
                  girara_event_t* UNUSED(event), unsigned int UNUSED(t))
{
  g_return_val_if_fail(session != NULL, false);
  g_return_val_if_fail(session->global.data != NULL, false);
  zathura_t* zathura = session->global.data;
  g_return_val_if_fail(argument != NULL, false);
  g_return_val_if_fail(zathura->document != NULL, false);

  if(zathura->ui.index == NULL) {
    return false;
  }

  GtkTreeView *tree_view = gtk_container_get_children(GTK_CONTAINER(zathura->ui.index))->data;
  GtkTreePath *path;

  gtk_tree_view_get_cursor(tree_view, &path, NULL);
  if (path == NULL) {
    return false;
  }

  GtkTreeModel *model = gtk_tree_view_get_model(tree_view);
  GtkTreeIter   iter;
  GtkTreeIter   child_iter;

  gboolean is_valid_path = TRUE;

  switch(argument->n) {
    case TOP:
      /* go to the first node */
      gtk_tree_path_free(path);
      path = gtk_tree_path_new_first();
      break;
    case BOTTOM:
      /* go to the last visiible node */
      gtk_tree_path_free(path);
      path = gtk_tree_path_new_from_indices(gtk_tree_model_iter_n_children(model, NULL) - 1, -1);
      gtk_tree_model_get_iter(model, &iter, path);
      while (gtk_tree_model_iter_has_child(model, &iter) == TRUE &&
          gtk_tree_view_row_expanded(tree_view, path) == TRUE) {
          gtk_tree_path_append_index(path, gtk_tree_model_iter_n_children(model, &iter) - 1);
      }
      break;
    case UP:
      if (gtk_tree_path_prev(path) == FALSE) {
        /* For some reason gtk_tree_path_up returns TRUE although we're not
         * moving anywhere. */
        is_valid_path = gtk_tree_path_up(path) && (gtk_tree_path_get_depth(path) > 0);
      } else { /* row above */
        while (gtk_tree_view_row_expanded(tree_view, path)) {
          gtk_tree_model_get_iter(model, &iter, path);
          /* select last child */
          gtk_tree_model_iter_nth_child(model, &child_iter, &iter,
                                        gtk_tree_model_iter_n_children(model, &iter)-1);
          gtk_tree_path_free(path);
          path = gtk_tree_model_get_path(model, &child_iter);
        }
      }
      break;
    case COLLAPSE:
      if (gtk_tree_view_collapse_row(tree_view, path) == FALSE
          && gtk_tree_path_get_depth(path) > 1) {
        gtk_tree_path_up(path);
        gtk_tree_view_collapse_row(tree_view, path);
      }
      break;
    case DOWN:
      if (gtk_tree_view_row_expanded(tree_view, path) == TRUE) {
        gtk_tree_path_down(path);
      } else {
        do {
          gtk_tree_model_get_iter(model, &iter, path);
          if (gtk_tree_model_iter_next(model, &iter)) {
            gtk_tree_path_free(path);
            path = gtk_tree_model_get_path(model, &iter);
            break;
          }
        } while((is_valid_path = (gtk_tree_path_get_depth(path) > 1))
                && gtk_tree_path_up(path));
      }
      break;
    case EXPAND:
      if (gtk_tree_view_expand_row(tree_view, path, FALSE)) {
        gtk_tree_path_down(path);
      }
      break;
    case EXPAND_ALL:
      gtk_tree_view_expand_all(tree_view);
      break;
    case COLLAPSE_ALL:
      gtk_tree_view_collapse_all(tree_view);
      gtk_tree_path_free(path);
      path = gtk_tree_path_new_first();
      gtk_tree_view_set_cursor(tree_view, path, NULL, FALSE);
      break;
    case TOGGLE:
      gtk_tree_model_get_iter(model, &iter, path);
      if (gtk_tree_model_iter_has_child(model, &iter) == TRUE) {
        if (gtk_tree_view_row_expanded(tree_view, path) == TRUE) {
          gtk_tree_view_collapse_row(tree_view, path);
        } else {
          gtk_tree_view_expand_row(tree_view, path, FALSE);
        }
        break;
      }
    case SELECT:
      cb_index_row_activated(tree_view, path, NULL, zathura);
      gtk_tree_path_free(path);
      return false;
  }

  if (is_valid_path == TRUE) {
    gtk_tree_view_set_cursor(tree_view, path, NULL, FALSE);
  }

  gtk_tree_path_free(path);

  return false;
}
Exemplo n.º 23
0
gboolean on_dir_tree_view_key_press( GtkWidget* view,
                                     GdkEventKey* evt,
                                     PtkFileBrowser* browser )
{
    VFSFileInfo* file;
    GtkTreeModel *model;
    GtkTreeIter iter;
    GtkTreeSelection *select = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
    
    if(!gtk_tree_selection_get_selected(select, &model, &iter))
        return FALSE;

    int keymod = ( evt->state & ( GDK_SHIFT_MASK | GDK_CONTROL_MASK |
            GDK_MOD1_MASK | GDK_SUPER_MASK | GDK_HYPER_MASK | GDK_META_MASK ) );

    GtkTreePath *path = gtk_tree_model_get_path(model, &iter);

    switch( evt->keyval ) {
    case GDK_KEY_Left:
        if(gtk_tree_view_row_expanded(GTK_TREE_VIEW(view), path)) {
            gtk_tree_view_collapse_row(GTK_TREE_VIEW(view), path);
        } else if(gtk_tree_path_up(path)) {
            gtk_tree_selection_select_path(select, path);
            gtk_tree_view_set_cursor(GTK_TREE_VIEW(view), path, NULL, FALSE);
        } else {
            gtk_tree_path_free( path );
            return FALSE;
        }
        break;
    case GDK_KEY_Right:
        if(!gtk_tree_view_row_expanded(GTK_TREE_VIEW(view), path)) {
            gtk_tree_view_expand_row(GTK_TREE_VIEW(view), path, FALSE);
        } else {
            gtk_tree_path_down(path);
            gtk_tree_selection_select_path(select, path);
            gtk_tree_view_set_cursor(GTK_TREE_VIEW(view), path, NULL, FALSE);
        }
        break;
    case GDK_KEY_F10:
    case GDK_KEY_Menu:
        if ( evt->keyval == GDK_KEY_F10 && keymod != GDK_SHIFT_MASK )
        {
            gtk_tree_path_free( path );
            return FALSE;
        }
        gtk_tree_model_get( gtk_tree_view_get_model( GTK_TREE_VIEW( view ) ),
                            &iter,
                            COL_DIR_TREE_INFO,
                            &file, -1 );
        if ( file )
        {
            GtkWidget * popup;
            char* file_path;
            GList* sel_files;
            char* dir_name;
            file_path = ptk_dir_view_get_dir_path(
                    gtk_tree_view_get_model( GTK_TREE_VIEW( view ) ), &iter );

            sel_files = g_list_prepend( NULL, vfs_file_info_ref(file) );
            dir_name = g_path_get_dirname( file_path );
            popup = ptk_file_menu_new( NULL, browser,
                        file_path, file,
                        dir_name, sel_files );
            g_free( dir_name );
            g_free( file_path );
            if ( popup )
                gtk_menu_popup( GTK_MENU( popup ), NULL, NULL,
                            NULL, NULL, 3, evt->time );

            vfs_file_info_unref( file );
        }
        break;
    default:
        gtk_tree_path_free( path );
        return FALSE;
    }
    gtk_tree_path_free( path );
    return TRUE;
}