Beispiel #1
0
static void changed(GtkTreeSelection *treeselection, gpointer user_data) {
  GtkWidget *list = static_cast<GtkWidget *>(user_data);
  list_priv_t *priv = static_cast<list_priv_t *>(g_object_get_data(G_OBJECT(list), "priv"));

  GtkTreeModel *model;
  GtkTreeIter iter;
  bool selected = list_get_selected(list, &model, &iter);

  /* scroll to selected entry if exactly one is selected */
  if(selected) {
    /* check if the entry isn't already visible */
    GtkTreePath *start = nullptr, *end = nullptr;
    tree_path_guard path(gtk_tree_model_get_path(model, &iter));

    gtk_tree_view_get_visible_range(priv->view, &start, &end);
    tree_path_guard sguard(start), eguard(end);

    /* check if path is before start of visible area or behin end of it */
    if((sguard && (gtk_tree_path_compare(path.get(), sguard.get())) < 0) ||
       (eguard && (gtk_tree_path_compare(path.get(), eguard.get()) > 0)))
      gtk_tree_view_scroll_to_cell(priv->view, path.get(), nullptr, TRUE, 0.5, 0.5);
  }

  /* the change event handler is overridden */
  priv->change(treeselection, priv->callback_context);
}
Beispiel #2
0
/* sort using merge sort */
static void
gbf_project_model_sort (GtkTreeModel *model,
                        GtkTreePath *begin,
                        GtkTreePath *end,
                        GtkTreeIterCompareFunc compare_func,
                        gpointer user_data)
{
	GtkTreePath *half;
	gint depth;

	/* Empty list are sorted */
	if (gtk_tree_path_compare (begin, end) >= 0)
	{
		return;
	}

	/* Split the list in two */
	half = gtk_tree_path_copy (begin);
	gtk_tree_path_up (half);
	gtk_tree_path_append_index (half, (gtk_tree_path_get_indices_with_depth (begin, &depth)[depth -1] +
	                                   gtk_tree_path_get_indices_with_depth (end, &depth)[depth - 1]) / 2);

	/* List with a single element are sorted too */
	if (gtk_tree_path_compare (begin, half) < 0)
	{
		gbf_project_model_sort (model, begin, half, compare_func, user_data);
		gbf_project_model_sort (model, half, end, compare_func, user_data);
		gbf_project_model_merge (model, begin, half, end, compare_func, user_data);
	}
	
	gtk_tree_path_free (half);
}
Beispiel #3
0
void 
gbf_project_model_move_target_shortcut (GbfProjectModel *model,
		     GtkTreeIter     *iter,
    		     GbfTreeData     *shortcut,
		     GtkTreePath     *before_path)
{
	AnjutaProjectNode *node;
	GtkTreeIter sibling;
	GtkTreePath *root_path;
	GtkTreePath *src_path;
	AnjutaProjectNode *parent;
	
	if (!shortcut)
		return;

	root_path = gbf_project_model_get_project_root (model);
	
	/* check before_path */
	if (!before_path ||
	    gtk_tree_path_get_depth (before_path) > 1)
	{
		/* Missing destination path, use root path */
		before_path = root_path;
	}
	else if (gtk_tree_path_compare (before_path, root_path) > 0)
	{
		/* Destination path outside shortcut are, remove shortcut */
		gbf_project_model_remove (model, iter);
		gtk_tree_path_free (root_path);
		
		return;
	}
		
	/* get the tree iter for the row before which to insert the shortcut */
	if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &sibling, before_path)) {
		gtk_tree_path_free (root_path);
		return;
	}

	src_path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), iter);
	if (gtk_tree_path_compare (src_path, before_path) != 0)
	{
		gtk_tree_store_remove (GTK_TREE_STORE (model), iter);			
		gtk_tree_store_insert_before (GTK_TREE_STORE (model), iter, NULL, &sibling);
		gtk_tree_store_set (GTK_TREE_STORE (model), iter, 
				    GBF_PROJECT_MODEL_COLUMN_DATA, shortcut,
				    -1);

		/* add sources */
		parent = gbf_tree_data_get_node (shortcut->shortcut);
		for (node = anjuta_project_node_first_child (parent); node; node = anjuta_project_node_next_sibling (node))
			gbf_project_model_add_node (model, node, iter);

	}

	gtk_tree_path_free (src_path);
	gtk_tree_path_free (root_path);

}
static gboolean
contact_list_view_drag_motion (GtkWidget      *widget,
			       GdkDragContext *context,
			       gint            x,
			       gint            y,
			       guint           time)
{
	static DragMotionData *dm = NULL;
	GtkTreePath           *path;
	gboolean               is_row;
	gboolean               is_different = FALSE;
	gboolean               cleanup = TRUE;

	is_row = gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (widget),
						x,
						y,
						&path,
						NULL,
						NULL,
						NULL);

	cleanup &= (!dm);

	if (is_row) {
		cleanup &= (dm && gtk_tree_path_compare (dm->path, path) != 0);
		is_different = (!dm || (dm && gtk_tree_path_compare (dm->path, path) != 0));
	} else {
		cleanup &= FALSE;
	}

	if (!is_different && !cleanup) {
		return TRUE;
	}

	if (dm) {
		gtk_tree_path_free (dm->path);
		if (dm->timeout_id) {
			g_source_remove (dm->timeout_id);
		}

		g_free (dm);

		dm = NULL;
	}

	if (!gtk_tree_view_row_expanded (GTK_TREE_VIEW (widget), path)) {
		dm = g_new0 (DragMotionData, 1);

		dm->view = EMPATHY_CONTACT_LIST_VIEW (widget);
		dm->path = gtk_tree_path_copy (path);

		dm->timeout_id = g_timeout_add_seconds (1,
			(GSourceFunc) contact_list_view_drag_motion_cb,
			dm);
	}

	return TRUE;
}
Beispiel #5
0
/* FIXME: is there a better implementation possible? */
static gboolean
is_iter_active (GtkComboBox *combo,
                GtkTreeIter *iter)
{
    GtkTreeModel *model;
    GtkTreeIter   active_iter;
    GtkTreePath  *active_path;
    GtkTreePath  *path;
    gboolean      ret;

    model = gtk_combo_box_get_model (combo);
    g_assert (model != NULL);

    path = gtk_tree_model_get_path (model, iter);
    g_assert (path != NULL);

    if (!gtk_combo_box_get_active_iter (combo, &active_iter)) {
        gtk_tree_path_free (path);

        return FALSE;
    }

    active_path = gtk_tree_model_get_path (model, &active_iter);
    g_assert (active_path != NULL);

    ret = (gtk_tree_path_compare (path, active_path) == 0);

    gtk_tree_path_free (path);
    gtk_tree_path_free (active_path);

    return ret;
}
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 ;
  }
