ocarina: Look for toggled signals from the CellRendererToggle

There is some other problem with updating the renderer, but I'm more
concerned with working on the gui and moving on to other stuff.  I'll
fix it later...

Signed-off-by: Bryan Schumaker <bjschuma@gmail.com>
This commit is contained in:
Bryan Schumaker 2012-08-10 08:24:29 -04:00
parent 5d2631d19a
commit 448acf1181
2 changed files with 33 additions and 9 deletions

View File

@ -21,7 +21,7 @@ static inline GtkListStore *get_list()
return GTK_LIST_STORE(get_object("LibraryList"));
}
static bool find_path(libsaria::library::Path *path, GtkTreeIter *iter)
static bool find_iter(libsaria::library::Path *path, GtkTreeIter *iter)
{
libsaria::library::Path *list_path;
@ -38,10 +38,21 @@ static bool find_path(libsaria::library::Path *path, GtkTreeIter *iter)
return false;
}
static libsaria::library::Path *find_path(gchar *path)
{
GtkTreeIter iter;
libsaria::library::Path *lib_path = NULL;
if (!gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(get_list()), &iter, path))
return NULL;
gtk_tree_model_get(GTK_TREE_MODEL(get_list()), &iter, 0, &lib_path, -1);
return lib_path;
}
void LibraryDriver::path_updated(libsaria::library::Path *path)
{
GtkTreeIter iter;
if (!find_path(path, &iter))
if (!find_iter(path, &iter))
return;
gtk_list_store_set(get_list(), &iter,
@ -67,7 +78,7 @@ void LibraryDriver::path_added(libsaria::library::Path *path)
void LibraryDriver::path_removed(libsaria::library::Path *path)
{
GtkTreeIter iter;
if (!find_path(path, &iter))
if (!find_iter(path, &iter))
return;
gtk_list_store_remove(get_list(), &iter);
}
@ -81,8 +92,21 @@ static void add_library(GtkWidget *b, gpointer d)
}
}
static void path_toggled(GtkCellRendererToggle *toggle, gchar *path, gpointer d)
{
libsaria::library::Path *lib_path = find_path(path);
if (!path)
return;
if (gtk_cell_renderer_toggle_get_active(toggle))
libsaria::library::show_path(lib_path);
else
libsaria::library::hide_path(lib_path);
}
void init_library()
{
connect_signal("AddLibrary", "clicked", G_CALLBACK(add_library), NULL);
connect_signal("UpdateLibraries", "clicked", G_CALLBACK(libsaria::library::update_all), NULL);
connect_signal("LibraryToggle", "toggled", G_CALLBACK(path_toggled), NULL);
}

View File

@ -14,11 +14,6 @@
<column type="guint"/>
</columns>
</object>
<object class="GtkAdjustment" id="PauseAdjustment">
<property name="upper">256</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAction" id="action1"/>
<object class="GtkFileChooserDialog" id="LibraryPathChooser">
<property name="can_focus">False</property>
@ -466,7 +461,7 @@
<object class="GtkTreeViewColumn" id="treeviewcolumn1">
<property name="title" translatable="yes">On</property>
<child>
<object class="GtkCellRendererToggle" id="cellrenderertoggle1"/>
<object class="GtkCellRendererToggle" id="LibraryToggle"/>
<attributes>
<attribute name="active">1</attribute>
</attributes>
@ -658,4 +653,9 @@
</object>
</child>
</object>
<object class="GtkAdjustment" id="PauseAdjustment">
<property name="upper">256</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
</interface>