Example #1
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) ;
    }
  }
static GtkTreePath *get_next_bus (GtkTreeModel *tm, GtkTreePath *tpSelBus)
  {
  int row_type ;
  int icRootChildren = -1 ;
  GtkTreePath *tp = NULL ;
  int idxChild = 0 ;
  GtkTreeIter itr ;

  if (1 != gtk_tree_path_get_depth (tpSelBus))
    return NULL ;

  icRootChildren = gtk_tree_model_iter_n_children (tm, NULL) ;

  tp = gtk_tree_path_new_first () ;
  while (gtk_tree_path_compare (tp, tpSelBus) <= 0 && idxChild < icRootChildren)
    {
    gtk_tree_model_get_iter (tm, &itr, tp) ;
    gtk_tree_path_next (tp) ;
    idxChild++ ;
    }

  while (idxChild < icRootChildren)
    {
    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)
      return tp ;
    if (++idxChild < icRootChildren)
      gtk_tree_path_next (tp) ;
    }
  gtk_tree_path_free (tp) ;
  return NULL ;
  }
Example #3
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++;
  }
}
// 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) ;
  }
Example #5
0
void
tsk_tasks_foreach (guint32 julian_start, guint32 julian_end, gboolean (*ttfunc)(), GUI *appGUI)
{
	GtkTreeModel *model = NULL;
	GtkTreePath *path;
	GtkTreeIter iter;
	gchar *category;
	guint32 julian;

	model = GTK_TREE_MODEL (appGUI->tsk->tasks_list_store);
	if (model == NULL) return;

	path = gtk_tree_path_new_first ();

	while (gtk_tree_model_get_iter (model, &iter, path) == TRUE) {

		gtk_tree_model_get (model, &iter,
		                    TA_COLUMN_DUE_DATE_JULIAN, &julian,
		                    TA_COLUMN_CATEGORY, &category, -1);

		if (julian >= julian_start && julian <= julian_end)
			if (tsk_get_category_state (category, STATE_EITHER, appGUI) == TRUE) {
				if ((*ttfunc)(julian, model, &iter, appGUI) == TRUE) {
					g_free (category);
					break;
				}
			}

		g_free (category);
		gtk_tree_path_next (path);
	}

	gtk_tree_path_free (path);
}
static void
dict_list_down_clicked_cb (GtkButton *button,
                           gpointer userdata)
{
    GtkTreeView *view = GTK_TREE_VIEW(userdata);
    GtkTreeModel *model = gtk_tree_view_get_model(view);
    GtkTreeSelection *selection = gtk_tree_view_get_selection(view);
    GtkTreeIter iter;
    if (gtk_tree_selection_get_selected(selection, NULL, &iter)) {
        GtkTreePath *path;
        GtkTreeIter next_iter;
        int i;
        path = gtk_tree_model_get_path(model, &iter);
        i = gtk_tree_path_get_indices(path)[0];
        if (i < __config_sysdicts.size() - 1) {
            vector<String>::iterator it  = __config_sysdicts.begin() + i;
            vector<String>::iterator it2 = it + 1;
            iter_swap(it, it2);
            __have_changed = true;
        }

        gtk_tree_path_next(path);
        if (gtk_tree_model_get_iter(model, &next_iter, path)) {
            gtk_list_store_move_after(GTK_LIST_STORE(model),
                                      &iter, &next_iter);
        }
        gtk_tree_path_free(path);
    }
}
Example #7
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));
}
Example #8
0
File: iopen.c Project: szfn/teddy
static bool iopen_other_keys(editor_t *editor, bool shift, bool ctrl, bool alt, bool super, guint keyval) {
	if (!shift && !ctrl && !alt && !super) {
		GtkTreePath *path;

		switch (keyval) {
		case GDK_KEY_Up:
			gtk_tree_view_get_cursor(GTK_TREE_VIEW(results_tree), &path, NULL);
			if (path == NULL) {
				path = gtk_tree_path_new_first();
			} else {
				gtk_tree_path_prev(path);
			}
			gtk_tree_view_set_cursor(GTK_TREE_VIEW(results_tree), path, NULL, FALSE);
			gtk_tree_path_free(path);
			return true;
		case GDK_KEY_Down:
			gtk_tree_view_get_cursor(GTK_TREE_VIEW(results_tree), &path, NULL);
			if (path == NULL) {
				path = gtk_tree_path_new_first();
			} else {
				gtk_tree_path_next(path);
			}
			gtk_tree_view_set_cursor(GTK_TREE_VIEW(results_tree), path, NULL, FALSE);
			gtk_tree_path_free(path);
			return true;
		}
	}
	return false;
}
Example #9
0
/****************************************************************
  Move item down in queue
*****************************************************************/
static void queue_bubble_down(struct worklist_data *ptr)
{
  GtkTreePath *path;
  GtkTreeViewColumn *col;
  GtkTreeModel *model;

  if (!gtk_widget_is_sensitive(ptr->dst_view)) {
    return;
  }

  model = GTK_TREE_MODEL(ptr->dst);
  gtk_tree_view_get_cursor(GTK_TREE_VIEW(ptr->dst_view), &path, &col);
  if (path) {
    GtkTreeIter it, it_next;

    gtk_tree_model_get_iter(model, &it, path);
    it_next = it;
    if (gtk_tree_model_iter_next(model, &it_next)) {
      gtk_list_store_swap(GTK_LIST_STORE(model), &it, &it_next);

      gtk_tree_path_next(path);
      gtk_tree_view_set_cursor(GTK_TREE_VIEW(ptr->dst_view), path, col, FALSE);
      commit_worklist(ptr);
    }
  }
  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);
}
Example #11
0
gboolean
tsk_check_tasks (guint32 julian_start, guint32 julian_end, gint type, GUI *appGUI)
{
	GtkTreeModel *model = NULL;
	GtkTreePath *path;
	GtkTreeIter iter;
	gchar *category;
	guint32 julian;

	model = GTK_TREE_MODEL (appGUI->tsk->tasks_list_store);
	if (model == NULL) return FALSE;

	path = gtk_tree_path_new_first ();

	while (gtk_tree_model_get_iter (model, &iter, path) == TRUE) {

		gtk_tree_model_get (model, &iter,
		                    TA_COLUMN_DUE_DATE_JULIAN, &julian,
		                    TA_COLUMN_CATEGORY, &category, -1);

		if (julian >= julian_start && julian <= julian_end)
			if (tsk_get_category_state (category, type, appGUI) == TRUE) {
				g_free (category);
				gtk_tree_path_free (path);
				return TRUE;
			}

		g_free (category);
		gtk_tree_path_next (path);
	}

	gtk_tree_path_free (path);

	return FALSE;
}
Example #12
0
int view_navigate_next(GtkTreeView *view)
{
	GtkTreeIter iter;
	GtkTreeModel *model;
	GtkTreePath *path;
	GtkTreeSelection *selection;

	path = view_get_current_path(view, &model, &selection);
	if (path != NULL) {
		gtk_tree_path_next(path);
		if (!gtk_tree_model_get_iter(model, &iter, path) &&
		    gtk_tree_model_get_iter_first(model, &iter)) {

			gtk_tree_path_free(path);
			path = gtk_tree_model_get_path(model, &iter);
		}

	}

	if (path != NULL) {
		select_path(view, selection, path);
		gtk_tree_path_free(path);
	}

	return path != NULL;

}
Example #13
0
static void on_add( GtkButton* btn, gpointer data )
{
    GtkWindow* parent = GTK_WINDOW(data);
    GtkTreeViewColumn* col;
    GtkTreeIter it, new_it, *pit;
    GtkTreePath* tree_path;
    GtkTreeView* view = (GtkTreeView*)g_object_get_data( G_OBJECT(data),
                                                         "list_view" );
    GtkTreeModel* model;
    GtkTreeSelection* sel = gtk_tree_view_get_selection( view );

    GdkPixbuf* icon = gtk_icon_theme_load_icon( gtk_icon_theme_get_default(),
                                                "gnome-fs-directory",
                                                20, 0, NULL );
    GtkWidget* dlg;
    char *path = NULL, *basename = NULL;

    if( gtk_tree_selection_get_selected ( sel, &model, &it ) )
    {
        tree_path = gtk_tree_model_get_path( model, &it );
        gtk_tree_path_next( tree_path );
        pit = &it;
    }
    else
    {
        tree_path = gtk_tree_path_new_first();
        pit = NULL;
    }

    dlg = gtk_file_chooser_dialog_new( NULL, parent,
                            GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
                            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                            GTK_STOCK_OK, GTK_RESPONSE_OK, NULL );
    if( gtk_dialog_run( (GtkDialog*) dlg ) == GTK_RESPONSE_OK )
    {
        path = gtk_file_chooser_get_filename( (GtkFileChooser*)dlg );
        basename = g_filename_display_basename( path );
    }
    gtk_widget_destroy( dlg );

    col = gtk_tree_view_get_column( view, 1 );
    gtk_list_store_insert_after( GTK_LIST_STORE(model), &new_it, pit );
    gtk_list_store_set( GTK_LIST_STORE(model), &new_it,
                        COL_ICON, icon,
                        COL_NAME, basename ? basename : _("New Item"),
                        COL_DIRPATH, path, -1);

    g_free( path );
    g_free( basename );

    if( tree_path )
    {
        gtk_tree_view_set_cursor_on_cell( view, tree_path, col, NULL, TRUE );
        gtk_tree_path_free( tree_path );
    }

    if( icon )
        g_object_unref( icon );
}
Example #14
0
/**
 * unselect the current selection of the custom list
 *
 * \param
 *
 * \return
 * */