static void
check_expand_timer (NautilusTreeViewDragDest *dest,
                    GtkTreePath *drop_path,
                    GtkTreePath *old_drop_path)
{
    GtkTreeModel *model;
    GtkTreeIter drop_iter;

    model = gtk_tree_view_get_model (dest->details->tree_view);

    if (drop_path == NULL ||
            (old_drop_path != NULL && gtk_tree_path_compare (old_drop_path, drop_path) != 0)) {
        remove_expand_timer (dest);
    }

    if (dest->details->expand_id == 0 &&
            drop_path != NULL) {
        gtk_tree_model_get_iter (model, &drop_iter, drop_path);
        if (gtk_tree_model_iter_has_child (model, &drop_iter)) {
            dest->details->expand_id =
                g_timeout_add_seconds (HOVER_EXPAND_TIMEOUT,
                                       expand_timeout,
                                       dest->details->tree_view);
        }
    }
}
Beispiel #8
0
/* is the user looking at the latest messages? */
static gboolean
is_pinned_to_new (struct MsgData * data)
{
  gboolean pinned_to_new = FALSE;

  if (data->view == NULL)
    {
      pinned_to_new = TRUE;
    }
  else
    {
      GtkTreePath * last_visible;
      if (gtk_tree_view_get_visible_range (data->view, NULL, &last_visible))
        {
          GtkTreeIter iter;
          const int row_count = gtk_tree_model_iter_n_children (data->sort, NULL);
          if (gtk_tree_model_iter_nth_child (data->sort, &iter, NULL, row_count-1))
            {
              GtkTreePath * last_row = gtk_tree_model_get_path (data->sort, &iter);
              pinned_to_new = !gtk_tree_path_compare (last_visible, last_row);
              gtk_tree_path_free (last_row);
            }
          gtk_tree_path_free (last_visible);
        }
    }

  return pinned_to_new;
}
void
gd_main_view_generic_set_rubberband_range (GdMainViewGeneric *self,
					   GtkTreePath *start,
					   GtkTreePath *end)
{
  RubberbandInfo *info;

  info = get_rubber_band_info (self);

  if (start == NULL || end == NULL)
    {
      g_clear_pointer (&info->rubberband_start,
		       gtk_tree_path_free);
      g_clear_pointer (&info->rubberband_end,
		       gtk_tree_path_free);
    }
  else
    {
      if (gtk_tree_path_compare (start, end) < 0)
	{
	  info->rubberband_start = gtk_tree_path_copy (start);
	  info->rubberband_end = gtk_tree_path_copy (end);
	}
      else
	{
	  info->rubberband_start = gtk_tree_path_copy (end);
	  info->rubberband_end = gtk_tree_path_copy (start);
	}
    }

  gtk_widget_queue_draw (GTK_WIDGET (self));
}
Beispiel #10
0
static void
gimp_scale_combo_box_mru_add (GimpScaleComboBox *combo_box,
                              GtkTreeIter       *iter)
{
  GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
  GtkTreePath  *path  = gtk_tree_model_get_path (model, iter);
  GList        *list;
  gboolean      found;

  for (list = combo_box->mru, found = FALSE; list && !found; list = list->next)
    {
      GtkTreePath *this = gtk_tree_row_reference_get_path (list->data);

      if (gtk_tree_path_compare (this, path) == 0)
        {
          if (list->prev)
            {
              combo_box->mru = g_list_remove_link (combo_box->mru, list);
              combo_box->mru = g_list_concat (list, combo_box->mru);
            }

          found = TRUE;
        }

      gtk_tree_path_free (this);
    }

  if (! found)
    combo_box->mru = g_list_prepend (combo_box->mru,
                                     gtk_tree_row_reference_new (model, path));

  gtk_tree_path_free (path);
}
Beispiel #11
0
static void renderer_toggled(GtkCellRendererToggle * cell,
			     gchar * path_string, gpointer user_data)
{
	GtkTreePath *path, *sel_path = NULL;
	GtkTreeIter iter, sel_iter;
	GtkTreeSelection *sel;
	struct menu *menu;

	path = gtk_tree_path_new_from_string(path_string);
	if (!gtk_tree_model_get_iter(model2, &iter, path))
		return;

	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree2_w));
	if (gtk_tree_selection_get_selected(sel, NULL, &sel_iter))
		sel_path = gtk_tree_model_get_path(model2, &sel_iter);
	if (!sel_path)
		goto out1;
	if (gtk_tree_path_compare(path, sel_path))
		goto out2;

	gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1);
	toggle_sym_value(menu);

      out2:
	gtk_tree_path_free(sel_path);
      out1:
	gtk_tree_path_free(path);
}
Beispiel #12
0
/*
 * env tree view value editing cancelled (Escape pressed)
 */
