[giv] Recursively toggled marker views when changing a parent view. Fixed bug in initial fit.
- From: Dov Grobgeld <dov src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [giv] Recursively toggled marker views when changing a parent view. Fixed bug in initial fit.
- Date: Fri, 27 Apr 2012 11:41:42 +0000 (UTC)
commit 9a3a86811bc5efa91dd282df3eac30f01cb72f27
Author: Dov Grobgeld <dov grobgeld gmail com>
Date: Fri Apr 27 14:41:06 2012 +0300
Recursively toggled marker views when changing a parent view. Fixed bug in initial fit.
notes.org | 6 ++++--
src/giv-mark-tree-dialog.gob | 28 ++++++++++++++++++++++++++--
src/giv-win.gob | 9 +++++++++
3 files changed, 39 insertions(+), 4 deletions(-)
---
diff --git a/notes.org b/notes.org
index c66aff1..695a5cd 100644
--- a/notes.org
+++ b/notes.org
@@ -31,5 +31,7 @@
- Save the following settings:
- [X] Sub pixel coordinate.
- [ ] Auto resize.
-
-
+* <2012-04-27 Fri>
+** Done/Todo
+ - [X] Recursively turn on and off child nodes when toggling the display of a parent in the model viewer.
+ - [X] Why is initial scaling different from the scaling received with "fill"? Due to the sticky autoscale setting. Fixed by forcing fill on initial load of dataset.
diff --git a/src/giv-mark-tree-dialog.gob b/src/giv-mark-tree-dialog.gob
index 7d8c113..bb22e65 100644
--- a/src/giv-mark-tree-dialog.gob
+++ b/src/giv-mark-tree-dialog.gob
@@ -13,6 +13,9 @@ static void
cb_toggled (GtkCellRendererToggle *cell,
gchar *path_string,
gpointer data);
+static void set_state_tree_node_children(GtkTreeModel *model,
+ GtkTreeIter *parent_iter,
+ bool new_state);
static void get_iter_from_mark_set(GivMarkTreeDialog *self,
giv_dataset_t *mark_set,
@@ -76,7 +79,7 @@ class Giv:Mark:Tree:Dialog from Gtk:Dialog {
gtk_tree_view_column_pack_start (column, cell, TRUE);
gtk_tree_view_column_set_attributes (column, cell,
"text", 0,
- NULL);
+ NULL);
gtk_tree_view_column_set_title (column, "Path");
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
@@ -202,13 +205,13 @@ cb_toggled (GtkCellRendererToggle *cell,
GtkTreeIter iter;
GtkTreePath *path = gtk_tree_path_new_from_string (path_string);
gboolean value;
-
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, 1, &value, -1);
value = !value;
gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 1, value, -1);
+ set_state_tree_node_children(model, &iter, value);
#if 0
if (value)
@@ -348,4 +351,25 @@ static void strip_last_leaf(const char *string_path,
}
}
+static void set_state_tree_node_children(GtkTreeModel *model,
+ GtkTreeIter *parent_iter,
+ bool new_state)
+{
+ int n_children = gtk_tree_model_iter_n_children(model,
+ parent_iter);
+ for (int i=0; i<n_children; i++)
+ {
+ GtkTreeIter iter;
+ gboolean value;
+ gtk_tree_model_iter_nth_child(model,
+ &iter,
+ parent_iter,
+ i);
+ // Set the new value
+ gtk_tree_store_set (GTK_TREE_STORE (model), &iter, 1, new_state, -1);
+
+ // recursive call
+ set_state_tree_node_children(model,&iter,new_state);
+ }
+}
%}
diff --git a/src/giv-win.gob b/src/giv-win.gob
index 5441b10..5279806 100644
--- a/src/giv-win.gob
+++ b/src/giv-win.gob
@@ -552,6 +552,7 @@ class Giv:Win from Gtk:Window
private GLibJsonRpcServer *jsonrpc_server;
private GLibJsonRpcAsyncQuery *json_query = NULL;
private gboolean do_pick_coordinate = FALSE;
+ private gboolean do_fit_on_load_image_when_idle = FALSE;
public GtkWidget *
new (int argc, char *argv[])
@@ -1002,6 +1003,7 @@ class Giv:Win from Gtk:Window
}
selfp->idle_index = selfp->filename_list_index;
+ selfp->do_fit_on_load_image_when_idle = TRUE;
selfp->idle_handle = g_idle_add(cb_load_image_when_idle,
self);
#if 0
@@ -1018,8 +1020,10 @@ class Giv:Win from Gtk:Window
scale, scale,
shift_x, shift_y);
}
+#if 0
else if (!selfp->img_org)
fit_marks_in_window(self);
+#endif
else if (!selfp->do_auto_fit_marks) {
gtk_image_viewer_zoom_reset(GTK_IMAGE_VIEWER(selfp->w_imgv));
}
@@ -3800,6 +3804,11 @@ cb_load_image_when_idle(gpointer user_data)
giv_win_set_current_file(self, selfp->idle_index);
selfp->idle_handle = -1;
+ if (selfp->do_fit_on_load_image_when_idle) {
+ fit_marks_in_window(self);
+ selfp->do_fit_on_load_image_when_idle = FALSE;
+ }
+
return false;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]