static void
xmp_model_finalize (GObject *object)
{
  XMPModel      *xmp_model = XMP_MODEL (object);
  GtkTreeModel  *model     = xmp_model_get_tree_model (xmp_model);
  GtkTreeIter    iter;
  GtkTreeIter    child;
  gchar        **value_array;
  gint           i;

  /* we used XMP_FLAG_DEFER_VALUE_FREE for the parser, so now we must free
     all value arrays */

  if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model), &iter))
    {
      do
        {
          if (gtk_tree_model_iter_children (model, &child, &iter))
            {
              gchar **last_value_array = NULL;

              do
                {
                  gtk_tree_model_get (model, &child,
                                      COL_XMP_VALUE_RAW, &value_array,
                                      -1);
                  if (value_array != last_value_array)
                    {
                      /* FIXME: this does not free everything */
                      for (i = 0; value_array[i] != NULL; i++)
                        g_free (value_array[i]);
                      g_free (value_array);
                    }

                  last_value_array = value_array;
                }
              while (gtk_tree_model_iter_next (model, &child));
            }
        }
      while (gtk_tree_model_iter_next (model, &iter));
    }

  G_OBJECT_CLASS (xmp_model_parent_class)->finalize (object);
}
static void
update_days_and_lines_for_log (LogviewLoglist *loglist,
                               GtkTreeIter *log, GSList *days)
{
  gboolean res;
  GtkTreeIter iter, dummy;
  GSList *l;
  int i;
  char date[200];
  Day *day;

  /* if we have some days, we can't remove all the items immediately, otherwise,
   * if the row is expanded, it will be collapsed because there are no items,
   * so we create a dummy entry, remove all the others and then remove the
   * dummy one.
   */
  res = gtk_tree_model_iter_children (GTK_TREE_MODEL (loglist->priv->model),
                                      &iter, log);
  if (res) {
    gtk_tree_store_insert_before (loglist->priv->model, &dummy, log, &iter);
    gtk_tree_store_set (loglist->priv->model, &dummy,
                        LOG_NAME, "", -1);
    do {
      gtk_tree_store_remove (loglist->priv->model, &iter);
    } while (gtk_tree_store_iter_is_valid (loglist->priv->model, &iter));
  }

  for (i = 1, l = days; l; l = l->next) {
    /* now insert all the days */
    day = l->data;

    g_date_strftime (date, 200, "%A, %e %b", day->date);

    gtk_tree_store_insert (GTK_TREE_STORE (loglist->priv->model),
                           &iter, log, i);
    gtk_tree_store_set (GTK_TREE_STORE (loglist->priv->model),
                        &iter, LOG_NAME, date, LOG_DAY, day, -1);
    i++;
  }

  if (res) {
    gtk_tree_store_remove (loglist->priv->model, &dummy);
  }
}
Exemple #3
0
static void
move_down (int val)
{
    int i;
    GtkTreePath *path;
    GtkTreePath *tree_path;
    GtkTreeIter iter1;
    GtkTreeIter iter2;
    GtkTreeModel *model;

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

    gtk_tree_view_get_cursor (GTK_TREE_VIEW (main_gui.displayed_list), &path, NULL);
    if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &iter1, path))
        return;

    for (i = 0; i < val; i++) {
        if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (main_gui.displayed_list), path)) {
            gtk_tree_model_iter_children (GTK_TREE_MODEL (model), &iter2, &iter1);
            iter1 = iter2;
        } else {
            iter2 = iter1;
            if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter1)) {
                if (gtk_tree_model_iter_parent (GTK_TREE_MODEL (model), &iter1, &iter2)) {
                    if (!gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter1)) {
                        iter1 = iter2;
                        break;
                    }
                } else {
                    iter1 = iter2;
                    break;
                }
            }
        }
        path=gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter1);
    }

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

    gtk_widget_grab_focus (main_gui.displayed_list);
}
Exemple #4
0
static void _model_combo_set_active_iter(GtkComboBox *cb, const gchar* modelstr) {
    GtkTreeIter iter;
    GtkTreeModel *cb_model = gtk_combo_box_get_model(cb);
    if (gtk_tree_model_get_iter_first(cb_model, &iter)) {
        do {
            GtkTreeIter iter_child;
            if (gtk_tree_model_iter_children (cb_model, &iter_child, &iter)) {
                do {
                    gchar *model;
                    gtk_tree_model_get(cb_model, &iter_child, COL_STRING, &model, -1);
                    if (g_str_equal(modelstr, model)) {
                        gtk_combo_box_set_active_iter(cb, &iter_child);
                        return;
                    }
                } while (gtk_tree_model_iter_next(cb_model, &iter_child));
            }
        } while (gtk_tree_model_iter_next(cb_model, &iter));
    }
}
Exemple #5
0
void
feed_list_node_remove_empty_node (GtkTreeIter *parent)
{
	GtkTreeIter	iter;
	nodePtr		node;
	gboolean	valid;
		
	gtk_tree_model_iter_children (GTK_TREE_MODEL (feedstore), &iter, parent);
	do {
		gtk_tree_model_get (GTK_TREE_MODEL (feedstore), &iter, FS_PTR, &node, -1);

		if (!node) {
			gtk_tree_store_remove (feedstore, &iter);
			return;
		}
		
		valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (feedstore), &iter);
	} while (valid);
}
static void
_consume_excess_rows(GtkTreeStore *store, int last_index, GtkTreeIter *parent_iter, GtkTreeIter *maybe_invalid_iter)
{
    if (last_index == -1)
    {
        // try to get whatever was there beforehand, if it exists
        if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(store), maybe_invalid_iter, parent_iter))
            return;
    }
    else
    {
        // increment the iter, or bail out.
        if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(store), maybe_invalid_iter))
            return;
    }

    // consume until we're done.
    while (gtk_tree_store_remove(store, maybe_invalid_iter));
}
Exemple #7
0
/**
 * bmark_get_bookmarked_lines:
 * @doc: Tdocument *
 * @ fromit: GtkTextIter *
 * @ toit: GtkTextIter *
 *
 * this function returns a hash table with all bookmarks between fromit and toit
 *
 * this function is called VERY OFTEN (might be 20X per second!!!!) by document.c
 * to redraw the bookmarks at the sides
 * so we obviously need to keep this function VERY FAST 
 *
 * the function will return NULL if no bookmarks for this document are 
 * known (this is faster then looking in an empty hash table)
 *
 * Return value: #GHashTable * pointer or NULL
 */
