placesview: add view for fixed drives and networks

Places sidebar shows XDG directories, mounted and unmounted devices,
connected networks, bookmarks and actions like 'Connect to server'
and 'Insert location', which causes the sidebar to grow very quickly
and look cluttered. Because of that, new mockups for the sidebar try
to simplify it.

To make the sidebar simpler, the new mockups propose that it should
only handle connected networks and removable devices such as flash
drives and USB devices, and delegates other devices for external
widgets through the 'Other Locations' item.

To handle fixed devices and manage network connections, add a new
widget named GtkPlacesView, based on Nautilus mockups to keep
consistency between GNOME file management tools - in this case,
between Nautilus and the bundled Gtk's file chooser.

https://bugzilla.gnome.org/show_bug.cgi?id=752034
This commit is contained in:
Georges Basile Stavracas Neto 2015-07-14 14:45:37 -03:00
parent 72bfb40ccf
commit 7af88d40b1
9 changed files with 3064 additions and 0 deletions

View File

@ -476,6 +476,8 @@ gtk_private_h_sources = \
gtkpango.h \
gtkpathbar.h \
gtkplacessidebarprivate.h \
gtkplacesviewprivate.h \
gtkplacesviewrowprivate.h \
gtkpopoverprivate.h \
gtkprintoperation-private.h \
gtkprintutils.h \
@ -757,6 +759,8 @@ gtk_base_c_sources = \
gtkpapersize.c \
gtkpathbar.c \
gtkplacessidebar.c \
gtkplacesview.c \
gtkplacesviewrow.c \
gtkprintcontext.c \
gtkprintoperation.c \
gtkprintoperationpreview.c \
@ -1087,6 +1091,8 @@ templates = \
ui/gtkmessagedialog.ui \
ui/gtkpagesetupunixdialog.ui \
ui/gtkpathbar.ui \
ui/gtkplacesview.ui \
ui/gtkplacesviewrow.ui \
ui/gtkprintunixdialog.ui \
ui/gtkrecentchooserdefault.ui \
ui/gtksearchbar.ui \

2028
gtk/gtkplacesview.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,93 @@
/* gtkplacesview.h
*
* Copyright (C) 2015 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GTK_PLACES_VIEW_H
#define GTK_PLACES_VIEW_H
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include <gtk/gtkbox.h>
#include <gtk/gtkplacessidebar.h>
G_BEGIN_DECLS
#define GTK_TYPE_PLACES_VIEW (gtk_places_view_get_type ())
#define GTK_PLACES_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_PLACES_VIEW, GtkPlacesView))
#define GTK_PLACES_VIEW_CLASS(klass)(G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_PLACES_VIEW, GtkPlacesViewClass))
#define GTK_IS_PLACES_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_PLACES_VIEW))
#define GTK_IS_PLACES_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_PLACES_VIEW))
#define GTK_PLACES_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTK_TYPE_PLACES_VIEW, GtkPlacesViewClass))
typedef struct _GtkPlacesView GtkPlacesView;
typedef struct _GtkPlacesViewClass GtkPlacesViewClass;
typedef struct _GtkPlacesViewPrivate GtkPlacesViewPrivate;
struct _GtkPlacesViewClass
{
GtkBoxClass parent_class;
void (* open_location) (GtkPlacesView *view,
GFile *location,
GtkPlacesOpenFlags open_flags);
void (* show_error_message) (GtkPlacesSidebar *sidebar,
const gchar *primary,
const gchar *secondary);
/*< private >*/
/* Padding for future expansion */
gpointer reserved[10];
};
struct _GtkPlacesView
{
GtkBox parent_instance;
};
GDK_AVAILABLE_IN_3_18
GType gtk_places_view_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_18
GtkPlacesOpenFlags gtk_places_view_get_open_flags (GtkPlacesView *view);
GDK_AVAILABLE_IN_3_18
void gtk_places_view_set_open_flags (GtkPlacesView *view,
GtkPlacesOpenFlags flags);
GDK_AVAILABLE_IN_3_18
const gchar* gtk_places_view_get_search_query (GtkPlacesView *view);
GDK_AVAILABLE_IN_3_18
void gtk_places_view_set_search_query (GtkPlacesView *view,
const gchar *query_text);
GDK_AVAILABLE_IN_3_18
gboolean gtk_places_view_get_local_only (GtkPlacesView *view);
GDK_AVAILABLE_IN_3_18
void gtk_places_view_set_local_only (GtkPlacesView *view,
gboolean local_only);
GDK_AVAILABLE_IN_3_18
GtkWidget * gtk_places_view_new (void);
G_END_DECLS
#endif /* GTK_PLACES_VIEW_H */

