[Xfce4-commits] <thunar:nick/gtk3> More porting to gtk3.
Nick Schermer
noreply at xfce.org
Mon May 7 21:56:01 CEST 2012
Updating branch refs/heads/nick/gtk3
to 7e71abb26054cb87af2640b9308beef4ec005a3f (commit)
from c61ff28517038ac281ca5588fc2ed18bfb33f489 (commit)
commit 7e71abb26054cb87af2640b9308beef4ec005a3f
Author: Nick Schermer <nick at xfce.org>
Date: Mon May 7 21:55:22 2012 +0200
More porting to gtk3.
thunar/thunar-location-button.c | 11 ++--
thunar/thunar-location-buttons.c | 108 ++++++++++++++++++++++++++----------
thunar/thunar-location-dialog.c | 1 -
thunar/thunar-location-entry.c | 4 +-
thunar/thunar-path-entry.c | 13 +++-
thunar/thunar-preferences-dialog.c | 1 -
thunar/thunar-progress-dialog.c | 4 +-
thunar/thunar-properties-dialog.c | 1 -
thunar/thunar-renamer-dialog.c | 1 -
thunar/thunar-window.c | 4 +-
10 files changed, 100 insertions(+), 48 deletions(-)
diff --git a/thunar/thunar-location-button.c b/thunar/thunar-location-button.c
index 94fcc3e..4abf7df 100644
--- a/thunar/thunar-location-button.c
+++ b/thunar/thunar-location-button.c
@@ -676,8 +676,9 @@ thunar_location_button_drag_data_received (GtkWidget *button,
if (G_LIKELY (!location_button->drop_data_ready))
{
/* extract the URI list from the selection data (if valid) */
- if (selection_data->format == 8 && selection_data->length > 0)
- location_button->drop_file_list = thunar_g_file_list_new_from_string ((const gchar *) selection_data->data);
+ if (gtk_selection_data_get_format (selection_data)
+ && gtk_selection_data_get_length (selection_data) > 0)
+ location_button->drop_file_list = thunar_g_file_list_new_from_string ((const gchar *) gtk_selection_data_get_data (selection_data));
/* reset the state */
location_button->drop_data_ready = TRUE;
@@ -694,9 +695,9 @@ thunar_location_button_drag_data_received (GtkWidget *button,
if (G_LIKELY ((actions & (GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK)) != 0))
{
/* as the user what to do with the drop data */
- action = (context->action == GDK_ACTION_ASK)
+ action = (gdk_drag_context_get_actions (context) == GDK_ACTION_ASK)
? thunar_dnd_ask (button, location_button->file, location_button->drop_file_list, timestamp, actions)
- : context->action;
+ : gdk_drag_context_get_actions (context);
/* perform the requested action */
if (G_LIKELY (action != 0))
@@ -969,7 +970,7 @@ thunar_location_button_set_file (ThunarLocationButton *location_button,
g_signal_connect_swapped (G_OBJECT (file), "destroy", G_CALLBACK (thunar_location_button_file_destroy), location_button);
/* update our internal state for the new file (if realized) */
- if (gtk_widget_get_realized (location_button))
+ if (gtk_widget_get_realized (GTK_WIDGET (location_button)))
thunar_location_button_file_changed (location_button, file);
}
diff --git a/thunar/thunar-location-buttons.c b/thunar/thunar-location-buttons.c
index 34f76a0..0933c42 100644
--- a/thunar/thunar-location-buttons.c
+++ b/thunar/thunar-location-buttons.c
@@ -73,8 +73,12 @@ static ThunarFile *thunar_location_buttons_get_current_directory (ThunarN
static void thunar_location_buttons_set_current_directory (ThunarNavigator *navigator,
ThunarFile *current_directory);
static void thunar_location_buttons_unmap (GtkWidget *widget);
-static void thunar_location_buttons_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
+static void thunar_location_buttons_get_preferred_width (GtkWidget *widget,
+ gint *normal_width,
+ gint *minimal_width);
+static void thunar_location_buttons_get_preferred_height (GtkWidget *widget,
+ gint *normal_height,
+ gint *minimal_height);
static void thunar_location_buttons_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void thunar_location_buttons_state_changed (GtkWidget *widget,
@@ -196,7 +200,8 @@ thunar_location_buttons_class_init (ThunarLocationButtonsClass *klass)
gtkwidget_class = GTK_WIDGET_CLASS (klass);
gtkwidget_class->unmap = thunar_location_buttons_unmap;
- gtkwidget_class->size_request = thunar_location_buttons_size_request;
+ gtkwidget_class->get_preferred_width = thunar_location_buttons_get_preferred_width;
+ gtkwidget_class->get_preferred_height = thunar_location_buttons_get_preferred_height;
gtkwidget_class->size_allocate = thunar_location_buttons_size_allocate;
gtkwidget_class->state_changed = thunar_location_buttons_state_changed;
gtkwidget_class->grab_notify = thunar_location_buttons_grab_notify;
@@ -538,6 +543,7 @@ thunar_location_buttons_size_request (GtkWidget *widget,
GtkRequisition child_requisition;
GList *lp;
gint spacing;
+ gint border_width;
gtk_widget_style_get (GTK_WIDGET (buttons),
"spacing", &spacing,
@@ -549,7 +555,7 @@ thunar_location_buttons_size_request (GtkWidget *widget,
/* calculate the size of the biggest button */
for (lp = buttons->list; lp != NULL; lp = lp->next)
{
- gtk_widget_size_request (GTK_WIDGET (lp->data), &child_requisition);
+ gtk_widget_get_preferred_size (GTK_WIDGET (lp->data), &child_requisition, NULL);
requisition->width = MAX (child_requisition.width, requisition->width);
requisition->height = MAX (child_requisition.height, requisition->height);
}
@@ -559,13 +565,40 @@ thunar_location_buttons_size_request (GtkWidget *widget,
if (buttons->list != NULL && buttons->list->next != NULL)
requisition->width += (spacing + buttons->slider_width) * 2;
- gtk_widget_size_request (buttons->left_slider, &child_requisition);
- gtk_widget_size_request (buttons->right_slider, &child_requisition);
+ gtk_widget_get_preferred_size (buttons->left_slider, &child_requisition, NULL);
+ gtk_widget_get_preferred_size (buttons->right_slider, &child_requisition, NULL);
+
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2;
+ requisition->width += border_width;
+ requisition->height += border_width;
+}
+
- requisition->width += GTK_CONTAINER (widget)->border_width * 2;
- requisition->height += GTK_CONTAINER (widget)->border_width * 2;
- widget->requisition = *requisition;
+static void
+thunar_location_buttons_get_preferred_width (GtkWidget *widget,
+ gint *normal_width,
+ gint *minimal_width)
+{
+ GtkRequisition req;
+
+ thunar_location_buttons_size_request (widget, &req);
+
+ *normal_width = *minimal_width = req.width;
+}
+
+
+
+static void
+thunar_location_buttons_get_preferred_height (GtkWidget *widget,
+ gint *normal_height,
+ gint *minimal_height)
+{
+ GtkRequisition req;
+
+ thunar_location_buttons_size_request (widget, &req);
+
+ *normal_height = *minimal_height = req.height;
}
@@ -589,8 +622,9 @@ thunar_location_buttons_size_allocate (GtkWidget *widget,
gint slider_space;
gint spacing;
gint width;
+ GtkRequisition req;
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
/* if no path is set, we don't have to allocate anything */
if (G_UNLIKELY (buttons->list == NULL))
@@ -599,7 +633,7 @@ thunar_location_buttons_size_allocate (GtkWidget *widget,
gtk_widget_style_get (GTK_WIDGET (buttons), "spacing", &spacing, NULL);
direction = gtk_widget_get_direction (widget);
- border_width = GTK_CONTAINER (buttons)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (buttons));
allocation_width = allocation->width - 2 * border_width;
/* check if we need to display the sliders */
@@ -610,7 +644,9 @@ thunar_location_buttons_size_allocate (GtkWidget *widget,
for (lp = buttons->list; lp != NULL; lp = lp->next)
{
- width += GTK_WIDGET (lp->data)->requisition.width + spacing;
+ /* TODO: cache the width during allocation */
+ gtk_widget_get_preferred_size (widget, &req, NULL);
+ width += req.width + spacing;
if (lp == buttons->fake_root_button)
break;
}
@@ -636,28 +672,34 @@ thunar_location_buttons_size_allocate (GtkWidget *widget,
* We start at the first button, count forward until hit the new
* button, then count backwards.
*/
- width = GTK_WIDGET (first_button->data)->requisition.width;
+ /* TODO: cache the width during allocation */
+ gtk_widget_get_preferred_size (GTK_WIDGET (first_button->data), &req, NULL);
+ width = req.width;
for (lp = first_button->prev, reached_end = FALSE; lp != NULL && !reached_end; lp = lp->prev)
{
child = lp->data;
- if (width + child->requisition.width + spacing + slider_space > allocation_width)
+ /* TODO: cache the width during allocation */
+ gtk_widget_get_preferred_size (GTK_WIDGET (child), &req, NULL);
+ if (width + req.width + spacing + slider_space > allocation_width)
reached_end = TRUE;
else if (lp == buttons->fake_root_button)
break;
else
- width += child->requisition.width + spacing;
+ width += req.width + spacing;
}
while (first_button->next != NULL && !reached_end)
{
child = first_button->data;
- if (width + child->requisition.width + spacing + slider_space > allocation_width)
+ /* TODO: cache the width during allocation */
+ gtk_widget_get_preferred_size (GTK_WIDGET (child), &req, NULL);
+ if (width + req.width + spacing + slider_space > allocation_width)
{
reached_end = TRUE;
}
else
{
- width += child->requisition.width + spacing;
+ width += req.width + spacing;
if (first_button == buttons->fake_root_button)
break;
first_button = first_button->next;
@@ -691,20 +733,21 @@ thunar_location_buttons_size_allocate (GtkWidget *widget,
for (lp = first_button; lp != NULL; lp = lp->prev)
{
child = lp->data;
-
- child_allocation.width = child->requisition.width;
+ /* TODO: cache the width during allocation */
+ gtk_widget_get_preferred_size (GTK_WIDGET (child), &req, NULL);
+ child_allocation.width = req.width;
if (G_UNLIKELY (direction == GTK_TEXT_DIR_RTL))
child_allocation.x -= child_allocation.width;
/* check to see if we don't have any more space to allocate buttons */
if (need_sliders && direction == GTK_TEXT_DIR_RTL)
{
- if (child_allocation.x - spacing - buttons->slider_width < widget->allocation.x + border_width)
+ if (child_allocation.x - spacing - buttons->slider_width < allocation->x + border_width)
break;
}
else if (need_sliders && direction == GTK_TEXT_DIR_LTR)
{
- if (child_allocation.x + child_allocation.width + spacing + buttons->slider_width > widget->allocation.x + border_width + allocation_width)
+ if (child_allocation.x + child_allocation.width + spacing + buttons->slider_width > allocation->x + border_width + allocation_width)
break;
}
@@ -766,7 +809,7 @@ static void
thunar_location_buttons_state_changed (GtkWidget *widget,
GtkStateType previous_state)
{
- if (!GTK_WIDGET_IS_SENSITIVE (widget))
+ if (!gtk_widget_get_sensitive (widget))
thunar_location_buttons_stop_scrolling (THUNAR_LOCATION_BUTTONS (widget));
}
@@ -884,7 +927,7 @@ static void
thunar_location_buttons_remove_1 (GtkContainer *container,
GtkWidget *widget)
{
- gboolean need_resize = GTK_WIDGET_VISIBLE (widget);
+ gboolean need_resize = gtk_widget_get_visible (widget);
gtk_widget_unparent (widget);
if (G_LIKELY (need_resize))
gtk_widget_queue_resize (GTK_WIDGET (container));
@@ -1045,6 +1088,7 @@ thunar_location_buttons_scroll_right (GtkWidget *button,
gint space_needed;
gint border_width;
gint spacing;
+ GtkAllocation alloc1, alloc2;
if (G_UNLIKELY (buttons->ignore_click))
{
@@ -1058,7 +1102,7 @@ thunar_location_buttons_scroll_right (GtkWidget *button,
gtk_widget_queue_resize (GTK_WIDGET (buttons));
- border_width = GTK_CONTAINER (buttons)->border_width;
+ border_width = gtk_container_get_border_width (GTK_CONTAINER (buttons));
direction = gtk_widget_get_direction (GTK_WIDGET (buttons));
/* find the button at the 'right' end that we have to make visible */
@@ -1077,15 +1121,20 @@ thunar_location_buttons_scroll_right (GtkWidget *button,
break;
}
- space_needed = GTK_WIDGET (right_button->data)->allocation.width + spacing;
+ gtk_widget_get_allocation (GTK_WIDGET (right_button->data), &alloc1);
+ space_needed = alloc1.width + spacing;
if (direction == GTK_TEXT_DIR_RTL)
{
- space_available = buttons->right_slider->allocation.x - GTK_WIDGET (buttons)->allocation.x;
+ gtk_widget_get_allocation (buttons->right_slider, &alloc1);
+ gtk_widget_get_allocation (GTK_WIDGET (buttons), &alloc2);
+ space_available = alloc1.x - alloc2.x;
}
else
{
- space_available = (GTK_WIDGET (buttons)->allocation.x + GTK_WIDGET (buttons)->allocation.width - border_width)
- - (buttons->right_slider->allocation.x + buttons->right_slider->allocation.width);
+ gtk_widget_get_allocation (buttons->right_slider, &alloc1);
+ gtk_widget_get_allocation (GTK_WIDGET (buttons), &alloc2);
+ space_available = (alloc2.x + alloc2.width - border_width)
+ - (alloc1.x + alloc1.width);
}
/* We have space_available extra space that's not being used. We
@@ -1093,9 +1142,10 @@ thunar_location_buttons_scroll_right (GtkWidget *button,
* from the end, removing buttons until we get all the space we
* need.
*/
+ gtk_widget_get_allocation (GTK_WIDGET (left_button->data), &alloc1);
while (space_available < space_needed)
{
- space_available += GTK_WIDGET (left_button->data)->allocation.width + spacing;
+ space_available += alloc1.width + spacing;
left_button = left_button->prev;
buttons->first_scrolled_button = left_button;
}
diff --git a/thunar/thunar-location-dialog.c b/thunar/thunar-location-dialog.c
index c58e557..6ab438c 100644
--- a/thunar/thunar-location-dialog.c
+++ b/thunar/thunar-location-dialog.c
@@ -63,7 +63,6 @@ thunar_location_dialog_init (ThunarLocationDialog *location_dialog)
content_area = gtk_dialog_get_content_area (GTK_DIALOG (location_dialog));
gtk_box_set_spacing (GTK_BOX (content_area), 2);
gtk_container_set_border_width (GTK_CONTAINER (location_dialog), 5);
- gtk_dialog_set_has_separator (GTK_DIALOG (location_dialog), FALSE);
gtk_window_set_default_size (GTK_WINDOW (location_dialog), 350, -1);
gtk_window_set_title (GTK_WINDOW (location_dialog), _("Open Location"));
diff --git a/thunar/thunar-location-entry.c b/thunar/thunar-location-entry.c
index 733f3dc..060107c 100644
--- a/thunar/thunar-location-entry.c
+++ b/thunar/thunar-location-entry.c
@@ -480,8 +480,8 @@ menu_position (GtkMenu *menu,
gtk_widget_translate_coordinates (GTK_WIDGET (entry), toplevel, 0, 0, &x0, &y0);
- gtk_widget_size_request (GTK_WIDGET (entry), &entry_request);
- gtk_widget_size_request (GTK_WIDGET (menu), &menu_request);
+ gtk_widget_get_preferred_size (GTK_WIDGET (entry), &entry_request, NULL);
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_request, NULL);
gdk_window_get_position (GTK_WIDGET (entry)->window, x, y);
diff --git a/thunar/thunar-path-entry.c b/thunar/thunar-path-entry.c
index c49107e..f9e77c4 100644
--- a/thunar/thunar-path-entry.c
+++ b/thunar/thunar-path-entry.c
@@ -404,7 +404,7 @@ thunar_path_entry_size_allocate (GtkWidget *widget,
"icon-size", &icon_size,
NULL);
- widget->allocation = *allocation;
+ gtk_widget_set_allocation (widget, allocation);
thunar_path_entry_get_text_area_size (path_entry, &xborder, &yborder, NULL, &text_height);
@@ -457,6 +457,8 @@ thunar_path_entry_realize (GtkWidget *widget)
gint text_height;
gint icon_size;
gint spacing;
+ GtkWidget allocation;
+ GtkRequisition requisition;
/* query the proper icon factory */
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (widget));
@@ -471,6 +473,9 @@ thunar_path_entry_realize (GtkWidget *widget)
thunar_path_entry_get_text_area_size (path_entry, NULL, NULL, NULL, &text_height);
spacing = widget->requisition.height -text_height;
+ gtk_widget_get_allocation (widget, &allocation);
+ gtk_widget_get_preferred_size (widget, &requisition, NULL);
+
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
@@ -482,10 +487,10 @@ thunar_path_entry_realize (GtkWidget *widget)
| GDK_EXPOSURE_MASK
| GDK_LEAVE_NOTIFY_MASK
| GDK_POINTER_MOTION_MASK;
- attributes.x = widget->allocation.x + widget->allocation.width - icon_size - spacing;
- attributes.y = widget->allocation.y + (widget->allocation.height - widget->requisition.height) / 2;
+ attributes.x = allocation.x + allocation.width - icon_size - spacing;
+ attributes.y = allocation.y + (allocation.height - requisition.height) / 2;
attributes.width = icon_size + spacing;
- attributes.height = widget->requisition.height;
+ attributes.height = requisition.height;
attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
path_entry->icon_area = gdk_window_new (widget->window, &attributes, attributes_mask);
diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c
index d2ba8a1..a395840 100644
--- a/thunar/thunar-preferences-dialog.c
+++ b/thunar/thunar-preferences-dialog.c
@@ -186,7 +186,6 @@ thunar_preferences_dialog_init (ThunarPreferencesDialog *dialog)
dialog->preferences = thunar_preferences_get ();
/* configure the dialog properties */
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce-filemanager");
gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
gtk_window_set_title (GTK_WINDOW (dialog), _("File Manager Preferences"));
diff --git a/thunar/thunar-progress-dialog.c b/thunar/thunar-progress-dialog.c
index b355b02..4471692 100644
--- a/thunar/thunar-progress-dialog.c
+++ b/thunar/thunar-progress-dialog.c
@@ -188,7 +188,7 @@ thunar_progress_dialog_toggled (ThunarProgressDialog *dialog,
_thunar_return_val_if_fail (GTK_IS_STATUS_ICON (status_icon), FALSE);
/* check if the window is visible and has the focus */
- if (GTK_WIDGET_VISIBLE (GTK_WIDGET (dialog))
+ if (gtk_widget_get_visible (GTK_WIDGET (dialog))
&& gtk_window_is_active (GTK_WINDOW (dialog)))
{
/* remember the position of the dialog */
@@ -200,7 +200,7 @@ thunar_progress_dialog_toggled (ThunarProgressDialog *dialog,
else
{
/* check if the dialog is invisible */
- if (!GTK_WIDGET_VISIBLE (GTK_WIDGET (dialog)))
+ if (!gtk_widget_get_visible (GTK_WIDGET (dialog)))
{
/* restore its previous position before presenting it */
gtk_window_move (GTK_WINDOW (dialog), dialog->x, dialog->y);
diff --git a/thunar/thunar-properties-dialog.c b/thunar/thunar-properties-dialog.c
index 95e2fdd..7bd973a 100644
--- a/thunar/thunar-properties-dialog.c
+++ b/thunar/thunar-properties-dialog.c
@@ -225,7 +225,6 @@ thunar_properties_dialog_init (ThunarPropertiesDialog *dialog)
GTK_STOCK_HELP, GTK_RESPONSE_HELP,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
NULL);
- gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);
gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 430);
dialog->notebook = gtk_notebook_new ();
diff --git a/thunar/thunar-renamer-dialog.c b/thunar/thunar-renamer-dialog.c
index 3bb99b3..16b822a 100644
--- a/thunar/thunar-renamer-dialog.c
+++ b/thunar/thunar-renamer-dialog.c
@@ -337,7 +337,6 @@ thunar_renamer_dialog_init (ThunarRenamerDialog *renamer_dialog)
g_list_free (providers);
/* initialize the dialog */
- gtk_dialog_set_has_separator (GTK_DIALOG (renamer_dialog), FALSE);
gtk_window_set_default_size (GTK_WINDOW (renamer_dialog), 510, 490);
gtk_window_set_title (GTK_WINDOW (renamer_dialog), _("Rename Multiple Files"));
diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c
index 9fe737e..3afdce1 100644
--- a/thunar/thunar-window.c
+++ b/thunar/thunar-window.c
@@ -1214,7 +1214,7 @@ thunar_window_configure_event (GtkWidget *widget,
g_source_remove (window->save_geometry_timer_id);
/* check if we should schedule another save timer */
- if (GTK_WIDGET_VISIBLE (widget))
+ if (gtk_widget_get_visible (widget))
{
/* save the geometry one second after the last configure event */
window->save_geometry_timer_id = g_timeout_add_full (G_PRIORITY_LOW, 1000, thunar_window_save_geometry_timer,
@@ -2681,7 +2681,7 @@ thunar_window_save_geometry_timer (gpointer user_data)
if (G_LIKELY (remember_geometry))
{
/* check if the window is still visible */
- if (GTK_WIDGET_VISIBLE (window))
+ if (gtk_widget_get_visible (window))
{
/* determine the current state of the window */
state = gdk_window_get_state (GTK_WIDGET (window)->window);
More information about the Xfce4-commits
mailing list