plug-ins: some GTK3 undeprecation in imagemap

This commit is contained in:
Michael Natterer 2019-07-22 10:28:37 +02:00
parent 8e809160f0
commit b9b8879ba0
6 changed files with 62 additions and 66 deletions

View File

@ -252,7 +252,7 @@ object_draw(Object_t *obj, cairo_t *cr)
{
PreferencesData_t *preferences = get_preferences();
ColorSelData_t *colors = &preferences->colors;
GdkColor *fg, *bg;
GdkRGBA *fg, *bg;
gdouble dash = 4.;
if (obj->selected & 4) {
@ -268,9 +268,9 @@ object_draw(Object_t *obj, cairo_t *cr)
}
cairo_save (cr);
gdk_cairo_set_source_color (cr, bg);
gdk_cairo_set_source_rgba (cr, bg);
obj->class->draw(obj, cr);
gdk_cairo_set_source_color (cr, fg);
gdk_cairo_set_source_rgba (cr, fg);
cairo_set_dash (cr, &dash, 1, 0.);
obj->class->draw(obj, cr);

View File

@ -463,7 +463,6 @@ polygon_create_info_widget(GtkWidget *frame)
props->store = gtk_list_store_new (1, G_TYPE_POINTER);
view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (props->store));
gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view), TRUE);
g_object_unref (props->store);
gtk_widget_show (view);

View File