void transaction_list_select_unselect (void)
{
    CustomRecord *record = NULL;
    GtkTreePath *path;
    GtkTreeIter iter;
    gint i;
    CustomList *custom_list;

    custom_list = transaction_model_get_model ();

    g_return_if_fail ( custom_list != NULL );
    g_return_if_fail ( custom_list -> selected_row != NULL );

    iter.stamp = custom_list->stamp;

    /* get the selected row */
    record = custom_list -> selected_row;

    if (record)
    {
        /* si l'opération n'est pas visible on sort */
        if ( ( record -> mother_row && record -> mother_row -> filtered_pos == -1 )
         ||
         record -> filtered_pos == -1 )
        {
            custom_list -> selected_row = NULL;
            return;
        }

        /* get the path of the row */
        path = gtk_tree_path_new ();
        if (record -> mother_row)
            /* it's a child, need to get the path of the mother */
            gtk_tree_path_append_index (path, record -> mother_row -> filtered_pos);

        gtk_tree_path_append_index (path, record -> filtered_pos);

        for (i=0 ; i < custom_list -> nb_rows_by_transaction ; i++)
        {
            record -> row_bg = record -> row_bg_save;
            record -> row_bg_save = NULL;

            /* inform the world that the row has changed */
            iter.user_data = record;
            gtk_tree_model_row_changed(GTK_TREE_MODEL(custom_list), path, &iter);

            /* if the selection was a child, we stop now, only 1 line */
            if (record -> mother_row)
            break;

            /* go to the next row of the transaction */
            record = custom_list -> visibles_rows [record -> filtered_pos + 1];
            gtk_tree_path_next (path);
        }
        gtk_tree_path_free (path);
    }
    custom_list -> selected_row = NULL;
}
Example #15
0
static void
gimp_path_editor_move_clicked (GtkWidget      *widget,
                               GimpPathEditor *editor)
{
  GtkTreePath  *path;
  GtkTreeModel *model;
  GtkTreeIter   iter1, iter2;
  gchar        *utf81, *utf82;
  gchar        *dir1, *dir2;
  gboolean      writable1, writable2;

  if (editor->sel_path == NULL)
    return;

  path = gtk_tree_path_copy (editor->sel_path);

  if (widget == editor->up_button)
    gtk_tree_path_prev (path);
  else
    gtk_tree_path_next (path);

  model = GTK_TREE_MODEL (editor->dir_list);

  gtk_tree_model_get_iter (model, &iter1, editor->sel_path);
  gtk_tree_model_get_iter (model, &iter2, path);

  gtk_tree_model_get (model, &iter1,
                      COLUMN_UTF8,      &utf81,
                      COLUMN_DIRECTORY, &dir1,
                      COLUMN_WRITABLE,  &writable1,
                      -1);
  gtk_tree_model_get (model, &iter2,
                      COLUMN_UTF8,      &utf82,
                      COLUMN_DIRECTORY, &dir2,
                      COLUMN_WRITABLE,  &writable2,
                      -1);

  gtk_list_store_set (editor->dir_list, &iter1,
                      COLUMN_UTF8,      utf82,
                      COLUMN_DIRECTORY, dir2,
                      COLUMN_WRITABLE,  writable2,
                      -1);
  gtk_list_store_set (editor->dir_list, &iter2,
                      COLUMN_UTF8,      utf81,
                      COLUMN_DIRECTORY, dir1,
                      COLUMN_WRITABLE,  writable1,
                      -1);

  g_free (utf81);
  g_free (utf82);

  g_free (dir2);
  g_free (dir1);

  gtk_tree_selection_select_iter (editor->sel, &iter2);

  g_signal_emit (editor, gimp_path_editor_signals[PATH_CHANGED], 0);
}
/**
 * Move account in list depending on direction and selected account
 */
