*/
#include "config.h"
+
+#include "gtkfilechooserentry.h"
+
#include <string.h>
#include "gtkalignment.h"
#include "gtkcelllayout.h"
#include "gtkcellrenderertext.h"
#include "gtkentry.h"
-#include "gtkfilechooserentry.h"
#include "gtklabel.h"
#include "gtkmain.h"
+#include "gtksizerequest.h"
#include "gtkwindow.h"
#include "gtkintl.h"
#define COMPLETION_FEEDBACK_TIMEOUT_MS 2000
-static void gtk_file_chooser_entry_iface_init (GtkEditableClass *iface);
+static void gtk_file_chooser_entry_iface_init (GtkEditableInterface *iface);
static void gtk_file_chooser_entry_finalize (GObject *object);
static void gtk_file_chooser_entry_dispose (GObject *object);
static void pop_up_completion_feedback (GtkFileChooserEntry *chooser_entry,
const gchar *feedback);
-static GtkEditableClass *parent_editable_iface;
+static GtkEditableInterface *parent_editable_iface;
G_DEFINE_TYPE_WITH_CODE (GtkFileChooserEntry, _gtk_file_chooser_entry, GTK_TYPE_ENTRY,
G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE,
}
static void
-gtk_file_chooser_entry_iface_init (GtkEditableClass *iface)
+gtk_file_chooser_entry_iface_init (GtkEditableInterface *iface)
{
parent_editable_iface = g_type_interface_peek_parent (iface);
}
static gboolean
-completion_feedback_window_expose_event_cb (GtkWidget *widget,
- GdkEventExpose *event,
- gpointer data)
+completion_feedback_window_draw_cb (GtkWidget *widget,
+ cairo_t *cr,
+ gpointer data)
{
/* Stolen from gtk_tooltip_paint_window() */
GtkFileChooserEntry *chooser_entry = GTK_FILE_CHOOSER_ENTRY (data);
- gtk_paint_flat_box (chooser_entry->completion_feedback_window->style,
- chooser_entry->completion_feedback_window->window,
+ gtk_paint_flat_box (gtk_widget_get_style (chooser_entry->completion_feedback_window),
+ cr,
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
- NULL,
chooser_entry->completion_feedback_window,
"tooltip",
0, 0,
- chooser_entry->completion_feedback_window->allocation.width,
- chooser_entry->completion_feedback_window->allocation.height);
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
return FALSE;
}
GdkDisplay *display;
GdkCursor *cursor;
- display = gdk_drawable_get_display (window);
+ display = gdk_window_get_display (window);
cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
gdk_window_set_cursor (window, cursor);
* GtkEntry hides the cursor when the user types. We don't want the cursor to
* come back if the completion feedback ends up where the mouse is.
*/
- set_invisible_mouse_cursor (widget->window);
+ set_invisible_mouse_cursor (gtk_widget_get_window (widget));
}
static void
{
/* Stolen from gtk_tooltip_init() */
+ GtkStyle *style;
GtkWidget *alignment;
chooser_entry->completion_feedback_window = gtk_window_new (GTK_WINDOW_POPUP);
gtk_widget_set_name (chooser_entry->completion_feedback_window, "gtk-tooltip");
alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ style = gtk_widget_get_style (chooser_entry->completion_feedback_window);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment),
- chooser_entry->completion_feedback_window->style->ythickness,
- chooser_entry->completion_feedback_window->style->ythickness,
- chooser_entry->completion_feedback_window->style->xthickness,
- chooser_entry->completion_feedback_window->style->xthickness);
+ style->ythickness, style->ythickness,
+ style->xthickness, style->xthickness);
gtk_container_add (GTK_CONTAINER (chooser_entry->completion_feedback_window), alignment);
gtk_widget_show (alignment);
- g_signal_connect (chooser_entry->completion_feedback_window, "expose-event",
- G_CALLBACK (completion_feedback_window_expose_event_cb), chooser_entry);
+ g_signal_connect (chooser_entry->completion_feedback_window, "draw",
+ G_CALLBACK (completion_feedback_window_draw_cb), chooser_entry);
g_signal_connect (chooser_entry->completion_feedback_window, "realize",
G_CALLBACK (completion_feedback_window_realize_cb), chooser_entry);
/* FIXME: connect to motion-notify-event, and *show* the cursor when the mouse moves */
gint layout_x, layout_y;
gint layout_index;
PangoRectangle strong_pos;
+ gint start_pos, end_pos;
layout = gtk_entry_get_layout (GTK_ENTRY (chooser_entry));
gtk_entry_get_layout_offsets (GTK_ENTRY (chooser_entry), &layout_x, &layout_y);
+ gtk_editable_get_selection_bounds (GTK_EDITABLE (chooser_entry), &start_pos, &end_pos);
layout_index = gtk_entry_text_index_to_layout_index (GTK_ENTRY (chooser_entry),
- GTK_ENTRY (chooser_entry)->current_pos);
+ end_pos);
+
pango_layout_get_cursor_pos (layout, layout_index, &strong_pos, NULL);
/* More or less stolen from gtk_tooltip_position() */
GtkRequisition feedback_req;
+ GtkWidget *widget = GTK_WIDGET (chooser_entry);
gint entry_x, entry_y;
gint cursor_x;
- GtkAllocation *entry_allocation;
+ GtkAllocation entry_allocation;
int feedback_x, feedback_y;
- gtk_widget_size_request (chooser_entry->completion_feedback_window, &feedback_req);
+ gtk_widget_get_preferred_size (chooser_entry->completion_feedback_window,
+ &feedback_req, NULL);
- gdk_window_get_origin (GTK_WIDGET (chooser_entry)->window, &entry_x, &entry_y);
- entry_allocation = &(GTK_WIDGET (chooser_entry)->allocation);
+ gdk_window_get_origin (gtk_widget_get_window (widget), &entry_x, &entry_y);
+ gtk_widget_get_allocation (widget, &entry_allocation);
get_entry_cursor_x (chooser_entry, &cursor_x);
/* FIXME: fit to the screen if we bump on the screen's edge */
/* cheap "half M-width", use height as approximation of character em-size */
- feedback_x = entry_x + cursor_x + entry_allocation->height / 2;
- feedback_y = entry_y + (entry_allocation->height - feedback_req.height) / 2;
+ feedback_x = entry_x + cursor_x + entry_allocation.height / 2;
+ feedback_y = entry_y + (entry_allocation.height - feedback_req.height) / 2;
gtk_window_move (GTK_WINDOW (chooser_entry->completion_feedback_window), feedback_x, feedback_y);
gtk_widget_show (chooser_entry->completion_feedback_window);
/* This is a bit evil -- it makes Tab never leave the entry. It basically
* makes it 'safe' for people to hit. */
- if (event->keyval == GDK_Tab && !control_pressed)
+ if (event->keyval == GDK_KEY_Tab && !control_pressed)
{
if (chooser_entry->has_completion)
gtk_editable_set_position (editable, gtk_entry_get_text_length (entry));
*position + (colon - new_text) != 1) ||
(new_text_length > 0 &&
*position <= 1 &&
- GTK_ENTRY (chooser_entry)->text_length >= 2 &&
+ gtk_entry_get_text_length (GTK_ENTRY (chooser_entry)) >= 2 &&
gtk_entry_get_text (GTK_ENTRY (chooser_entry))[1] == ':'))
{
gtk_widget_error_bell (GTK_WIDGET (chooser_entry));
{
/* If deleting a drive letter, delete the colon, too */
if (start_pos == 0 && end_pos == 1 &&
- GTK_ENTRY (chooser_entry)->text_length >= 2 &&
+ gtk_entry_get_text_length (GTK_ENTRY (chooser_entry)) >= 2 &&
gtk_entry_get_text (GTK_ENTRY (chooser_entry))[1] == ':')
{
g_signal_handlers_block_by_func (chooser_entry,