246
gtk/gtkplacesviewrow.c Normal file
View File

@ -0,0 +1,246 @@
/* gtkplacesviewrow.c
*
* Copyright (C) 2015 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gio/gio.h>
#include <gtk/gtk.h>
#include "gtkintl.h"
#include "gtkplacesviewrowprivate.h"
#include "gtktypebuiltins.h"
struct _GtkPlacesViewRow
{
GtkListBoxRow parent_instance;
GtkSpinner *busy_spinner;
GtkButton *eject_button;
GtkEventBox *event_box;
GtkImage *icon_image;
GtkLabel *name_label;
GtkLabel *path_label;
GVolume *volume;
GMount *mount;
};
G_DEFINE_TYPE (GtkPlacesViewRow, gtk_places_view_row, GTK_TYPE_LIST_BOX_ROW)
enum {
PROP_0,
PROP_ICON,
PROP_NAME,
PROP_PATH,
PROP_VOLUME,
PROP_MOUNT,
LAST_PROP
};
static GParamSpec *properties [LAST_PROP];
static void
gtk_places_view_row_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
GtkPlacesViewRow *self;
GIcon *icon;
self = GTK_PLACES_VIEW_ROW (object);
icon = NULL;
switch (prop_id)
{
case PROP_ICON:
gtk_image_get_gicon (self->icon_image, &icon, NULL);
g_value_set_object (value, icon);
break;
case PROP_NAME:
g_value_set_string (value, gtk_label_get_label (self->name_label));
break;
case PROP_PATH:
g_value_set_string (value, gtk_label_get_label (self->path_label));
break;
case PROP_VOLUME:
g_value_set_object (value, self->volume);
break;
case PROP_MOUNT:
g_value_set_object (value, self->mount);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gtk_places_view_row_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
GtkPlacesViewRow *self = GTK_PLACES_VIEW_ROW (object);
switch (prop_id)
{
case PROP_ICON:
gtk_image_set_from_gicon (self->icon_image,
g_value_get_object (value),
GTK_ICON_SIZE_LARGE_TOOLBAR);
break;
case PROP_NAME:
gtk_label_set_label (self->name_label, g_value_get_string (value));
break;
case PROP_PATH:
gtk_label_set_label (self->path_label, g_value_get_string (value));
break;
case PROP_VOLUME:
self->volume = g_value_get_object (value);
break;
case PROP_MOUNT:
self->mount = g_value_get_object (value);
gtk_widget_set_visible (GTK_WIDGET (self->eject_button), self->mount != NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
gtk_places_view_row_class_init (GtkPlacesViewRowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->get_property = gtk_places_view_row_get_property;
object_class->set_property = gtk_places_view_row_set_property;
properties[PROP_ICON] =
g_param_spec_object ("icon",
P_("Icon of the row"),
P_("The icon representing the volume"),
G_TYPE_ICON,
G_PARAM_READWRITE);
properties[PROP_NAME] =
g_param_spec_string ("name",
P_("Name of the volume"),
P_("The name of the volume"),
"",
G_PARAM_READWRITE);
properties[PROP_PATH] =
g_param_spec_string ("path",
P_("Path of the volume"),
P_("The path of the volume"),
"",
G_PARAM_READWRITE);
properties[PROP_VOLUME] =
g_param_spec_object ("volume",
P_("Volume represented by the row"),
P_("The volume represented by the row"),
G_TYPE_VOLUME,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
properties[PROP_MOUNT] =
g_param_spec_object ("mount",
P_("Mount represented by the row"),
P_("The mount point represented by the row, if any"),
G_TYPE_MOUNT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
g_object_class_install_properties (object_class, LAST_PROP, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkplacesviewrow.ui");
gtk_widget_class_bind_template_child (widget_class, GtkPlacesViewRow, busy_spinner);
gtk_widget_class_bind_template_child (widget_class, GtkPlacesViewRow, eject_button);
gtk_widget_class_bind_template_child (widget_class, GtkPlacesViewRow, event_box);
gtk_widget_class_bind_template_child (widget_class, GtkPlacesViewRow, icon_image);
gtk_widget_class_bind_template_child (widget_class, GtkPlacesViewRow, name_label);
gtk_widget_class_bind_template_child (widget_class, GtkPlacesViewRow, path_label);
}
static void
gtk_places_view_row_init (GtkPlacesViewRow *self)
{
gtk_widget_init_template (GTK_WIDGET (self));
}
GtkWidget*
gtk_places_view_row_new (GVolume *volume,
GMount *mount)
{
return g_object_new (GTK_TYPE_PLACES_VIEW_ROW,
"volume", volume,
"mount", mount,
NULL);
}
GMount*
gtk_places_view_row_get_mount (GtkPlacesViewRow *row)
{
g_return_val_if_fail (GTK_IS_PLACES_VIEW_ROW (row), NULL);
return row->mount;
}
GVolume*
gtk_places_view_row_get_volume (GtkPlacesViewRow *row)
{
g_return_val_if_fail (GTK_IS_PLACES_VIEW_ROW (row), NULL);
return row->volume;
}
GtkWidget*
gtk_places_view_row_get_eject_button (GtkPlacesViewRow *row)
{
g_return_val_if_fail (GTK_IS_PLACES_VIEW_ROW (row), NULL);
return GTK_WIDGET (row->eject_button);
}
GtkWidget*
gtk_places_view_row_get_event_box (GtkPlacesViewRow *row)
{
g_return_val_if_fail (GTK_IS_PLACES_VIEW_ROW (row), NULL);
return GTK_WIDGET (row->event_box);
}
void
gtk_places_view_row_set_busy (GtkPlacesViewRow *row,
gboolean is_busy)
{
g_return_if_fail (GTK_IS_PLACES_VIEW_ROW (row));
gtk_widget_set_visible (GTK_WIDGET (row->busy_spinner), is_busy);
}

View File

@ -0,0 +1,51 @@
/* gtkplacesviewrow.h
*
* Copyright (C) 2015 Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GTK_PLACES_VIEW_ROW_H
#define GTK_PLACES_VIEW_ROW_H
#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
#error "Only <gtk/gtk.h> can be included directly."
#endif
#include "gtkwidget.h"
#include "gtklistbox.h"
G_BEGIN_DECLS
#define GTK_TYPE_PLACES_VIEW_ROW (gtk_places_view_row_get_type())
G_DECLARE_FINAL_TYPE (GtkPlacesViewRow, gtk_places_view_row, GTK, PLACES_VIEW_ROW, GtkListBoxRow)
GtkWidget* gtk_places_view_row_new (GVolume *volume,
GMount *mount);
GtkWidget* gtk_places_view_row_get_eject_button (GtkPlacesViewRow *row);
GtkWidget* gtk_places_view_row_get_event_box (GtkPlacesViewRow *row);
GMount* gtk_places_view_row_get_mount (GtkPlacesViewRow *row);
GVolume* gtk_places_view_row_get_volume (GtkPlacesViewRow *row);
void gtk_places_view_row_set_busy (GtkPlacesViewRow *row,
gboolean is_busy);
G_END_DECLS
#endif /* GTK_PLACES_VIEW_ROW_H */

