Skip to content

Commit

Permalink
icon view: Use bold text instead of an emblem for pinned files.
Browse files Browse the repository at this point in the history
This gives it the same behavior as in the list view, and removes any
angst about icons and icon themes.
  • Loading branch information
mtwebster committed Jun 18, 2019
1 parent dfc39a5 commit c3f9575
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 335 deletions.
327 changes: 0 additions & 327 deletions data/icons/hicolor/emblems/scalable/emblem-pinned.svg

This file was deleted.

1 change: 0 additions & 1 deletion data/icons/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ privateIcons = [
'hicolor/emblems/16x16/emblem-note.png',
'hicolor/emblems/24x24/emblem-note.png',
'hicolor/emblems/48x48/emblem-note.png',
'hicolor/emblems/scalable/emblem-pinned.svg'
]
noInstallIcons = [
'hicolor/apps/16x16/nemo.svg',
Expand Down
26 changes: 25 additions & 1 deletion libnemo-private/nemo-icon-canvas-item.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ struct NemoIconCanvasItemDetails {

guint is_visible : 1;

guint is_pinned : 1;

/* Cached PangoLayouts. Only used if the icon is visible */
PangoLayout *editable_text_layout;
PangoLayout *additional_text_layout;
Expand All @@ -142,7 +144,8 @@ enum {
PROP_HIGHLIGHTED_FOR_SELECTION,
PROP_HIGHLIGHTED_AS_KEYBOARD_FOCUS,
PROP_HIGHLIGHTED_FOR_DROP,
PROP_HIGHLIGHTED_FOR_CLIPBOARD
PROP_HIGHLIGHTED_FOR_CLIPBOARD,
PROP_PINNED
};

typedef enum {
Expand Down Expand Up @@ -358,6 +361,15 @@ nemo_icon_canvas_item_set_property (GObject *object,
details->is_highlighted_for_clipboard = g_value_get_boolean (value);
break;

case PROP_PINNED:
if (!details->is_pinned == !g_value_get_boolean (value)) {
return;
}
details->is_pinned = g_value_get_boolean (value);
nemo_icon_canvas_item_invalidate_label (item);

break;

default:
g_warning ("nemo_icons_view_item_item_set_arg on unknown argument");
return;
Expand Down Expand Up @@ -1450,6 +1462,10 @@ create_label_layout (NemoIconCanvasItem *item,
container->details->font_size_table [container->details->zoom_level]);
}

if (item->details->is_pinned) {
pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
}

pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
g_free (zeroified_text);
Expand Down Expand Up @@ -2054,6 +2070,14 @@ nemo_icon_canvas_item_class_init (NemoIconCanvasItemClass *class)
"whether we are highlighted for a clipboard paste (after we have been cut)",
FALSE, G_PARAM_READWRITE));

g_object_class_install_property (
object_class,
PROP_PINNED,
g_param_spec_boolean ("pinned",
"pinned",
"backing file is pinned",
FALSE, G_PARAM_READWRITE));

item_class->update = nemo_icon_canvas_item_update;
item_class->draw = nemo_icon_canvas_item_draw;
item_class->point = nemo_icon_canvas_item_point;
Expand Down
5 changes: 3 additions & 2 deletions libnemo-private/nemo-icon-container.c
Original file line number Diff line number Diff line change
Expand Up @@ -3777,14 +3777,15 @@ nemo_icon_container_get_icon_text (NemoIconContainer *container,
NemoIconData *data,
char **editable_text,
char **additional_text,
gboolean *pinned,
gboolean include_invisible)
{
NemoIconContainerClass *klass;

klass = NEMO_ICON_CONTAINER_GET_CLASS (container);
g_assert (klass->get_icon_text != NULL);

klass->get_icon_text (container, data, editable_text, additional_text, include_invisible);
klass->get_icon_text (container, data, editable_text, additional_text, pinned, include_invisible);
}

static gboolean
Expand Down Expand Up @@ -3817,7 +3818,7 @@ nemo_icon_container_search_iter (NemoIconContainer *container,
for (p = container->details->icons; p != NULL && count != n; p = p->next) {
icon = p->data;
nemo_icon_container_get_icon_text (container, icon->data, &name,
NULL, TRUE);
NULL, NULL, TRUE);

/* This can happen if a key event is handled really early while
* loading the icon container, before the items have all been
Expand Down
1 change: 1 addition & 0 deletions libnemo-private/nemo-icon-container.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ typedef struct {
NemoIconData *data,
char **editable_text,
char **additional_text,
gboolean *pinned,
gboolean include_invisible);
void (* update_icon) (NemoIconContainer *container,
NemoIcon *icon);
Expand Down
1 change: 1 addition & 0 deletions libnemo-private/nemo-icon-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ void nemo_icon_container_get_icon_text (NemoIconContainer *container,
NemoIconData *data,
char **editable_text,
char **additional_text,
gboolean *pinned,
gboolean include_invisible);

/* nemo-centered-placement-grid api
Expand Down
14 changes: 10 additions & 4 deletions src/nemo-icon-view-container.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,6 @@ nemo_icon_view_container_get_icon_images (NemoIconContainer *container,
emblem_icons = nemo_file_get_emblem_icons (file,
nemo_view_get_directory_as_file (NEMO_VIEW (icon_view)));

if (nemo_file_get_pinning (file)) {
emblem_icons = g_list_prepend (emblem_icons, g_themed_icon_new ("emblem-pinned"));
}

scale = gtk_widget_get_scale_factor (GTK_WIDGET (icon_view));
icon_info = nemo_file_get_icon (file, size, 0, scale, flags);

Expand Down Expand Up @@ -333,6 +329,7 @@ nemo_icon_view_container_get_icon_text (NemoIconContainer *container,
NemoIconData *data,
char **editable_text,
char **additional_text,
gboolean *pinned,
gboolean include_invisible)
{
GQuark *attributes;
Expand All @@ -355,9 +352,15 @@ nemo_icon_view_container_get_icon_text (NemoIconContainer *container,
if (nemo_icon_container_get_zoom_level (container) == NEMO_ZOOM_LEVEL_SMALLEST &&
!include_invisible) {
*editable_text = NULL;
if (pinned) {
*pinned = FALSE;
}
} else {
/* Strip the suffix for nemo object xml files. */
*editable_text = nemo_file_get_display_name (file);
if (pinned) {
*pinned = nemo_file_get_pinning (file);
}
}

if (!use_additional) {
Expand Down Expand Up @@ -1483,6 +1486,7 @@ nemo_icon_view_container_update_icon (NemoIconContainer *container,
GdkPixbuf *pixbuf;
char *editable_text, *additional_text;
gboolean has_open_window;
gboolean pinned;

if (icon == NULL) {
return;
Expand Down Expand Up @@ -1528,6 +1532,7 @@ nemo_icon_view_container_update_icon (NemoIconContainer *container,
icon->data,
&editable_text,
&additional_text,
&pinned,
FALSE);


Expand All @@ -1546,6 +1551,7 @@ nemo_icon_view_container_update_icon (NemoIconContainer *container,
"editable_text", editable_text,
"additional_text", additional_text,
"highlighted_for_drop", icon == details->drop_target,
"pinned", pinned,
NULL);

nemo_icon_canvas_item_set_image (icon->item, pixbuf);
Expand Down
2 changes: 2 additions & 0 deletions src/nemo-icon-view-grid-container.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ nemo_icon_view_grid_container_get_icon_text (NemoIconContainer *container,
NemoIconData *data,
char **editable_text,
char **additional_text,
gboolean *pinned,
gboolean include_invisible)
{
GQuark *attributes;
Expand Down Expand Up @@ -888,6 +889,7 @@ nemo_icon_view_grid_container_update_icon (NemoIconContainer *container,
icon->data,
&editable_text,
&additional_text,
NULL,
FALSE);

/* If name of icon being renamed was changed from elsewhere, end renaming mode.
Expand Down

0 comments on commit c3f9575

Please sign in to comment.