static void
account_move(gboolean move_up, gpointer data)
{
    // Get view, model and selection of account
    GtkTreeView *tree_view = GTK_TREE_VIEW(data);
    GtkTreeModel *model = gtk_tree_view_get_model(tree_view);
    GtkTreeSelection *selection = gtk_tree_view_get_selection(tree_view);

    // Find selected iteration and create a copy
    GtkTreeIter iter;
    gtk_tree_selection_get_selected(selection, &model, &iter);
    GtkTreeIter *iter_copy;
    iter_copy = gtk_tree_iter_copy(&iter);

    // Find path of iteration
    gchar *path = gtk_tree_model_get_string_from_iter(model, &iter);

    // The first real account in the list can't move up because of the IP2IP account
    // It can still move down though
    if (g_strcmp0(path, "1") == 0 && move_up)
        return;

    GtkTreePath *tree_path = gtk_tree_path_new_from_string(path);
    gint *indices = gtk_tree_path_get_indices(tree_path);
    const gint pos = indices[0] - 1; /* black magic : gtk tree order is not account queue order */

    // Depending on button direction get new path
    if (move_up)
        gtk_tree_path_prev(tree_path);
    else
        gtk_tree_path_next(tree_path);

    gtk_tree_model_get_iter(model, &iter, tree_path);

    // Swap iterations if valid
    if (gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter))
        gtk_list_store_swap(GTK_LIST_STORE(model), &iter, iter_copy);

    // Scroll to new position
    gtk_tree_view_scroll_to_cell(tree_view, tree_path, NULL, FALSE, 0, 0);

    // Free resources
    gtk_tree_path_free(tree_path);
    gtk_tree_iter_free(iter_copy);
    g_free(path);

    // Perpetuate changes in account queue
    if (move_up)
        account_list_move_up(pos);
    else
        account_list_move_down(pos);

    // Set the order in the configuration file
    gchar *ordered_account_list = account_list_get_ordered_list();
    dbus_set_accounts_order(ordered_account_list);
    g_free(ordered_account_list);
}
Example #17
0
static gboolean
acwin_move_selection(BluefishTextView * btv, gint keyval)
{
	GtkTreeSelection *selection;
	GtkTreeIter it;
	GtkTreeModel *model;
	GtkTreePath *path;

	selection = gtk_tree_view_get_selection(ACWIN(btv->autocomp)->tree);
	if (gtk_tree_selection_get_selected(selection, &model, &it)) {
		gboolean retval = TRUE;
		gint i, rows = 12, *indices = NULL;
		path = gtk_tree_model_get_path(model, &it);
		indices = gtk_tree_path_get_indices(path);
		switch (keyval) {
		case GDK_Up:			/* move the selection one up */
			retval = gtk_tree_path_prev(path);
			break;
		case GDK_Down:
			gtk_tree_path_next(path);
			break;
		case GDK_Page_Down:
			i = MIN(gtk_tree_model_iter_n_children(model, NULL) - 1, indices[0] + rows);
			gtk_tree_path_free(path);
			path = gtk_tree_path_new_from_indices(i, -1);
			break;
		case GDK_Page_Up:
			i = MAX(indices[0] - rows, 0);
			gtk_tree_path_free(path);
			path = gtk_tree_path_new_from_indices(i, -1);
			break;
		case GDK_Home:
			gtk_tree_path_free(path);
			path = gtk_tree_path_new_first();
			break;
		case GDK_End:
			gtk_tree_path_free(path);
			i = gtk_tree_model_iter_n_children(model, NULL);
			path = gtk_tree_path_new_from_indices(i - 1, -1);
			break;
		default:
			return FALSE;
			break;
		}
		if (gtk_tree_model_get_iter(model, &it, path)) {
			gtk_tree_selection_select_iter(selection, &it);
			gtk_tree_view_scroll_to_cell(ACWIN(btv->autocomp)->tree, path, NULL, FALSE, 0, 0);
		} else
			retval = FALSE;
		gtk_tree_path_free(path);
		return retval;
	} else {
		/* set selection */

	}
	return FALSE;
}
Example #18
0
static void
codec_moved_cb (GtkWidget *widget, 
                gpointer data)
{ 	
  CodecsBox *self = NULL;

  GtkTreeIter iter;
  GtkTreeIter *iter2 = NULL;
  GtkTreeModel *model = NULL;
  GtkTreeSelection *selection = NULL;
  GtkTreePath *tree_path = NULL;

  std::list<std::string> list;

  gchar *path_str = NULL;

  self = CODECS_BOX (data);

  model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->priv->codecs_list));
  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (self->priv->codecs_list));
  if (!gtk_tree_selection_get_selected (GTK_TREE_SELECTION (selection), 
                                        NULL, &iter))
    return;

  /* Update the tree view */
  iter2 = gtk_tree_iter_copy (&iter);
  path_str = gtk_tree_model_get_string_from_iter (GTK_TREE_MODEL (model), 
                                                  &iter);
  tree_path = gtk_tree_path_new_from_string (path_str);
  if (!g_strcmp0 ((gchar *) g_object_get_data (G_OBJECT (widget), "operation"), 
               "up"))
    gtk_tree_path_prev (tree_path);
  else
    gtk_tree_path_next (tree_path);

  gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter, tree_path);
  if (gtk_list_store_iter_is_valid (GTK_LIST_STORE (model), &iter)
      && gtk_list_store_iter_is_valid (GTK_LIST_STORE (model), iter2))
    gtk_list_store_swap (GTK_LIST_STORE (model), &iter, iter2);

  /* Scroll to the new position */
  gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (self->priv->codecs_list), 
                                tree_path, NULL, FALSE, 0, 0);

  gtk_tree_path_free (tree_path);
  gtk_tree_iter_free (iter2);
  g_free (path_str);

  /* Update the key */
  list = codecs_box_to_list (self);
  if (self->priv->type == Ekiga::Call::Audio)
    self->priv->audio_settings->set_string_list ("media-list", list);
  else if (self->priv->type == Ekiga::Call::Video)
    self->priv->video_settings->set_string_list ("media-list", list);
}
Example #19
0
char *gTreeRow::next()
{
	GtkTreePath* path;
	
	path = gtk_tree_model_get_path(GTK_TREE_MODEL(tree->store), dataiter);
	if (!path)
		return NULL;
	
	gtk_tree_path_next(path);
	return tree->pathToKey(path);
}
Example #20
0
static void on_theme_changed (GtkIconTheme *theme, FmDirTreeModel *dir_tree_model)
{
    GtkTreePath *tree_path = gtk_tree_path_new_first ();
    
    GList *l;
    for (l = dir_tree_model->root_list; l; l = l->next)
    {
        fm_dir_tree_model_item_reload_icon (dir_tree_model, (FmDirTreeItem*) l->data, tree_path);
        gtk_tree_path_next (tree_path);
    }
    gtk_tree_path_free (tree_path);
}
Example #21
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);
}
/**
 * callback called when toggle a radio button of an archive
 * we want only 1 toggle, so erase the others before
 *
 * \param renderer
 * \param path
 * \param assistant
 *
 * \return FALSE
 * */