@ -99,11 +99,12 @@ parse_int(void)
}
static void
parse_color(GdkColor *gdk_color)
parse_color(GdkRGBA *color)
{
gdk_color->red = (guint16) parse_int();
gdk_color->green = (guint16) parse_int();
gdk_color->blue = (guint16) parse_int();
color->red = (gdouble) parse_int() / 255.0;
color->green = (gdouble) parse_int() / 255.0;
color->blue = (gdouble) parse_int() / 255.0;
color->alpha = 1.0;
}
static void
@ -222,23 +223,29 @@ preferences_save(PreferencesData_t *data)
fprintf(out, "(mru-size %d)\n", data->mru_size);
fprintf(out, "(normal-fg-color %d %d %d)\n",
colors->normal_fg.red, colors->normal_fg.green,
colors->normal_fg.blue);
ROUND (colors->normal_fg.red * 255.0),
ROUND (colors->normal_fg.green * 255.0),
ROUND (colors->normal_fg.blue * 255.0));
fprintf(out, "(normal-bg-color %d %d %d)\n",
colors->normal_bg.red, colors->normal_bg.green,
colors->normal_bg.blue);
ROUND (colors->normal_bg.red * 255.0),
ROUND (colors->normal_bg.green * 255.0),
ROUND (colors->normal_bg.blue * 255.0));
fprintf(out, "(selected-fg-color %d %d %d)\n",
colors->selected_fg.red, colors->selected_fg.green,
colors->selected_fg.blue);
ROUND (colors->selected_fg.red * 255.0),
ROUND (colors->selected_fg.green * 255.0),
ROUND (colors->selected_fg.blue * 255.0));
fprintf(out, "(selected-bg-color %d %d %d)\n",
colors->selected_bg.red, colors->selected_bg.green,
colors->selected_bg.blue);
ROUND (colors->selected_bg.red * 255.0),
ROUND (colors->selected_bg.green * 255.0),
ROUND (colors->selected_bg.blue * 255.0));
fprintf(out, "(interactive-fg-color %d %d %d)\n",
colors->interactive_fg.red, colors->interactive_fg.green,
colors->interactive_fg.blue);
ROUND (colors->interactive_fg.red * 255.0),
ROUND (colors->interactive_fg.green * 255.0),
ROUND (colors->interactive_fg.blue * 255.0));
fprintf(out, "(interactive-bg-color %d %d %d)\n",
colors->interactive_bg.red, colors->interactive_bg.green,
colors->interactive_bg.blue);
ROUND (colors->interactive_bg.red * 255.0),
ROUND (colors->interactive_bg.green * 255.0),
ROUND (colors->interactive_bg.blue * 255.0));
mru_write(get_mru(), out);
@ -292,13 +299,15 @@ preferences_ok_cb(gpointer data)
}
static void
get_button_color (GtkWidget *button, GdkColor *color)
get_button_color (GtkWidget *button,
GdkRGBA *color)
{
GimpRGB rgb;
gimp_color_button_get_color (GIMP_COLOR_BUTTON (button), &rgb);
color->red = rgb.r * 0xffff;
color->green = rgb.g * 0xffff;
color->blue = rgb.b * 0xffff;
color->red = rgb.r;
color->green = rgb.g;
color->blue = rgb.b;
color->alpha = 1.0;
}
static void
@ -313,16 +322,16 @@ get_button_colors(PreferencesDialog_t *dialog, ColorSelData_t *colors)
}
static void
set_button_color (GtkWidget *button, GdkColor *color)
set_button_color (GtkWidget *button,
GdkRGBA *color)
{
GimpRGB rgb;
gimp_rgb_set (&rgb, color->red, color->green, color->blue);
gimp_rgb_multiply (&rgb, 1.0 / 0xffff);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button), &rgb);
gimp_color_button_set_color (GIMP_COLOR_BUTTON (button),
(GimpRGB *) color);
}
static void
set_button_colors(PreferencesDialog_t *dialog, ColorSelData_t *colors)
set_button_colors(PreferencesDialog_t *dialog,
ColorSelData_t *colors)
{
set_button_color (dialog->normal_fg, &colors->normal_fg);
set_button_color (dialog->normal_bg, &colors->normal_bg);

View File

@ -26,12 +26,12 @@
#include "imap_default_dialog.h"
typedef struct {
GdkColor normal_fg;
GdkColor normal_bg;
GdkColor selected_fg;
GdkColor selected_bg;
GdkColor interactive_bg;
GdkColor interactive_fg;
GdkRGBA normal_fg;
GdkRGBA normal_bg;
GdkRGBA selected_fg;
GdkRGBA selected_bg;
GdkRGBA interactive_bg;
GdkRGBA interactive_fg;
} ColorSelData_t;
typedef struct {

View File

@ -77,20 +77,11 @@ preview_get_height(GtkWidget *preview)
static void
render_background(Preview_t *preview_base)
{
GtkWidget *preview = preview_base->preview;
GtkStyle *style;
const GdkColor *bg_color;
gtk_widget_ensure_style (preview);
style = gtk_widget_get_style (preview);
bg_color = &style->bg[GTK_STATE_NORMAL];
GtkWidget *preview = preview_base->preview;
gimp_preview_area_fill (GIMP_PREVIEW_AREA (preview),
0, 0, G_MAXINT, G_MAXINT,
bg_color->red >> 8,
bg_color->green >> 8,
bg_color->blue >> 8);
255, 255, 255);
}
static void
@ -145,32 +136,28 @@ arrow_cb(GtkWidget *widget, GdkEventButton *event, gpointer data)
}
static gboolean
preview_expose(GtkWidget *widget, GdkEventExpose *event)
preview_draw (GtkWidget *widget,
cairo_t *cr)
{
cairo_t *cr;
gint width = preview_get_width (widget);
gint height = preview_get_height (widget);
gint width = preview_get_width (widget);
gint height = preview_get_height (widget);
cr = gdk_cairo_create (event->window);
gdk_cairo_region (cr, event->region);
cairo_clip (cr);
cairo_set_line_width (cr, 1.);
draw_grid (cr, width, height);
cairo_set_line_width (cr, 1.);
draw_grid (cr, width, height);
draw_shapes (cr);
draw_shapes (cr);
if (_tmp_obj)
{
if (_tmp_obj)
{
/* this is a bit of a hack */
gdouble dash = 4.;
_tmp_obj->selected |= 4;
cairo_set_source_rgb (cr, 1., 0., 1.);
cairo_set_dash (cr, &dash, 1, dash);
object_draw (_tmp_obj, cr);
}
}
cairo_destroy (cr);
return FALSE;
return FALSE;
}
void
@ -287,8 +274,8 @@ make_preview (gint32 drawable_id)
g_object_set_data (G_OBJECT (preview), "preview", data);
gtk_widget_set_events (GTK_WIDGET (preview), PREVIEW_MASK);
g_signal_connect_after (preview, "expose-event",
G_CALLBACK (preview_expose),
g_signal_connect_after (preview, "draw",
G_CALLBACK (preview_draw),
data);
g_signal_connect (preview, "size-allocate",
G_CALLBACK (preview_size_allocate),
@ -325,7 +312,8 @@ make_preview (gint32 drawable_id)
G_CALLBACK (arrow_cb),
NULL);
arrow = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_OUT);
arrow = gtk_image_new_from_icon_name (GIMP_ICON_GO_NEXT,
GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER (button), arrow);
gtk_widget_show (arrow);

View File

@ -74,7 +74,7 @@ settings_ok_cb(gpointer data)
static void
type_toggled_cb(GtkWidget *widget, gpointer data)
{
if (gtk_widget_get_state (widget) & GTK_STATE_SELECTED)
if (gtk_widget_get_state_flags (widget) & GTK_STATE_FLAG_SELECTED)
_map_format = (MapFormat_t) data;
}