diff options
-rw-r--r-- | geyes/geyes.c | 39 | ||||
-rw-r--r-- | geyes/themes.c | 8 |
2 files changed, 46 insertions, 1 deletions
diff --git a/geyes/geyes.c b/geyes/geyes.c index 34599102..0f2a9d20 100644 --- a/geyes/geyes.c +++ b/geyes/geyes.c @@ -32,6 +32,24 @@ #define gtk_hbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_HORIZONTAL,Y) #endif +#if GTK_CHECK_VERSION (3, 0, 0) +static gfloat +gtk_align_to_gfloat (GtkAlign align) +{ + switch (align) { + case GTK_ALIGN_START: + return 0.0; + case GTK_ALIGN_END: + return 1.0; + case GTK_ALIGN_CENTER: + case GTK_ALIGN_FILL: + return 0.5; + default: + return 0.0; + } +} +#endif + /* TODO - Optimize this a bit */ static void calculate_pupil_xy (EyesApplet *eyes_applet, @@ -51,7 +69,13 @@ calculate_pupil_xy (EyesApplet *eyes_applet, gtk_widget_get_allocation (GTK_WIDGET(widget), &allocation); width = allocation.width; height = allocation.height; +#if GTK_CHECK_VERSION (3, 0, 0) + + xalign = gtk_align_to_gfloat (gtk_widget_get_halign (widget)); + yalign = gtk_align_to_gfloat (gtk_widget_get_valign (widget)); +#else gtk_misc_get_alignment(GTK_MISC(widget), &xalign, &yalign); +#endif nx = x - MAX(width - eyes_applet->eye_width, 0) * xalign - eyes_applet->eye_width / 2; ny = y - MAX(height- eyes_applet->eye_height, 0) * yalign - eyes_applet->eye_height / 2; @@ -226,13 +250,26 @@ setup_eyes (EyesApplet *eyes_applet) 0); if ((eyes_applet->num_eyes != 1) && (i == 0)) { - gtk_misc_set_alignment (GTK_MISC (eyes_applet->eyes[i]), 1.0, 0.5); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_set_halign (eyes_applet->eyes[i], GTK_ALIGN_END); + gtk_widget_set_valign (eyes_applet->eyes[i], GTK_ALIGN_CENTER); + } + else if ((eyes_applet->num_eyes != 1) && (i == eyes_applet->num_eyes - 1)) { + gtk_widget_set_halign (eyes_applet->eyes[i], GTK_ALIGN_START); + gtk_widget_set_valign (eyes_applet->eyes[i], GTK_ALIGN_CENTER); + } + else { + gtk_widget_set_halign (eyes_applet->eyes[i], GTK_ALIGN_CENTER); + gtk_widget_set_valign (eyes_applet->eyes[i], GTK_ALIGN_CENTER); +#else + gtk_misc_set_alignment (GTK_MISC (eyes_applet->eyes[i]), 1.0, 0.5); } else if ((eyes_applet->num_eyes != 1) && (i == eyes_applet->num_eyes - 1)) { gtk_misc_set_alignment (GTK_MISC (eyes_applet->eyes[i]), 0.0, 0.5); } else { gtk_misc_set_alignment (GTK_MISC (eyes_applet->eyes[i]), 0.5, 0.5); +#endif } gtk_widget_realize (eyes_applet->eyes[i]); diff --git a/geyes/themes.c b/geyes/themes.c index 325a14af..e562bf8a 100644 --- a/geyes/themes.c +++ b/geyes/themes.c @@ -320,7 +320,11 @@ properties_cb (GtkAction *action, label = gtk_label_new (_(title)); gtk_label_set_use_markup (GTK_LABEL (label), TRUE); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_set_halign (label, GTK_ALIGN_START); +#else gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); +#endif gtk_box_pack_start (GTK_BOX (category_vbox), label, FALSE, FALSE, 0); g_free (title); @@ -338,7 +342,11 @@ properties_cb (GtkAction *action, gtk_widget_show (control_vbox); label = gtk_label_new_with_mnemonic (_("_Select a theme:")); +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_set_halign (label, GTK_ALIGN_START); +#else gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); +#endif gtk_box_pack_start (GTK_BOX (control_vbox), label, FALSE, FALSE, 0); scrolled = gtk_scrolled_window_new (NULL, NULL); |