static void on_value_editing_cancelled(GtkCellRenderer *renderer, gpointer user_data)
{
	/* check whether escape was pressed when editing
	new variable value cell */
	GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row);
	if(!gtk_tree_path_compare(being_edited_value, empty_path))
	{
		/* if so - clear name sell */
		GtkTreeIter iter;
		gtk_tree_model_get_iter(model, &iter, being_edited_value);
		
		gtk_list_store_set (
			store,
			&iter,
			NAME, "",
		   -1);

		entering_new_var = FALSE;
	}

	g_object_set (renderer_value, "editable", FALSE, NULL);

	gtk_tree_path_free(being_edited_value);
	gtk_tree_path_free(empty_path);
}
Beispiel #13
0
/*
 * env tree view value changed hadler 
 */
static void on_value_changed(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data)
{
	GtkTreeIter  iter;
    GtkTreePath *tree_path = gtk_tree_path_new_from_string (path);
    
	gboolean empty = !gtk_tree_path_compare(tree_path, gtk_tree_row_reference_get_path(empty_row));

	gboolean res = gtk_tree_model_get_iter (
		 model,
		 &iter,
		 tree_path);
	
	gchar *striped = g_strstrip(g_strdup(new_text));
	
	if (!strlen(striped))
	{
		/* if new value is empty string, if it's a new row - do nothig
		 otheerwise - offer to delete a variable */
		if (empty)
			gtk_list_store_set(store, &iter, NAME, "", -1);
		else
		{
			if (dialogs_show_question(_("Delete variable?")))
			{
				delete_selected_rows();
				gtk_widget_grab_focus(envtree);
			}
		}
	}
	else
	{
		/* if old variable - change value, otherwise - add another empty row below */
		gchar* oldvalue;
		gtk_tree_model_get (
			model,
			&iter,
			VALUE, &oldvalue,
		   -1);

		if (strcmp(oldvalue, striped))
		{
			gtk_list_store_set(store, &iter, VALUE, striped, -1);
			if (empty)
				add_empty_row();
			
			g_object_set (renderer_value, "editable", FALSE, NULL);
		}
		
		g_free(oldvalue);
	}
	
	if (empty)
		entering_new_var = FALSE;

	gtk_tree_path_free(tree_path);
	g_free(striped);

	gtk_tree_path_free(being_edited_value);
}
Beispiel #14
0
/* 
 * text has been dragged into the watch tree view
 */