static gboolean gsb_assistant_archive_export_toggled ( GtkCellRendererToggle *renderer,
						       gchar *path_string,
						       GtkWidget *assistant )
{
    GtkTreeIter iter;
    gboolean value;
    GtkTreePath *path;
    GtkTreePath *path_clicked;
    GtkTreeModel *model;
    gboolean selected = FALSE;

    model = gtk_tree_view_get_model (GTK_TREE_VIEW (archive_export_treeview));
    path_clicked = gtk_tree_path_new_from_string (path_string);
    path = gtk_tree_path_new_first ();

    while (gtk_tree_model_get_iter ( GTK_TREE_MODEL (model),
				     &iter,
				     path ))
    {
	/* if we are on the clicked path, we invert the value,
	 * else, we set the value to 0 */
	if (gtk_tree_path_compare (path, path_clicked))
	    /* the 2 path are different */
	    value = 0;
	else
	{
	    /* the paths are equal */
	    gtk_tree_model_get ( GTK_TREE_MODEL (model),
				 &iter,
				 ARCHIVES_EXPORT_SELECT_COLUMN, &value,
				 -1 );
	    value = !value;

	    /* we will unsensitive the next button only if something chosen */
	    if (value)
		selected = TRUE;
	}
	gtk_list_store_set ( GTK_LIST_STORE (model),
			     &iter,
			     ARCHIVES_EXPORT_SELECT_COLUMN, value,
			     -1 );
	gtk_tree_path_next (path);
    }
    gtk_tree_path_free (path);
    gtk_tree_path_free (path_clicked);

    gsb_assistant_sensitive_button_next (assistant, selected);

    return FALSE;
}
static void
photos_preview_nav_buttons_next (PhotosPreviewNavButtons *self)
{
  GtkTreePath *current_path;

  if (!self->enable_next)
    return;

  current_path = gtk_tree_row_reference_get_path (self->current_row);
  gtk_tree_path_next (current_path);
  photos_preview_nav_buttons_set_active_path (self, current_path);
  photos_preview_nav_buttons_update_visibility (self);
  gtk_tree_path_free (current_path);
}
Example #24
0
/**
 * select the transaction by the record
 * static function
 *
 * \param record	the CustomRecord to select
 *
 * \return TRUE ok, FALSE problem
 * */
