/**
* Try to select the bookmark before the current one.
* If none is selected the last in the list is picked.
* Wraps around.
*/
void
AP_UnixDialog_Goto::_selectPrevBookmark () 
{
	UT_DEBUGMSG (("ROB: AP_UnixDialog_Goto::_selectPrevBookmark ()\n"));
	GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (m_lvBookmarks));
	UT_return_if_fail (model != NULL);

	GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (m_lvBookmarks));
	GtkTreeIter iter;

	// try to select prev
	gboolean haveSelected = gtk_tree_selection_get_selected (selection, &model, &iter);
	if (haveSelected) {
		GtkTreePath *path = gtk_tree_model_get_path (model, &iter);
		gtk_tree_path_prev (path);
		gboolean havePrev = gtk_tree_model_get_iter (model, &iter, path);
		if (havePrev) {
			gtk_tree_selection_select_path (selection, path);
			gtk_tree_path_free (path);
			return;
		}
		gtk_tree_path_free (path);
	}

	// select last
	UT_uint32 idx = getExistingBookmarksCount () - 1;
	GtkTreePath *path = gtk_tree_path_new_from_indices (idx);
	gtk_tree_selection_select_path (selection, path);
	UT_DEBUGMSG (("ROB: AP_UnixDialog_Goto::_selectPrevBookmark () select last '%d'\n", 
					gtk_tree_model_get_iter (model, &iter, path)));
	gtk_tree_path_free (path);
}
/**
* Try to select the bookmark after the current one.
* If none is selected the first in the list is picked.
* Wraps around.
*/
void
AP_UnixDialog_Goto::_selectNextBookmark () 
{
	UT_DEBUGMSG (("ROB: AP_UnixDialog_Goto::_selectNextBookmark ()\n"));
	GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (m_lvBookmarks));
	UT_return_if_fail (model != NULL);

	GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (m_lvBookmarks));
	GtkTreeIter iter;

	// try to select next
	gboolean haveSelected = gtk_tree_selection_get_selected (selection, &model, &iter);
	if (haveSelected) {
		GtkTreePath *path = gtk_tree_model_get_path (model, &iter);
		gtk_tree_path_next (path);
		gboolean haveNext = gtk_tree_model_get_iter (model, &iter, path);
		if (haveNext) {
			gtk_tree_selection_select_path (selection, path);
			gtk_tree_path_free (path);
			return;
		}
		gtk_tree_path_free (path);
	}

	// select first
	GtkTreePath *path = gtk_tree_path_new_first ();
	gtk_tree_selection_select_path (selection, path);
	UT_DEBUGMSG (("ROB: AP_UnixDialog_Goto::_selectNextBookmark () select first '%d'\n", 
					gtk_tree_model_get_iter (model, &iter, path)));
	gtk_tree_path_free (path);
}
static void 
libre_impuesto_sync_selection(LibreImpuesto * impuesto, const gchar * args)
{
  GtkWindow * impuesto_window = libre_impuesto_get_active_window(impuesto);
  GtkWidget * notebook, * switcher;
  GtkWidget * page_child, * tree_view;
  GtkTreeSelection * selection;
  GtkTreeIter selected;
  GtkTreePath * page_path, * tree_path;
  GtkWidget * page_tree_view;

  notebook = g_object_get_data ( G_OBJECT(impuesto_window), "notebook");
  switcher = g_object_get_data ( G_OBJECT(impuesto_window), "switcher");

  page_child = gtk_notebook_get_nth_page (GTK_NOTEBOOK(notebook), 
					  gtk_notebook_get_current_page(GTK_NOTEBOOK(notebook) ));

  page_path = g_object_get_data ( G_OBJECT(page_child), "path" );
  page_tree_view = g_object_get_data ( G_OBJECT(page_child), "tree-view" );
  
  tree_view = gtk_stack_get_visible_child(gtk_stack_switcher_get_stack (GTK_STACK_SWITCHER(switcher)));
  tree_view = gtk_bin_get_child(GTK_BIN(tree_view));

  selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW(tree_view) );
  gtk_tree_selection_get_selected (selection, NULL, &selected);

  if (page_path == NULL || page_tree_view == NULL ) {
    gtk_tree_selection_unselect_all( selection );
    return;
  }

  if ( gtk_tree_selection_count_selected_rows(selection) > 0 ) {
    tree_path = gtk_tree_model_get_path (gtk_tree_view_get_model(GTK_TREE_VIEW(tree_view)), &selected);
    if (  gtk_tree_path_compare( page_path, tree_path ) != 0 ) {
      tree_view = g_object_get_data ( G_OBJECT(page_child), "tree-view" );
      selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW(tree_view) );
      gtk_tree_selection_select_path ( selection, page_path );    
      tree_view = gtk_widget_get_parent ( GTK_WIDGET(tree_view) );
      gtk_stack_set_visible_child (gtk_stack_switcher_get_stack (GTK_STACK_SWITCHER(switcher)), tree_view );
    }
    gtk_tree_path_free(tree_path);
  }
  else {
    tree_view = g_object_get_data ( G_OBJECT(page_child), "tree-view" );
    selection = gtk_tree_view_get_selection ( GTK_TREE_VIEW(tree_view) );
    gtk_tree_selection_select_path ( selection, page_path );    
    tree_view = gtk_widget_get_parent ( GTK_WIDGET(tree_view) );
    gtk_stack_set_visible_child (gtk_stack_switcher_get_stack (GTK_STACK_SWITCHER(switcher)), tree_view );
  }
}
Esempio n. 4
0
void
dh_book_tree_show_uri (DhBookTree *tree, const gchar *uri)
{
#if 0
	GtkTreeSelection    *selection;
	GtkTreeRowReference *row;
	GtkTreePath         *path;

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree));

	/* FIXME: Hmm .. */
	row = g_hash_table_lookup (tree->priv->node_rows, book_node);
	g_return_if_fail (row != NULL);

	path = gtk_tree_row_reference_get_path (row);
	g_return_if_fail (path != NULL);
	
	g_signal_handlers_block_by_func
		(selection, 
		 book_tree_selection_changed_cb,
		 tree);

	gtk_tree_selection_select_path (selection, path);
	gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree), path, NULL, 0);	

	g_signal_handlers_unblock_by_func
		(selection, 
		 book_tree_selection_changed_cb,
		 tree);

	gtk_tree_path_free (path);
