summaryrefslogtreecommitdiff
path: root/src/trg-tree-view.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/trg-tree-view.c')
-rw-r--r--src/trg-tree-view.c489
1 files changed, 294 insertions, 195 deletions
diff --git a/src/trg-tree-view.c b/src/trg-tree-view.c
index f4dae36..26c90cd 100644
--- a/src/trg-tree-view.c
+++ b/src/trg-tree-view.c
@@ -57,52 +57,60 @@ struct _TrgTreeViewPrivate {
TrgPrefs *prefs;
};
-gboolean trg_tree_view_is_column_showing(TrgTreeView *tv, gint index) {
+gboolean trg_tree_view_is_column_showing(TrgTreeView * tv, gint index)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
GList *li;
for (li = priv->columns; li; li = g_list_next(li)) {
- trg_column_description *cd = (trg_column_description*) li->data;
- if (cd->model_column == index) {
- if (cd->flags & TRG_COLUMN_SHOWING
- )
- return TRUE;
- else
- break;
- }
+ trg_column_description *cd = (trg_column_description *) li->data;
+ if (cd->model_column == index) {
+ if (cd->flags & TRG_COLUMN_SHOWING)
+ return TRUE;
+ else
+ break;
+ }
}
return FALSE;
}
static void trg_tree_view_get_property(GObject * object, guint property_id,
- GValue * value, GParamSpec * pspec) {
+ GValue * value, GParamSpec * pspec)
+{
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
}
static void trg_tree_view_set_property(GObject * object, guint property_id,
- const GValue * value, GParamSpec * pspec) {
+ const GValue * value,
+ GParamSpec * pspec)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(object);
switch (property_id) {
case PROP_PREFS:
- priv->prefs = g_value_get_object(value);
- break;
+ priv->prefs = g_value_get_object(value);
+ break;
default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
- break;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec);
+ break;
}
}
static GObject *trg_tree_view_constructor(GType type,
- guint n_construct_properties, GObjectConstructParam * construct_params) {
+ guint n_construct_properties,
+ GObjectConstructParam *
+ construct_params)
+{
GObject *obj = G_OBJECT_CLASS
- (trg_tree_view_parent_class)->constructor(type,
- n_construct_properties, construct_params);
+ (trg_tree_view_parent_class)->constructor(type,
+ n_construct_properties,
+ construct_params);
return obj;
}
-static JsonObject* trg_prefs_get_tree_view_props(TrgTreeView *tv) {
+static JsonObject *trg_prefs_get_tree_view_props(TrgTreeView * tv)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
JsonObject *root = trg_prefs_get_root(priv->prefs);
const gchar *className = G_OBJECT_TYPE_NAME(tv);
@@ -110,28 +118,34 @@ static JsonObject* trg_prefs_get_tree_view_props(TrgTreeView *tv) {
JsonObject *tvProps = NULL;
if (!json_object_has_member(root, TRG_PREFS_KEY_TREE_VIEWS)) {
- obj = json_object_new();
- json_object_set_object_member(root, TRG_PREFS_KEY_TREE_VIEWS, obj);
+ obj = json_object_new();
+ json_object_set_object_member(root, TRG_PREFS_KEY_TREE_VIEWS, obj);
} else {
- obj = json_object_get_object_member(root, TRG_PREFS_KEY_TREE_VIEWS);
+ obj =
+ json_object_get_object_member(root, TRG_PREFS_KEY_TREE_VIEWS);
}
if (!json_object_has_member(obj, className)) {
- tvProps = json_object_new();
- json_object_set_object_member(obj, className, tvProps);
+ tvProps = json_object_new();
+ json_object_set_object_member(obj, className, tvProps);
} else {
- tvProps = json_object_get_object_member(obj, className);
+ tvProps = json_object_get_object_member(obj, className);
}
return tvProps;
}
static void trg_tree_view_add_column_after(TrgTreeView * tv,
- trg_column_description * desc, gint64 width,
- GtkTreeViewColumn * after_col);
-
-trg_column_description *trg_tree_view_reg_column(TrgTreeView * tv, gint type,
- gint model_column, gchar * header, gchar * id, gint flags) {
+ trg_column_description * desc,
+ gint64 width,
+ GtkTreeViewColumn * after_col);
+
+trg_column_description *trg_tree_view_reg_column(TrgTreeView * tv,
+ gint type,
+ gint model_column,
+ gchar * header,
+ gchar * id, gint flags)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
trg_column_description *desc = g_new0(trg_column_description, 1);
@@ -147,43 +161,51 @@ trg_column_description *trg_tree_view_reg_column(TrgTreeView * tv, gint type,
}
static trg_column_description *trg_tree_view_find_column(TrgTreeView * tv,
- const gchar * id) {
+ const gchar * id)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
GList *li;
trg_column_description *desc;
for (li = priv->columns; li; li = g_list_next(li)) {
- desc = (trg_column_description *) li->data;
- if (!g_strcmp0(desc->id, id))
- return desc;
+ desc = (trg_column_description *) li->data;
+ if (!g_strcmp0(desc->id, id))
+ return desc;
}
return NULL;
}
-static void trg_tree_view_hide_column(GtkWidget * w, GtkTreeViewColumn * col) {
+static void trg_tree_view_hide_column(GtkWidget * w,
+ GtkTreeViewColumn * col)
+{
trg_column_description *desc = g_object_get_data(G_OBJECT(col),
- "column-desc");
+ "column-desc");
GtkWidget *tv = gtk_tree_view_column_get_tree_view(col);
desc->flags &= ~TRG_COLUMN_SHOWING;
gtk_tree_view_remove_column(GTK_TREE_VIEW(tv), col);
}
static void trg_tree_view_add_column(TrgTreeView * tv,
- trg_column_description * desc, gint64 width) {
+ trg_column_description * desc,
+ gint64 width)
+{
trg_tree_view_add_column_after(tv, desc, width, NULL);
}
static void trg_tree_view_user_add_column_cb(GtkWidget * w,
- trg_column_description * desc) {
+ trg_column_description * desc)
+{
GtkTreeViewColumn *col = g_object_get_data(G_OBJECT(w), "parent-col");
- TrgTreeView *tv = TRG_TREE_VIEW(gtk_tree_view_column_get_tree_view(col));
+ TrgTreeView *tv =
+ TRG_TREE_VIEW(gtk_tree_view_column_get_tree_view(col));
trg_tree_view_add_column_after(tv, desc, -1, col);
}
static void view_popup_menu(GtkButton * button, GdkEventButton * event,
- GtkTreeViewColumn * column) {
+ GtkTreeViewColumn * column)
+{
GtkWidget *tv = gtk_tree_view_column_get_tree_view(column);
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
GtkWidget *menu, *menuitem;
@@ -196,130 +218,179 @@ static void view_popup_menu(GtkButton * button, GdkEventButton * event,
menuitem = gtk_check_menu_item_new_with_label(desc->header);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
g_signal_connect(menuitem, "activate",
- G_CALLBACK(trg_tree_view_hide_column), column);
- gtk_widget_set_sensitive(menuitem, !(desc->flags & TRG_COLUMN_UNREMOVABLE));
+ G_CALLBACK(trg_tree_view_hide_column), column);
+ gtk_widget_set_sensitive(menuitem,
+ !(desc->flags & TRG_COLUMN_UNREMOVABLE));
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
for (li = priv->columns; li; li = g_list_next(li)) {
- trg_column_description *desc = (trg_column_description *) li->data;
- if (!(desc->flags & TRG_COLUMN_SHOWING)) {
- menuitem = gtk_check_menu_item_new_with_label(desc->header);
- g_object_set_data(G_OBJECT(menuitem), "parent-col", column);
- g_signal_connect(menuitem, "activate",
- G_CALLBACK(trg_tree_view_user_add_column_cb), desc);
- gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
- }
+ trg_column_description *desc = (trg_column_description *) li->data;
+ if (!(desc->flags & TRG_COLUMN_SHOWING)) {
+ menuitem = gtk_check_menu_item_new_with_label(desc->header);
+ g_object_set_data(G_OBJECT(menuitem), "parent-col", column);
+ g_signal_connect(menuitem, "activate",
+ G_CALLBACK(trg_tree_view_user_add_column_cb),
+ desc);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem);
+ }
}
gtk_widget_show_all(menu);
gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
- (event != NULL) ? event->button : 0,
- gdk_event_get_time((GdkEvent *) event));
- }
+ (event != NULL) ? event->button : 0,
+ gdk_event_get_time((GdkEvent *) event));
+}
-static gboolean col_onButtonPressed(GtkButton * button, GdkEventButton * event,
- GtkTreeViewColumn * col) {
+static gboolean col_onButtonPressed(GtkButton * button,
+ GdkEventButton * event,
+ GtkTreeViewColumn * col)
+{
if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
- view_popup_menu(button, event, col);
- return TRUE;
+ view_popup_menu(button, event, col);
+ return TRUE;
}
return FALSE;
}
-static GtkTreeViewColumn *trg_tree_view_icontext_column_new(
- trg_column_description *desc, gchar *renderer_property) {
+static GtkTreeViewColumn
+ *trg_tree_view_icontext_column_new(trg_column_description * desc,
+ gchar * renderer_property)
+{
GtkTreeViewColumn *column = gtk_tree_view_column_new();
GtkCellRenderer *renderer = gtk_cell_renderer_pixbuf_new();
gtk_tree_view_column_set_title(column, desc->header);
gtk_tree_view_column_pack_start(column, renderer, FALSE);
- gtk_tree_view_column_set_attributes(column, renderer, renderer_property,
- desc->model_column_icon, NULL);
+ gtk_tree_view_column_set_attributes(column, renderer,
+ renderer_property,
+ desc->model_column_icon, NULL);
renderer = gtk_cell_renderer_text_new();
gtk_tree_view_column_pack_start(column, renderer, TRUE);
gtk_tree_view_column_set_attributes(column, renderer, "text",
- desc->model_column, NULL);
+ desc->model_column, NULL);
return column;
}
static void trg_tree_view_add_column_after(TrgTreeView * tv,
- trg_column_description * desc, gint64 width,
- GtkTreeViewColumn * after_col) {
+ trg_column_description * desc,
+ gint64 width,
+ GtkTreeViewColumn * after_col)
+{
GtkCellRenderer *renderer;
GtkTreeViewColumn *column = NULL;
switch (desc->type) {
case TRG_COLTYPE_TEXT:
- renderer =
- desc->customRenderer ? desc->customRenderer :
- gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "text", desc->model_column, NULL);
-
- break;
+ renderer =
+ desc->customRenderer ? desc->customRenderer :
+ gtk_cell_renderer_text_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer, "text",
+ desc->
+ model_column,
+ NULL);
+
+ break;
case TRG_COLTYPE_SPEED:
- renderer = trg_cell_renderer_speed_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "speed-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_speed_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "speed-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_EPOCH:
- renderer = trg_cell_renderer_epoch_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "epoch-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_epoch_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "epoch-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_ETA:
- renderer = trg_cell_renderer_eta_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "eta-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_eta_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "eta-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_SIZE:
- renderer = trg_cell_renderer_size_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "size-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_size_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "size-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_PROG:
- renderer = gtk_cell_renderer_progress_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "value", desc->model_column, NULL);
- break;
+ renderer = gtk_cell_renderer_progress_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_RATIO:
- renderer = trg_cell_renderer_ratio_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "ratio-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_ratio_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "ratio-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_ICON:
- column = gtk_tree_view_column_new();
- renderer = gtk_cell_renderer_pixbuf_new();
- gtk_cell_renderer_set_alignment(GTK_CELL_RENDERER(renderer), 0.5f, 0.0);
- gtk_tree_view_column_set_title(column, desc->header);
- gtk_tree_view_column_pack_start(column, renderer, TRUE);
- gtk_tree_view_column_set_attributes(column, renderer, "stock-id",
- desc->model_column, NULL);
- break;
+ column = gtk_tree_view_column_new();
+ renderer = gtk_cell_renderer_pixbuf_new();
+ gtk_cell_renderer_set_alignment(GTK_CELL_RENDERER(renderer), 0.5f,
+ 0.0);
+ gtk_tree_view_column_set_title(column, desc->header);
+ gtk_tree_view_column_pack_start(column, renderer, TRUE);
+ gtk_tree_view_column_set_attributes(column, renderer, "stock-id",
+ desc->model_column, NULL);
+ break;
case TRG_COLTYPE_STOCKICONTEXT:
- column = trg_tree_view_icontext_column_new(desc, "stock-id");
- break;
+ column = trg_tree_view_icontext_column_new(desc, "stock-id");
+ break;
case TRG_COLTYPE_GICONTEXT:
- column = trg_tree_view_icontext_column_new(desc, "gicon");
- break;
+ column = trg_tree_view_icontext_column_new(desc, "gicon");
+ break;
case TRG_COLTYPE_PRIO:
- renderer = trg_cell_renderer_priority_new();
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "priority-value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_priority_new();
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "priority-value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_NUMGTZERO:
- renderer = trg_cell_renderer_numgteqthan_new(1);
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_numgteqthan_new(1);
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "value",
+ desc->
+ model_column,
+ NULL);
+ break;
case TRG_COLTYPE_NUMGTEQZERO:
- renderer = trg_cell_renderer_numgteqthan_new(0);
- column = gtk_tree_view_column_new_with_attributes(desc->header,
- renderer, "value", desc->model_column, NULL);
- break;
+ renderer = trg_cell_renderer_numgteqthan_new(0);
+ column = gtk_tree_view_column_new_with_attributes(desc->header,
+ renderer,
+ "value",
+ desc->
+ model_column,
+ NULL);
+ break;
}
gtk_tree_view_column_set_min_width(column, 0);
@@ -328,8 +399,9 @@ static void trg_tree_view_add_column_after(TrgTreeView * tv,
gtk_tree_view_column_set_sort_column_id(column, desc->model_column);
if (width >= 0) {
- gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
- gtk_tree_view_column_set_fixed_width(column, width);
+ gtk_tree_view_column_set_sizing(column,
+ GTK_TREE_VIEW_COLUMN_FIXED);
+ gtk_tree_view_column_set_fixed_width(column, width);
}
g_object_set_data(G_OBJECT(column), "column-desc", desc);
@@ -337,23 +409,26 @@ static void trg_tree_view_add_column_after(TrgTreeView * tv,
gtk_tree_view_append_column(GTK_TREE_VIEW(tv), column);
if (after_col)
- gtk_tree_view_move_column_after(GTK_TREE_VIEW(tv), column, after_col);
+ gtk_tree_view_move_column_after(GTK_TREE_VIEW(tv), column,
+ after_col);
#if GTK_CHECK_VERSION( 3,0,0 )
- g_signal_connect(gtk_tree_view_column_get_button(column), "button-press-event",
- G_CALLBACK(col_onButtonPressed), column);
+ g_signal_connect(gtk_tree_view_column_get_button(column),
+ "button-press-event", G_CALLBACK(col_onButtonPressed),
+ column);
#else
g_signal_connect(column->button, "button-press-event",
- G_CALLBACK(col_onButtonPressed), column);
+ G_CALLBACK(col_onButtonPressed), column);
#endif
if (desc->out)
- *(desc->out) = column;
+ *(desc->out) = column;
desc->flags |= TRG_COLUMN_SHOWING;
}
-void trg_tree_view_persist(TrgTreeView * tv, gboolean parentIsSortable) {
+void trg_tree_view_persist(TrgTreeView * tv, gboolean parentIsSortable)
+{
JsonObject *props = trg_prefs_get_tree_view_props(tv);
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tv));
GList *cols = gtk_tree_view_get_columns(GTK_TREE_VIEW(tv));
@@ -364,106 +439,123 @@ void trg_tree_view_persist(TrgTreeView * tv, gboolean parentIsSortable) {
JsonArray *widths, *columns;
if (json_object_has_member(props, TRG_PREFS_KEY_TV_WIDTHS))
- json_object_remove_member(props, TRG_PREFS_KEY_TV_WIDTHS);
+ json_object_remove_member(props, TRG_PREFS_KEY_TV_WIDTHS);
widths = json_array_new();
json_object_set_array_member(props, TRG_PREFS_KEY_TV_WIDTHS, widths);
if (json_object_has_member(props, TRG_PREFS_KEY_TV_COLUMNS))
- json_object_remove_member(props, TRG_PREFS_KEY_TV_COLUMNS);
+ json_object_remove_member(props, TRG_PREFS_KEY_TV_COLUMNS);
columns = json_array_new();
json_object_set_array_member(props, TRG_PREFS_KEY_TV_COLUMNS, columns);
for (li = cols; li; li = g_list_next(li)) {
- GtkTreeViewColumn *col = (GtkTreeViewColumn *) li->data;
- trg_column_description *desc = g_object_get_data(G_OBJECT(li->data),
- "column-desc");
-
- json_array_add_string_element(columns, desc->id);
- json_array_add_int_element(widths, gtk_tree_view_column_get_width(col));
+ GtkTreeViewColumn *col = (GtkTreeViewColumn *) li->data;
+ trg_column_description *desc =
+ g_object_get_data(G_OBJECT(li->data),
+ "column-desc");
+
+ json_array_add_string_element(columns, desc->id);
+ json_array_add_int_element(widths,
+ gtk_tree_view_column_get_width(col));
}
g_list_free(cols);
- gtk_tree_sortable_get_sort_column_id(
- GTK_TREE_SORTABLE(parentIsSortable ? gtk_tree_model_filter_get_model(
- GTK_TREE_MODEL_FILTER(model)) :
- model), &sort_column_id, &sort_type);
+ gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE
+ (parentIsSortable ?
+ gtk_tree_model_filter_get_model
+ (GTK_TREE_MODEL_FILTER(model)) :
+ model), &sort_column_id,
+ &sort_type);
if (json_object_has_member(props, TRG_PREFS_KEY_TV_SORT_COL))
- json_object_remove_member(props, TRG_PREFS_KEY_TV_SORT_COL);
+ json_object_remove_member(props, TRG_PREFS_KEY_TV_SORT_COL);
if (json_object_has_member(props, TRG_PREFS_KEY_TV_SORT_TYPE))
- json_object_remove_member(props, TRG_PREFS_KEY_TV_SORT_TYPE);
+ json_object_remove_member(props, TRG_PREFS_KEY_TV_SORT_TYPE);
json_object_set_int_member(props, TRG_PREFS_KEY_TV_SORT_COL,
- (gint64) sort_column_id);
+ (gint64) sort_column_id);
json_object_set_int_member(props, TRG_PREFS_KEY_TV_SORT_TYPE,
- (gint64) sort_type);
+ (gint64) sort_type);
}
-void trg_tree_view_restore_sort(TrgTreeView * tv, gboolean parentIsSortable) {
+void trg_tree_view_restore_sort(TrgTreeView * tv,
+ gboolean parentIsSortable)
+{
JsonObject *props = trg_prefs_get_tree_view_props(tv);
GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(tv));
if (json_object_has_member(props, TRG_PREFS_KEY_TV_SORT_COL)
- && json_object_has_member(props, TRG_PREFS_KEY_TV_SORT_TYPE)) {
- gint64 sort_col = json_object_get_int_member(props,
- TRG_PREFS_KEY_TV_SORT_COL);
- gint64 sort_type = json_object_get_int_member(props,
- TRG_PREFS_KEY_TV_SORT_TYPE);
- gtk_tree_sortable_set_sort_column_id(
- GTK_TREE_SORTABLE(parentIsSortable ? gtk_tree_model_filter_get_model(
- GTK_TREE_MODEL_FILTER(model)) :
- model), sort_col, (GtkSortType) sort_type);
+ && json_object_has_member(props, TRG_PREFS_KEY_TV_SORT_TYPE)) {
+ gint64 sort_col = json_object_get_int_member(props,
+ TRG_PREFS_KEY_TV_SORT_COL);
+ gint64 sort_type = json_object_get_int_member(props,
+ TRG_PREFS_KEY_TV_SORT_TYPE);
+ gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE
+ (parentIsSortable ?
+ gtk_tree_model_filter_get_model
+ (GTK_TREE_MODEL_FILTER
+ (model)) : model), sort_col,
+ (GtkSortType) sort_type);
}
}
-void trg_tree_view_set_prefs(TrgTreeView *tv, TrgPrefs *prefs) {
+void trg_tree_view_set_prefs(TrgTreeView * tv, TrgPrefs * prefs)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
priv->prefs = prefs;
}
-void trg_tree_view_setup_columns(TrgTreeView * tv) {
+void trg_tree_view_setup_columns(TrgTreeView * tv)
+{
TrgTreeViewPrivate *priv = TRG_TREE_VIEW_GET_PRIVATE(tv);
JsonObject *props = trg_prefs_get_tree_view_props(tv);
if (!json_object_has_member(props, TRG_PREFS_KEY_TV_COLUMNS)
- || !json_object_has_member(props, TRG_PREFS_KEY_TV_WIDTHS)) {
- GList *li;
- for (li = priv->columns; li; li = g_list_next(li)) {
- trg_column_description *desc = (trg_column_description *) li->data;
- if (desc && !(desc->flags & TRG_COLUMN_EXTRA))
- trg_tree_view_add_column(tv, desc, -1);
- }
- return;
+ || !json_object_has_member(props, TRG_PREFS_KEY_TV_WIDTHS)) {
+ GList *li;
+ for (li = priv->columns; li; li = g_list_next(li)) {
+ trg_column_description *desc =
+ (trg_column_description *) li->data;
+ if (desc && !(desc->flags & TRG_COLUMN_EXTRA))
+ trg_tree_view_add_column(tv, desc, -1);
+ }
+ return;
}
- GList *columns = json_array_get_elements(
- json_object_get_array_member(props, TRG_PREFS_KEY_TV_COLUMNS));
- GList *widths = json_array_get_elements(
- json_object_get_array_member(props, TRG_PREFS_KEY_TV_WIDTHS));
+ GList *columns =
+ json_array_get_elements(json_object_get_array_member
+ (props, TRG_PREFS_KEY_TV_COLUMNS));
+ GList *widths =
+ json_array_get_elements(json_object_get_array_member
+ (props, TRG_PREFS_KEY_TV_WIDTHS));
GList *wli = widths;
GList *cli = columns;
for (; cli; cli = g_list_next(cli)) {
- trg_column_description *desc = trg_tree_view_find_column(tv,
- json_node_get_string((JsonNode*) cli->data));
- if (desc) {
- gint64 width = json_node_get_int((JsonNode*) wli->data);
- trg_tree_view_add_column(tv, desc, width);
- }
- wli = g_list_next(wli);
+ trg_column_description *desc = trg_tree_view_find_column(tv,
+ json_node_get_string
+ ((JsonNode
+ *) cli->
+ data));
+ if (desc) {
+ gint64 width = json_node_get_int((JsonNode *) wli->data);
+ trg_tree_view_add_column(tv, desc, width);
+ }
+ wli = g_list_next(wli);
}
g_list_free(columns);
g_list_free(widths);
}
-GList *trg_tree_view_get_selected_refs_list(GtkTreeView * tv) {
+GList *trg_tree_view_get_selected_refs_list(GtkTreeView * tv)
+{
GtkTreeModel *model = gtk_tree_view_get_model(tv);
GtkTreeSelection *selection = gtk_tree_view_get_selection(tv);
GList *li, *selectionList;
@@ -471,17 +563,18 @@ GList *trg_tree_view_get_selected_refs_list(GtkTreeView * tv) {
selectionList = gtk_tree_selection_get_selected_rows(selection, NULL);
for (li = selectionList; li != NULL; li = g_list_next(li)) {
- GtkTreePath *path = (GtkTreePath *) li->data;
- GtkTreeRowReference *ref = gtk_tree_row_reference_new(model, path);
- gtk_tree_path_free(path);
- refList = g_list_append(refList, ref);
+ GtkTreePath *path = (GtkTreePath *) li->data;
+ GtkTreeRowReference *ref = gtk_tree_row_reference_new(model, path);
+ gtk_tree_path_free(path);
+ refList = g_list_append(refList, ref);
}
g_list_free(selectionList);
return refList;
}
-static void trg_tree_view_class_init(TrgTreeViewClass * klass) {
+static void trg_tree_view_class_init(TrgTreeViewClass * klass)
+{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
g_type_class_add_private(klass, sizeof(TrgTreeViewPrivate));
@@ -490,29 +583,35 @@ static void trg_tree_view_class_init(TrgTreeViewClass * klass) {
object_class->set_property = trg_tree_view_set_property;
object_class->constructor = trg_tree_view_constructor;
- g_object_class_install_property(
- object_class,
- PROP_PREFS,
- g_param_spec_object(
- "prefs",
- "Trg Prefs",
- "Trg Prefs",
- TRG_TYPE_PREFS,
- G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY
- | G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK
- | G_PARAM_STATIC_BLURB));
+ g_object_class_install_property(object_class,
+ PROP_PREFS,
+ g_param_spec_object("prefs",
+ "Trg Prefs",
+ "Trg Prefs",
+ TRG_TYPE_PREFS,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT_ONLY
+ |
+ G_PARAM_STATIC_NAME
+ |
+ G_PARAM_STATIC_NICK
+ |
+ G_PARAM_STATIC_BLURB));
}
-static void trg_tree_view_init(TrgTreeView * tv) {
+static void trg_tree_view_init(TrgTreeView * tv)
+{
gtk_tree_view_set_rubber_banding(GTK_TREE_VIEW(tv), TRUE);
gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(tv), TRUE);
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(tv), TRUE);
- gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)),
- GTK_SELECTION_MULTIPLE);
+ gtk_tree_selection_set_mode(gtk_tree_view_get_selection
+ (GTK_TREE_VIEW(tv)),
+ GTK_SELECTION_MULTIPLE);
gtk_widget_set_sensitive(GTK_WIDGET(tv), FALSE);
}
-GtkWidget *trg_tree_view_new(void) {
+GtkWidget *trg_tree_view_new(void)
+{
return GTK_WIDGET(g_object_new(TRG_TYPE_TREE_VIEW, NULL));
}