static gboolean transaction_list_select_record ( CustomRecord *record )
{
    GtkTreePath *path;
    GtkTreeIter iter;
    gint i;
    gint selected_transaction;
    CustomList *custom_list;

    custom_list = transaction_model_get_model ();

    g_return_val_if_fail ( custom_list != NULL, FALSE );
    g_return_val_if_fail ( record != NULL, FALSE );

    /* get the transaction number */
    selected_transaction = gsb_data_transaction_get_transaction_number (record -> transaction_pointer);

    /* record is the first row of the transaction to select */
    custom_list -> selected_row = record;

    /* get the path of the row we want to select */
    path = gtk_tree_path_new ();
    if ( record -> mother_row )
        /* it's a child, need to get the path of the mother */
        gtk_tree_path_append_index (path, record -> mother_row -> filtered_pos);

    gtk_tree_path_append_index (path, record -> filtered_pos);

    /* colorize the record */
    for (i=0 ; i < custom_list -> nb_rows_by_transaction ; i++)
    {
	record -> row_bg_save = record -> row_bg;
	record -> row_bg = gsb_rgba_get_couleur ( "couleur_selection" );

	/* inform the world that the row has changed */
	iter.user_data = record;
	gtk_tree_model_row_changed(GTK_TREE_MODEL(custom_list), path, &iter);

	/* if the selection was a child, we stop now, only 1 line */
	if (record -> mother_row)
	    break;

	/* go to the next row of the transaction */
	record = custom_list -> visibles_rows [record -> filtered_pos + 1];
	gtk_tree_path_next (path);
    }

    /** update account and other stuff */
    gsb_transactions_list_selection_changed (selected_transaction);
    return TRUE;
}
Example #25
0
void reload_icons(FmFolderModel* model, enum ReloadFlags flags)
{
    /* reload icons */
    GSequenceIter* it = g_sequence_get_begin_iter(model->items);
    GtkTreePath* tp = gtk_tree_path_new_from_indices(0, -1);

    if(model->thumbnail_requests)
    {
        g_list_foreach(model->thumbnail_requests, (GFunc)fm_thumbnail_request_cancel, NULL);
        g_list_free(model->thumbnail_requests);
        model->thumbnail_requests = NULL;
    }

    for( ; !g_sequence_iter_is_end(it); it = g_sequence_iter_next(it) )
    {
        FmFolderItem* item = (FmFolderItem*)g_sequence_get(it);
        if(item->icon)
        {
            GtkTreeIter tree_it = {0};
            if((flags & RELOAD_ICONS && !item->is_thumbnail) ||
               (flags & RELOAD_THUMBNAILS && item->is_thumbnail))
            {
                g_object_unref(item->icon);
                item->icon = NULL;
                item->is_thumbnail = FALSE;
                item->thumbnail_loading = FALSE;
                tree_it.stamp = model->stamp;
                tree_it.user_data = it;
                gtk_tree_model_row_changed(GTK_TREE_MODEL(model), tp, &tree_it);
            }
        }
        gtk_tree_path_next(tp);
    }
    gtk_tree_path_free(tp);

    it = g_sequence_get_begin_iter(model->hidden);
    for( ; !g_sequence_iter_is_end(it); it = g_sequence_iter_next(it) )
    {
        FmFolderItem* item = (FmFolderItem*)g_sequence_get(it);
        if(item->icon)
        {
            g_object_unref(item->icon);
            item->icon = NULL;
            item->is_thumbnail = FALSE;
            item->thumbnail_loading = FALSE;
        }
    }
}
static void
tree_selection_next (GtkTreeSelection *selection)
{
	GtkTreeIter   iter;
	GtkTreeModel *model;
	GtkTreePath  *path;

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

	path = gtk_tree_model_get_path (model, &iter);
	gtk_tree_path_next (path);
	gtk_tree_selection_select_path (selection, path);
}
Example #27
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 ;
  }