#endif
}
Esempio n. 5
0
static void
add_path_to_playlist(GtkTreePath * path, GtkTreeIter * piter, int new_tab) {

	int depth = gtk_tree_path_get_depth(path);

	gtk_tree_selection_select_path(music_select, path);

	if (new_tab) {
		char * name;
		GtkTreeIter iter;

		gtk_tree_model_get_iter(GTK_TREE_MODEL(music_store), &iter, path);
		gtk_tree_model_get(GTK_TREE_MODEL(music_store), &iter, MS_COL_NAME, &name, -1);
		playlist_tab_new_if_nonempty(name);

		g_free(name);
	}

	switch (depth) {
	case 1:
		cdda_store__addlist_defmode(piter);
		break;
	case 2:
		cdda_record__addlist_defmode(piter);
		break;
	case 3:
		cdda_track__addlist_cb(piter);
		break;
	}
}
static void update_cb (void * data, void * user)
{
    g_return_if_fail (treeview);

    GtkTreeModel * model;
    GtkTreeIter iter;
    GtkTreePath * path = NULL;

    if (GPOINTER_TO_INT (data) <= PLAYLIST_UPDATE_SELECTION)
        return;

    if (cache != NULL)
    {
        ui_jump_to_track_cache_free (cache);
        cache = NULL;
    }

    /* If it's only a metadata update, save and restore the cursor position. */
    if (GPOINTER_TO_INT (data) <= PLAYLIST_UPDATE_METADATA &&
     gtk_tree_selection_get_selected (gtk_tree_view_get_selection
     ((GtkTreeView *) treeview), & model, & iter))
        path = gtk_tree_model_get_path (model, & iter);

    fill_list ();

    if (path != NULL)
    {
        gtk_tree_selection_select_path (gtk_tree_view_get_selection
         ((GtkTreeView *) treeview), path);
        gtk_tree_view_scroll_to_cell ((GtkTreeView *) treeview, path, NULL, TRUE, 0.5, 0);
        gtk_tree_path_free (path);
    }
}
Esempio n. 7
0
static void
select_created_user (UmUser *user, UmUserPanelPrivate *d)
{
        GtkTreeView *tv;
        GtkTreeModel *model;
        GtkTreeSelection *selection;
        GtkTreeIter iter;
        UmUser *current;
        GtkTreePath *path;

        tv = (GtkTreeView *)get_widget (d, "list-treeview");
        model = gtk_tree_view_get_model (tv);
        selection = gtk_tree_view_get_selection (tv);

        gtk_tree_model_get_iter_first (model, &iter);
        do {
                gtk_tree_model_get (model, &iter, USER_COL, &current, -1);
                if (user == current) {
                        path = gtk_tree_model_get_path (model, &iter);
                        gtk_tree_view_scroll_to_cell (tv, path, NULL, FALSE, 0.0, 0.0);
                        gtk_tree_selection_select_path (selection, path);
                        gtk_tree_path_free (path);
                        g_object_unref (current);
                        break;
                }
                if (current)
                        g_object_unref (current);
        } while (gtk_tree_model_iter_next (model, &iter));
}
Esempio n. 8
0
bool gtkgui_sel_playlist(unsigned int chan, int row)
{
	struct gchan *c = NULL;
	GtkTreeModel *model = NULL;
	GtkTreeSelection *selection = NULL;
	GtkTreeIter iter;
	GtkTreePath *path = NULL;

	c = (struct gchan *) list_get_data(listachan, chan+1, 0); 

	if(!c) return false;

	if(!c->playmode)
		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(c->play), FALSE);

	gtk_entry_set_text(GTK_ENTRY(c->ptime), "00:00:00");
	gtk_adjustment_set_value(GTK_ADJUSTMENT(c->adjprog), 0.0);

	model = gtk_tree_view_get_model(GTK_TREE_VIEW(c->tree));
	if(!model) return false;
	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(c->tree));
	if(!selection) return false;
	gtk_tree_selection_get_selected(selection, NULL, &iter);
	path = gtk_tree_model_get_path(model, &iter);
	if(!path) return false;
	
	gtk_tree_selection_select_path(selection, path);
	
	gtk_tree_path_free(path);
	

	return true;
}
Esempio n. 9
0
File: Cheat.c Progetto: bsv798/pcsxr
static void LoadCheatListItems(int index) {
	GtkListStore *store = gtk_list_store_new(2, G_TYPE_BOOLEAN, G_TYPE_STRING);
	GtkTreeIter iter;
	GtkWidget *widget;

	int i;

	widget = gtk_builder_get_object(builder, "GtkCList_Cheat");

	for (i = 0; i < NumCheats; i++) {
		gtk_list_store_append(store, &iter);
		gtk_list_store_set(store, &iter, 0, Cheats[i].Enabled, 1, Cheats[i].Descr, -1);
	}

	gtk_tree_view_set_model(GTK_TREE_VIEW(widget), GTK_TREE_MODEL(store));
	g_object_unref(G_OBJECT(store));
	gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(widget), TRUE);
	gtk_tree_view_set_search_column(GTK_TREE_VIEW(widget), 1);
	gtk_widget_show(widget);

	if (index >= NumCheats) {
		index = NumCheats - 1;
	}

	if (index >= 0) {
		GtkTreePath *path;
		GtkTreeSelection *sel;

		path = gtk_tree_path_new_from_indices(index, -1);
		sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));

		gtk_tree_selection_select_path(sel, path);
		gtk_tree_path_free(path);
	}
}
Esempio n. 10
0
static void
select_or_unselect_range(GtkTreeSelection *selection,
                         guint from, guint to,
                         gboolean select)
{
    if (from == to)
        return;

    GtkTreePath *pathfrom = gtk_tree_path_new();
    gtk_tree_path_append_index(pathfrom, from);
    if (from+1 == to) {
        if (select)
            gtk_tree_selection_select_path(selection, pathfrom);
        else
            gtk_tree_selection_unselect_path(selection, pathfrom);
    }
    else {
        GtkTreePath *pathto = gtk_tree_path_new();
        gtk_tree_path_append_index(pathto, to);
        if (select)
            gtk_tree_selection_select_range(selection, pathfrom, pathto);
        else
            gtk_tree_selection_unselect_range(selection, pathfrom, pathto);
        gtk_tree_path_free(pathto);
    }
    gtk_tree_path_free(pathfrom);
}
Esempio n. 11
0
File: lists.c Progetto: proton/xmpc
static gboolean
cb_button_pressed (XfmpcLists *lists,
									GdkEventButton *event)
{
	XfmpcListsPrivate    *priv = XFMPC_LISTS (lists)->priv;
	GtkTreeSelection         *selection;
	GtkTreePath              *path;

	if (event->type != GDK_BUTTON_PRESS || event->button != 3)
		return FALSE;

	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->treeview));
	if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (priv->treeview),
																		event->x, event->y,
																		&path, NULL, NULL, NULL))
		{
			if (!gtk_tree_selection_path_is_selected (selection, path))
				{
					gtk_tree_selection_unselect_all (selection);
					gtk_tree_selection_select_path (selection, path);
				}
			gtk_tree_path_free (path);
		}

	popup_menu (lists);

	return TRUE;
}
Esempio n. 12
0
static gboolean cm_try_to_select(CMPathWalkFunc path_func, GtkTreeSelection *selection,
                                 GtkTreeModel *model, GtkTreePath *path)
{
    GtkTreeIter iter;

    if (gtk_tree_path_get_depth(path) <= 0) /* sanity check */
        return FALSE;

    /* modify the path using the passed function */
    if (path_func != NULL)
        path_func(path);

    if (gtk_tree_path_get_depth(path) <= 0) /* sanity check */
        return FALSE;

    /* check whether the path points to something valid and if so, select it */
    if (gtk_tree_model_get_iter(model, &iter, path))
    {
        GtkTreeView *treeview = gtk_tree_selection_get_tree_view(selection);
        gboolean was_expanded = gtk_tree_view_row_expanded(treeview, path);
        /* to get gtk_tree_selection_select_path() working, we need to expand the row first
         * if it isn't expanded yet, at least when the row is a parent item */
        if (! was_expanded)
            gtk_tree_view_expand_to_path(treeview, path);

        gtk_tree_selection_select_path(selection, path);

        if (! was_expanded) /* restore the previous state */
            gtk_tree_view_collapse_row(treeview, path);
        return TRUE;
    }

    return FALSE;
}
Esempio n. 13
0
gboolean
on_tree_view_button_pressed (GtkWidget *      view,
                             GdkEventButton * event,
                             gpointer         func)
{
  GtkTreeView * tv = GTK_TREE_VIEW (view);

  if (event->type == GDK_BUTTON_PRESS  &&  event->button == 3)
    {
      GtkTreePath * path;
      GtkTreeSelection * selection = gtk_tree_view_get_selection (tv);

      if (gtk_tree_view_get_path_at_pos (tv,
                                         (gint) event->x,
                                         (gint) event->y,
                                         &path, NULL, NULL, NULL))
        {
          if (!gtk_tree_selection_path_is_selected (selection, path))
            {
              gtk_tree_selection_unselect_all (selection);
              gtk_tree_selection_select_path (selection, path);
            }
          gtk_tree_path_free (path);
        }

      if (func != NULL)
        ((PopupFunc*)func)(view, event);

      return TRUE;
    }

  return FALSE;
}
Esempio n. 14
0
gboolean on_button_pressed(GtkWidget * treeview, GdkEventButton * event, gpointer UNUSED(userdata))
{
  /* single click with the right mouse button? */
  if (event->type == GDK_BUTTON_PRESS && event->button == 3)
  {
    /* select row if no row is selected or only one other row is selected */
    {
      GtkTreeSelection *selection;

      selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));

      /* Note: gtk_tree_selection_count_selected_rows() does not exist in gtk+-2.0, only in gtk+ >= v2.2 ! */
      if (gtk_tree_selection_count_selected_rows(selection) <= 1)
      {
        GtkTreePath *path;

        /* Get tree path for row that was clicked */
        if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), (gint)event->x, (gint)event->y, &path, NULL, NULL, NULL))
        {
          gtk_tree_selection_unselect_all(selection);
          gtk_tree_selection_select_path(selection, path);
          gtk_tree_path_free(path);
        }
      }
    }

    popup_menu(treeview, event);

    return TRUE; /* we handled this */
  }

  return FALSE; /* we did not handle this */
}
Esempio n. 15
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) ;
    }
  }
