General widget for changing the order of elements
Xfce4 has many places where the user can customize the order of elements and some of their other properties (the order may not be customizable, but I have not yet come up with a decent name other than OrderWidget). I'll attach a few screenshots below (1 panel, 2 keyboard, 3 thunar, 4 thunar, 5 clipman, 6 launcher editor, 7 xfce4-session-settings, 8 notifications journal).
I think there are problems:
- Each time these widgets are implemented from scratch
- They have different capabilities, for example, in some places you can drag elements, but in others you can’t
- They have different style
How do you look at developing a generic widget? I also think that such a widget needs its own model interface, which can be simply implemented for data.
I started working on the general dialog for Thunar (third screenshot), and so far I have this design. However, there are problems with this model, it is impossible to add a column that xfce4-keyboard-settings needs. I propose to discuss the need for such a widget and its code design.
!!! THIS DESIGN IS OUT OF DATE, HERE'S A NEW DESIGN !!!
enum OrderModelColumn {
ACTIVE, ACTIVITY_EDITABLE, ICON, NAME, TOOLTIP
}
/*
* The developer only needs to implement the virtual methods of this class,
* and does not need to worry about implementing the GtkTreeModel,
* GtkTreeDragSource, GtkTreeDragDest interfaces
*/
abstact class OrderModel implements GtkTreeModel, GtkTreeDragSource, GtkTreeDragDest {
virtual gint get_n_items ()
virtual GValue get_item_value (gint nth_item, OrderModelColumn column)
virtual void set_activity (gint nth_item, gboolean activity)
virtual void swap_items (gint nth_item_a, gint nth_item_b)
/* optional for implementation */
virtual void reset_to_default ()
}
enum OrderWidgetFeatureFlags {
/* show reset button? */
ORDER_WIDGET_FEATURE_RESETTABLE = 1 << 0,
};
/* TreeView, bottom and right panel with buttons */
class OrderWidget {
property OrderWidgetFeatureFlags features;
property OrderModel model;
GtkContainer *get_right_area ();
GtkContainer *get_bottom_area ();
}








Draft for thunar-specific general dialog: thunar!716 (The design proposed above is slightly different from my implementation)