Skip to content

Commit

Permalink
fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksiy-Yakovenko committed Nov 18, 2023
1 parent 58d9f4b commit d291f51
Show file tree
Hide file tree
Showing 5 changed files with 413 additions and 108 deletions.
4 changes: 2 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BinPackParameters: false
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
Expand All @@ -55,7 +55,7 @@ BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeComma
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: false
ColumnLimit: 0
ColumnLimit: 120
CommentPragmas: '^ IWYU pragma:'
QualifierAlignment: Leave
CompactNamespaces: false
Expand Down
65 changes: 43 additions & 22 deletions plugins/gtkui/medialib/medialibwidget.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,10 @@ _scriptableSelectSelectionDidChange (gtkScriptableSelectViewController_t *vc, sc
}

static void
_scriptableSelectScriptableDidChange (gtkScriptableSelectViewController_t *view_controller, gtkScriptableChange_t change_type, void *context) {
_scriptableSelectScriptableDidChange (
gtkScriptableSelectViewController_t *view_controller,
gtkScriptableChange_t change_type,
void *context) {
w_medialib_viewer_t *mlv = context;
scriptableItem_t *presets = plugin->get_queries_scriptable (mlv->source);
scriptableItemSave (presets);
Expand Down Expand Up @@ -433,13 +436,26 @@ _create_text_column (w_medialib_viewer_t *w, GtkTreeView *tree, int column_index
}

static GtkTreeViewColumn *
_create_lazy_pixbuf_column (w_medialib_viewer_t *w, GtkTreeView *tree, int path_column_index, int pixbuf_column_index, const char *title, int align_right) {
_create_lazy_pixbuf_column (
w_medialib_viewer_t *w,
GtkTreeView *tree,
int path_column_index,
int pixbuf_column_index,
const char *title,
int align_right) {
GtkCellRenderer *rend = NULL;
rend = GTK_CELL_RENDERER (ml_cell_renderer_pixbuf_new (&w->pixbuf_cell_delegate));
if (align_right) {
g_object_set (rend, "xalign", 1.0, NULL);
}
return gtk_tree_view_column_new_with_attributes (title, rend, "path", path_column_index, "pixbuf", pixbuf_column_index, NULL);
return gtk_tree_view_column_new_with_attributes (
title,
rend,
"path",
path_column_index,
"pixbuf",
pixbuf_column_index,
NULL);
}

static GtkTreeViewColumn *
Expand Down Expand Up @@ -500,7 +516,11 @@ _collect_tracks_from_iter (GtkTreeModel *model, GtkTreeIter *iter, ddb_playItem_
}

static int
_collect_selected_tracks (GtkTreeModel *model, GtkTreeSelection *selection, ddb_playItem_t **tracks, int append_position) {
_collect_selected_tracks (
GtkTreeModel *model,
GtkTreeSelection *selection,
ddb_playItem_t **tracks,
int append_position) {
GList *selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);

int count = 0;
Expand Down Expand Up @@ -710,12 +730,7 @@ _configure_did_activate (GtkButton *self, gpointer user_data) {
}

static void
_drag_data_get (
GtkWidget *widget,
GdkDragContext *context,
GtkSelectionData *selection_data,
guint info,
guint time) {
_drag_data_get (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data, guint info, guint time) {
GtkTreeModel *model = GTK_TREE_MODEL (gtk_tree_view_get_model (GTK_TREE_VIEW (widget)));
GtkTreeSelection *selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));

Expand All @@ -727,7 +742,12 @@ _drag_data_get (
_collect_selected_tracks (model, selection, tracks, 0);

GdkAtom type = gtk_selection_data_get_target (selection_data);
gtk_selection_data_set (selection_data, type, sizeof (void *) * 8, (const guchar *)tracks, count * sizeof (ddb_playItem_t *));
gtk_selection_data_set (
selection_data,
type,
sizeof (void *) * 8,
(const guchar *)tracks,
count * sizeof (ddb_playItem_t *));

free (tracks);
tracks = NULL;
Expand Down Expand Up @@ -801,11 +821,15 @@ _pixbuf_cell_did_become_visible (void *ctx, const char *pathstr) {
}

int64_t reload_index = mlv->reload_index;
GdkPixbuf *cached_cover = covermanager_cover_for_track_no_default (covermanager_shared (), track, mlv->artwork_source_id, ^(GdkPixbuf *img) {
if (reload_index == mlv->reload_index && img != NULL) {
_receive_cover (mlv, path, img);
}
});
GdkPixbuf *cached_cover = covermanager_cover_for_track_no_default (
covermanager_shared (),
track,
mlv->artwork_source_id,
^(GdkPixbuf *img) {
if (reload_index == mlv->reload_index && img != NULL) {
_receive_cover (mlv, path, img);
}
});

if (cached_cover != NULL) {
_receive_cover (mlv, path, cached_cover);
Expand Down Expand Up @@ -908,7 +932,8 @@ w_medialib_viewer_create (void) {
gtk_tree_view_set_model (GTK_TREE_VIEW (w->tree), GTK_TREE_MODEL (store));

gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (w->tree), TRUE);
GtkTreeViewColumn *col_icon = _create_lazy_pixbuf_column (w, GTK_TREE_VIEW (w->tree), COL_PATH, COL_ICON, "Icon", 0);
GtkTreeViewColumn *col_icon =
_create_lazy_pixbuf_column (w, GTK_TREE_VIEW (w->tree), COL_PATH, COL_ICON, "Icon", 0);
GtkTreeViewColumn *col_text = _create_text_column (w, GTK_TREE_VIEW (w->tree), COL_TITLE, "Title", 0);

_setup_treeview_column (GTK_TREE_VIEW (w->tree), col_icon, "Icon", 0, 0);
Expand All @@ -925,11 +950,7 @@ w_medialib_viewer_create (void) {
g_signal_connect ((gpointer)w->tree, "button_press_event", G_CALLBACK (_treeview_row_mousedown), w);
g_signal_connect ((gpointer)configure_button, "clicked", G_CALLBACK (_configure_did_activate), w);

GtkTargetEntry entry = {
.target = TARGET_PLAYITEM_POINTERS,
.flags = GTK_TARGET_SAME_APP,
.info = 0
};
GtkTargetEntry entry = { .target = TARGET_PLAYITEM_POINTERS, .flags = GTK_TARGET_SAME_APP, .info = 0 };
gtk_drag_source_set (GTK_WIDGET (w->tree), GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_COPY);

g_signal_connect ((gpointer)w->tree, "drag_data_get", G_CALLBACK (_drag_data_get), w);
Expand Down
49 changes: 34 additions & 15 deletions plugins/gtkui/medialib/mlcellrendererpixbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ _finalize (GObject *object) {
}

static void
_get_property (
GObject *object,
guint param_id,
GValue *value,
GParamSpec *psec) {
_get_property (GObject *object, guint param_id, GValue *value, GParamSpec *psec) {
MlCellRendererPixbuf *self = ML_CELL_RENDERER_PIXBUF (object);

switch (param_id) {
Expand All @@ -85,11 +81,7 @@ _get_property (
}

static void
_set_property (
GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec) {
_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec) {
MlCellRendererPixbuf *cellpixbuf = ML_CELL_RENDERER_PIXBUF (object);

switch (param_id) {
Expand Down Expand Up @@ -122,10 +114,24 @@ _set_property (

#if !GTK_CHECK_VERSION(3, 0, 0)
static void
_get_size (GtkCellRenderer *cell, GtkWidget *widget, GdkRectangle *cell_area, gint *x_offset, gint *y_offset, gint *width, gint *height) {
_get_size (
GtkCellRenderer *cell,
GtkWidget *widget,
GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height) {
#else
static void
_get_size (GtkCellRenderer *cell, GtkWidget *widget, const GdkRectangle *cell_area, gint *x_offset, gint *y_offset, gint *width, gint *height) {
_get_size (
GtkCellRenderer *cell,
GtkWidget *widget,
const GdkRectangle *cell_area,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height) {
#endif
if (width != NULL) {
*width = ML_CELL_RENDERER_PIXBUF_SIZE;
Expand All @@ -137,7 +143,14 @@ _get_size (GtkCellRenderer *cell, GtkWidget *widget, const GdkRectangle *cell_ar

#if !GTK_CHECK_VERSION(3, 0, 0)
static void
_render (GtkCellRenderer *cell, GdkDrawable *window, GtkWidget *widget, GdkRectangle *background_area, GdkRectangle *cell_area, GdkRectangle *expose_area, GtkCellRendererState flags) {
_render (
GtkCellRenderer *cell,
GdkDrawable *window,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
GtkCellRendererState flags) {
#else
static void
_render (
Expand Down Expand Up @@ -198,8 +211,14 @@ ml_cell_renderer_pixbuf_class_init (MlCellRendererPixbufClass *class) {
class->parent_class.get_size = _get_size;
class->parent_class.render = _render;

g_object_class_install_property (object_class, PROP_PATH, g_param_spec_string ("path", "Track Object", "The path", "", G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_PIXBUF, g_param_spec_object ("pixbuf", "Pixbuf Object", "The pixbuf", GDK_TYPE_PIXBUF, G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
PROP_PATH,
g_param_spec_string ("path", "Track Object", "The path", "", G_PARAM_READWRITE));
g_object_class_install_property (
object_class,
PROP_PIXBUF,
g_param_spec_object ("pixbuf", "Pixbuf Object", "The pixbuf", GDK_TYPE_PIXBUF, G_PARAM_READWRITE));
}

MlCellRendererPixbuf *
Expand Down
Loading

0 comments on commit d291f51

Please sign in to comment.