Esempio n. 16
0
static void
sequence_prev (void)
{
  GtkTreeIter       iter;
  GtkTreePath      *path;
  GtkTreeSelection *selection;

  selection = gtk_tree_view_get_selection (sequence_view);

  if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
    return;

  path = gtk_tree_model_get_path (GTK_TREE_MODEL (sequence_store), &iter);

  if (!gtk_tree_path_prev (path))
    return;

  if (sequence_source_id > 0)
    {
      current_step->progress = 0;
      gtk_tree_model_get (GTK_TREE_MODEL (sequence_store), &iter,
                          COLUMN_DATA, &current_step,
                          -1);
      current_step->progress = 0;
    }
  
  gtk_tree_selection_select_path (selection, path);
  sequence_scroll_to_selected ();
}
Esempio n. 17
0
static gboolean table_onButtonPressed(GtkWidget *treeview, GdkEventButton *event, gpointer userdata){
	dataToSend_ *dataToSend;
	/* single click with the right mouse button? */
    if (event->type == GDK_BUTTON_PRESS  &&  event->button == 3){
		g_print ("Single right click on the tree view.\n");
		if (1){
			GtkTreeSelection *selection;
			selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
			//! Note: gtk_tree_selection_count_selected_rows() does not exist in gtk+-2.0, only in gtk+ >= v2.2
			if (gtk_tree_selection_count_selected_rows(selection)  <= 1){
				GtkTreePath *path;
				//! Get tree path for row that was clicked
				if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),(gint) event->x, (gint) event->y,&path, NULL, NULL, NULL)){
					gtk_tree_selection_unselect_all(selection);
					gtk_tree_selection_select_path(selection, path);
					gtk_tree_path_free(path);
					
					GtkTreeModel     *model;
					GtkTreeIter       iter;
					if (gtk_tree_selection_get_selected(selection, &model, &iter)){
						dataToSend = struct_new(dataToSend_);
						gtk_tree_model_get (model, &iter, 0, &dataToSend->id, -1);    
						gtk_tree_model_get (model, &iter, 5, &dataToSend->file, -1);    
					}
				}
			}
		}
		table_popup_menu(treeview, event, dataToSend);
		return TRUE; /* we handled this */
	}
	return FALSE; /* we did not handle this */
}
Esempio n. 18
0
static gboolean button_pressed(GtkWidget *widget,
				GdkEventButton *event, gpointer user_data)
{
	GtkTreeSelection *selection;
	GtkTreePath *path;

	if (event->type != GDK_BUTTON_PRESS)
		return FALSE;

	if (event->button != 3)
		return FALSE;

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(widget));

	if (gtk_tree_selection_count_selected_rows(selection) != 1)
		return FALSE;

	if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
					(gint) event->x, (gint) event->y,
					&path, NULL, NULL, NULL) == FALSE)
		return FALSE;

	gtk_tree_selection_unselect_all(selection);
	gtk_tree_selection_select_path(selection, path);

	gtk_tree_path_free(path);

	show_popup(widget, event, selection);

	return TRUE;
}
Esempio n. 19
0
/**
 * Advance selection to previous/next item in list.
 * \param list_view List to process.
 * \param forward Set to <i>TRUE</i> to select next or <i>FALSE</i> for
 *                previous entry.
 */