GHashTable *bmark_get_bookmarked_lines(Tdocument * doc, GtkTextIter *fromit, GtkTextIter *toit) {
	if (doc->bmark_parent) {
		gboolean cont = TRUE;
		guint offset;
		Tbmark *mark;
		GtkTreeIter tmpiter;

		GHashTable *ret = g_hash_table_new_full(g_int_hash, g_int_equal, g_free, g_free);

		/* because the bookmarks are sorted by line number, we don't have to scan trough all 
		bookmarks, we can start at the bookmark *before* fromit, and continue until the 
		first bookmark > toit */
		offset = gtk_text_iter_get_offset(fromit);
		mark = bmark_find_bookmark_before_offset(BFWIN(doc->bfwin), offset, doc->bmark_parent);
		if (mark) {
			tmpiter = mark->iter;
		} else {
			cont = gtk_tree_model_iter_children(GTK_TREE_MODEL(BFWIN(doc->bfwin)->bookmarkstore), 
									&tmpiter, doc->bmark_parent);
		}
		
		while (cont) {
			Tbmark *mark;
			gtk_tree_model_get(GTK_TREE_MODEL(BFWIN(doc->bfwin)->bookmarkstore), &tmpiter, PTR_COLUMN,
							   &mark, -1);
			if (mark && mark->mark) {
				GtkTextIter it;
				gint *iaux;
				gtk_text_buffer_get_iter_at_mark(doc->buffer, &it, mark->mark);
				if (gtk_text_iter_compare(toit,&it) < 0) {
					break;
				} else if (gtk_text_iter_compare(fromit,&it) < 0) {
					iaux = g_new(gint, 1);
					*iaux = gtk_text_iter_get_line(&it);
					g_hash_table_insert(ret, iaux, g_strdup(mark->is_temp ? "1" : "0"));
				}
			}
			cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(BFWIN(doc->bfwin)->bookmarkstore), &tmpiter);
		} /* cont */
		return ret;
	}
	return NULL;
}
Exemple #8
0
int tree_buttons_get_selected_button_rawcode(void)
{
	GtkTreeModel *model;
	GtkTreeSelection *sel;
	GtkTreeIter iter, iter_parent;
	gchar *rawcode, *name=NULL;
	int rawcode_val;
	
	sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(GET_WIDGET(TREEVIEW_BUTTONS_CONFIG)));
	if (gtk_tree_selection_get_selected(sel, &model, &iter) == FALSE)
		return 0;
	if (gtk_tree_model_iter_parent(model, &iter_parent, &iter) == TRUE)
		iter = iter_parent;
	else
		iter_parent = iter;
	
	if (gtk_tree_model_iter_children(model, &iter, &iter_parent) == FALSE)
	{
		fprintf(stderr, "Error: button has no children, or another iter level error occurred.\n");
		return 0;
	}
	
	while (1)
	{
		gtk_tree_model_get(model, &iter, COL_NAME, &name, COL_PROPERTY, &rawcode, -1);
		if (strcasecmp("RC", name) == 0)
			break;
		g_free(name);
		g_free(rawcode);
		if (gtk_tree_model_iter_next(model, &iter) == FALSE)
		{
			fprintf(stderr, "Error: tree_buttons_get_selected_button_rawcode did not find a rawcode row.\n");
			return 0;
		}
	}
	
	rawcode_val = strtol(rawcode, NULL, 16);
	g_free(name);
	g_free(rawcode);
	
	return rawcode_val;
}
Exemple #9
0
GtkTreePath *
gbf_project_model_get_project_root_group (GbfProjectModel *model)
{
	GtkTreePath *path = NULL;
	
	g_return_val_if_fail (GBF_IS_PROJECT_MODEL (model), NULL);

	if (model->priv->root_group == NULL)
	{
		GtkTreeIter root;

		path = gbf_project_model_get_project_root (model);
		if ((path != NULL) && gtk_tree_model_get_iter (GTK_TREE_MODEL (model), &root, path))
		{
			gboolean valid;
			GtkTreeIter iter;

			
			/* Search root group */
			for (valid = gtk_tree_model_iter_children (GTK_TREE_MODEL (model), &iter, &root); valid; valid = gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter))
			{
				GbfTreeData *data;
			
				gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
	   				 GBF_PROJECT_MODEL_COLUMN_DATA, &data,
		    			-1);

				if (data->type == GBF_TREE_NODE_GROUP)
				{
					path = gtk_tree_model_get_path (GTK_TREE_MODEL (model), &iter);
					model->priv->root_group = gtk_tree_row_reference_new (GTK_TREE_MODEL (model), path);
				}
			}
		}
	}
	else
	{
		path = gtk_tree_row_reference_get_path (model->priv->root_group);
	}
	
	return path;
}
Exemple #10
0
static void display_variable(GtkTreeModel *Variables, GtkTreeIter *Iter, Std$Object$t *Value, Std$Object_t **Address) {
	//printf("Address = 0x%x, Value = 0x%x\n", Address, Value);
	const char *String;
	if (Value->Type == Agg$Table$T) {
		size_t OldGeneration, CurrentGeneration = Agg$Table$generation(Value);
		gtk_tree_model_get(Variables, Iter, 5, &OldGeneration, -1);
		//printf("OldGeneration = %d, CurrentGeneration = %d\n", OldGeneration, CurrentGeneration);
		if (OldGeneration != CurrentGeneration) {
			gtk_tree_store_set(Variables, Iter, 1, "{...}", 3, Value, 5, CurrentGeneration, -1);
			GtkTreeIter Child;
			while (gtk_tree_model_iter_children(Variables, &Child, Iter)) gtk_tree_store_remove(Variables, &Child);
			if (Agg$Table$size(Value) < 100) {
				Agg$Table$trav *Trav = Agg$Table$trav_new();
				for (Std$Object$t *Node = Agg$Table$trav_first(Trav, Value); Node; Node = Agg$Table$trav_next(Trav)) {
					gtk_tree_store_append(Variables, &Child, Iter);
					gtk_tree_store_set(Variables, &Child, 0, to_string(Agg$Table$node_key(Node)) ?: "<key>", 5, -1, -1);
					Std$Object$t **NodeAddress = Agg$Table$node_value_ref(Node);
					display_variable(Variables, &Child, *NodeAddress, NodeAddress);
				};
			};
Exemple #11
0
static void
recurse_set_shown (GtkTreeModel *model, GtkTreeIter *parent, gboolean shown)
{
    GtkTreeIter iter;

    if (gtk_tree_model_iter_children (model, &iter, parent)) do {
	test_case_t *c;

	gtk_tree_model_get (model, &iter, CASE_DATA, &c, -1);
	if (c == NULL) {
	    recurse_set_shown (model, &iter, shown);
	} else if (shown != c->shown) {
	    c->shown = shown;
	    gtk_tree_store_set (GTK_TREE_STORE (model), &iter,
		                CASE_SHOWN, shown,
				CASE_INCONSISTENT, FALSE,
				-1);
	}
    } while (gtk_tree_model_iter_next (model, &iter));
}
/* This function calls itself recurively */
static void folder_toggle_recurse_tree(GtkTreeStore *tree_store,
				       GtkTreeIter *iterp, gint column,
				       gboolean toggle_item)
{
  GtkTreeIter iter = *iterp;
  GtkTreeIter next;

  /* set the value of this iter */
  gtk_tree_store_set(tree_store, &iter, column, toggle_item, -1);

  /* do the same for the first child */
  if(gtk_tree_model_iter_children(GTK_TREE_MODEL(tree_store),&next, &iter))
    folder_toggle_recurse_tree(tree_store,&next,
			       FOLDERCHECK_CHECK, toggle_item);

  /* do the same for the next sibling */
  if(gtk_tree_model_iter_next(GTK_TREE_MODEL(tree_store), &iter))
    folder_toggle_recurse_tree(tree_store, &iter,
			       FOLDERCHECK_CHECK, toggle_item);
}
Exemple #13
0
const char* cardtree_find_ext(cardtree_t* ct, GtkTreeIter* iter, 
			      const char* t_node, const char *t_id)
{
  gboolean leaf;
  gchar* node;
  gchar* id;
  GtkTreeIter child;
  int match;
  const char * retval;

  do {
    /* check item */
    gtk_tree_model_get(GTK_TREE_MODEL(ct->_store),iter,
	  	       C_LEAF,&leaf,
	  	       C_NODE,&node,
	  	       C_ID,&id,
	  	       -1);

    if ((t_node==NULL || (node && strcmp(t_node,node)==0)) &&
	(t_id==NULL || (id && strcmp(t_id,id)==0)))
      match = 1;
    else
      match = 0;
    if (node) g_free(node);
    if (id) g_free(id);

    if (match)
    {
      cardtree_clear_tmpstr(ct);
      ct->_tmpstr = gtk_tree_model_get_string_from_iter(GTK_TREE_MODEL(ct->_store),iter);
      return ct->_tmpstr;
    }
    /* check children */
    if (gtk_tree_model_iter_children(GTK_TREE_MODEL(ct->_store),&child,iter)!=FALSE)
    {
      retval = cardtree_find_ext(ct,&child,t_node,t_id);
      if (retval) return retval;
    }
  } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(ct->_store),iter)!=FALSE);
  return NULL;
}
Exemple #14
0
static void display_desktop_remove_children(display_desktop_t *desktop, GtkTreeIter *parent)
{
  GtkTreeIter iter;

  if ( gtk_tree_model_iter_children(display_desktop_model, &iter, parent) ) {
    do {
      frame_hdr_t *frame;

      display_desktop_remove_children(desktop, &iter);

      gtk_tree_model_get(display_desktop_model, &iter,
			 DESKTOP_TREE_FRAME, &frame,
			 -1);

      /* Free frame descriptor */
      if ( frame != NULL ) {
	display_desktop_free_frame(&(display_current->desktop), frame);
      }
    } while ( gtk_tree_store_remove(GTK_TREE_STORE(display_desktop_model), &iter) );
  }
}
Exemple #15
0
static frame_hdr_t *display_desktop_find_frame_children(int shmid, GtkTreeIter *iter, GtkTreeIter *parent)
{
  frame_hdr_t *frame = NULL;

  if ( gtk_tree_model_iter_children(display_desktop_model, iter, parent) ) {
    do {
      gtk_tree_model_get(display_desktop_model, iter,
			 DESKTOP_TREE_FRAME, &frame,
			 -1);

      if ( (frame == NULL) || (frame->shmid != shmid) ) {
	GtkTreeIter child;
	frame = display_desktop_find_frame_children(shmid, &child, iter);
	if ( frame != NULL )
	  *iter = child;
      }
    } while ( (frame == NULL) && gtk_tree_model_iter_next(display_desktop_model, iter) );
  }

  return frame;
}
Exemple #16
0
static void
model_foreach_1 (GtkTreeModel *model, void (*func)(void *, GtkTreeIter *),
					  void *userdata)
{
	GtkTreeIter iter, inner;

	if (gtk_tree_model_get_iter_first (model, &iter))
	{
		do
		{
			func (userdata, &iter);
			if (gtk_tree_model_iter_children (model, &inner, &iter))
			{
				do
					func (userdata, &inner);
				while (gtk_tree_model_iter_next (model, &inner));
			}
		}
		while (gtk_tree_model_iter_next (model, &iter));
	}
}
Exemple #17
0
static void keyword_hide_unset_in_recursive(GtkTreeStore *keyword_tree, GtkTreeIter *iter_ptr, gpointer id, GList *keywords)
{
	GtkTreeIter iter = *iter_ptr;
	while (TRUE)
		{
		if (!keyword_tree_is_set(GTK_TREE_MODEL(keyword_tree), &iter, keywords))
			{
			keyword_hide_in(keyword_tree, &iter, id);
			/* no need to check children of hidden node */
			}
		else
			{
			GtkTreeIter child;
			if (gtk_tree_model_iter_children(GTK_TREE_MODEL(keyword_tree), &child, &iter))
				{
				keyword_hide_unset_in_recursive(keyword_tree, &child, id, keywords);
				}
			}
		if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(keyword_tree), &iter)) return;
		}
}
static void
do_recurse_subtree_and_remove (SymbolDBViewLocals *dbvl, 
							   GtkTreeIter *parent_subtree_iter)
{
	gint curr_symbol_id;
	const GdkPixbuf *curr_pixbuf;
	GtkTreeStore *store;
	gchar *curr_symbol_name;

	SymbolDBViewLocalsPriv *priv;
	
	g_return_if_fail (dbvl != NULL);
	
	priv = dbvl->priv;
	store = GTK_TREE_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (dbvl)));	
	
	gtk_tree_model_get (GTK_TREE_MODEL (store), parent_subtree_iter,
				COLUMN_SYMBOL_ID, &curr_symbol_id,
			    COLUMN_PIXBUF, &curr_pixbuf, 
				COLUMN_NAME, &curr_symbol_name,	/* no strdup required */
				-1);
	
	/*DEBUG_PRINT ("do_recurse_subtree_and_remove (): curr_symbol_id %d", 
				 curr_symbol_id);*/
				 
	while (gtk_tree_model_iter_has_child  (GTK_TREE_MODEL (store), parent_subtree_iter)) 
	{
		GtkTreeIter child;
		gtk_tree_model_iter_children (GTK_TREE_MODEL (store), &child, parent_subtree_iter);
		
		/* recurse */
		do_recurse_subtree_and_remove (dbvl, &child);
	}

	gtk_tree_store_remove (store, parent_subtree_iter);
	g_tree_remove (priv->nodes_displayed, GINT_TO_POINTER (curr_symbol_id));

	/* don't forget to free this gchar */				   
	g_free (curr_symbol_name);
}
/* moves iter to the next iter in the model in the display order
 * inside a treeview. Returns FALSE if no more rows exist.
 */