static void on_watch_dragged_callback(GtkWidget *wgt, GdkDragContext *context, int x, int y,
	GtkSelectionData *seldata, guint info, guint _time,
    gpointer userdata)
{
	/* string that is dragged */
	gchar *expression = (gchar*)seldata->data;
	GtkTreePath *path = NULL;
	GtkTreeViewDropPosition pos;
	GtkTreePath *empty_path;
	GtkTreeIter newvar;

	/* lookup for where the text has been dropped */
	gtk_tree_view_get_dest_row_at_pos(GTK_TREE_VIEW(wtree), x, y, &path, &pos);

	/* if dropped into last row - insert before it */
	empty_path = wtree_empty_path();
	if (!gtk_tree_path_compare(empty_path, path))
		pos = GTK_TREE_VIEW_DROP_BEFORE;
	gtk_tree_path_free(empty_path);
	
	/* if dropped into children area - insert before parent */
	if (gtk_tree_path_get_depth(path) > 1)
	{
		while (gtk_tree_path_get_depth(path) > 1)
			gtk_tree_path_up(path);
		pos = GTK_TREE_VIEW_DROP_BEFORE;
	}
	
	/* insert new row */
	if (path)
	{
		GtkTreeIter sibling;
		gtk_tree_model_get_iter(wmodel, &sibling, path);
		
		if (GTK_TREE_VIEW_DROP_BEFORE == pos || GTK_TREE_VIEW_DROP_INTO_OR_BEFORE == pos)
			gtk_tree_store_insert_before(wstore, &newvar, NULL, &sibling);
		else
			gtk_tree_store_insert_after(wstore, &newvar, NULL, &sibling);
	}
	else
	{
		GtkTreeIter empty;

		wtree_empty_row(&empty);
		gtk_tree_store_insert_before(wstore, &newvar, NULL, &empty);
	}
	
	/* if debugger is active (in stopped condition) - add to run-time watch list
	 *  if not - just set new expession in the tree view */ 
	if (DBS_STOPPED == debug_state)
	{
		variable *var = active_module->add_watch(expression);
		change_watch(GTK_TREE_VIEW(wtree), &newvar, var);
	}
	else
		variable_set_name_only(wstore, &newvar, expression);

	config_set_debug_changed();
}
Beispiel #15
0
gboolean keyword_compare(GtkTreeModel *keyword_tree, GtkTreeIter *a, GtkTreeIter *b)
{
	GtkTreePath *pa = gtk_tree_model_get_path(keyword_tree, a);
	GtkTreePath *pb = gtk_tree_model_get_path(keyword_tree, b);
	gint ret = gtk_tree_path_compare(pa, pb);
	gtk_tree_path_free(pa);
	gtk_tree_path_free(pb);
	return ret;
}
Beispiel #16
0
static void
filename_cell_data_func (GtkTreeViewColumn *column,
                         GtkCellRenderer   *renderer,
                         GtkTreeModel      *model,
                         GtkTreeIter       *iter,
                         FMListView        *view)
{
    char *text;
    char *color;
    GdkRGBA rgba;

    GtkTreePath *path, *hover_path;
    PangoUnderline underline;

    gtk_tree_model_get (model, iter,
                        FM_LIST_MODEL_FILENAME, &text,
                        -1);

    gtk_tree_model_get (model, iter,
                        FM_LIST_MODEL_COLOR, &color,
                        -1);
    if (color != NULL) {
        gdk_rgba_parse (&rgba, color);
        //rgba.alpha = 0.85;
    }

    /*if (color) {
      GList *lrenderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT(column));
      GList *l;
      for (l=lrenderers; l != NULL; l=l->next)
      g_object_set(l->data, "cell-background", color, NULL);
      g_list_free (lrenderers);
      }
      g_free (color);*/

	underline = PANGO_UNDERLINE_NONE;
    if (exo_tree_view_get_single_click (EXO_TREE_VIEW (view->tree))) {
		path = gtk_tree_model_get_path (model, iter);
        hover_path = exo_tree_view_get_hover_path (EXO_TREE_VIEW (view->tree));

		if (hover_path == NULL || gtk_tree_path_compare (path, hover_path)) {
			underline = PANGO_UNDERLINE_NONE;
		} else {
			underline = PANGO_UNDERLINE_SINGLE;
		}

		gtk_tree_path_free (path);
	}

    g_object_set (G_OBJECT (renderer),
                  "text", text,
                  "underline", underline,
                  //"cell-background", color,
                  "cell-background-rgba", &rgba,
                  NULL);
    g_free (text);
}
Beispiel #17
0
static VALUE
rg_operator_treepath_equal(VALUE self, VALUE other)
{
    if (!RVAL2CBOOL(rb_funcall(CLASS_OF(self), id_equal, 1, CLASS_OF(other)))) {
        return Qfalse;
    }

    return CBOOL2RVAL(gtk_tree_path_compare(_SELF(self), _SELF(other)) == 0);
}
Beispiel #18
0
static void mimeview_selection_changed(GtkTreeSelection *selection,
				       MimeView *mimeview)
{
	GtkTreeModel *model = GTK_TREE_MODEL(mimeview->store);
	GtkTreeIter iter;
	GtkTreePath *path;
	MimeInfo *partinfo;

	if (!gtk_tree_selection_get_selected(selection, NULL, &iter)) {
		if (mimeview->opened) {
			gtk_tree_path_free(mimeview->opened);
			mimeview->opened = NULL;
		}
		return;
	}

	path = gtk_tree_model_get_path(model, &iter);

	if (mimeview->opened &&
	    gtk_tree_path_compare(mimeview->opened, path) == 0) {
		gtk_tree_path_free(path);
		return;
	}

	gtk_tree_path_free(mimeview->opened);
	mimeview->opened = path;
	path = NULL;

	gtk_tree_model_get(model, &iter, COL_MIME_INFO, &partinfo, -1);
	if (!partinfo)
		return;

	switch (partinfo->mime_type) {
	case MIME_TEXT:
	case MIME_TEXT_HTML:
	case MIME_MESSAGE_RFC822:
	case MIME_MULTIPART:
		mimeview_show_message_part(mimeview, partinfo);
		break;
	case MIME_IMAGE:
		if (prefs_common.inline_image) {
			mimeview_show_image_part(mimeview, partinfo);
			break;
		}
		/* FALLTHROUGH */
	default:
		mimeview_change_view_type(mimeview, MIMEVIEW_TEXT);
#if USE_GPGME
		if (rfc2015_is_signature_part(partinfo))
			mimeview_show_signature_part(mimeview, partinfo);
		else
#endif
			mimeview_show_mime_part(mimeview, partinfo);
		break;
	}
}
Beispiel #19
0
/*
 *  Handles same tree row click to open frame position
 */
