* This is used by ql_drag_motion() and ql_drag_data_received() to identify a
* drop would or does land. It's important that they use the same code since
* otherwise the visual feedback can be inconsistent with the actual effect!
+ *
+ * Remember to free the returned path.
*/
static GtkTreePath *ql_drop_path(GtkWidget *w,
GtkTreeModel *model,
if(path)
gtk_tree_path_free(path);
}
- /* TODO _something_ is not quite right here. Supposedly if action=0 we
- * should probably be returning FALSE; _but_ actually we always want to
- * support dropping, as dropping into the big empty space at the bottom
- * should be the same as dropping at the end of the last row.
- *
- * As the code stands the drop works but the visual feedback is not quite
- * right.
- */
autoscroll_add(GTK_TREE_VIEW(w));
return TRUE; /* We are (always) in a drop zone */
}
ql->drop(ql, tracks->nvec, tracks->vec, NULL, q);
break;
}
+ if(path)
+ gtk_tree_path_free(path);
}
/** @brief Initialize a @ref queuelike */
/* The selection should support multiple things being selected */
ql->selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(ql->view));
+ g_object_ref(ql->selection);
gtk_tree_selection_set_mode(ql->selection, GTK_SELECTION_MULTIPLE);
/* Catch button presses */
/* TODO style? */
- ql->init(ql);
+ if(ql->init)
+ ql->init(ql);
/* Update display text when lookups complete */
event_register("lookups-completed", queue_lookups_completed, ql);
return scrolled;
}
+/** @brief Destroy a queuelike
+ * @param ql Queuelike to destroy
+ *
+ * Returns @p ql to its initial state.
+ */
+void destroy_queuelike(struct queuelike *ql) {
+ if(ql->store) {
+ g_object_unref(ql->store);
+ ql->store = NULL;
+ }
+ if(ql->view) {
+ gtk_object_destroy(GTK_OBJECT(ql->view));
+ ql->view = NULL;
+ }
+ if(ql->menu) {
+ gtk_object_destroy(GTK_OBJECT(ql->menu));
+ ql->menu = NULL;
+ }
+ if(ql->selection) {
+ g_object_unref(ql->selection);
+ ql->selection = NULL;
+ }
+ ql->q = NULL;
+}
+
/*
Local Variables:
c-basic-offset:2