504
gtk/ui/gtkplacesview.ui Normal file
View File

@ -0,0 +1,504 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.16"/>
<object class="GtkListStore" id="completion_store">
<columns>
<!-- column-name name -->
<column type="gchararray"/>
<!-- column-name uri -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkEntryCompletion" id="address_entry_completion">
<property name="model">completion_store</property>
<property name="minimum_key_length">1</property>
<property name="text_column">1</property>
<property name="inline_completion">True</property>
<property name="popup_completion">False</property>
</object>
<object class="GtkPopover" id="recent_servers_popover">
<child>
<object class="GtkStack" id="recent_servers_stack">
<property name="visible">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vexpand">True</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">18</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel-size">48</property>
<property name="icon_name">network-server-symbolic</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" comments="Translators: Server as any successfully connected network address">No recent servers found</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">empty</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="border_width">12</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Recent Servers</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="vexpand">True</property>
<property name="shadow_type">in</property>
<property name="min_content_width">250</property>
<property name="min_content_height">150</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkListBox" id="recent_servers_listbox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
<signal name="row-activated" handler="on_recent_servers_listbox_row_activated" object="GtkPlacesView" swapped="yes" />
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">list</property>
</packing>
</child>
</object>
</child>
</object>
<template class="GtkPlacesView" parent="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<signal name="key-press-event" handler="on_key_press_event" object="GtkPlacesView" swapped="no" />
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="vhomogeneous">False</property>
<property name="transition_type">crossfade</property>
<child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkBox" id="main_box">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox" id="drives_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="label" translatable="yes">This Computer</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkListBox" id="drives_listbox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
<signal name="row-activated" handler="on_listbox_row_activated" object="GtkPlacesView" swapped="yes" />
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="network_grid">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="hexpand">False</property>
<property name="label" translatable="yes" comments="Translators: header of the Network section of the Other Locations view">Network</property>
<property name="ellipsize">end</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinner" id="network_spinner">
<property name="visible">True</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSeparator">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="can_focus">False</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkListBox" id="network_listbox">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="selection_mode">none</property>
<signal name="row-activated" handler="on_listbox_row_activated" object="GtkPlacesView" swapped="yes" />
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
<property name="width">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<style>
<class name="view"/>
</style>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="name">browse</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">72</property>
<property name="icon_name">drive-harddisk-symbolic</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">No drives or networks found</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.44"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="name">empty</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">72</property>
<property name="icon_name">edit-find-symbolic</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">No results found</property>
<attributes>
<attribute name="weight" value="bold"/>
<attribute name="scale" value="1.44"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Try a different search</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="name">search</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkActionBar" id="actionbar">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Connect to _Server</property>
<property name="mnemonic_widget">address_entry</property>
<property name="use_underline">True</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
</object>
</child>
<child>
<object class="GtkButton" id="connect_button">
<property name="label" translatable="yes">Con_nect</property>
<property name="use_underline">True</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="sensitive">False</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_connect_button_clicked" object="GtkPlacesView" swapped="yes" />
</object>
<packing>
<property name="pack_type">end</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="hexpand">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkEntry" id="address_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="width_chars">20</property>
<property name="placeholder_text" translatable="yes">Address…</property>
<property name="completion">address_entry_completion</property>
<signal name="notify::text" handler="on_address_entry_text_changed" object="GtkPlacesView" swapped="yes" />
<signal name="activate" handler="on_connect_button_clicked" object="GtkPlacesView" swapped="yes" />
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="server_list_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="direction">up</property>
<property name="popover">recent_servers_popover</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">pan-up-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<style>
<class name="linked"/>
</style>
</object>
<packing>
<property name="pack_type">end</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</template>
</interface>

