gui/collection: Convert checkbox into a right click menu
This feature isn't used very often, and keeping the checkbox in the sidebar looks pretty ugly. Fixes #50: Remove Collection checkbox Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
d2c4a36945
commit
25211e93ac
|
@ -1,4 +1,5 @@
|
|||
6.4.11:
|
||||
- Move collection enabled checkboxes into a right click menu
|
||||
- Various UI tweaks
|
||||
|
||||
6.4.11-rc:
|
||||
|
|
|
@ -10,8 +10,6 @@
|
|||
|
||||
enum collection_sidebar_columns {
|
||||
C_SB_IMAGE,
|
||||
C_SB_ENABLED,
|
||||
C_SB_SHOW_ENABLED,
|
||||
C_SB_PATH,
|
||||
C_SB_LIBRARY,
|
||||
};
|
||||
|
@ -28,8 +26,6 @@ static void __collection_set_header(GtkTreeIter *iter, const gchar *image,
|
|||
static void __collection_set_library(GtkTreeIter *iter, struct library *library)
|
||||
{
|
||||
gtk_tree_store_set(GTK_TREE_STORE(c_model), iter,
|
||||
C_SB_ENABLED, library->li_enabled,
|
||||
C_SB_SHOW_ENABLED, true,
|
||||
C_SB_IMAGE, "folder",
|
||||
C_SB_PATH, library->li_path,
|
||||
C_SB_LIBRARY, library, -1);
|
||||
|
@ -58,18 +54,25 @@ void __collection_activated(GtkTreeView *treeview, GtkTreePath *path,
|
|||
gui_collection_idle_enable();
|
||||
}
|
||||
|
||||
void __collection_toggled(GtkCellRendererToggle *toggle, gchar *path,
|
||||
gpointer data)
|
||||
void __collection_toggled(GtkCheckMenuItem *check, gpointer data)
|
||||
{
|
||||
GtkTreeView *treeview = GTK_TREE_VIEW(gui_builder_widget("o_collection_view"));
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
||||
struct library *library = NULL;
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
GList *rows;
|
||||
|
||||
if (gtk_tree_model_get_iter_from_string(c_model, &iter, path))
|
||||
rows = gtk_tree_selection_get_selected_rows(selection, &c_model);
|
||||
if (!rows)
|
||||
return;
|
||||
path = rows->data;
|
||||
if (gtk_tree_model_get_iter(c_model, &iter, path))
|
||||
library = __collection_get_library(&iter);
|
||||
if (!library)
|
||||
return;
|
||||
|
||||
collection_set_enabled(library, !library->li_enabled);
|
||||
collection_set_enabled(library, gtk_check_menu_item_get_active(check));
|
||||
__collection_set_library(&iter, library);
|
||||
}
|
||||
|
||||
|
@ -100,6 +103,35 @@ out:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool __collection_buttonpress(GtkWidget *widget, GdkEventButton *event, gpointer data)
|
||||
{
|
||||
GtkCheckMenuItem *check = GTK_CHECK_MENU_ITEM(gui_builder_widget("o_collection_enabled"));
|
||||
GtkTreeView *treeview = GTK_TREE_VIEW(gui_builder_widget("o_collection_view"));
|
||||
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
|
||||
GtkMenu *menu = GTK_MENU(gui_builder_widget("o_collection_rc"));
|
||||
struct library *library = NULL;
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
if (event->button != 3)
|
||||
return false;
|
||||
|
||||
if (gtk_tree_view_get_path_at_pos(treeview, event->x, event->y,
|
||||
&path, NULL, NULL, NULL))
|
||||
gtk_tree_selection_select_path(selection, path);
|
||||
if (gtk_tree_model_get_iter(c_model, &iter, path))
|
||||
library = __collection_get_library(&iter);
|
||||
|
||||
if (library) {
|
||||
gtk_check_menu_item_set_active(check, library->li_enabled);
|
||||
gtk_menu_popup(menu, NULL, NULL, NULL, NULL,
|
||||
event->button, event->time);
|
||||
}
|
||||
|
||||
gtk_tree_path_free(path);
|
||||
return true;
|
||||
}
|
||||
|
||||
void __collection_add(GtkButton *button, GtkFileChooser *chooser)
|
||||
{
|
||||
gchar *filename = gtk_file_chooser_get_filename(chooser);
|
||||
|
|
|
@ -210,14 +210,23 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">window-close</property>
|
||||
</object>
|
||||
<object class="GtkMenu" id="o_collection_rc">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkCheckMenuItem" id="o_collection_enabled">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Library Path Enabled</property>
|
||||
<property name="use_underline">True</property>
|
||||
<signal name="toggled" handler="__collection_toggled" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkTreeStore" id="o_collection_store">
|
||||
<columns>
|
||||
<!-- column-name Image -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Enabled -->
|
||||
<column type="gboolean"/>
|
||||
<!-- column-name ShowEnabled -->
|
||||
<column type="gboolean"/>
|
||||
<!-- column-name Path -->
|
||||
<column type="gchararray"/>
|
||||
<!-- column-name Library -->
|
||||
|
@ -747,6 +756,7 @@
|
|||
<property name="model">o_collection_store</property>
|
||||
<property name="headers_visible">False</property>
|
||||
<property name="enable_tree_lines">True</property>
|
||||
<signal name="button-press-event" handler="__collection_buttonpress" swapped="no"/>
|
||||
<signal name="key-press-event" handler="__collection_keypress" swapped="no"/>
|
||||
<signal name="row-activated" handler="__collection_activated" swapped="no"/>
|
||||
<child internal-child="selection">
|
||||
|
@ -767,28 +777,13 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn4">
|
||||
<property name="title" translatable="yes">Enabled</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererToggle" id="cellrenderertoggle1">
|
||||
<signal name="toggled" handler="__collection_toggled" swapped="no"/>
|
||||
</object>
|
||||
<attributes>
|
||||
<attribute name="visible">2</attribute>
|
||||
<attribute name="active">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkTreeViewColumn" id="treeviewcolumn5">
|
||||
<property name="title" translatable="yes">Path</property>
|
||||
<child>
|
||||
<object class="GtkCellRendererText" id="cellrenderertext3"/>
|
||||
<attributes>
|
||||
<attribute name="markup">3</attribute>
|
||||
<attribute name="text">3</attribute>
|
||||
<attribute name="markup">1</attribute>
|
||||
</attributes>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
@ -70,7 +70,7 @@ static void test_collection_sidebar()
|
|||
gtk_tree_model_get_iter_first(model, &iter);
|
||||
test_equal(gtk_tree_model_iter_n_children(model, &iter), 2);
|
||||
gtk_tree_model_iter_nth_child(model, &child, &iter, 0);
|
||||
gtk_tree_model_get(model, &child, 4, &library, -1);
|
||||
gtk_tree_model_get(model, &child, 2, &library, -1);
|
||||
test_equal((void *)library, (void *)library_get(0));
|
||||
|
||||
/* Run two idle events to scan the added path. */
|
||||
|
@ -85,7 +85,7 @@ static void test_collection_sidebar()
|
|||
gtk_tree_model_get_iter_first(model, &iter);
|
||||
test_equal(gtk_tree_model_iter_n_children(model, &iter), 2);
|
||||
gtk_tree_model_iter_nth_child(model, &child, &iter, 0);
|
||||
gtk_tree_model_get(model, &child, 4, &library, -1);
|
||||
gtk_tree_model_get(model, &child, 2, &library, -1);
|
||||
test_equal((void *)library, (void *)library_get(0));
|
||||
|
||||
path = gtk_tree_model_get_path(model, &child);
|
||||
|
|
Loading…
Reference in New Issue