static gboolean on_msgwin_button_press(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
{
	if (event->type == GDK_BUTTON_PRESS)
	{
		GtkTreePath *pressed_path = NULL;
		if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(tree), (int)event->x, (int)event->y, &pressed_path, NULL, NULL, NULL))
		{
			if (2 == gtk_tree_path_get_depth(pressed_path))
			{
				GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
				GList *rows = gtk_tree_selection_get_selected_rows(selection, &model);
				GtkTreePath *selected_path = (GtkTreePath*)rows->data;

				if (!gtk_tree_path_compare(pressed_path, selected_path))
				{
					GtkTreeIter iter;
					gtk_tree_model_get_iter (
						 model,
						 &iter,
						 pressed_path);

					gboolean have_source;
					gtk_tree_model_get (
						model,
						&iter,
						S_HAVE_SOURCE, &have_source,
						-1);
					
					/* check if file name is not empty and we have source files for the frame */
					if (have_source)
					{
						gchar *file;
						gint line;
						gtk_tree_model_get (
							model,
							&iter,
							S_FILEPATH, &file,
							S_LINE, &line,
							-1);
						callback(file, line);

						g_free(file);
					}
				}

				g_list_foreach (rows, (GFunc) gtk_tree_path_free, NULL);
				g_list_free (rows);
			}

			gtk_tree_path_free(pressed_path);
		}
	}

	return FALSE;
}
Beispiel #20
0
/*#
    @method compare GtkTreePath
    @brief Compares two paths.
    @param b A GtkTreePath to compare with.
    @return The relative positions of a and b

    If a appears before b in a tree, then -1 is returned.
    If b appears before a, then 1 is returned.
    If the two nodes are equal, then 0 is returned.
 */
