Skip to content

Commit 518d699

Browse files
committed
patch 8.0.1099: warnings for GDK calls
Problem: Warnings for GDK calls. Solution: Use other calls for GTK 3 and fix a few problems. (Kazunobu Kuriyama)
1 parent b984b80 commit 518d699

2 files changed

Lines changed: 76 additions & 0 deletions

File tree

src/mbyte.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4891,19 +4891,92 @@ im_preedit_window_set_position(void)
48914891
im_preedit_window_open()
48924892
{
48934893
char *preedit_string;
4894+
#if !GTK_CHECK_VERSION(3,16,0)
48944895
char buf[8];
4896+
#endif
48954897
PangoAttrList *attr_list;
48964898
PangoLayout *layout;
4899+
#if GTK_CHECK_VERSION(3,0,0)
4900+
# if !GTK_CHECK_VERSION(3,16,0)
4901+
GdkRGBA color;
4902+
# endif
4903+
#else
48974904
GdkColor color;
4905+
#endif
48984906
gint w, h;
48994907

49004908
if (preedit_window == NULL)
49014909
{
49024910
preedit_window = gtk_window_new(GTK_WINDOW_POPUP);
4911+
gtk_window_set_transient_for(GTK_WINDOW(preedit_window),
4912+
GTK_WINDOW(gui.mainwin));
49034913
preedit_label = gtk_label_new("");
4914+
gtk_widget_set_name(preedit_label, "vim-gui-preedit-area");
49044915
gtk_container_add(GTK_CONTAINER(preedit_window), preedit_label);
49054916
}
49064917

4918+
#if GTK_CHECK_VERSION(3,16,0)
4919+
{
4920+
GtkStyleContext * const context
4921+
= gtk_widget_get_style_context(gui.drawarea);
4922+
GtkCssProvider * const provider = gtk_css_provider_new();
4923+
gchar *css = NULL;
4924+
const char * const fontname
4925+
= pango_font_description_get_family(gui.norm_font);
4926+
gint fontsize
4927+
= pango_font_description_get_size(gui.norm_font) / PANGO_SCALE;
4928+
gchar *fontsize_propval = NULL;
4929+
4930+
if (!pango_font_description_get_size_is_absolute(gui.norm_font))
4931+
{
4932+
/* fontsize was given in points. Convert it into that in pixels
4933+
* to use with CSS. */
4934+
GdkScreen * const screen
4935+
= gdk_window_get_screen(gtk_widget_get_window(gui.mainwin));
4936+
const gdouble dpi = gdk_screen_get_resolution(screen);
4937+
fontsize = dpi * fontsize / 72;
4938+
}
4939+
if (fontsize > 0)
4940+
fontsize_propval = g_strdup_printf("%dpx", fontsize);
4941+
else
4942+
fontsize_propval = g_strdup_printf("inherit");
4943+
4944+
css = g_strdup_printf(
4945+
"widget#vim-gui-preedit-area {\n"
4946+
" font-family: %s,monospace;\n"
4947+
" font-size: %s;\n"
4948+
" color: #%.2lx%.2lx%.2lx;\n"
4949+
" background-color: #%.2lx%.2lx%.2lx;\n"
4950+
"}\n",
4951+
fontname != NULL ? fontname : "inherit",
4952+
fontsize_propval,
4953+
(gui.norm_pixel >> 16) & 0xff,
4954+
(gui.norm_pixel >> 8) & 0xff,
4955+
gui.norm_pixel & 0xff,
4956+
(gui.back_pixel >> 16) & 0xff,
4957+
(gui.back_pixel >> 8) & 0xff,
4958+
gui.back_pixel & 0xff);
4959+
4960+
gtk_css_provider_load_from_data(provider, css, -1, NULL);
4961+
gtk_style_context_add_provider(context,
4962+
GTK_STYLE_PROVIDER(provider), G_MAXUINT);
4963+
4964+
g_free(css);
4965+
g_free(fontsize_propval);
4966+
g_object_unref(provider);
4967+
}
4968+
#elif GTK_CHECK_VERSION(3,0,0)
4969+
gtk_widget_override_font(preedit_label, gui.norm_font);
4970+
4971+
vim_snprintf(buf, sizeof(buf), "#%06X", gui.norm_pixel);
4972+
gdk_rgba_parse(&color, buf);
4973+
gtk_widget_override_color(preedit_label, GTK_STATE_FLAG_NORMAL, &color);
4974+
4975+
vim_snprintf(buf, sizeof(buf), "#%06X", gui.back_pixel);
4976+
gdk_rgba_parse(&color, buf);
4977+
gtk_widget_override_background_color(preedit_label, GTK_STATE_FLAG_NORMAL,
4978+
&color);
4979+
#else
49074980
gtk_widget_modify_font(preedit_label, gui.norm_font);
49084981

49094982
vim_snprintf(buf, sizeof(buf), "#%06X", gui.norm_pixel);
@@ -4913,6 +4986,7 @@ im_preedit_window_open()
49134986
vim_snprintf(buf, sizeof(buf), "#%06X", gui.back_pixel);
49144987
gdk_color_parse(buf, &color);
49154988
gtk_widget_modify_bg(preedit_window, GTK_STATE_NORMAL, &color);
4989+
#endif
49164990

49174991
gtk_im_context_get_preedit_string(xic, &preedit_string, &attr_list, NULL);
49184992

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,8 @@ static char *(features[]) =
769769

770770
static int included_patches[] =
771771
{ /* Add new patch number below this line */
772+
/**/
773+
1099,
772774
/**/
773775
1098,
774776
/**/

0 commit comments

Comments
 (0)