static gboolean
tree_model_iter_step (GtkTreeModel *model,
                      GtkTreeIter *iter)
{
  GtkTreeIter tmp;
  
  if (gtk_tree_model_iter_children (model, &tmp, iter))
    {
      *iter = tmp;
      return TRUE;
    }

  do {
    tmp = *iter;

    if (gtk_tree_model_iter_next (model, iter))
      return TRUE;
    }
  while (gtk_tree_model_iter_parent (model, iter, &tmp));

  return FALSE;
}
Exemple #20
0
GtkTreeIter* TreeViewCategories_FindCategoryByID(GtkTreeModel* model, GtkTreeIter* iter1, GtkTreeIter* iter2, gint parent_id)
{
	GtkTreeIter iter_child;
	gboolean isNotEnd;
	guint id;
	GtkTreeIter iter3;
	
	
	if (iter2 == NULL)
	{
		isNotEnd = gtk_tree_model_get_iter_first(model, &iter3);
	}
	else
	{
		isNotEnd = TRUE;
		iter3 = *iter2;
	}
	
	for ( ; isNotEnd; isNotEnd = gtk_tree_model_iter_next(model, &iter3))
	{
		gtk_tree_model_get(model, &iter3, COL_ID_ID, &id, -1);
		
		if (id == parent_id)
		{
			*iter1 = iter3;
			return iter1;
		}
		
		if (gtk_tree_model_iter_children(model, &iter_child, &iter3))
		{
			if (TreeViewCategories_FindCategoryByID(model, iter1, &iter_child, parent_id))
			{
				return iter1;
			}
		}
	}
	
	return NULL;
}
Exemple #21
0
void bmark_del_all(Tbfwin *bfwin,gboolean ask) {
	gint ret;
	gchar *btns[]={GTK_STOCK_NO,GTK_STOCK_YES,NULL};
	GtkTreeIter tmpiter;

	if (bfwin==NULL) return;
			
	if (ask)	{
	  ret = multi_query_dialog(bfwin->main_window,_("Delete all bookmarks."), _("Are you sure?"), 0, 0, btns);
	  if (ret==0) return;
	}
	DEBUG_MSG("bmark_del_all, deleting all bookmarks!\n");
	while (gtk_tree_model_iter_children(GTK_TREE_MODEL(bfwin->bookmarkstore), &tmpiter, NULL) ) {
#ifdef DEBUG
		gchar *name;
		gtk_tree_model_get(GTK_TREE_MODEL(bfwin->bookmarkstore), &tmpiter, NAME_COLUMN,&name, -1);
		DEBUG_MSG("bmark_del_all, the toplevel has child '%s'\n", name);
#endif
		bmark_del_children_backend(bfwin, &tmpiter);
	}
	gtk_widget_grab_focus(bfwin->current_document->view);
}	
Exemple #22
0
static void select_first_log(PidginLogViewer *lv)
{
	GtkTreeModel *model;
	GtkTreeIter iter, it;
	GtkTreePath *path;

	model = GTK_TREE_MODEL(lv->treestore);

	if (!gtk_tree_model_get_iter_first(model, &iter))
		return;

	path = gtk_tree_model_get_path(model, &iter);
	if (gtk_tree_model_iter_children(model, &it, &iter))
	{
		gtk_tree_view_expand_row(GTK_TREE_VIEW(lv->treeview), path, TRUE);
		path = gtk_tree_model_get_path(model, &it);
	}

	gtk_tree_selection_select_path(gtk_tree_view_get_selection(GTK_TREE_VIEW(lv->treeview)), path);

	gtk_tree_path_free(path);
}
Exemple #23
0
static void
doSave( GtkWindow * parent, struct MsgData * data, const char * filename )
{
    FILE * fp = fopen( filename, "w+" );

    if( !fp )
    {
        GtkWidget * w = gtk_message_dialog_new( parent, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _( "Couldn't save \"%s\"" ), filename );
        gtk_message_dialog_format_secondary_text( GTK_MESSAGE_DIALOG( w ), "%s", g_strerror( errno ) );
        g_signal_connect_swapped( w, "response", G_CALLBACK( gtk_widget_destroy ), w );
        gtk_widget_show( w );
    }
    else
    {
        GtkTreeIter iter;
        GtkTreeModel * model = GTK_TREE_MODEL( data->sort );
        if( gtk_tree_model_iter_children( model, &iter, NULL ) ) do
        {
            char * date;
            const char * levelStr;
            const struct tr_msg_list * node;

            gtk_tree_model_get( model, &iter, COL_TR_MSG, &node, -1 );
            date = gtr_localtime( node->when );
            switch( node->level ) {
                case TR_MSG_DBG: levelStr = "debug"; break;
                case TR_MSG_ERR: levelStr = "error"; break;
                default:         levelStr = "     "; break;
            }
            fprintf( fp, "%s\t%s\t%s\t%s\n", date, levelStr,
                     ( node->name ? node->name : "" ),
                     ( node->message ? node->message : "" ) );
            g_free( date );
        }
        while( gtk_tree_model_iter_next( model, &iter ) );

        fclose( fp );
    }
}
Exemple #24
0
static void
chanview_insert_sorted (chanview *cv, GtkTreeIter *add_iter, GtkTreeIter *parent, void *ud)
{
	GtkTreeIter iter;
	chan *ch;

	if (cv->sorted && gtk_tree_model_iter_children (GTK_TREE_MODEL (cv->store), &iter, parent))
	{
		do
		{
			gtk_tree_model_get (GTK_TREE_MODEL (cv->store), &iter, COL_CHAN, &ch, -1);
			if (ch->tag == 0 && cv->cb_compare (ch->userdata, ud) > 0)
			{
				gtk_tree_store_insert_before (cv->store, add_iter, parent, &iter);
				return;
			}
		}
		while (gtk_tree_model_iter_next (GTK_TREE_MODEL (cv->store), &iter));
	}

	gtk_tree_store_append (cv->store, add_iter, parent);
}
Exemple #25
0
static GtkTreeIter *
get_row_by_type (GtkTreeModel *model, PangoAttrType type)
{
  GtkTreeIter iter, *ret_iter = NULL;
  gboolean valid;
  PangoAttrType iter_type;

  valid = gtk_tree_model_iter_children (model, &iter, NULL);

  while (valid)
    {
      gtk_tree_model_get (model, &iter, COLUMN_TYPE, &iter_type, -1);

      if (iter_type == type)
        {
          ret_iter = gtk_tree_iter_copy (&iter);
          break;
        }
      valid = gtk_tree_model_iter_next (model, &iter);
    }
  return ret_iter;
}
Exemple #26
0
void bmark_check_length(Tbfwin * bfwin, Tdocument * doc) {
	GtkTreeIter tmpiter;
	gboolean cont;
	if (!doc || !doc->bmark_parent) {
		DEBUG_MSG("bmark_check_length, no bmark_parent iter => no bookmarks, returning\n");
		return;
	}
	DEBUG_MSG("bmark_check_length, doc %p, filename %s\n\n", doc, doc->filename);

	cont =
		gtk_tree_model_iter_children(GTK_TREE_MODEL(bfwin->bookmarkstore), &tmpiter,
									 doc->bmark_parent);
	while (cont) {
		Tbmark *mark = NULL;
		gtk_tree_model_get(GTK_TREE_MODEL(BFWIN(doc->bfwin)->bookmarkstore), &tmpiter, PTR_COLUMN,
						   &mark, -1);
		if (mark) {
			glong size;
			size = doc->statbuf.st_size;
			DEBUG_MSG("bmark_check_length, bmark has %d, file has %ld\n",mark->len, size);
			if (mark->len != size) {
				gint ret;
				gchar *btns[]={GTK_STOCK_NO,GTK_STOCK_YES,NULL};
				gchar *str;
				str = g_strconcat(_("File size changed in file\n"),doc->filename,NULL);
				ret = multi_query_dialog(bfwin->main_window,_("Bookmarks positions could be incorrect. Delete bookmarks?"), str, 0, 0, btns);
				if (ret==1) {
					bmark_del_for_document(bfwin, doc);
				}
				return;
			}
		} else {
			DEBUG_MSG("bmark_check_length, NOT GOOD no mark in the treestore??\n");
		}
		cont = gtk_tree_model_iter_next(GTK_TREE_MODEL(bfwin->bookmarkstore), &tmpiter);
	}
	DEBUG_MSG("bmark_check_length, all bookmarks OK, returning\n");
}
Exemple #27
0
/* Remove node without checking its shortcuts */
static gboolean
gbf_project_model_remove_children (GbfProjectModel *model, GtkTreeIter *iter)
{
	GtkTreeIter child;
	GbfTreeData *data;
	gboolean valid;

	/* Free all children */
	valid = gtk_tree_model_iter_children (GTK_TREE_MODEL (model), &child, iter);
	while (valid)
	{
		valid = gbf_project_model_remove_children (model, &child);
		
		/* Free children node */
		gtk_tree_model_get (GTK_TREE_MODEL (model), &child,
		   	 GBF_PROJECT_MODEL_COLUMN_DATA, &data,
		    	-1);
		valid = gtk_tree_store_remove (GTK_TREE_STORE (model), &child);
		if (data != NULL) gbf_tree_data_free (data);
	}

	return valid;
}
Exemple #28
0
void hview_detail_cell_func(GtkTreeViewColumn	*col,
			 GtkCellRenderer	*renderer,
			 GtkTreeModel		*model,
			 GtkTreeIter		*iter,
			 gpointer		data)
{
      GtkTreeIter	child;
      guint		type,	state;

      g_object_set(renderer, "foreground-set", FALSE,
		   "weight-set", FALSE, "style-set", FALSE, NULL);

      if (gtk_tree_model_iter_children(model, &child, iter) == TRUE) {
	    g_object_set(renderer, "foreground", "Blue",
			 "foreground-set", TRUE, NULL);
      }

      g_object_set(renderer, "weight", PANGO_WEIGHT_BOLD,
		   "weight-set", TRUE,
		   "style", PANGO_STYLE_ITALIC,
		   "style-set", TRUE, NULL);

}
Exemple #29
0
static gboolean
set_active_unit(GtkComboBox *combo, GtkTreeIter *iter, Unit *unit)
{
    GtkTreeModel *model;
    GtkTreeIter child_iter;

    model = gtk_combo_box_get_model(combo);
  
    if (iter && iter_is_unit(model, iter, unit)) {
        gtk_combo_box_set_active_iter(combo, iter);
        return TRUE;
    }

    if (!gtk_tree_model_iter_children(model, &child_iter, iter))
        return FALSE;
  
    do {
        if (set_active_unit(combo, &child_iter, unit))
            return TRUE;
    } while (gtk_tree_model_iter_next(model, &child_iter));
  
    return FALSE;
}
static void bus_layout_tree_model_dump_priv (GtkTreeModel *model, FILE *pfile, GtkTreeIter *itr, int icIndent)
  {
  char *pszIcon = NULL, *pszName = NULL ;
  int row_type = -1, idx = -1 ;
  GtkTreeIter itrChild ;

  do
    {
    gtk_tree_model_get (model, itr, 
      BUS_LAYOUT_MODEL_COLUMN_ICON, &pszIcon,
      BUS_LAYOUT_MODEL_COLUMN_NAME, &pszName,
      BUS_LAYOUT_MODEL_COLUMN_TYPE, &row_type,
      BUS_LAYOUT_MODEL_COLUMN_INDEX, &idx, -1) ;

    fprintf (pfile, "%*sicon:%s, name:%s, row_type:%d, idx = %d\n", icIndent, "", pszIcon, pszName, row_type, idx) ;
    g_free (pszIcon) ;
    g_free (pszName) ;

    if (gtk_tree_model_iter_children (model, &itrChild, itr))
      bus_layout_tree_model_dump_priv (model, pfile, &itrChild, icIndent + 2) ;
    }
  while (gtk_tree_model_iter_next (model, itr)) ;
  }