Import newer upstream.

This commit is contained in:
2023-09-25 16:54:03 -07:00
parent a8611b8b16
commit 098531073c
66 changed files with 13399 additions and 10203 deletions

View File

@ -32,6 +32,7 @@
#include "core/pika.h"
#include "core/pikaviewable.h"
#include "widgets/pikaaction.h"
#include "widgets/pikahelp-ids.h"
#include "widgets/pikaviewabledialog.h"
@ -54,6 +55,9 @@ typedef struct
GtkAdjustment *scale_adj;
GtkAdjustment *num_adj;
GtkAdjustment *denom_adj;
gdouble prev_scale;
gdouble *other_scale;
} ScaleDialogData;
@ -81,6 +85,8 @@ static void update_zoom_values (GtkAdjustment *adj,
void
pika_display_shell_scale_dialog (PikaDisplayShell *shell)
{
/* scale factor entered in Zoom->Other*/
static gdouble other_scale = 0.0;
ScaleDialogData *data;
PikaImage *image;
GtkWidget *toplevel;
@ -98,19 +104,21 @@ pika_display_shell_scale_dialog (PikaDisplayShell *shell)
return;
}
if (SCALE_EQUALS (shell->other_scale, 0.0))
data = g_slice_new (ScaleDialogData);
data->prev_scale = other_scale;
data->other_scale = &other_scale;
if (SCALE_EQUALS (other_scale, 0.0))
{
/* other_scale not yet initialized */
shell->other_scale = pika_zoom_model_get_factor (shell->zoom);
other_scale = pika_zoom_model_get_factor (shell->zoom);
}
image = pika_display_get_image (shell->display);
data = g_slice_new (ScaleDialogData);
data->shell = shell;
data->model = g_object_new (PIKA_TYPE_ZOOM_MODEL,
"value", fabs (shell->other_scale),
"value", fabs (other_scale),
NULL);
g_set_weak_pointer
@ -189,7 +197,7 @@ pika_display_shell_scale_dialog (PikaDisplayShell *shell)
_("Zoom:"), 0.0, 0.5,
hbox, 1);
data->scale_adj = gtk_adjustment_new (fabs (shell->other_scale) * 100,
data->scale_adj = gtk_adjustment_new (other_scale * 100,
100.0 / 256.0, 25600.0,
10, 50, 0);
spin = pika_spin_button_new (data->scale_adj, 1.0, 2);
@ -219,7 +227,10 @@ pika_display_shell_scale_dialog_response (GtkWidget *widget,
{
if (response_id == GTK_RESPONSE_OK)
{
gdouble scale;
GAction *action;
gchar *label;
gchar *zoom_str;
gdouble scale;
scale = gtk_adjustment_get_value (dialog->scale_adj);
@ -227,14 +238,32 @@ pika_display_shell_scale_dialog_response (GtkWidget *widget,
PIKA_ZOOM_TO,
scale / 100.0,
PIKA_ZOOM_FOCUS_BEST_GUESS);
g_object_get (dialog->shell->zoom,
"percentage", &zoom_str,
NULL);
/* Change the "view-zoom-other" label. */
action = g_action_map_lookup_action (G_ACTION_MAP (dialog->shell->display->pika->app),
"view-zoom-other");
label = g_strdup_printf (_("Othe_r (%s)..."), zoom_str);
pika_action_set_short_label (PIKA_ACTION (action), label);
g_free (label);
label = g_strdup_printf (_("Custom Zoom (%s)..."), zoom_str);
pika_action_set_label (PIKA_ACTION (action), label);
g_free (label);
g_free (zoom_str);
}
else
{
/* need to emit "scaled" to get the menu updated */
pika_display_shell_scaled (dialog->shell);
}
dialog->shell->other_scale = - fabs (dialog->shell->other_scale);
*(dialog->other_scale) = dialog->prev_scale;
}
gtk_widget_destroy (dialog->shell->scale_dialog);
}
@ -271,6 +300,8 @@ update_zoom_values (GtkAdjustment *adj,
gtk_adjustment_set_value (dialog->num_adj, num);
gtk_adjustment_set_value (dialog->denom_adj, denom);
*(dialog->other_scale) = scale / 100.0;
}
else /* fraction adjustments */
{
@ -278,6 +309,8 @@ update_zoom_values (GtkAdjustment *adj,
gtk_adjustment_get_value (dialog->denom_adj));
gtk_adjustment_set_value (dialog->scale_adj, scale * 100);
*(dialog->other_scale) = scale;
}
g_signal_handlers_unblock_by_func (dialog->scale_adj,

View File

@ -87,8 +87,6 @@ struct _PikaDisplayShell
gint last_offset_x; /* offsets used when reverting zoom */
gint last_offset_y;
gdouble other_scale; /* scale factor entered in Zoom->Other*/
gint disp_width; /* width of drawing area */
gint disp_height; /* height of drawing area */

View File

@ -4210,11 +4210,12 @@ void
pika_tool_rectangle_frame_item (PikaToolRectangle *rectangle,
PikaItem *item)
{
PikaDisplayShell *shell;
gint offset_x;
gint offset_y;
gint width;
gint height;
PikaDisplayShell *shell;
gint offset_x;
gint offset_y;
gint width;
gint height;
PikaRectangleFunction old_function;
g_return_if_fail (PIKA_IS_TOOL_RECTANGLE (rectangle));
g_return_if_fail (PIKA_IS_ITEM (item));
@ -4230,6 +4231,7 @@ pika_tool_rectangle_frame_item (PikaToolRectangle *rectangle,
pika_item_get_offset (item, &offset_x, &offset_y);
old_function = rectangle->private->function;
pika_tool_rectangle_set_function (rectangle, PIKA_TOOL_RECTANGLE_CREATING);
g_object_set (rectangle,
@ -4243,6 +4245,7 @@ pika_tool_rectangle_frame_item (PikaToolRectangle *rectangle,
* if this function is ever moved out of the text tool code.
*/
pika_tool_rectangle_set_constraint (rectangle, PIKA_RECTANGLE_CONSTRAIN_NONE);
pika_tool_rectangle_set_function (rectangle, old_function);
}
void