static void completion_window_advance_selection(GtkTreeView *list_view, gboolean forward)
{
	GtkTreeSelection *selection;
	GtkTreeIter iter;
	GtkTreeModel *model;

	cm_return_if_fail(list_view != NULL);

	selection = gtk_tree_view_get_selection(list_view);
	if (!gtk_tree_selection_get_selected(selection, &model, &iter))
		return;

	if (forward) { 
		forward = gtk_tree_model_iter_next(model, &iter);
		if (forward) 
			gtk_tree_selection_select_iter(selection, &iter);
	} else {
		GtkTreePath *prev;

		prev = gtk_tree_model_get_path(model, &iter);
		if (!prev) 
			return;

		if (gtk_tree_path_prev(prev))
			gtk_tree_selection_select_path(selection, prev);
		
		gtk_tree_path_free(prev);
	}
}
Esempio n. 20
0
static void
did_not_drag (EphyNodeView *view,
	      GdkEventButton *event)
{
	GtkTreeView *tree_view;
	GtkTreeSelection *selection;
	GtkTreePath *path;

	tree_view = GTK_TREE_VIEW (view);
	selection = gtk_tree_view_get_selection (tree_view);

	if (gtk_tree_view_get_path_at_pos (tree_view, event->x, event->y,
					   &path, NULL, NULL, NULL))
	{
		if((event->button == 1 || event->button == 2) &&
		   gtk_tree_selection_path_is_selected (selection, path) &&
		   !button_event_modifies_selection (event))
		{
			if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE)
			{
				gtk_tree_selection_unselect_all (selection);
			}

			gtk_tree_selection_select_path (selection, path);
		}

		gtk_tree_path_free (path);
	}
}
Esempio n. 21
0
static void sp_font_selector_family_select_row(GtkTreeSelection *selection,
                                               SPFontSelector *fsel)
{
    GtkTreeIter   iter;
    GtkTreeModel *model;
    GtkListStore *store;
    GtkTreePath  *path;
    GList        *list=0;

    if (!gtk_tree_selection_get_selected (selection, &model, &iter)) return;

    path = gtk_tree_model_get_path (model, &iter);
    gtk_tree_model_get (model, &iter, 1, &list, -1);
    fsel->familyidx = gtk_tree_path_get_indices (path)[0];
    fsel->styleidx = 0;

    store = gtk_list_store_new (1, G_TYPE_STRING);

    for ( ; list ; list = list->next )
    {
        gtk_list_store_append (store, &iter);
        gtk_list_store_set (store, &iter, 0, (char*)list->data, -1);
    }

    gtk_tree_view_set_model (GTK_TREE_VIEW (fsel->style_treeview), GTK_TREE_MODEL (store));
    path = gtk_tree_path_new ();
    gtk_tree_path_append_index (path, 0);
    gtk_tree_selection_select_path (gtk_tree_view_get_selection (GTK_TREE_VIEW (fsel->style_treeview)), path);
    gtk_tree_path_free (path);
}
Esempio n. 22
0
static gboolean menu_cardview_button_press_event(GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
{
    GtkTreeSelection *selection;
    GtkTreePath *path;

    if (event->type == GDK_BUTTON_PRESS  &&  event->button == 3)
    {
        selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));

        if (gtk_tree_selection_count_selected_rows(selection)  <= 1)
        {

            /* Get tree path for row that was clicked */
            if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview),
                                              (gint) event->x,
                                              (gint) event->y,
                                              &path, NULL, NULL, NULL))
            {
                gtk_tree_selection_unselect_all(selection);
                gtk_tree_selection_select_path(selection, path);
                gtk_tree_path_free(path);
            }
        }
        menu_cardview_context_menu(treeview,event,userdata);
        return TRUE;
    }
    /*
    else if (event->type == GDK_2BUTTON_PRESS  &&  event->button == 1)
    {
      g_printf("double click\n");
    }
    */
    return FALSE;
}
Esempio n. 23
0
static gboolean
reload_section(gpointer data)
{
    ShellModuleEntry	*entry = (ShellModuleEntry *) data;

    /* if the entry is still selected, update it */
    if (entry->selected && entry->reloadfunc) {
        GtkTreePath		*path = NULL;
        GtkTreeSelection	*ts;
        GtkTreeIter		 iter;

        /* gets the current selected path */
        ts = gtk_tree_view_get_selection(GTK_TREE_VIEW
                                         (shell->info->view));
        if (gtk_tree_selection_get_selected(ts, &shell->info->model, &iter))
            path = gtk_tree_model_get_path(shell->info->model, &iter);

        /* update the information, clear the treeview and populate it again */
        entry->reloadfunc(entry->number);
        info_selected_show_extra(NULL);	/* clears the more info store */
        module_selected_show_info(entry, TRUE);

        /* if there was a selection, reselect it */
        if (path) {
            gtk_tree_selection_select_path(ts, path);
            gtk_tree_path_free(path);
        }
    }

    /* destroy the timeout: it'll be set up again */
    return FALSE;
}
Esempio n. 24
0
static void
update_bookmarks_treeview(UiBookmarks *bookmarks, gchar *uri)
{
    GtkTreeSelection *selection;
    GtkTreeIter iter;
    GList *l;

    selection = gtk_tree_view_get_selection(GTK_TREE_VIEW (bookmarks->list));
    gtk_list_store_clear(bookmarks->store);

    for (l = bookmarks->links; l; l = l->next) {
        Link *link = l->data;

        gtk_list_store_append(bookmarks->store, &iter);
        gtk_list_store_set(bookmarks->store, &iter,
                           COL_TITLE, link->name,
                           COL_URI, link->uri,
                           -1);

        if (uri != NULL && ncase_compare_utf8_string(uri, link->uri) == 0)
            gtk_tree_selection_select_iter(selection, &iter);
    }

    if (uri == NULL || strlen(uri) == 0)
        gtk_tree_selection_select_path(selection, gtk_tree_path_new_first());
}
Esempio n. 25
0
/* Remove an item from the page's current list.
 */
