forked from AuroraMiddleware/gtk
Merge branch 'filechooser-popover-fixes' into 'master'
Filechooser popover fixes See merge request GNOME/gtk!1553
This commit is contained in:
commit
d7e5f5b368
@ -85,6 +85,7 @@
|
||||
#include "gtkbinlayout.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gtkpopovermenuprivate.h"
|
||||
#include "gtknative.h"
|
||||
|
||||
#include <cairo-gobject.h>
|
||||
|
||||
@ -1535,7 +1536,12 @@ rename_selected_cb (GtkTreeModel *model,
|
||||
path, priv->list_name_column, &rect);
|
||||
|
||||
gtk_tree_view_convert_bin_window_to_widget_coords (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
||||
rect.x, rect.y, &rect.x, &rect.y);
|
||||
rect.x, rect.y,
|
||||
&rect.x, &rect.y);
|
||||
gtk_widget_translate_coordinates (priv->browse_files_tree_view,
|
||||
GTK_WIDGET (impl),
|
||||
rect.x, rect.y,
|
||||
&rect.x, &rect.y);
|
||||
|
||||
filename = g_file_get_basename (priv->rename_file_source_file);
|
||||
gtk_editable_set_text (GTK_EDITABLE (priv->rename_file_name_entry), filename);
|
||||
@ -2036,7 +2042,7 @@ file_list_build_popover (GtkFileChooserWidget *impl)
|
||||
g_object_unref (section);
|
||||
|
||||
priv->browse_files_popover = gtk_popover_menu_new_from_model (G_MENU_MODEL (menu));
|
||||
gtk_widget_set_parent (priv->browse_files_popover, priv->browse_files_tree_view);
|
||||
gtk_widget_set_parent (priv->browse_files_popover, GTK_WIDGET (impl));
|
||||
g_object_unref (menu);
|
||||
}
|
||||
|
||||
@ -2113,7 +2119,12 @@ file_list_show_popover (GtkFileChooserWidget *impl,
|
||||
path = list->data;
|
||||
gtk_tree_view_get_cell_area (GTK_TREE_VIEW (priv->browse_files_tree_view), path, NULL, &rect);
|
||||
gtk_tree_view_convert_bin_window_to_widget_coords (GTK_TREE_VIEW (priv->browse_files_tree_view),
|
||||
rect.x, rect.y, &rect.x, &rect.y);
|
||||
rect.x, rect.y,
|
||||
&rect.x, &rect.y);
|
||||
gtk_widget_translate_coordinates (priv->browse_files_tree_view,
|
||||
GTK_WIDGET (impl),
|
||||
rect.x, rect.y,
|
||||
&rect.x, &rect.y);
|
||||
|
||||
rect.x = CLAMP (x - 20, 0, bounds.size.width - 40);
|
||||
rect.width = 40;
|
||||
@ -2132,25 +2143,6 @@ file_list_show_popover (GtkFileChooserWidget *impl,
|
||||
gtk_popover_popup (GTK_POPOVER (priv->browse_files_popover));
|
||||
}
|
||||
|
||||
/* Callback used for the GtkWidget::popup-menu signal of the file list */
|
||||
static gboolean
|
||||
list_popup_menu_cb (GtkWidget *widget,
|
||||
GtkFileChooserWidget *impl)
|
||||
{
|
||||
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
|
||||
graphene_rect_t bounds;
|
||||
|
||||
if (gtk_widget_compute_bounds (priv->browse_files_tree_view,
|
||||
priv->browse_files_tree_view,
|
||||
&bounds))
|
||||
{
|
||||
file_list_show_popover (impl, 0.5 * bounds.size.width, 0.5 * bounds.size.height);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Callback used when a button is pressed on the file list. We trap button 3 to
|
||||
* bring up a popup menu.
|
||||
*/
|
||||
@ -2179,12 +2171,17 @@ click_cb (GtkGesture *gesture,
|
||||
double y,
|
||||
GtkFileChooserWidget *impl)
|
||||
{
|
||||
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
|
||||
PopoverData *pd;
|
||||
int xx, yy;
|
||||
|
||||
pd = g_new (PopoverData, 1);
|
||||
pd->impl = impl;
|
||||
pd->x = x;
|
||||
pd->y = y;
|
||||
gtk_widget_translate_coordinates (priv->browse_files_tree_view,
|
||||
GTK_WIDGET (impl),
|
||||
x, y, &xx, &yy);
|
||||
pd->x = xx;
|
||||
pd->y = yy;
|
||||
|
||||
g_idle_add (file_list_show_popover_in_idle, pd);
|
||||
}
|
||||
@ -7475,6 +7472,22 @@ add_normal_and_shifted_binding (GtkBindingSet *binding_set,
|
||||
signal_name, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_widget_size_allocate (GtkWidget *widget,
|
||||
int width,
|
||||
int height,
|
||||
int baseline)
|
||||
{
|
||||
GtkFileChooserWidget *impl = GTK_FILE_CHOOSER_WIDGET (widget);
|
||||
GtkFileChooserWidgetPrivate *priv = gtk_file_chooser_widget_get_instance_private (impl);
|
||||
|
||||
GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->size_allocate (widget, width, height, baseline);
|
||||
if (priv->browse_files_popover)
|
||||
gtk_native_check_resize (GTK_NATIVE (priv->browse_files_popover));
|
||||
if (priv->rename_file_popover)
|
||||
gtk_native_check_resize (GTK_NATIVE (priv->rename_file_popover));
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
||||
{
|
||||
@ -7497,6 +7510,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
||||
widget_class->root = gtk_file_chooser_widget_root;
|
||||
widget_class->unroot = gtk_file_chooser_widget_unroot;
|
||||
widget_class->css_changed = gtk_file_chooser_widget_css_changed;
|
||||
widget_class->size_allocate = gtk_file_chooser_widget_size_allocate;
|
||||
|
||||
/*
|
||||
* Signals
|
||||
@ -7893,7 +7907,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
||||
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, box);
|
||||
|
||||
/* And a *lot* of callbacks to bind ... */
|
||||
gtk_widget_class_bind_template_callback (widget_class, list_popup_menu_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, file_list_query_tooltip_cb);
|
||||
gtk_widget_class_bind_template_callback (widget_class, list_row_activated);
|
||||
gtk_widget_class_bind_template_callback (widget_class, list_selection_changed);
|
||||
@ -7984,10 +7997,13 @@ post_process_ui (GtkFileChooserWidget *impl)
|
||||
g_action_map_add_action_entries (G_ACTION_MAP (priv->item_actions),
|
||||
entries, G_N_ELEMENTS (entries),
|
||||
impl);
|
||||
gtk_widget_insert_action_group (GTK_WIDGET (priv->browse_files_tree_view), "item",
|
||||
gtk_widget_insert_action_group (GTK_WIDGET (impl),
|
||||
"item",
|
||||
priv->item_actions);
|
||||
|
||||
gtk_search_entry_set_key_capture_widget (GTK_SEARCH_ENTRY (priv->search_entry), priv->search_entry);
|
||||
|
||||
gtk_widget_set_parent (priv->rename_file_popover, GTK_WIDGET (impl));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2396,7 +2396,11 @@ show_rename_popover (GtkSidebarRow *row)
|
||||
sidebar->rename_uri = g_strdup (uri);
|
||||
|
||||
gtk_editable_set_text (GTK_EDITABLE (sidebar->rename_entry), name);
|
||||
g_object_ref (sidebar->rename_popover);
|
||||
gtk_widget_unparent (sidebar->rename_popover);
|
||||
gtk_widget_set_parent (sidebar->rename_popover, GTK_WIDGET (row));
|
||||
g_object_unref (sidebar->rename_popover);
|
||||
|
||||
setup_popover_shadowing (sidebar->rename_popover);
|
||||
|
||||
gtk_popover_popup (GTK_POPOVER (sidebar->rename_popover));
|
||||
@ -4084,6 +4088,9 @@ gtk_places_sidebar_size_allocate (GtkWidget *widget,
|
||||
&(GtkAllocation) { 0, 0, width, height },
|
||||
baseline);
|
||||
|
||||
if (sidebar->popover)
|
||||
gtk_native_check_resize (GTK_NATIVE (sidebar->popover));
|
||||
|
||||
if (sidebar->rename_popover)
|
||||
gtk_native_check_resize (GTK_NATIVE (sidebar->rename_popover));
|
||||
}
|
||||
|
@ -63,7 +63,6 @@
|
||||
<property name="tooltip-text" translatable="yes">Create Folder</property>
|
||||
<property name="popover">new_folder_popover</property>
|
||||
<property name="icon-name">folder-new-symbolic</property>
|
||||
<signal name="notify::active" handler="new_folder_popover_active"/>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
@ -165,7 +164,6 @@
|
||||
<signal name="key-pressed" handler="treeview_key_press_cb" swapped="no"/>
|
||||
</object>
|
||||
</child>
|
||||
<signal name="popup-menu" handler="list_popup_menu_cb" swapped="no"/>
|
||||
<signal name="query-tooltip" handler="file_list_query_tooltip_cb" swapped="no"/>
|
||||
<signal name="row-activated" handler="list_row_activated" swapped="no"/>
|
||||
<signal name="keynav-failed" handler="browse_files_tree_view_keynav_failed_cb"/>
|
||||
@ -382,6 +380,7 @@
|
||||
</widgets>
|
||||
</object>
|
||||
<object class="GtkPopover" id="new_folder_popover">
|
||||
<signal name="notify::visible" handler="new_folder_popover_active"/>
|
||||
<child>
|
||||
<object class="GtkGrid">
|
||||
<property name="margin-start">10</property>
|
||||
|
Loading…
Reference in New Issue
Block a user