mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
places-sidebar: add optional enter location place
https://bugzilla.gnome.org/show_bug.cgi?id=722211
This commit is contained in:
parent
e2b2339b89
commit
1e925a85ca
@ -165,6 +165,7 @@ struct _GtkPlacesSidebar {
|
|||||||
guint show_desktop_set : 1;
|
guint show_desktop_set : 1;
|
||||||
guint show_desktop : 1;
|
guint show_desktop : 1;
|
||||||
guint show_connect_to_server : 1;
|
guint show_connect_to_server : 1;
|
||||||
|
guint show_enter_location : 1;
|
||||||
guint local_only : 1;
|
guint local_only : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -192,6 +193,7 @@ struct _GtkPlacesSidebarClass {
|
|||||||
GFile *dest_file,
|
GFile *dest_file,
|
||||||
GList *source_file_list,
|
GList *source_file_list,
|
||||||
GdkDragAction action);
|
GdkDragAction action);
|
||||||
|
void (* show_enter_location) (GtkPlacesSidebar *sidebar);
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -219,6 +221,7 @@ typedef enum {
|
|||||||
PLACES_BOOKMARK,
|
PLACES_BOOKMARK,
|
||||||
PLACES_HEADING,
|
PLACES_HEADING,
|
||||||
PLACES_CONNECT_TO_SERVER,
|
PLACES_CONNECT_TO_SERVER,
|
||||||
|
PLACES_ENTER_LOCATION,
|
||||||
PLACES_DROP_FEEDBACK
|
PLACES_DROP_FEEDBACK
|
||||||
} PlaceType;
|
} PlaceType;
|
||||||
|
|
||||||
@ -234,6 +237,7 @@ enum {
|
|||||||
POPULATE_POPUP,
|
POPULATE_POPUP,
|
||||||
SHOW_ERROR_MESSAGE,
|
SHOW_ERROR_MESSAGE,
|
||||||
SHOW_CONNECT_TO_SERVER,
|
SHOW_CONNECT_TO_SERVER,
|
||||||
|
SHOW_ENTER_LOCATION,
|
||||||
DRAG_ACTION_REQUESTED,
|
DRAG_ACTION_REQUESTED,
|
||||||
DRAG_ACTION_ASK,
|
DRAG_ACTION_ASK,
|
||||||
DRAG_PERFORM_DROP,
|
DRAG_PERFORM_DROP,
|
||||||
@ -245,6 +249,7 @@ enum {
|
|||||||
PROP_OPEN_FLAGS,
|
PROP_OPEN_FLAGS,
|
||||||
PROP_SHOW_DESKTOP,
|
PROP_SHOW_DESKTOP,
|
||||||
PROP_SHOW_CONNECT_TO_SERVER,
|
PROP_SHOW_CONNECT_TO_SERVER,
|
||||||
|
PROP_SHOW_ENTER_LOCATION,
|
||||||
PROP_LOCAL_ONLY,
|
PROP_LOCAL_ONLY,
|
||||||
NUM_PROPERTIES
|
NUM_PROPERTIES
|
||||||
};
|
};
|
||||||
@ -363,6 +368,12 @@ emit_show_connect_to_server (GtkPlacesSidebar *sidebar)
|
|||||||
g_signal_emit (sidebar, places_sidebar_signals[SHOW_CONNECT_TO_SERVER], 0);
|
g_signal_emit (sidebar, places_sidebar_signals[SHOW_CONNECT_TO_SERVER], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
emit_show_enter_location (GtkPlacesSidebar *sidebar)
|
||||||
|
{
|
||||||
|
g_signal_emit (sidebar, places_sidebar_signals[SHOW_ENTER_LOCATION], 0);
|
||||||
|
}
|
||||||
|
|
||||||
static GdkDragAction
|
static GdkDragAction
|
||||||
emit_drag_action_requested (GtkPlacesSidebar *sidebar,
|
emit_drag_action_requested (GtkPlacesSidebar *sidebar,
|
||||||
GdkDragContext *context,
|
GdkDragContext *context,
|
||||||
@ -852,6 +863,17 @@ update_places (GtkPlacesSidebar *sidebar)
|
|||||||
/* XDG directories */
|
/* XDG directories */
|
||||||
add_special_dirs (sidebar);
|
add_special_dirs (sidebar);
|
||||||
|
|
||||||
|
if (sidebar->show_enter_location)
|
||||||
|
{
|
||||||
|
icon = g_themed_icon_new_with_default_fallbacks (ICON_NAME_NETWORK_SERVER);
|
||||||
|
add_place (sidebar, PLACES_ENTER_LOCATION,
|
||||||
|
SECTION_COMPUTER,
|
||||||
|
_("Enter Location"), icon, NULL,
|
||||||
|
NULL, NULL, NULL, 0,
|
||||||
|
_("Manually enter a location"));
|
||||||
|
g_object_unref (icon);
|
||||||
|
}
|
||||||
|
|
||||||
/* Trash */
|
/* Trash */
|
||||||
if (!sidebar->local_only)
|
if (!sidebar->local_only)
|
||||||
{
|
{
|
||||||
@ -2327,6 +2349,10 @@ open_selected_bookmark (GtkPlacesSidebar *sidebar,
|
|||||||
{
|
{
|
||||||
emit_show_connect_to_server (sidebar);
|
emit_show_connect_to_server (sidebar);
|
||||||
}
|
}
|
||||||
|
else if (place_type == PLACES_ENTER_LOCATION)
|
||||||
|
{
|
||||||
|
emit_show_enter_location (sidebar);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
open_selected_volume (sidebar, model, iter, open_flags);
|
open_selected_volume (sidebar, model, iter, open_flags);
|
||||||
@ -3899,6 +3925,10 @@ gtk_places_sidebar_set_property (GObject *obj,
|
|||||||
gtk_places_sidebar_set_show_connect_to_server (sidebar, g_value_get_boolean (value));
|
gtk_places_sidebar_set_show_connect_to_server (sidebar, g_value_get_boolean (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_SHOW_ENTER_LOCATION:
|
||||||
|
gtk_places_sidebar_set_show_enter_location (sidebar, g_value_get_boolean (value));
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_LOCAL_ONLY:
|
case PROP_LOCAL_ONLY:
|
||||||
gtk_places_sidebar_set_local_only (sidebar, g_value_get_boolean (value));
|
gtk_places_sidebar_set_local_only (sidebar, g_value_get_boolean (value));
|
||||||
break;
|
break;
|
||||||
@ -3935,6 +3965,10 @@ gtk_places_sidebar_get_property (GObject *obj,
|
|||||||
g_value_set_boolean (value, gtk_places_sidebar_get_show_connect_to_server (sidebar));
|
g_value_set_boolean (value, gtk_places_sidebar_get_show_connect_to_server (sidebar));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case PROP_SHOW_ENTER_LOCATION:
|
||||||
|
g_value_set_boolean (value, gtk_places_sidebar_get_show_enter_location (sidebar));
|
||||||
|
break;
|
||||||
|
|
||||||
case PROP_LOCAL_ONLY:
|
case PROP_LOCAL_ONLY:
|
||||||
g_value_set_boolean (value, gtk_places_sidebar_get_local_only (sidebar));
|
g_value_set_boolean (value, gtk_places_sidebar_get_local_only (sidebar));
|
||||||
break;
|
break;
|
||||||
@ -4134,6 +4168,26 @@ gtk_places_sidebar_class_init (GtkPlacesSidebarClass *class)
|
|||||||
_gtk_marshal_VOID__VOID,
|
_gtk_marshal_VOID__VOID,
|
||||||
G_TYPE_NONE, 0);
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GtkPlacesSidebar::show-enter-location:
|
||||||
|
* @sidebar: the object which received the signal.
|
||||||
|
*
|
||||||
|
* The places sidebar emits this signal when it needs the calling
|
||||||
|
* application to present an way to directly enter a location.
|
||||||
|
* For example, the application may bring up a dialog box asking for
|
||||||
|
* a URL like "http://http.example.com".
|
||||||
|
*
|
||||||
|
* Since: 3.14
|
||||||
|
*/
|
||||||
|
places_sidebar_signals [SHOW_ENTER_LOCATION] =
|
||||||
|
g_signal_new (I_("show-enter-location"),
|
||||||
|
G_OBJECT_CLASS_TYPE (gobject_class),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
G_STRUCT_OFFSET (GtkPlacesSidebarClass, show_enter_location),
|
||||||
|
NULL, NULL,
|
||||||
|
_gtk_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GtkPlacesSidebar::drag-action-requested:
|
* GtkPlacesSidebar::drag-action-requested:
|
||||||
* @sidebar: the object which received the signal.
|
* @sidebar: the object which received the signal.
|
||||||
@ -4244,6 +4298,12 @@ gtk_places_sidebar_class_init (GtkPlacesSidebarClass *class)
|
|||||||
P_("Whether the sidebar includes a builtin shortcut to a 'Connect to server' dialog"),
|
P_("Whether the sidebar includes a builtin shortcut to a 'Connect to server' dialog"),
|
||||||
FALSE,
|
FALSE,
|
||||||
G_PARAM_READWRITE);
|
G_PARAM_READWRITE);
|
||||||
|
properties[PROP_SHOW_ENTER_LOCATION] =
|
||||||
|
g_param_spec_boolean ("show-enter-location",
|
||||||
|
P_("Show 'Enter Location'"),
|
||||||
|
P_("Whether the sidebar includes a builtin shortcut to manually enter a location"),
|
||||||
|
FALSE,
|
||||||
|
G_PARAM_READWRITE);
|
||||||
properties[PROP_LOCAL_ONLY] =
|
properties[PROP_LOCAL_ONLY] =
|
||||||
g_param_spec_boolean ("local-only",
|
g_param_spec_boolean ("local-only",
|
||||||
P_("Local Only"),
|
P_("Local Only"),
|
||||||
@ -4605,6 +4665,50 @@ gtk_places_sidebar_get_show_connect_to_server (GtkPlacesSidebar *sidebar)
|
|||||||
return sidebar->show_connect_to_server;
|
return sidebar->show_connect_to_server;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_places_sidebar_set_show_enter_location:
|
||||||
|
* @sidebar: a places sidebar
|
||||||
|
* @show_enter_location: whether to show an item for the Connect to Server command
|
||||||
|
*
|
||||||
|
* Sets whether the @sidebar should show an item for connecting to a network server; this is off by default.
|
||||||
|
* An application may want to turn this on if it implements a way for the user to connect
|
||||||
|
* to network servers directly.
|
||||||
|
*
|
||||||
|
* Since: 3.14
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gtk_places_sidebar_set_show_enter_location (GtkPlacesSidebar *sidebar,
|
||||||
|
gboolean show_enter_location)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar));
|
||||||
|
|
||||||
|
show_enter_location = !!show_enter_location;
|
||||||
|
if (sidebar->show_enter_location != show_enter_location)
|
||||||
|
{
|
||||||
|
sidebar->show_enter_location = show_enter_location;
|
||||||
|
update_places (sidebar);
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (sidebar), properties[PROP_SHOW_ENTER_LOCATION]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gtk_places_sidebar_get_show_enter_location:
|
||||||
|
* @sidebar: a places sidebar
|
||||||
|
*
|
||||||
|
* Returns the value previously set with gtk_places_sidebar_set_show_enter_location()
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if the sidebar will display an “Enter Location” item.
|
||||||
|
*
|
||||||
|
* Since: 3.14
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
gtk_places_sidebar_get_show_enter_location (GtkPlacesSidebar *sidebar)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GTK_IS_PLACES_SIDEBAR (sidebar), FALSE);
|
||||||
|
|
||||||
|
return sidebar->show_enter_location;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gtk_places_sidebar_set_local_only:
|
* gtk_places_sidebar_set_local_only:
|
||||||
* @sidebar: a places sidebar
|
* @sidebar: a places sidebar
|
||||||
|
@ -105,6 +105,11 @@ gboolean gtk_places_sidebar_get_show_connect_to_server (GtkPlacesSideb
|
|||||||
GDK_AVAILABLE_IN_3_10
|
GDK_AVAILABLE_IN_3_10
|
||||||
void gtk_places_sidebar_set_show_connect_to_server (GtkPlacesSidebar *sidebar,
|
void gtk_places_sidebar_set_show_connect_to_server (GtkPlacesSidebar *sidebar,
|
||||||
gboolean show_connect_to_server);
|
gboolean show_connect_to_server);
|
||||||
|
GDK_AVAILABLE_IN_3_14
|
||||||
|
gboolean gtk_places_sidebar_get_show_enter_location (GtkPlacesSidebar *sidebar);
|
||||||
|
GDK_AVAILABLE_IN_3_14
|
||||||
|
void gtk_places_sidebar_set_show_enter_location (GtkPlacesSidebar *sidebar,
|
||||||
|
gboolean show_enter_location);
|
||||||
|
|
||||||
GDK_AVAILABLE_IN_3_12
|
GDK_AVAILABLE_IN_3_12
|
||||||
void gtk_places_sidebar_set_local_only (GtkPlacesSidebar *sidebar,
|
void gtk_places_sidebar_set_local_only (GtkPlacesSidebar *sidebar,
|
||||||
|
Loading…
Reference in New Issue
Block a user