Skip to content

Commit b44aa36

Browse files
committed
More symbolic fixes, cleanup in pathbar.
1 parent 920654f commit b44aa36

6 files changed

Lines changed: 54 additions & 91 deletions

File tree

libnemo-private/nemo-file-utilities.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,6 +1467,19 @@ nemo_get_cached_x_content_types_for_mount (GMount *mount)
14671467
return NULL;
14681468
}
14691469

1470+
GIcon *nemo_get_mount_gicon (GMount *mount)
1471+
{
1472+
GIcon *icon;
1473+
1474+
g_return_val_if_fail (mount != NULL, NULL);
1475+
1476+
if (g_mount_can_eject (mount)) {
1477+
return g_themed_icon_new ("media-removable-symbolic");
1478+
}
1479+
1480+
return g_mount_get_symbolic_icon (mount);
1481+
}
1482+
14701483
#if !defined (NEMO_OMIT_SELF_CHECK)
14711484

14721485
void

libnemo-private/nemo-file-utilities.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,5 @@ void nemo_get_x_content_types_for_mount_async (GMount *mount,
106106
GCancellable *cancellable,
107107
gpointer user_data);
108108

109+
GIcon *nemo_get_mount_gicon (GMount *mount);
109110
#endif /* NEMO_FILE_UTILITIES_H */

libnemo-private/nemo-file.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4410,7 +4410,17 @@ nemo_file_get_control_icon (NemoFile *file)
44104410
if (file->details->symbolic_icon != NULL) {
44114411
gicon = g_object_ref (file->details->symbolic_icon);
44124412
} else {
4413-
gicon = get_symbolic_icon_for_file (file);
4413+
gchar *uri;
4414+
4415+
uri = nemo_file_get_uri (file);
4416+
4417+
if (eel_uri_is_search (uri)) {
4418+
gicon = g_themed_icon_new (NEMO_ICON_SYMBOLIC_FOLDER_SAVED_SEARCH);
4419+
} else {
4420+
gicon = get_symbolic_icon_for_file (file);
4421+
}
4422+
4423+
g_free (uri);
44144424
}
44154425

44164426
return gicon;