107
gtk/ui/gtkplacesviewrow.ui Normal file
View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="3.16"/>
<template class="GtkPlacesViewRow" parent="GtkListBoxRow">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<style>
<class name="volume-row" />
</style>
<child>
<object class="GtkEventBox" id="event_box">
<property name="visible">True</property>
<child>
<object class="GtkBox" id="box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">12</property>
<property name="margin_end">12</property>
<property name="margin_top">6</property>
<property name="margin_bottom">6</property>
<property name="border_width">0</property>
<property name="spacing">18</property>
<child>
<object class="GtkImage" id="icon_image">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">32</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="name_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="path_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="justify">right</property>
<property name="ellipsize">middle</property>
<property name="xalign">1</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="eject_button">
<property name="visible">False</property>
<property name="halign">end</property>
<property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Unmount</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="icon_name">media-eject-symbolic</property>
<property name="icon_size">1</property>
</object>
</child>
<style>
<class name="image-button"/>
<class name="sidebar-button"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkSpinner" id="busy_spinner">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="active">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</template>
</interface>

View File

@ -106,6 +106,7 @@ noinst_PROGRAMS = $(TEST_PROGS) \
testorientable \
testoverlay \
testoverlaystyleclass \
testplacesview \
testprint \
testrecentchooser \
testrecentchoosermenu \
@ -253,6 +254,7 @@ testappchooserbutton_DEPENDENCIES = $(TEST_DEPS)
testorientable_DEPENDENCIES = $(TEST_DEPS)
testoverlay_DEPENDENCIES = $(TEST_DEPS)
testoverlaystyleclass_DEPENDENCIES = $(TEST_DEPS)
testplacesview_DEPENDENCIES = $(TEST_DEPS)
testprint_DEPENDENCIES = $(TEST_DEPS)
testrecentchooser_DEPENDENCIES = $(TEST_DEPS)
testrecentchoosermenu_DEPENDENCIES = $(TEST_DEPS)
@ -397,6 +399,9 @@ testtoolbar_SOURCES = \
testmenubutton_SOURCES = \
testmenubutton.c
testplacesview_SOURCES = \
testplacesview.c
testprint_SOURCES = \
testprint.c \
testprintfileoperation.h \

24
tests/testplacesview.c Normal file
View File

@ -0,0 +1,24 @@
#include <gtk/gtk.h>
int
main (int argc, char *argv[])
{
GtkWidget *win;
GtkWidget *view;
gtk_init (&argc, &argv);
win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (win), 400, 600);
view = gtk_places_view_new ();
gtk_container_add (GTK_CONTAINER (win), view);
gtk_widget_show_all (win);
g_signal_connect (win, "delete-event", G_CALLBACK (gtk_main_quit), win);
gtk_main ();
return 0;
}