static void
tp_page_remove_selected(ToolbarPage * page)
{
    GtkTreeSelection *selection =
        gtk_tree_view_get_selection(GTK_TREE_VIEW(page->current));
    GtkTreeModel *model;
    GtkTreeIter iter;
    GtkTreePath *path;

    if (!gtk_tree_selection_get_selected(selection, &model, &iter))
        return;
    path = gtk_tree_model_get_path(model, &iter);

    gtk_list_store_remove(GTK_LIST_STORE(model), &iter);

    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);

    gtk_widget_set_sensitive(page->standard_button, TRUE);
    tp_page_refresh_preview(page);
#ifndef BALSA_TOOLBAR_DEBUG_ACTIONS
    tp_page_refresh_available(page);
#else /* BALSA_TOOLBAR_DEBUG_ACTIONS */
    tp_page_refresh_available(page, NULL);
#endif /* BALSA_TOOLBAR_DEBUG_ACTIONS */
    balsa_toolbar_model_changed(page->model);
}
Esempio n. 26
0
gboolean
on_table_button_press_event (GtkWidget *widget, GdkEventButton *event, gpointer data)
{
	GtkTreePath *path;
	GtkTreeView *treeview = GTK_TREE_VIEW (widget);
	GtkWidget *popup;

	if (event->button == 3) {
		if (gtk_tree_view_get_path_at_pos (treeview, event->x, event->y, &path, NULL, NULL, NULL)) {
			gtk_tree_selection_unselect_all (gtk_tree_view_get_selection (treeview));
			gtk_tree_selection_select_path (gtk_tree_view_get_selection (treeview), path);

			popup = g_object_get_data (G_OBJECT (treeview), "popup");
			do_popup_menu (widget, popup, event);
		}

		return TRUE;
	}

	/*
	if (event->type == GDK_2BUTTON_PRESS ||
	    event->type == GDK_3BUTTON_PRESS) {
		show_settings ();

		return TRUE;
	}
	*/

	return FALSE;
}
Esempio n. 27
0
static gboolean
cv_tree_click_cb (GtkTreeView *tree, GdkEventButton *event, chanview *cv)
{
	chan *ch;
	GtkTreeSelection *sel;
	GtkTreePath *path;
	GtkTreeIter iter;
	int ret = FALSE;

	if (event->button != 3 && event->state == 0)
		return FALSE;

	sel = gtk_tree_view_get_selection (tree);
	if (gtk_tree_view_get_path_at_pos (tree, event->x, event->y, &path, 0, 0, 0))
	{
		if (event->button == 2)
		{
			gtk_tree_selection_unselect_all (sel);
			gtk_tree_selection_select_path (sel, path);
		}
		if (gtk_tree_model_get_iter (GTK_TREE_MODEL (cv->store), &iter, path))
		{
			gtk_tree_model_get (GTK_TREE_MODEL (cv->store), &iter, COL_CHAN, &ch, -1);
			ret = cv->cb_contextmenu (cv, ch, ch->tag, ch->userdata, event);
		}
		gtk_tree_path_free (path);
	}
	return ret;
}
Esempio n. 28
0
static void
fm_list_view_select_path (FMDirectoryView *view, GtkTreePath *path)
{
    GtkTreeSelection *selection;

    selection = gtk_tree_view_get_selection (FM_LIST_VIEW (view)->tree);
    gtk_tree_selection_select_path (selection, path);
}
Esempio n. 29
0
void remove_button_clicked_cb(GtkWidget *widget, gpointer data) {
	struct add_data *ad = (struct add_data *) data;
	GtkTreeIter iter,temp_iter;
	GtkTreeModel *model;
	gboolean valid;
	int index,nindices;
	int i;
	char buffer[512];

	if (gtk_tree_selection_get_selected(ad->select, &model, &iter)) {
		valid = gtk_tree_model_get_iter_first(model, &temp_iter);
		index = 0;
		nindices = 0;
		while(valid) {
			if (gtk_tree_selection_iter_is_selected(ad->select, &temp_iter)) {
#if DEBUG == 1
				fprintf(stdout,"Index: %i\n",nindices);
#endif
				index = nindices;
			}
			nindices++;
			valid = gtk_tree_model_iter_next(model, &temp_iter);
		}

		for (i = index ; i < nindices ; i++) {
			(*(ad->cw->lw->my_layer))->weight[i] =(*(ad->cw->lw->my_layer))->weight[i+1];
			(*(ad->cw->lw->my_layer))->Z[i] =(*(ad->cw->lw->my_layer))->Z[i+1];
		}
		(*(ad->cw->lw->my_layer))->weight = (double *) realloc((*(ad->cw->lw->my_layer))->weight, sizeof(double)*((*(ad->cw->lw->my_layer))->n_elements-1));
		(*(ad->cw->lw->my_layer))->Z = (int *) realloc((*(ad->cw->lw->my_layer))->Z, sizeof(int)*((*(ad->cw->lw->my_layer))->n_elements-1));
		(*(ad->cw->lw->my_layer))->n_elements--;
		gtk_list_store_remove(ad->store, &iter);
		sprintf(buffer,"%g", xmi_sum_double((*(ad->cw->lw->my_layer))->weight,(*(ad->cw->lw->my_layer))->n_elements )*100.0);
		gtk_entry_set_text(GTK_ENTRY(ad->cw->lw->sumEntry), buffer);
		if ((*(ad->cw->lw->my_layer))->n_elements == 0)
			gtk_widget_set_sensitive(ad->cw->lw->okButton, FALSE);
		else{
			//select next line if available
			if (index == nindices -1)
				gtk_tree_selection_select_path(ad->select,gtk_tree_path_new_from_indices(nindices-2,-1));
			else 
				gtk_tree_selection_select_path(ad->select,gtk_tree_path_new_from_indices(index,-1));

		}
	}
}
Esempio n. 30
0
void select_row(gint row)
{
	if (row < 0)
		return;
	GtkTreePath *p = gtk_tree_path_new_from_indices(row, -1);
	gtk_tree_selection_select_path(tree_selection, p);
	gtk_tree_path_free(p);
}