summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Soriano <csoriano@gnome.org>2015-07-05 19:54:57 +0200
committerCarlos Soriano <csoriano@gnome.org>2015-07-05 19:54:57 +0200
commit88438fb048944d8668b13e1f3888c9cd99eb06f4 (patch)
tree5735671a36467820283d5b1f2681516e82b1769c
parent19f74cb5677f29a87d26346535833382c0c48877 (diff)
downloadgtk+-origin/wip/csoriano/cloud-providers.tar.gz
gtkplacessidebar: implement cloud providers supportorigin/wip/csoriano/cloud-providers
Since now we have dbus cloud providers, we can use them on the gtkplacessidebar for nautilus and file chooser.
-rw-r--r--gtk/gtkplacessidebar.c191
-rw-r--r--gtk/gtkplacessidebarprivate.h1
-rw-r--r--gtk/gtksidebarrow.c88
-rw-r--r--gtk/ui/gtksidebarrow.ui22
4 files changed, 213 insertions, 89 deletions
diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c
index f8f87d6b3e..3ec44b458c 100644
--- a/gtk/gtkplacessidebar.c
+++ b/gtk/gtkplacessidebar.c
@@ -35,6 +35,8 @@
#include "gtkcelllayout.h"
#include "gtkcellrenderertext.h"
#include "gtkcellrendererpixbuf.h"
+#include "gtkcloudprovidermanager.h"
+#include "gtkcloudprovider.h"
#include "gtkfilesystem.h"
#include "gtkicontheme.h"
#include "gtkintl.h"
@@ -109,6 +111,7 @@ struct _GtkPlacesSidebar {
GtkWidget *new_bookmark_row;
GtkBookmarksManager *bookmarks_manager;
+ GtkCloudProviderManager *cloud_manager;
GVolumeMonitor *volume_monitor;
GtkTrashMonitor *trash_monitor;
GtkSettings *gtk_settings;
@@ -383,7 +386,8 @@ add_place (GtkPlacesSidebar *sidebar,
GtkPlacesSidebarPlaceType place_type,
GtkPlacesSidebarSectionType section_type,
const gchar *name,
- GIcon *icon,
+ GIcon *left_icon,
+ GIcon *right_icon,
const gchar *uri,
GDrive *drive,
GVolume *volume,
@@ -412,7 +416,8 @@ add_place (GtkPlacesSidebar *sidebar,
tooltip_escaped = g_markup_escape_text (tooltip, -1);
row = g_object_new (GTK_TYPE_SIDEBAR_ROW,
"sidebar", sidebar,
- "icon", icon,
+ "left-icon", left_icon,
+ "right-icon", right_icon,
"label", name,
"tooltip", tooltip_escaped,
"ejectable", show_eject_button,
@@ -549,7 +554,7 @@ add_special_dirs (GtkPlacesSidebar *sidebar)
{
const gchar *path;
GFile *root;
- GIcon *icon;
+ GIcon *left_icon;
gchar *name;
gchar *mount_uri;
gchar *tooltip;
@@ -574,18 +579,18 @@ add_special_dirs (GtkPlacesSidebar *sidebar)
if (!name)
name = g_file_get_basename (root);
- icon = special_directory_get_gicon (index);
+ left_icon = special_directory_get_gicon (index);
mount_uri = g_file_get_uri (root);
tooltip = g_file_get_parse_name (root);
add_place (sidebar, PLACES_XDG_DIR,
SECTION_COMPUTER,
- name, icon, mount_uri,
+ name, left_icon, NULL, mount_uri,
NULL, NULL, NULL, 0,
tooltip);
g_free (name);
g_object_unref (root);
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (mount_uri);
g_free (tooltip);
@@ -688,11 +693,11 @@ on_app_shortcuts_query_complete (GObject *source,
gchar *uri;
gchar *tooltip;
const gchar *name;
- GIcon *icon;
+ GIcon *left_icon;
int pos = 0;
name = g_file_info_get_display_name (info);
- icon = g_file_info_get_symbolic_icon (info);
+ left_icon = g_file_info_get_symbolic_icon (info);
uri = g_file_get_uri (file);
tooltip = g_file_get_parse_name (file);
@@ -705,7 +710,7 @@ on_app_shortcuts_query_complete (GObject *source,
add_place (sidebar, PLACES_BUILT_IN,
SECTION_COMPUTER,
- name, icon, uri,
+ name, left_icon, NULL, uri,
NULL, NULL, NULL,
pos,
tooltip);
@@ -761,7 +766,7 @@ on_bookmark_query_info_complete (GObject *source,
gchar *bookmark_name;
gchar *mount_uri;
gchar *tooltip;
- GIcon *icon;
+ GIcon *left_icon;
info = g_file_query_info_finish (root, result, &error);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
@@ -782,23 +787,23 @@ on_bookmark_query_info_complete (GObject *source,
}
if (info)
- icon = g_object_ref (g_file_info_get_symbolic_icon (info));
+ left_icon = g_object_ref (g_file_info_get_symbolic_icon (info));
else
- icon = g_themed_icon_new_with_default_fallbacks (clos->is_native ? ICON_NAME_FOLDER : ICON_NAME_FOLDER_NETWORK);
+ left_icon = g_themed_icon_new_with_default_fallbacks (clos->is_native ? ICON_NAME_FOLDER : ICON_NAME_FOLDER_NETWORK);
mount_uri = g_file_get_uri (root);
tooltip = g_file_get_parse_name (root);
add_place (sidebar, PLACES_BOOKMARK,
SECTION_BOOKMARKS,
- bookmark_name, icon, mount_uri,
+ bookmark_name, left_icon, NULL, mount_uri,
NULL, NULL, NULL, clos->index,
tooltip);
g_free (mount_uri);
g_free (tooltip);
g_free (bookmark_name);
- g_object_unref (icon);
+ g_object_unref (left_icon);
out:
g_clear_object (&info);
@@ -820,11 +825,15 @@ update_places (GtkPlacesSidebar *sidebar)
gchar *original_uri, *mount_uri, *name, *identifier;
GtkListBoxRow *selected;
gchar *home_uri;
- GIcon *icon;
+ GIcon *left_icon;
+ GIcon *right_icon;
GFile *root;
gchar *tooltip;
GList *network_mounts, *network_volumes;
GIcon *new_bookmark_icon;
+ GList *cloud_providers;
+ guint provider_status;
+ const gchar *provider_name;
GtkStyleContext *context;
/* save original selection */
@@ -852,24 +861,24 @@ update_places (GtkPlacesSidebar *sidebar)
if (should_show_recent (sidebar))
{
mount_uri = "recent:///";
- icon = g_themed_icon_new_with_default_fallbacks ("document-open-recent-symbolic");
+ left_icon = g_themed_icon_new_with_default_fallbacks ("document-open-recent-symbolic");
add_place (sidebar, PLACES_BUILT_IN,
SECTION_COMPUTER,
- _("Recent"), icon, mount_uri,
+ _("Recent"), left_icon, NULL, mount_uri,
NULL, NULL, NULL, 0,
_("Recent files"));
- g_object_unref (icon);
+ g_object_unref (left_icon);
}
/* home folder */
home_uri = get_home_directory_uri ();
- icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_HOME);
+ left_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_HOME);
add_place (sidebar, PLACES_BUILT_IN,
SECTION_COMPUTER,
- _("Home"), icon, home_uri,
+ _("Home"), left_icon, NULL, home_uri,
NULL, NULL, NULL, 0,
_("Open your personal folder"));
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (home_uri);
/* desktop */
@@ -878,13 +887,13 @@ update_places (GtkPlacesSidebar *sidebar)
mount_uri = get_desktop_directory_uri ();
if (mount_uri)
{
- icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_DESKTOP);
+ left_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_DESKTOP);
add_place (sidebar, PLACES_BUILT_IN,
SECTION_COMPUTER,
- _("Desktop"), icon, mount_uri,
+ _("Desktop"), left_icon, NULL, mount_uri,
NULL, NULL, NULL, 0,
_("Open the contents of your desktop in a folder"));
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (mount_uri);
}
}
@@ -894,31 +903,78 @@ update_places (GtkPlacesSidebar *sidebar)
if (sidebar->show_enter_location)
{
- icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_NETWORK_SERVER);
+ left_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_NETWORK_SERVER);
add_place (sidebar, PLACES_ENTER_LOCATION,
SECTION_COMPUTER,
- _("Enter Location"), icon, NULL,
+ _("Enter Location"), left_icon, NULL, NULL,
NULL, NULL, NULL, 0,
_("Manually enter a location"));
- g_object_unref (icon);
+ g_object_unref (left_icon);
}
/* Trash */
if (!sidebar->local_only)
{
mount_uri = "trash:///"; /* No need to strdup */
- icon = _gtk_trash_monitor_get_icon (sidebar->trash_monitor);
+ left_icon = _gtk_trash_monitor_get_icon (sidebar->trash_monitor);
add_place (sidebar, PLACES_BUILT_IN,
SECTION_COMPUTER,
- _("Trash"), icon, mount_uri,
+ _("Trash"), left_icon, NULL, mount_uri,
NULL, NULL, NULL, 0,
_("Open the trash"));
- g_object_unref (icon);
+ g_object_unref (left_icon);
}
/* Application-side shortcuts */
add_application_shortcuts (sidebar);
+ /* Cloud providers */
+ cloud_providers = gtk_cloud_provider_manager_get_providers (sidebar->cloud_manager);
+ g_print ("cloud providers length %d\n", g_list_length (cloud_providers));
+ for (l = cloud_providers; l != NULL; l = l->next)
+ {
+ left_icon = gtk_cloud_provider_get_icon (l->data);
+ name = gtk_cloud_provider_get_name (l->data);
+ provider_status = gtk_cloud_provider_get_status (l->data);
+ if (left_icon == NULL || name == NULL || provider_status == GTK_CLOUD_PROVIDER_STATUS_INVALID)
+ {
+ g_print ("Icon %p \n", left_icon);
+ //g_print ("Icon %s \n", G_OBJECT_TYPE_NAME (left_icon));
+ //g_clear_object (&left_icon);
+ continue;
+ }
+
+ switch (provider_status)
+ {
+ case GTK_CLOUD_PROVIDER_STATUS_IDLE:
+ right_icon = NULL;
+ break;
+
+ case GTK_CLOUD_PROVIDER_STATUS_SYNCING:
+ right_icon = g_themed_icon_new ("emblem-synchronizing-symbolic");
+ break;
+
+ case GTK_CLOUD_PROVIDER_STATUS_ERROR:
+ right_icon = g_themed_icon_new ("dialog-warning-symbolic");
+ break;
+
+ default:
+ continue;
+ }
+
+ tooltip = g_strdup_printf ("Open %s", name);
+
+ mount_uri = "recent:///";
+ add_place (sidebar, PLACES_BUILT_IN,
+ SECTION_CLOUD,
+ name, left_icon, right_icon, mount_uri,
+ NULL, NULL, NULL, 0,
+ tooltip);
+
+ if (right_icon)
+ g_object_unref (right_icon);
+ }
+
/* go through all connected drives */
drives = g_volume_monitor_get_connected_drives (sidebar->volume_monitor);
@@ -946,7 +1002,7 @@ update_places (GtkPlacesSidebar *sidebar)
if (mount != NULL)
{
/* Show mounted volume in the sidebar */
- icon = g_mount_get_symbolic_icon (mount);
+ left_icon = g_mount_get_symbolic_icon (mount);
root = g_mount_get_default_location (mount);
mount_uri = g_file_get_uri (root);
name = g_mount_get_name (mount);
@@ -954,11 +1010,11 @@ update_places (GtkPlacesSidebar *sidebar)
add_place (sidebar, PLACES_MOUNTED_VOLUME,
SECTION_DEVICES,
- name, icon, mount_uri,
+ name, left_icon, NULL, mount_uri,
drive, volume, mount, 0, tooltip);
g_object_unref (root);
g_object_unref (mount);
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (tooltip);
g_free (name);
g_free (mount_uri);
@@ -973,15 +1029,15 @@ update_places (GtkPlacesSidebar *sidebar)
* cue that the user should remember to yank out the media if
* he just unmounted it.
*/
- icon = g_volume_get_symbolic_icon (volume);
+ left_icon = g_volume_get_symbolic_icon (volume);
name = g_volume_get_name (volume);
tooltip = g_strdup_printf (_("Mount and open “%s”"), name);
add_place (sidebar, PLACES_MOUNTED_VOLUME,
SECTION_DEVICES,
- name, icon, NULL,
+ name, left_icon, NULL, NULL,
drive, volume, NULL, 0, tooltip);
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (name);
g_free (tooltip);
}
@@ -1001,15 +1057,15 @@ update_places (GtkPlacesSidebar *sidebar)
* work.. but it's also for human beings who like to turn off media detection
* in the OS to save battery juice.
*/
- icon = g_drive_get_symbolic_icon (drive);
+ left_icon = g_drive_get_symbolic_icon (drive);
name = g_drive_get_name (drive);
tooltip = g_strdup_printf (_("Mount and open “%s”"), name);
add_place (sidebar, PLACES_BUILT_IN,
SECTION_DEVICES,
- name, icon, NULL,
+ name, left_icon, NULL, NULL,
drive, NULL, NULL, 0, tooltip);
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (tooltip);
g_free (name);
}
@@ -1044,18 +1100,18 @@ update_places (GtkPlacesSidebar *sidebar)
mount = g_volume_get_mount (volume);
if (mount != NULL)
{
- icon = g_mount_get_symbolic_icon (mount);
+ left_icon = g_mount_get_symbolic_icon (mount);
root = g_mount_get_default_location (mount);
mount_uri = g_file_get_uri (root);
tooltip = g_file_get_parse_name (root);
name = g_mount_get_name (mount);
add_place (sidebar, PLACES_MOUNTED_VOLUME,
SECTION_DEVICES,
- name, icon, mount_uri,
+ name, left_icon, NULL, mount_uri,
NULL, volume, mount, 0, tooltip);
g_object_unref (mount);
g_object_unref (root);
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (name);
g_free (tooltip);
g_free (mount_uri);
@@ -1063,13 +1119,13 @@ update_places (GtkPlacesSidebar *sidebar)
else
{
/* see comment above in why we add an icon for an unmounted mountable volume */
- icon = g_volume_get_symbolic_icon (volume);
+ left_icon = g_volume_get_symbolic_icon (volume);
name = g_volume_get_name (volume);
add_place (sidebar, PLACES_MOUNTED_VOLUME,
SECTION_DEVICES,
- name, icon, NULL,
+ name, left_icon, NULL, NULL,
NULL, volume, NULL, 0, name);
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (name);
}
g_object_unref (volume);
@@ -1078,13 +1134,13 @@ update_places (GtkPlacesSidebar *sidebar)
/* file system root */
mount_uri = "file:///"; /* No need to strdup */
- icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_FILESYSTEM);
+ left_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_FILESYSTEM);
add_place (sidebar, PLACES_BUILT_IN,
SECTION_DEVICES,
- sidebar->hostname, icon, mount_uri,
+ sidebar->hostname, left_icon, NULL, mount_uri,
NULL, NULL, NULL, 0,
_("Open the contents of the file system"));
- g_object_unref (icon);
+ g_object_unref (left_icon);
/* add mounts that has no volume (/etc/mtab mounts, ftp, sftp,...) */
mounts = g_volume_monitor_get_mounts (sidebar->volume_monitor);
@@ -1113,17 +1169,17 @@ update_places (GtkPlacesSidebar *sidebar)
continue;
}
- icon = g_mount_get_symbolic_icon (mount);
+ left_icon = g_mount_get_symbolic_icon (mount);
mount_uri = g_file_get_uri (root);
name = g_mount_get_name (mount);
tooltip = g_file_get_parse_name (root);
add_place (sidebar, PLACES_MOUNTED_VOLUME,
SECTION_COMPUTER,
- name, icon, mount_uri,
+ name, left_icon, NULL, mount_uri,
NULL, NULL, mount, 0, tooltip);
g_object_unref (root);
g_object_unref (mount);
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (name);
g_free (mount_uri);
g_free (tooltip);
@@ -1167,7 +1223,7 @@ update_places (GtkPlacesSidebar *sidebar)
new_bookmark_icon = g_themed_icon_new ("bookmark-new-symbolic");
sidebar->new_bookmark_row = add_place (sidebar, PLACES_DROP_FEEDBACK,
SECTION_BOOKMARKS,
- _("New bookmark"), new_bookmark_icon, NULL,
+ _("New bookmark"), new_bookmark_icon, NULL, NULL,
NULL, NULL, NULL, 0,
_("Add a new bookmark"));
context = gtk_widget_get_style_context (sidebar->new_bookmark_row);
@@ -1178,23 +1234,23 @@ update_places (GtkPlacesSidebar *sidebar)
if (!sidebar->local_only)
{
mount_uri = "network:///";
- icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_NETWORK);
+ left_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_NETWORK);
add_place (sidebar, PLACES_BUILT_IN,
SECTION_NETWORK,
- _("Browse Network"), icon, mount_uri,
+ _("Browse Network"), left_icon, NULL, mount_uri,
NULL, NULL, NULL, 0,
_("Browse the contents of the network"));
- g_object_unref (icon);
+ g_object_unref (left_icon);
if (sidebar->show_connect_to_server)
{
- icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_NETWORK_SERVER);
+ left_icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_NETWORK_SERVER);
add_place (sidebar, PLACES_CONNECT_TO_SERVER,
SECTION_NETWORK,
- _("Connect to Server"), icon, NULL,
+ _("Connect to Server"), left_icon, NULL, NULL,
NULL, NULL, NULL, 0,
_("Connect to a network server address"));
- g_object_unref (icon);
+ g_object_unref (left_icon);
}
network_volumes = g_list_reverse (network_volumes);
@@ -1210,15 +1266,15 @@ update_places (GtkPlacesSidebar *sidebar)
}
else
{
- icon = g_volume_get_symbolic_icon (volume);
+ left_icon = g_volume_get_symbolic_icon (volume);
name = g_volume_get_name (volume);
tooltip = g_strdup_printf (_("Mount and open “%s”"), name);
add_place (sidebar, PLACES_MOUNTED_VOLUME,
SECTION_NETWORK,
- name, icon, NULL,
+ name, left_icon, NULL, NULL,
NULL, volume, NULL, 0, tooltip);
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (name);
g_free (tooltip);
}
@@ -1229,16 +1285,16 @@ update_places (GtkPlacesSidebar *sidebar)
{
mount = l->data;
root = g_mount_get_default_location (mount);
- icon = g_mount_get_symbolic_icon (mount);
+ left_icon = g_mount_get_symbolic_icon (mount);
mount_uri = g_file_get_uri (root);
name = g_mount_get_name (mount);
tooltip = g_file_get_parse_name (root);
add_place (sidebar, PLACES_MOUNTED_VOLUME,
SECTION_NETWORK,
- name, icon, mount_uri,
+ name, left_icon, NULL, mount_uri,
NULL, NULL, mount, 0, tooltip);
g_object_unref (root);
- g_object_unref (icon);
+ g_object_unref (left_icon);
g_free (name);
g_free (mount_uri);
g_free (tooltip);
@@ -3700,6 +3756,13 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar)
g_object_get (sidebar->gtk_settings, "gtk-shell-shows-desktop", &show_desktop, NULL);
sidebar->show_desktop = show_desktop;
+ /* Cloud providers */
+ sidebar->cloud_manager = gtk_cloud_provider_manager_dup_singleton ();
+ g_signal_connect_swapped (sidebar->cloud_manager,
+ "changed",
+ G_CALLBACK (update_places),
+ sidebar);
+ gtk_cloud_provider_manager_update (sidebar->cloud_manager);
/* populate the sidebar */
update_places (sidebar);
}
diff --git a/gtk/gtkplacessidebarprivate.h b/gtk/gtkplacessidebarprivate.h
index dd5f34b571..03550d4195 100644
--- a/gtk/gtkplacessidebarprivate.h
+++ b/gtk/gtkplacessidebarprivate.h
@@ -29,6 +29,7 @@ G_BEGIN_DECLS
typedef enum {
SECTION_INVALID,
SECTION_COMPUTER,
+ SECTION_CLOUD,
SECTION_DEVICES,
SECTION_NETWORK,
SECTION_BOOKMARKS,
diff --git a/gtk/gtksidebarrow.c b/gtk/gtksidebarrow.c
index e56180c538..02885165b7 100644
--- a/gtk/gtksidebarrow.c
+++ b/gtk/gtksidebarrow.c
@@ -30,8 +30,10 @@
struct _GtkSidebarRow
{
GtkListBoxRow parent_instance;
- GIcon *icon;
- GtkWidget *icon_widget;
+ GIcon *left_icon;
+ GIcon *right_icon;
+ GtkWidget *left_icon_widget;
+ GtkWidget *right_icon_widget;
gchar *label;
gchar *tooltip;
GtkWidget *label_widget;
@@ -56,7 +58,8 @@ G_DEFINE_TYPE (GtkSidebarRow, gtk_sidebar_row, GTK_TYPE_LIST_BOX_ROW)
enum
{
PROP_0,
- PROP_ICON,
+ PROP_LEFT_ICON,
+ PROP_RIGHT_ICON,
PROP_LABEL,
PROP_TOOLTIP,
PROP_EJECTABLE,
@@ -93,9 +96,15 @@ gtk_sidebar_row_get_property (GObject *object,
break;
}
- case PROP_ICON:
+ case PROP_LEFT_ICON:
{
- g_value_set_object (value, self->icon);
+ g_value_set_object (value, self->left_icon);
+ break;
+ }
+
+ case PROP_RIGHT_ICON:
+ {
+ g_value_set_object (value, self->right_icon);
break;
}
@@ -204,18 +213,40 @@ gtk_sidebar_row_set_property (GObject *object,
break;
}
- case PROP_ICON:
+ case PROP_LEFT_ICON:
+ {
+ g_clear_object (&self->left_icon);
+ object = g_value_get_object (value);
+ if (object != NULL)
+ {
+ self->left_icon = g_object_ref (object);
+ gtk_image_set_from_gicon (GTK_IMAGE (self->left_icon_widget),
+ self->left_icon,
+ GTK_ICON_SIZE_MENU);
+ }
+ else
+ {
+ gtk_image_clear (GTK_IMAGE (self->left_icon_widget));
+ }
+ break;
+ }
+
+ case PROP_RIGHT_ICON:
{
- g_clear_object (&self->icon);
- if (value != NULL)
+ g_clear_object (&self->right_icon);
+ object = g_value_get_object (value);
+ if (object != NULL)
{
- self->icon = g_object_ref (g_value_get_object (value));
- gtk_image_set_from_gicon (GTK_IMAGE (self->icon_widget), self->icon, GTK_ICON_SIZE_MENU);
+ self->right_icon = g_object_ref (object);
+ gtk_image_set_from_gicon (GTK_IMAGE (self->right_icon_widget),
+ self->right_icon,
+ GTK_ICON_SIZE_MENU);
+ gtk_widget_show (self->right_icon_widget);
}
else
{
- self->icon = NULL;
- gtk_image_clear (GTK_IMAGE (self->icon_widget));
+ gtk_image_clear (GTK_IMAGE (self->right_icon_widget));
+ gtk_widget_hide (self->right_icon_widget);
}
break;
}
@@ -333,7 +364,8 @@ gtk_sidebar_row_set_property (GObject *object,
self->placeholder = g_value_get_boolean (value);
if (self->placeholder)
{
- g_clear_object (&self->icon);
+ g_clear_object (&self->left_icon);
+ g_clear_object (&self->right_icon);
g_free (self->label);
self->label = NULL;
g_free (self->tooltip);
@@ -403,7 +435,8 @@ gtk_sidebar_row_finalize (GObject *object)
{
GtkSidebarRow *self = GTK_SIDEBAR_ROW (object);
- g_clear_object (&self->icon);
+ g_clear_object (&self->left_icon);
+ g_clear_object (&self->right_icon);
g_free (self->label);
self->label = NULL;
g_free (self->tooltip);
@@ -441,15 +474,24 @@ gtk_sidebar_row_class_init (GtkSidebarRowClass *klass)
G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_SIDEBAR,
gParamSpecs [PROP_SIDEBAR]);
- gParamSpecs [PROP_ICON] =
- g_param_spec_object ("icon",
- "icon",
- "The place icon.",
+ gParamSpecs [PROP_LEFT_ICON] =
+ g_param_spec_object ("left-icon",
+ "left-icon",
+ "The left icon.",
+ G_TYPE_ICON,
+ (G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class, PROP_LEFT_ICON,
+ gParamSpecs [PROP_LEFT_ICON]);
+ gParamSpecs [PROP_RIGHT_ICON] =
+ g_param_spec_object ("right-icon",
+ "right-icon",
+ "The right icon.",
G_TYPE_ICON,
(G_PARAM_READWRITE |
G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (object_class, PROP_ICON,
- gParamSpecs [PROP_ICON]);
+ g_object_class_install_property (object_class, PROP_RIGHT_ICON,
+ gParamSpecs [PROP_RIGHT_ICON]);
gParamSpecs [PROP_LABEL] =
g_param_spec_string ("label",
@@ -599,7 +641,8 @@ gtk_sidebar_row_class_init (GtkSidebarRowClass *klass)
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gtk/libgtk/ui/gtksidebarrow.ui");
- gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, icon_widget);
+ gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, left_icon_widget);
+ gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, right_icon_widget);
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, label_widget);
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, eject_button);
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, event_box);
@@ -614,7 +657,8 @@ gtk_sidebar_row_clone (GtkSidebarRow *self)
{
return g_object_new (GTK_TYPE_SIDEBAR_ROW,
"sidebar", self->sidebar,
- "icon", self->icon,
+ "left-icon", self->left_icon,
+ "right-icon", self->right_icon,
"label", self->label,
"tooltip", self->tooltip,
"ejectable", self->ejectable,
diff --git a/gtk/ui/gtksidebarrow.ui b/gtk/ui/gtksidebarrow.ui
index 291e4f082e..23da47163b 100644
--- a/gtk/ui/gtksidebarrow.ui
+++ b/gtk/ui/gtksidebarrow.ui
@@ -19,7 +19,7 @@
<object class="GtkGrid">
<property name="visible">True</property>
<child>
- <object class="GtkImage" id="icon_widget">
+ <object class="GtkImage" id="left_icon_widget">
<property name="visible">True</property>
<style>
<class name="sidebar-icon"/>
@@ -43,6 +43,21 @@
</packing>
</child>
<child>
+ <object class="GtkImage" id="right_icon_widget">
+ <property name="visible">False</property>
+ <property name="hexpand">True</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ <style>
+ <class name="sidebar-icon"/>
+ </style>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkButton" id="eject_button">
<property name="visible">True</property>
<property name="hexpand">True</property>
@@ -63,7 +78,7 @@
</style>
</object>
<packing>
- <property name="left_attach">2</property>
+ <property name="left_attach">3</property>
<property name="top_attach">0</property>
</packing>
</child>
@@ -80,7 +95,8 @@
<widgets>
<widget name="eject_button"/>
<widget name="label_widget"/>
- <widget name="icon_widget"/>
+ <widget name="left_icon_widget"/>
+ <widget name="right_icon_widget"/>
</widgets>
</object>
</interface>