src/nemo-pathbar.c

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,7 @@ typedef struct {
8686
NemoFile *file;
8787
unsigned int file_changed_signal_id;
8888

89-
/* custom icon */
90-
GdkPixbuf *custom_icon;
91-
92-
char *xdg_icon;
93-
89+
GIcon *mount_icon;
9490
/* flag to indicate its the base folder in the URI */
9591
gboolean is_base_dir;
9692

@@ -128,7 +124,6 @@ struct _NemoPathBarDetails {
128124
GtkWidget *up_slider_button;
129125
GtkWidget *down_slider_button;
130126
guint settings_signal_id;
131-
gint icon_size;
132127
gint slider_width;
133128
gint16 spacing;
134129
gint16 button_offset;
@@ -155,11 +150,9 @@ static gboolean nemo_path_bar_slider_button_release (GtkWidget *widget,
155150
GdkEventButton *event,
156151
NemoPathBar *path_bar);
157152
static void nemo_path_bar_check_icon_theme (NemoPathBar *path_bar);
158-
static void nemo_path_bar_update_button_appearance (ButtonData *button_data,
159-
gint scale);
153+
static void nemo_path_bar_update_button_appearance (ButtonData *button_data);
160154
static void nemo_path_bar_update_button_state (ButtonData *button_data,
161-
gboolean current_dir,
162-
gint scale);
155+
gboolean current_dir);
163156
static gboolean nemo_path_bar_update_path (NemoPathBar *path_bar,
164157
GFile *file_path,
165158
gboolean emit_signal);
@@ -351,7 +344,6 @@ nemo_path_bar_init (NemoPathBar *path_bar)
351344

352345
path_bar->priv->up_slider_button = get_slider_button (path_bar, GTK_POS_LEFT);
353346
path_bar->priv->down_slider_button = get_slider_button (path_bar, GTK_POS_RIGHT);
354-
path_bar->priv->icon_size = NEMO_PATH_BAR_ICON_SIZE;
355347

356348
p = nemo_get_desktop_directory ();
357349
path_bar->priv->desktop_path = g_file_new_for_path (p);
@@ -1383,8 +1375,7 @@ reload_icons (NemoPathBar *path_bar)
13831375
ButtonData *button_data;
13841376
button_data = BUTTON_DATA (list->data);
13851377
if (button_data->type != NORMAL_BUTTON || button_data->is_base_dir) {
1386-
nemo_path_bar_update_button_appearance (button_data,
1387-
gtk_widget_get_scale_factor (GTK_WIDGET (path_bar)));
1378+
nemo_path_bar_update_button_appearance (button_data);
13881379
}
13891380
}
13901381
}
@@ -1458,12 +1449,9 @@ button_data_free (ButtonData *button_data)
14581449
{
14591450
g_object_unref (button_data->path);
14601451
g_free (button_data->dir_name);
1461-
if (button_data->custom_icon) {
1462-
g_object_unref (button_data->custom_icon);
1463-
}
1464-
if (button_data->type == XDG_BUTTON) {
1465-
g_free (button_data->xdg_icon);
1466-
}
1452+
1453+
g_clear_object (&button_data->mount_icon);
1454+
14671455
if (button_data->file != NULL) {
14681456
g_signal_handler_disconnect (button_data->file,
14691457
button_data->file_changed_signal_id);
@@ -1519,7 +1507,7 @@ set_label_padding_size (ButtonData *button_data)
15191507
}
15201508

15211509
static void
1522-
nemo_path_bar_update_button_appearance (ButtonData *button_data, gint scale)
1510+
nemo_path_bar_update_button_appearance (ButtonData *button_data)
15231511
{
15241512
GIcon *gicon;
15251513

@@ -1558,6 +1546,10 @@ nemo_path_bar_update_button_appearance (ButtonData *button_data, gint scale)
15581546
}
15591547
case DEFAULT_LOCATION_BUTTON:
15601548
case MOUNT_BUTTON:
1549+
if (button_data->mount_icon) {
1550+
gicon = button_data->mount_icon;
1551+
break;
1552+
}
15611553
default:
15621554
gicon = NULL;
15631555
}
@@ -1571,15 +1563,14 @@ nemo_path_bar_update_button_appearance (ButtonData *button_data, gint scale)
15711563