Example #28
0
char *
tsk_get_tasks_str (guint32 julian, gboolean show_done, gint hidden_category, GUI *appGUI)
{
	GtkTreeModel *model;
	GtkTreePath *path;
	GtkTreeIter iter;

	char buffer[BUFFER_SIZE], tmpbuf[BUFFER_SIZE];
	char *summ, *categ;
	guint32 tsk_julian;
	gint time;
	gint done;

	model = GTK_TREE_MODEL (appGUI->tsk->tasks_list_store);
	g_return_val_if_fail (model != NULL, NULL);

	path = gtk_tree_path_new_first ();
	buffer[0] = '\0';

	while (gtk_tree_model_get_iter (model, &iter, path) == TRUE) {

		gtk_tree_model_get (model, &iter, TA_COLUMN_DUE_DATE_JULIAN, &tsk_julian,
		                                  TA_COLUMN_CATEGORY, &categ,
		                                  TA_COLUMN_DONE, &done, -1);

		if (tsk_julian == julian && (show_done || !done) && tsk_get_category_state (categ, hidden_category, appGUI)) {
			gtk_tree_model_get (model, &iter, TA_COLUMN_DUE_TIME, &time, TA_COLUMN_SUMMARY, &summ, -1);

			if (time >= 0) {
				g_snprintf (tmpbuf, BUFFER_SIZE, "\n[%02d:%02d] %s", time / 3600, time / 60 % 60, summ);
			} else {
				g_snprintf (tmpbuf, BUFFER_SIZE, "\n%s", summ);
			}

			g_strlcat (buffer, tmpbuf, BUFFER_SIZE);
			g_free (summ);
		}

		g_free (categ);
		gtk_tree_path_next (path);
	}

	gtk_tree_path_free (path);
	g_strstrip (buffer);

	return g_strdup (buffer);
}
Example #29
0
static void
set_column_order (CajaColumnChooser *chooser,
                  char **column_order)

