2015-05-06 21:07:17 +00:00
|
|
|
/* gtksidebarrow.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 Carlos Soriano <csoriano@gnome.org>
|
|
|
|
*
|
|
|
|
* This file is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as
|
2015-11-19 12:43:24 +00:00
|
|
|
* published by the Free Software Foundation; either version 2.1 of the
|
2015-05-06 21:07:17 +00:00
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This file is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
2015-11-19 12:43:24 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
2015-05-06 21:07:17 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "gtksidebarrowprivate.h"
|
|
|
|
/* For section and place type enums */
|
|
|
|
#include "gtkplacessidebarprivate.h"
|
|
|
|
#include "gtkplacessidebar.h"
|
|
|
|
#include "gtkwidget.h"
|
|
|
|
#include "gtkimage.h"
|
|
|
|
#include "gtklabel.h"
|
|
|
|
#include "gtkstylecontext.h"
|
|
|
|
#include "gtkrevealer.h"
|
|
|
|
#include "gtkselection.h"
|
2017-08-10 20:30:36 +00:00
|
|
|
#ifdef HAVE_CLOUDPROVIDERS
|
|
|
|
#include <cloudproviders/cloudproviderproxy.h>
|
|
|
|
#endif
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
struct _GtkSidebarRow
|
|
|
|
{
|
|
|
|
GtkListBoxRow parent_instance;
|
2017-08-10 20:30:36 +00:00
|
|
|
GIcon *start_icon;
|
|
|
|
GIcon *end_icon;
|
|
|
|
GtkWidget *start_icon_widget;
|
|
|
|
GtkWidget *end_icon_widget;
|
2015-05-06 21:07:17 +00:00
|
|
|
gchar *label;
|
|
|
|
gchar *tooltip;
|
|
|
|
GtkWidget *label_widget;
|
|
|
|
gboolean ejectable;
|
|
|
|
GtkWidget *eject_button;
|
|
|
|
gint order_index;
|
|
|
|
GtkPlacesSidebarSectionType section_type;
|
|
|
|
GtkPlacesSidebarPlaceType place_type;
|
|
|
|
gchar *uri;
|
|
|
|
GDrive *drive;
|
|
|
|
GVolume *volume;
|
|
|
|
GMount *mount;
|
2017-08-10 20:30:36 +00:00
|
|
|
GObject *cloud_provider;
|
2015-05-06 21:07:17 +00:00
|
|
|
gboolean placeholder;
|
|
|
|
GtkPlacesSidebar *sidebar;
|
|
|
|
GtkWidget *event_box;
|
|
|
|
GtkWidget *revealer;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GtkSidebarRow, gtk_sidebar_row, GTK_TYPE_LIST_BOX_ROW)
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2017-08-10 20:30:36 +00:00
|
|
|
PROP_START_ICON,
|
|
|
|
PROP_END_ICON,
|
2015-05-06 21:07:17 +00:00
|
|
|
PROP_LABEL,
|
|
|
|
PROP_TOOLTIP,
|
|
|
|
PROP_EJECTABLE,
|
|
|
|
PROP_SIDEBAR,
|
|
|
|
PROP_ORDER_INDEX,
|
|
|
|
PROP_SECTION_TYPE,
|
|
|
|
PROP_PLACE_TYPE,
|
|
|
|
PROP_URI,
|
|
|
|
PROP_DRIVE,
|
|
|
|
PROP_VOLUME,
|
|
|
|
PROP_MOUNT,
|
2017-08-10 20:30:36 +00:00
|
|
|
PROP_CLOUD_PROVIDER,
|
2015-05-06 21:07:17 +00:00
|
|
|
PROP_PLACEHOLDER,
|
|
|
|
LAST_PROP
|
|
|
|
};
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
static GParamSpec *properties [LAST_PROP];
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_sidebar_row_get_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkSidebarRow *self = GTK_SIDEBAR_ROW (object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_SIDEBAR:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_object (value, self->sidebar);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
case PROP_START_ICON:
|
|
|
|
g_value_set_object (value, self->start_icon);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_END_ICON:
|
|
|
|
g_value_set_object (value, self->end_icon);
|
2015-06-23 20:28:18 +00:00
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_LABEL:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_string (value, self->label);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_TOOLTIP:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_string (value, self->tooltip);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_EJECTABLE:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_boolean (value, self->ejectable);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_ORDER_INDEX:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_int (value, self->order_index);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_SECTION_TYPE:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_int (value, self->section_type);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_PLACE_TYPE:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_int (value, self->place_type);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_URI:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_string (value, self->uri);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_DRIVE:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_object (value, self->drive);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_VOLUME:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_object (value, self->volume);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_MOUNT:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_object (value, self->mount);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
case PROP_CLOUD_PROVIDER:
|
|
|
|
g_value_set_object (value, self->cloud_provider);
|
|
|
|
break;
|
|
|
|
|
2015-05-06 21:07:17 +00:00
|
|
|
case PROP_PLACEHOLDER:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_value_set_boolean (value, self->placeholder);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_sidebar_row_set_property (GObject *object,
|
|
|
|
guint prop_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkSidebarRow *self = GTK_SIDEBAR_ROW (object);
|
2015-06-23 20:28:18 +00:00
|
|
|
GtkStyleContext *context;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
|
|
|
case PROP_SIDEBAR:
|
2015-06-23 20:28:18 +00:00
|
|
|
self->sidebar = g_value_get_object (value);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
case PROP_START_ICON:
|
|
|
|
{
|
|
|
|
g_clear_object (&self->start_icon);
|
|
|
|
object = g_value_get_object (value);
|
|
|
|
if (object != NULL)
|
|
|
|
{
|
|
|
|
self->start_icon = g_object_ref (object);
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (self->start_icon_widget),
|
|
|
|
self->start_icon,
|
|
|
|
GTK_ICON_SIZE_MENU);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_image_clear (GTK_IMAGE (self->start_icon_widget));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case PROP_END_ICON:
|
|
|
|
{
|
|
|
|
g_clear_object (&self->end_icon);
|
|
|
|
object = g_value_get_object (value);
|
|
|
|
if (object != NULL)
|
|
|
|
{
|
|
|
|
self->end_icon = g_object_ref (object);
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (self->end_icon_widget),
|
|
|
|
self->end_icon,
|
|
|
|
GTK_ICON_SIZE_MENU);
|
|
|
|
gtk_widget_show (self->end_icon_widget);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gtk_image_clear (GTK_IMAGE (self->end_icon_widget));
|
|
|
|
gtk_widget_hide (self->end_icon_widget);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_LABEL:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_free (self->label);
|
|
|
|
self->label = g_strdup (g_value_get_string (value));
|
|
|
|
gtk_label_set_text (GTK_LABEL (self->label_widget), self->label);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_TOOLTIP:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_free (self->tooltip);
|
|
|
|
self->tooltip = g_strdup (g_value_get_string (value));
|
|
|
|
gtk_widget_set_tooltip_text (GTK_WIDGET (self), self->tooltip);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_EJECTABLE:
|
2015-06-23 20:28:18 +00:00
|
|
|
self->ejectable = g_value_get_boolean (value);
|
|
|
|
if (self->ejectable)
|
|
|
|
gtk_widget_show (self->eject_button);
|
|
|
|
else
|
|
|
|
gtk_widget_hide (self->eject_button);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_ORDER_INDEX:
|
2015-06-23 20:28:18 +00:00
|
|
|
self->order_index = g_value_get_int (value);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_SECTION_TYPE:
|
2015-06-23 20:28:18 +00:00
|
|
|
self->section_type = g_value_get_int (value);
|
2016-02-28 04:03:55 +00:00
|
|
|
if (self->section_type == SECTION_COMPUTER ||
|
|
|
|
self->section_type == SECTION_OTHER_LOCATIONS)
|
2015-06-23 20:28:18 +00:00
|
|
|
gtk_label_set_ellipsize (GTK_LABEL (self->label_widget), PANGO_ELLIPSIZE_NONE);
|
2016-02-28 04:03:55 +00:00
|
|
|
else
|
|
|
|
gtk_label_set_ellipsize (GTK_LABEL (self->label_widget), PANGO_ELLIPSIZE_END);
|
2015-06-23 20:28:18 +00:00
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_PLACE_TYPE:
|
2015-06-23 20:28:18 +00:00
|
|
|
self->place_type = g_value_get_int (value);
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_URI:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_free (self->uri);
|
|
|
|
self->uri = g_strdup (g_value_get_string (value));
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_DRIVE:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_set_object (&self->drive, g_value_get_object (value));
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_VOLUME:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_set_object (&self->volume, g_value_get_object (value));
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
case PROP_MOUNT:
|
2015-06-23 20:28:18 +00:00
|
|
|
g_set_object (&self->mount, g_value_get_object (value));
|
|
|
|
break;
|
2015-05-06 21:07:17 +00:00
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
case PROP_CLOUD_PROVIDER:
|
|
|
|
{
|
|
|
|
#ifdef HAVE_CLOUDPROVIDERS
|
|
|
|
gpointer *object;
|
|
|
|
object = g_value_get_object (value);
|
|
|
|
if (IS_CLOUD_PROVIDER_PROXY(object))
|
|
|
|
self->cloud_provider = g_object_ref (object);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-05-06 21:07:17 +00:00
|
|
|
case PROP_PLACEHOLDER:
|
2017-08-10 20:30:36 +00:00
|
|
|
{
|
|
|
|
self->placeholder = g_value_get_boolean (value);
|
|
|
|
if (self->placeholder)
|
|
|
|
{
|
|
|
|
g_clear_object (&self->start_icon);
|
|
|
|
g_clear_object (&self->end_icon);
|
|
|
|
g_free (self->label);
|
|
|
|
self->label = NULL;
|
|
|
|
g_free (self->tooltip);
|
|
|
|
self->tooltip = NULL;
|
|
|
|
gtk_widget_set_tooltip_text (GTK_WIDGET (self), NULL);
|
|
|
|
self->ejectable = FALSE;
|
|
|
|
self->section_type = SECTION_BOOKMARKS;
|
|
|
|
self->place_type = PLACES_BOOKMARK_PLACEHOLDER;
|
|
|
|
g_free (self->uri);
|
|
|
|
self->uri = NULL;
|
|
|
|
g_clear_object (&self->drive);
|
|
|
|
g_clear_object (&self->volume);
|
|
|
|
g_clear_object (&self->mount);
|
|
|
|
|
|
|
|
gtk_container_foreach (GTK_CONTAINER (self),
|
|
|
|
(GtkCallback) gtk_widget_destroy,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
context = gtk_widget_get_style_context (GTK_WIDGET (self));
|
|
|
|
gtk_style_context_add_class (context, "sidebar-placeholder-row");
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_child_revealed (GObject *self,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
/* We need to hide the actual widget because if not the GtkListBoxRow will
|
|
|
|
* still allocate the paddings, even if the revealer is not revealed, and
|
|
|
|
* therefore the row will be still somewhat visible. */
|
|
|
|
if (!gtk_revealer_get_reveal_child (GTK_REVEALER (self)))
|
|
|
|
gtk_widget_hide (GTK_WIDGET (GTK_SIDEBAR_ROW (user_data)));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_sidebar_row_reveal (GtkSidebarRow *self)
|
|
|
|
{
|
|
|
|
gtk_widget_show_all (GTK_WIDGET (self));
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_sidebar_row_hide (GtkSidebarRow *self,
|
|
|
|
gboolean inmediate)
|
|
|
|
{
|
|
|
|
guint transition_duration;
|
|
|
|
|
|
|
|
transition_duration = gtk_revealer_get_transition_duration (GTK_REVEALER (self->revealer));
|
|
|
|
if (inmediate)
|
|
|
|
gtk_revealer_set_transition_duration (GTK_REVEALER (self->revealer), 0);
|
|
|
|
|
|
|
|
gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), FALSE);
|
|
|
|
|
|
|
|
gtk_revealer_set_transition_duration (GTK_REVEALER (self->revealer), transition_duration);
|
|
|
|
}
|
|
|
|
|
2016-02-25 13:25:40 +00:00
|
|
|
void
|
2017-08-10 20:30:36 +00:00
|
|
|
gtk_sidebar_row_set_start_icon (GtkSidebarRow *self,
|
|
|
|
GIcon *icon)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_SIDEBAR_ROW (self));
|
|
|
|
|
|
|
|
if (self->start_icon != icon)
|
|
|
|
{
|
|
|
|
g_set_object (&self->start_icon, icon);
|
|
|
|
if (self->start_icon != NULL)
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (self->start_icon_widget), self->start_icon,
|
|
|
|
GTK_ICON_SIZE_MENU);
|
|
|
|
else
|
|
|
|
gtk_image_clear (GTK_IMAGE (self->start_icon_widget));
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_START_ICON]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_sidebar_row_set_end_icon (GtkSidebarRow *self,
|
|
|
|
GIcon *icon)
|
2016-02-25 13:25:40 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_SIDEBAR_ROW (self));
|
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
if (self->end_icon != icon)
|
2016-02-25 13:25:40 +00:00
|
|
|
{
|
2017-08-10 20:30:36 +00:00
|
|
|
g_set_object (&self->end_icon, icon);
|
|
|
|
if (self->end_icon != NULL)
|
|
|
|
gtk_image_set_from_gicon (GTK_IMAGE (self->end_icon_widget), self->end_icon,
|
2016-02-25 13:25:40 +00:00
|
|
|
GTK_ICON_SIZE_MENU);
|
|
|
|
else
|
2017-08-10 20:30:36 +00:00
|
|
|
if (self->end_icon_widget != NULL)
|
|
|
|
gtk_image_clear (GTK_IMAGE (self->end_icon_widget));
|
2016-02-25 13:25:40 +00:00
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_END_ICON]);
|
2016-02-25 13:25:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-06 21:07:17 +00:00
|
|
|
static void
|
|
|
|
gtk_sidebar_row_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GtkSidebarRow *self = GTK_SIDEBAR_ROW (object);
|
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
g_clear_object (&self->start_icon);
|
|
|
|
g_clear_object (&self->end_icon);
|
2015-05-06 21:07:17 +00:00
|
|
|
g_free (self->label);
|
|
|
|
self->label = NULL;
|
|
|
|
g_free (self->tooltip);
|
|
|
|
self->tooltip = NULL;
|
|
|
|
g_free (self->uri);
|
|
|
|
self->uri = NULL;
|
|
|
|
g_clear_object (&self->drive);
|
|
|
|
g_clear_object (&self->volume);
|
|
|
|
g_clear_object (&self->mount);
|
2015-07-21 23:51:50 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_sidebar_row_parent_class)->finalize (object);
|
2015-05-06 21:07:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_sidebar_row_init (GtkSidebarRow *self)
|
|
|
|
{
|
|
|
|
gtk_widget_init_template (GTK_WIDGET (self));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_sidebar_row_class_init (GtkSidebarRowClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->get_property = gtk_sidebar_row_get_property;
|
|
|
|
object_class->set_property = gtk_sidebar_row_set_property;
|
|
|
|
object_class->finalize = gtk_sidebar_row_finalize;
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_SIDEBAR] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_object ("sidebar",
|
|
|
|
"Sidebar",
|
|
|
|
"Sidebar",
|
|
|
|
GTK_TYPE_PLACES_SIDEBAR,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2015-06-23 20:28:18 +00:00
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
properties [PROP_START_ICON] =
|
|
|
|
g_param_spec_object ("start-icon",
|
|
|
|
"start-icon",
|
|
|
|
"The start icon.",
|
|
|
|
G_TYPE_ICON,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
properties [PROP_END_ICON] =
|
|
|
|
g_param_spec_object ("end-icon",
|
|
|
|
"end-icon",
|
|
|
|
"The end icon.",
|
2015-05-06 21:07:17 +00:00
|
|
|
G_TYPE_ICON,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_LABEL] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_string ("label",
|
|
|
|
"label",
|
|
|
|
"The label text.",
|
|
|
|
NULL,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_TOOLTIP] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_string ("tooltip",
|
|
|
|
"Tooltip",
|
|
|
|
"Tooltip",
|
|
|
|
NULL,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_EJECTABLE] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_boolean ("ejectable",
|
|
|
|
"Ejectable",
|
|
|
|
"Ejectable",
|
|
|
|
FALSE,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_ORDER_INDEX] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_int ("order-index",
|
|
|
|
"OrderIndex",
|
|
|
|
"Order Index",
|
|
|
|
0, G_MAXINT, 0,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_SECTION_TYPE] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_int ("section-type",
|
|
|
|
"section type",
|
|
|
|
"The section type.",
|
|
|
|
SECTION_INVALID, N_SECTIONS, SECTION_INVALID,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_PLACE_TYPE] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_int ("place-type",
|
|
|
|
"place type",
|
|
|
|
"The place type.",
|
|
|
|
PLACES_INVALID, N_PLACES, PLACES_INVALID,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_URI] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_string ("uri",
|
|
|
|
"Uri",
|
|
|
|
"Uri",
|
|
|
|
NULL,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2015-06-23 20:28:18 +00:00
|
|
|
|
|
|
|
properties [PROP_DRIVE] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_object ("drive",
|
|
|
|
"Drive",
|
|
|
|
"Drive",
|
|
|
|
G_TYPE_DRIVE,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_VOLUME] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_object ("volume",
|
|
|
|
"Volume",
|
|
|
|
"Volume",
|
|
|
|
G_TYPE_VOLUME,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_MOUNT] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_object ("mount",
|
|
|
|
"Mount",
|
|
|
|
"Mount",
|
|
|
|
G_TYPE_MOUNT,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2015-06-23 20:28:18 +00:00
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
properties [PROP_CLOUD_PROVIDER] =
|
|
|
|
g_param_spec_object ("cloud-provider",
|
|
|
|
"CloudProviderProxy",
|
|
|
|
"CloudProviderProxy",
|
|
|
|
G_TYPE_OBJECT,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
|
|
|
|
2015-06-23 20:28:18 +00:00
|
|
|
properties [PROP_PLACEHOLDER] =
|
2015-05-06 21:07:17 +00:00
|
|
|
g_param_spec_boolean ("placeholder",
|
|
|
|
"Placeholder",
|
|
|
|
"Placeholder",
|
|
|
|
FALSE,
|
|
|
|
(G_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY |
|
|
|
|
G_PARAM_STATIC_STRINGS));
|
2015-06-23 20:28:18 +00:00
|
|
|
|
|
|
|
g_object_class_install_properties (object_class, LAST_PROP, properties);
|
2015-05-06 21:07:17 +00:00
|
|
|
|
|
|
|
gtk_widget_class_set_template_from_resource (widget_class,
|
|
|
|
"/org/gtk/libgtk/ui/gtksidebarrow.ui");
|
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, start_icon_widget);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, end_icon_widget);
|
2015-05-06 21:07:17 +00:00
|
|
|
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);
|
|
|
|
gtk_widget_class_bind_template_child (widget_class, GtkSidebarRow, revealer);
|
|
|
|
|
|
|
|
gtk_widget_class_bind_template_callback (widget_class, on_child_revealed);
|
2015-11-05 18:51:58 +00:00
|
|
|
gtk_widget_class_set_css_name (widget_class, "row");
|
2015-05-06 21:07:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkSidebarRow*
|
|
|
|
gtk_sidebar_row_clone (GtkSidebarRow *self)
|
|
|
|
{
|
2015-06-23 18:42:57 +00:00
|
|
|
return g_object_new (GTK_TYPE_SIDEBAR_ROW,
|
|
|
|
"sidebar", self->sidebar,
|
2017-08-10 20:30:36 +00:00
|
|
|
"start-icon", self->start_icon,
|
|
|
|
"end-icon", self->end_icon,
|
2015-06-23 18:42:57 +00:00
|
|
|
"label", self->label,
|
|
|
|
"tooltip", self->tooltip,
|
|
|
|
"ejectable", self->ejectable,
|
|
|
|
"order-index", self->order_index,
|
|
|
|
"section-type", self->section_type,
|
|
|
|
"place-type", self->place_type,
|
|
|
|
"uri", self->uri,
|
|
|
|
"drive", self->drive,
|
|
|
|
"volume", self->volume,
|
|
|
|
"mount", self->mount,
|
2017-08-10 20:30:36 +00:00
|
|
|
"cloud-provider", self->cloud_provider,
|
2015-06-23 18:42:57 +00:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
GtkWidget*
|
2015-06-23 18:42:57 +00:00
|
|
|
gtk_sidebar_row_get_eject_button (GtkSidebarRow *self)
|
|
|
|
{
|
|
|
|
return self->eject_button;
|
|
|
|
}
|
|
|
|
|
2017-08-10 20:30:36 +00:00
|
|
|
GtkWidget*
|
2015-06-23 18:42:57 +00:00
|
|
|
gtk_sidebar_row_get_event_box (GtkSidebarRow *self)
|
|
|
|
{
|
|
|
|
return self->event_box;
|
2015-05-06 21:07:17 +00:00
|
|
|
}
|