FALCON_FUNC TreePath::compare( VMARG )
{
    Item* i_b = vm->param( 0 );
#ifndef NO_PARAMETER_CHECK
    if ( !i_b || !i_b->isObject() || !IS_DERIVED( i_b, GtkTreePath ) )
        throw_inv_params( "GtkTreePath" );
#endif
    GtkTreePath* b = GET_TREEPATH( *i_b );
    MYSELF;
    vm->retval( gtk_tree_path_compare( self->getTreePath(), b ) );
}
Beispiel #21
0
/*
 * env tree view name changed hadler 
 */
static void on_name_changed(GtkCellRendererText *renderer, gchar *path, gchar *new_text, gpointer user_data)
{
	GtkTreeIter  iter;
	GtkTreePath *tree_path = gtk_tree_path_new_from_string (path);
	GtkTreePath *empty_path = gtk_tree_row_reference_get_path(empty_row);
    
	gboolean empty = !gtk_tree_path_compare(tree_path, empty_path);

	gtk_tree_model_get_iter (
		 model,
		 &iter,
		 tree_path);
	
	gchar* oldvalue;
	gtk_tree_model_get (
		model,
		&iter,
		NAME, &oldvalue,
       -1);
    
	gchar *striped = g_strstrip(g_strdup(new_text));

	if (!strlen(striped))
	{
		/* if name is empty - offer to delete variable */
		if (!empty && dialogs_show_question(_("Delete variable?")))
		{
			delete_selected_rows();
			config_set_debug_changed();

			gtk_widget_grab_focus(tree);
		}
	}
	else if (strcmp(oldvalue, striped))
    {
		gtk_list_store_set(store, &iter, NAME, striped, -1);
		if (empty)
		{
			/* if it was a new row - move cursor to a value cell */
			entering_new_var = TRUE;
			gtk_tree_view_set_cursor_on_cell(GTK_TREE_VIEW(tree), tree_path, column_value, renderer_value, TRUE);
		}
		if (!empty)
		{
			config_set_debug_changed();
		}
	}
	
	gtk_tree_path_free(tree_path);
	gtk_tree_path_free(empty_path);
	g_free(oldvalue);
	g_free(striped);
}
Beispiel #22
0
static void
rows_reordered_cb (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer new_order, RBDisplayPageMenu *menu)
{
	GtkTreePath *root;
	root = get_root_path (menu);
	if (root != NULL) {
		if (gtk_tree_path_compare (path, root) == 0)
			rebuild_menu (menu);

		gtk_tree_path_free (root);
	}
}
Beispiel #23
0
static VALUE
rg_operator_treeiter_eql(VALUE self, VALUE other)
{
    gint i, num1, num2;
    GtkTreeIter* iter1 = _SELF(self);
    GtkTreeIter* iter2;
    GtkTreeModel* model1;
    GtkTreeModel* model2;
    GtkTreePath* path1;
    GtkTreePath* path2;

    if (!rb_obj_is_kind_of(other, GTYPE2CLASS(GTK_TYPE_TREE_ITER)))
        return Qfalse;

    iter2 = _SELF(other);

    model1 = (GtkTreeModel*)iter1->user_data3;
    model2 = (GtkTreeModel*)iter2->user_data3;
    if (model1 != model2) return Qfalse;

    num1 = gtk_tree_model_get_n_columns(model1);
    num2 = gtk_tree_model_get_n_columns(model2);
    if (num1 != num2) return Qfalse;

    path1 = gtk_tree_model_get_path(model1, iter1);
    path2 = gtk_tree_model_get_path(model2, iter2);
    if (gtk_tree_path_compare(path1, path2) != 0) {
        gtk_tree_path_free(path1);
        gtk_tree_path_free(path2);
        return Qfalse;
    } else {
        gtk_tree_path_free(path1);
        gtk_tree_path_free(path2);
    }

    for (i = 0; i < num1; i++){
        GValue gval1 = G_VALUE_INIT;
        GValue gval2 = G_VALUE_INIT;
        VALUE ret1, ret2;
        gtk_tree_model_get_value(model1, iter1, i, &gval1);
        gtk_tree_model_get_value(model2, iter2, i, &gval2);

        ret1 = GVAL2RVAL(&gval1);
        ret2 = GVAL2RVAL(&gval2);
        g_value_unset(&gval1);
        g_value_unset(&gval2);
        if (rb_equal(ret1, ret2) == Qfalse) 
            return Qfalse;
    }
    return Qtrue;
}
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 );
  }
}
/**
 * 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;
}
Beispiel #26
0
static gboolean topmost_selected(GtkTreeModel *model, GtkTreeIter *iter, gboolean first)
{
	GtkTreePath *path, *first_path;
	gboolean ret, is_first;
	
	first_path = gtk_tree_path_new_first();
	path = gtk_tree_model_get_path(model, iter);
	
	is_first = gtk_tree_path_compare(first_path, path) == 0;
	ret = gtk_tree_path_get_depth(path) == 1 && ((is_first && first) || (!is_first && !first));
	gtk_tree_path_free(first_path);
	gtk_tree_path_free(path);
	return ret;
}
Beispiel #27
0
static gboolean tree_keypress(GtkTreeView *t, GdkEventKey *event, GtkWidget *entry)
{
	if(event->keyval == GDK_Return) {
		submit();
		gtk_dialog_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
	}
	if(event->keyval == GDK_Up) {
		GtkTreePath  *current;
		gtk_tree_view_get_cursor(t, &current, NULL);
		if(gtk_tree_path_compare(current,first) == 0) {
			gtk_widget_grab_focus(entry);
		}
	}
	return FALSE;
}
Beispiel #28
0
gboolean vdtree_set_fd(ViewDir *vd, FileData *dir_fd)
{
	FileData *fd;
	GtkTreeIter iter;

	if (!dir_fd) return FALSE;
	if (vd->dir_fd == dir_fd) return TRUE;

	file_data_unref(vd->dir_fd);
	vd->dir_fd = file_data_ref(dir_fd);;

	fd = vdtree_populate_path(vd, vd->dir_fd, TRUE, FALSE);

	if (!fd) return FALSE;

	if (vd_find_row(vd, fd, &iter))
		{
		GtkTreeModel *store;
		GtkTreePath *tpath, *old_tpath;
		GtkTreeSelection *selection;

		store = gtk_tree_view_get_model(GTK_TREE_VIEW(vd->view));

		selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(vd->view));

		/* hack, such that selection is only allowed to be changed from here */
		selection_is_ok = TRUE;
		gtk_tree_selection_select_iter(selection, &iter);
		selection_is_ok = FALSE;

		gtk_tree_view_get_cursor(GTK_TREE_VIEW(vd->view), &old_tpath, NULL);
		tpath = gtk_tree_model_get_path(store, &iter);

		if (!old_tpath || gtk_tree_path_compare(tpath, old_tpath) != 0)
			{
			/* setting the cursor scrolls the view; do not do that unless it is necessary */
			gtk_tree_view_set_cursor(GTK_TREE_VIEW(vd->view), tpath, NULL, FALSE);

			/* gtk_tree_view_set_cursor scrolls the window itself, but it sometimes
			   does not work (switch from dir_list to dir_tree) */
			tree_view_row_make_visible(GTK_TREE_VIEW(vd->view), &iter, TRUE);
			}
		gtk_tree_path_free(tpath);
		gtk_tree_path_free(old_tpath);
		}

	return TRUE;
}
Beispiel #29
0
gboolean utils_files_charmap_active_toggled ( GtkCellRendererToggle *cell,
                        gchar *path_str,
                        gpointer model )
{
    GtkWidget *dialog;
    GtkTreePath *path = gtk_tree_path_new_from_string ( path_str );
    GtkTreePath *tmp_path;
    GtkTreeIter iter;
    gchar *enc;
    gboolean toggle_item;

    /* on commence par initialiser les données */
    dialog = g_object_get_data ( G_OBJECT ( model ), "dialog" );

    gtk_dialog_set_response_sensitive   ( GTK_DIALOG ( dialog ), GTK_RESPONSE_OK, FALSE );
    tmp_path = gtk_tree_path_new_first ( );
    gtk_tree_model_get_iter_first ( GTK_TREE_MODEL ( model ), &iter );
    do
    {
        gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &iter,
                        IMPORT_CHARMAP_SELECTED, &toggle_item,
                        IMPORT_CHARMAP_ENCODING, &enc, -1 );

        tmp_path = gtk_tree_model_get_path ( GTK_TREE_MODEL ( model ), &iter );
        if ( gtk_tree_path_compare ( path, tmp_path ) == 0 )
        {
            gtk_list_store_set ( GTK_LIST_STORE ( model ), &iter,
                        IMPORT_CHARMAP_SELECTED, !toggle_item, -1 );
            if ( toggle_item  == 0 )
            {
                GOCharmapSel *cs;

                cs = g_object_get_data ( G_OBJECT ( dialog ), "charset_cs" );
                go_charmap_sel_set_encoding (cs, enc);
                g_object_set_data ( G_OBJECT ( dialog ), "charset", enc );
                gtk_dialog_set_response_sensitive   ( GTK_DIALOG ( dialog ),
                        GTK_RESPONSE_OK, TRUE );
            }
        }
        else
            gtk_list_store_set ( GTK_LIST_STORE ( model ), &iter,
                        IMPORT_CHARMAP_SELECTED, FALSE, -1 );
    }
    while ( gtk_tree_model_iter_next ( GTK_TREE_MODEL ( model ), &iter ) );

    return FALSE;
}
Beispiel #30
0
gboolean on_dnd_dest_query_info(FmDndDest* dd, int x, int y,
			GdkDragAction* action, FmPlacesView* view)
{
    GtkTreeViewDropPosition pos;
	GtkTreePath* tp = NULL;
    GtkTreeViewColumn* col;
    if(gtk_tree_view_get_dest_row_at_pos((GtkTreeView*)view, x, y, &tp, &pos))
    {
        /* FIXME: this is inefficient. we should record the index of separator instead. */
        if(pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE || pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER)
        {

        }
        else
        {
            GtkTreePath* sep = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &sep_it);
            if(gtk_tree_path_compare(sep, tp) < 0) /* tp is after sep */
            {
                *action = GDK_ACTION_LINK;
            }
            else
            {
                *action = 0;
                gtk_tree_path_free(tp);
                tp = NULL;
            }
            gtk_tree_path_free(sep);
        }
    }
    else
    {
        tp = gtk_tree_path_new_from_indices(gtk_tree_model_iter_n_children(GTK_TREE_MODEL(model), NULL)-1, -1);
        pos = GTK_TREE_VIEW_DROP_AFTER;
        *action = GDK_ACTION_LINK;
    }

    gtk_tree_view_set_drag_dest_row((GtkTreeView*)view, tp, pos);
    fm_dnd_dest_set_dest_file(view->dnd_dest, NULL);

    if(view->dest_row)
        gtk_tree_path_free(view->dest_row);
    view->dest_row = tp;
    view->dest_pos = pos;

	return TRUE;
}