{
    GList *columns;
    GList *l;
    GtkTreePath *path;

    columns = caja_get_columns_for_file (chooser->details->file);
    columns = caja_sort_columns (columns, column_order);

    g_signal_handlers_block_by_func (chooser->details->store,
                                     G_CALLBACK (row_deleted_callback),
                                     chooser);

    path = gtk_tree_path_new_first ();
    for (l = columns; l != NULL; l = l->next)
    {
        GtkTreeIter iter;

        if (get_column_iter (chooser, CAJA_COLUMN (l->data), &iter))
        {
            GtkTreeIter before;
            if (path)
            {
                gtk_tree_model_get_iter (GTK_TREE_MODEL (chooser->details->store),
                                         &before, path);
                gtk_list_store_move_after (chooser->details->store,
                                           &iter, &before);
                gtk_tree_path_next (path);

            }
            else
            {
                gtk_list_store_move_after (chooser->details->store,
                                           &iter, NULL);
            }
        }
    }
    gtk_tree_path_free (path);
    g_signal_handlers_unblock_by_func (chooser->details->store,
                                       G_CALLBACK (row_deleted_callback),
                                       chooser);

    caja_column_list_free (columns);
}
Example #30
0
void config_plugin_save (Sven *sven)
{
	gchar *filename;
	GtkTreeModel *model;
	GtkTreeIter  iter;
	GtkTreePath *path;

	if(sven==NULL)
		return;
	
	filename= g_strconcat(g_get_home_dir(),"/.sven/config", NULL);

	if (!sven->config->all)
		sven->config->all = sven_cfg_new();
		
	sven_cfg_remove_section(sven->config->all, "plugins");

	model=gtk_tree_view_get_model(GTK_TREE_VIEW(plugins_tree_view));
	path = gtk_tree_path_new_first ();
	if (gtk_tree_model_get_iter (model, &iter, path) == FALSE)
	{
		gtk_tree_path_free (path);
		return;
	}

	do
	{

		gchar *name;
		gint i=1;

		gtk_tree_model_get(model,&iter,0,&i,2,&name,-1);
	
		if(i==1)
			sven_cfg_write_int(sven->config->all,"plugins",g_strdup(g_basename(name)),i);
	
		gtk_tree_path_next (path);
	}
	while (gtk_tree_model_iter_next (model,&iter));

	sven_cfg_write_file(sven->config->all, filename);
	g_free(filename);
}