15721564
static void
15731565
nemo_path_bar_update_button_state (ButtonData *button_data,
1574-
gboolean current_dir,
1575-
gint scale)
1566+
gboolean current_dir)
15761567
{
15771568
if (button_data->label != NULL) {
15781569
gtk_label_set_label (GTK_LABEL (button_data->label), NULL);
15791570
gtk_label_set_use_markup (GTK_LABEL (button_data->label), current_dir);
15801571
}
15811572

1582-
nemo_path_bar_update_button_appearance (button_data, scale);
1573+
nemo_path_bar_update_button_appearance (button_data);
15831574

15841575
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button_data->button)) != current_dir) {
15851576
button_data->ignore_changes = TRUE;
@@ -1589,14 +1580,12 @@ nemo_path_bar_update_button_state (ButtonData *button_data,
15891580
}
15901581

15911582
static gboolean
1592-
setup_file_path_mounted_mount (GFile *location, ButtonData *button_data, gint scale)
1583+
setup_file_path_mounted_mount (GFile *location, ButtonData *button_data)
15931584
{
15941585
GVolumeMonitor *volume_monitor;
15951586
GList *mounts, *l;
15961587
GMount *mount;
15971588
gboolean result;
1598-
GIcon *icon;
1599-
NemoIconInfo *info;
16001589
GFile *root, *default_location;
16011590

16021591
result = FALSE;
@@ -1615,14 +1604,7 @@ setup_file_path_mounted_mount (GFile *location, ButtonData *button_data, gint sc
16151604
result = TRUE;
16161605
/* set mount specific details in button_data */
16171606
if (button_data) {
1618-
icon = g_mount_get_icon (mount);
1619-
if (icon == NULL) {
1620-
icon = g_themed_icon_new (NEMO_ICON_FOLDER);
1621-
}
1622-
info = nemo_icon_info_lookup (icon, NEMO_PATH_BAR_ICON_SIZE, scale);
1623-
g_object_unref (icon);
1624-
button_data->custom_icon = nemo_icon_info_get_pixbuf_at_size (info, NEMO_PATH_BAR_ICON_SIZE);
1625-
g_object_unref (info);
1607+
button_data->mount_icon = nemo_get_mount_gicon (mount);
16261608
button_data->dir_name = g_mount_get_name (mount);
16271609
button_data->type = MOUNT_BUTTON;
16281610
button_data->fake_root = TRUE;
@@ -1636,14 +1618,7 @@ setup_file_path_mounted_mount (GFile *location, ButtonData *button_data, gint sc
16361618
result = TRUE;
16371619
/* set mount specific details in button_data */
16381620
if (button_data) {
1639-
icon = g_mount_get_icon (mount);
1640-
if (icon == NULL) {
1641-
icon = g_themed_icon_new (NEMO_ICON_FOLDER);
1642-
}
1643-
info = nemo_icon_info_lookup (icon, NEMO_PATH_BAR_ICON_SIZE, scale);
1644-
g_object_unref (icon);
1645-
button_data->custom_icon = nemo_icon_info_get_pixbuf_at_size (info, NEMO_PATH_BAR_ICON_SIZE);
1646-
g_object_unref (info);
1621+
button_data->mount_icon = nemo_get_mount_gicon (mount);
16471622
button_data->type = DEFAULT_LOCATION_BUTTON;
16481623
button_data->fake_root = TRUE;
16491624
}
@@ -1676,27 +1651,19 @@ setup_button_type (ButtonData *button_data,
16761651
}
16771652
} else if (path_bar->priv->xdg_documents_path != NULL && g_file_equal (location, path_bar->priv->xdg_documents_path)) {
16781653
button_data->type = XDG_BUTTON;
1679-
button_data->xdg_icon = g_strdup (NEMO_ICON_SYMBOLIC_FOLDER_DOCUMENTS);
16801654
} else if (path_bar->priv->xdg_download_path != NULL && g_file_equal (location, path_bar->priv->xdg_download_path)) {
16811655
button_data->type = XDG_BUTTON;
1682-
button_data->xdg_icon = g_strdup (NEMO_ICON_SYMBOLIC_FOLDER_DOWNLOAD);
16831656
} else if (path_bar->priv->xdg_music_path != NULL && g_file_equal (location, path_bar->priv->xdg_music_path)) {
16841657
button_data->type = XDG_BUTTON;
1685-
button_data->xdg_icon = g_strdup (NEMO_ICON_SYMBOLIC_FOLDER_MUSIC);
16861658
} else if (path_bar->priv->xdg_pictures_path != NULL && g_file_equal (location, path_bar->priv->xdg_pictures_path)) {
16871659
button_data->type = XDG_BUTTON;
1688-
button_data->xdg_icon = g_strdup (NEMO_ICON_SYMBOLIC_FOLDER_PICTURES);
16891660
} else if (path_bar->priv->xdg_templates_path != NULL && g_file_equal (location, path_bar->priv->xdg_templates_path)) {
16901661
button_data->type = XDG_BUTTON;
1691-
button_data->xdg_icon = g_strdup (NEMO_ICON_SYMBOLIC_FOLDER_TEMPLATES);
16921662
} else if (path_bar->priv->xdg_videos_path != NULL && g_file_equal (location, path_bar->priv->xdg_videos_path)) {
16931663
button_data->type = XDG_BUTTON;
1694-
button_data->xdg_icon = g_strdup (NEMO_ICON_SYMBOLIC_FOLDER_VIDEOS);
16951664
} else if (path_bar->priv->xdg_public_path != NULL && g_file_equal (location, path_bar->priv->xdg_public_path)) {
16961665
button_data->type = XDG_BUTTON;
1697-
button_data->xdg_icon = g_strdup (NEMO_ICON_SYMBOLIC_FOLDER_PUBLIC_SHARE);
1698-
} else if (setup_file_path_mounted_mount (location, button_data,
1699-
gtk_widget_get_scale_factor (GTK_WIDGET (path_bar)))) {
1666+
} else if (setup_file_path_mounted_mount (location, button_data)) {
17001667
/* already setup */
17011668
} else {
17021669
button_data->type = NORMAL_BUTTON;
@@ -1860,8 +1827,7 @@ button_data_file_changed (NemoFile *file,
18601827

18611828
g_free (display_name);
18621829
}
1863-
nemo_path_bar_update_button_appearance (button_data,
1864-
gtk_widget_get_scale_factor (GTK_WIDGET (path_bar)));
1830+
nemo_path_bar_update_button_appearance (button_data);
18651831
}
18661832

18671833
static ButtonData *
@@ -1936,8 +1902,7 @@ make_directory_button (NemoPathBar *path_bar,
19361902
gtk_container_add (GTK_CONTAINER (button_data->button), child);
19371903
gtk_widget_show_all (button_data->button);
19381904

1939-
nemo_path_bar_update_button_state (button_data, current_dir,
1940-
gtk_widget_get_scale_factor (GTK_WIDGET (path_bar)));
1905+
nemo_path_bar_update_button_state (button_data, current_dir);
19411906

19421907
g_signal_connect (button_data->button, "clicked", G_CALLBACK (button_clicked_cb), button_data);
19431908
g_object_weak_ref (G_OBJECT (button_data->button), (GWeakNotify) button_data_free, button_data);
@@ -2001,8 +1966,7 @@ nemo_path_bar_check_parent_path (NemoPathBar *path_bar,
20011966

20021967
for (list = path_bar->priv->button_list; list; list = list->next) {
20031968
nemo_path_bar_update_button_state (BUTTON_DATA (list->data),
2004-
(list == current_path) ? TRUE : FALSE,
2005-
gtk_widget_get_scale_factor (GTK_WIDGET (path_bar)));
1969+
(list == current_path) ? TRUE : FALSE);
20061970
}
20071971

20081972
if (!gtk_widget_get_child_visible (BUTTON_DATA (current_path->data)->button)) {

src/nemo-places-sidebar.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -657,18 +657,6 @@ get_gicon (const gchar *uri)
657657
return nemo_file_get_control_icon (file);
658658
}
659659

660-
static GIcon *
661-
get_mount_gicon (GMount *mount)
662-
{
663-
GIcon *icon;
664-
665-
if (g_mount_can_eject (mount)) {
666-
return g_themed_icon_new ("media-removable-symbolic");
667-
}
668-
669-
return g_mount_get_symbolic_icon (mount);
670-
}
671-
672660
static void
673661
update_places (NemoPlacesSidebar *sidebar)
674662
{
@@ -906,7 +894,7 @@ update_places (NemoPlacesSidebar *sidebar)
906894
}
907895
}
908896

909-
icon = get_mount_gicon (mount);
897+
icon = nemo_get_mount_gicon (mount);
910898
mount_uri = g_file_get_uri (root);
911899
name = g_mount_get_name (mount);
912900
tooltip = g_file_get_parse_name (root);
@@ -947,7 +935,7 @@ update_places (NemoPlacesSidebar *sidebar)
947935
mount = g_volume_get_mount (volume);
948936
if (mount != NULL) {
949937
/* Show mounted volume in the sidebar */
950-
icon = get_mount_gicon (mount);
938+
icon = nemo_get_mount_gicon (mount);
951939
root = g_mount_get_default_location (mount);
952940
mount_uri = g_file_get_uri (root);
953941
name = g_mount_get_name (mount);
@@ -1047,7 +1035,7 @@ update_places (NemoPlacesSidebar *sidebar)
10471035

10481036
mount = g_volume_get_mount (volume);
10491037
if (mount != NULL) {
1050-
icon = get_mount_gicon (mount);
1038+
icon = nemo_get_mount_gicon (mount);
10511039
root = g_mount_get_default_location (mount);
10521040
mount_uri = g_file_get_uri (root);
10531041
full = get_disk_full (g_file_new_for_uri (mount_uri), &tooltip_info);
@@ -1117,7 +1105,7 @@ update_places (NemoPlacesSidebar *sidebar)
11171105
for (l = network_mounts; l != NULL; l = l->next) {
11181106
mount = l->data;
11191107
root = g_mount_get_default_location (mount);
1120-
icon = get_mount_gicon (mount);
1108+
icon = nemo_get_mount_gicon (mount);
11211109
mount_uri = g_file_get_uri (root);
11221110
name = g_mount_get_name (mount);
11231111
tooltip = g_file_get_parse_name (root);

src/nemo-view.c

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5149,19 +5149,6 @@ add_place_to_action (NemoView *view, const gchar *bookmark_name, GIcon *icon, gc
51495149
view);
51505150
}
51515151

5152-
// FIXME: duplicated in nemo-places-sidebar.c
5153-
static GIcon *
5154-
get_mount_gicon (GMount *mount)
5155-
{
5156-
GIcon *icon;
5157-
5158-
if (g_mount_can_eject (mount)) {
5159-
return g_themed_icon_new ("media-removable-symbolic");
5160-
}
5161-
5162-
return g_mount_get_symbolic_icon (mount);
5163-
}
5164-
51655152
static void
51665153
reset_move_copy_to_menu (NemoView *view)
51675154
{
@@ -5304,7 +5291,7 @@ reset_move_copy_to_menu (NemoView *view)
53045291
}
53055292
}
53065293

5307-
icon = get_mount_gicon (mount);
5294+
icon = nemo_get_mount_gicon (mount);
53085295
mount_uri = g_file_get_uri (root);
53095296
name = g_mount_get_name (mount);
53105297

@@ -5346,7 +5333,7 @@ reset_move_copy_to_menu (NemoView *view)
53465333
mount = g_volume_get_mount (volume);
53475334
if (mount != NULL) {
53485335
/* Show mounted volume in the sidebar */
5349-
icon = get_mount_gicon (mount);
5336+
icon = nemo_get_mount_gicon (mount);
53505337
root = g_mount_get_default_location (mount);
53515338
mount_uri = g_file_get_uri (root);
53525339
name = g_mount_get_name (mount);
@@ -5394,7 +5381,7 @@ reset_move_copy_to_menu (NemoView *view)
53945381

53955382
mount = g_volume_get_mount (volume);
53965383
if (mount != NULL) {
5397-
icon = get_mount_gicon (mount);
5384+
icon = nemo_get_mount_gicon (mount);
53985385
root = g_mount_get_default_location (mount);
53995386
mount_uri = g_file_get_uri (root);
54005387

@@ -5435,7 +5422,7 @@ reset_move_copy_to_menu (NemoView *view)
54355422
for (l = network_mounts; l != NULL; l = l->next) {
54365423
mount = l->data;
54375424
root = g_mount_get_default_location (mount);
5438-
icon = get_mount_gicon (mount);
5425+
icon = nemo_get_mount_gicon (mount);
54395426
mount_uri = g_file_get_uri (root);
54405427
name = g_mount_get_name (mount);
54415428

0 commit comments

Comments
 (0)