Skip to content

Commit

Permalink
require GTK+ 3.22 and GLib 2.50
Browse files Browse the repository at this point in the history
  • Loading branch information
monsta committed Jan 31, 2018
1 parent f553591 commit ab79877
Show file tree
Hide file tree
Showing 39 changed files with 42 additions and 938 deletions.
8 changes: 0 additions & 8 deletions applets/clock/clock-location-tile.c
Expand Up @@ -277,25 +277,17 @@ clock_location_tile_fill (ClockLocationTile *this)

priv->city_label = gtk_label_new (NULL);
gtk_widget_set_margin_end (priv->city_label, 3);
#if GTK_CHECK_VERSION (3, 16, 0)
gtk_label_set_xalign (GTK_LABEL (priv->city_label), 0.0);
gtk_label_set_yalign (GTK_LABEL (priv->city_label), 0.0);
#else
gtk_misc_set_alignment (GTK_MISC (priv->city_label), 0, 0);
#endif

head_section = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_box_pack_start (GTK_BOX (head_section), priv->city_label, FALSE, FALSE, 0);

priv->time_label = gtk_label_new (NULL);
gtk_label_set_width_chars (GTK_LABEL (priv->time_label), 20);
gtk_widget_set_margin_end (priv->time_label, 3);
#if GTK_CHECK_VERSION (3, 16, 0)
gtk_label_set_xalign (GTK_LABEL (priv->time_label), 0.0);
gtk_label_set_yalign (GTK_LABEL (priv->time_label), 0.0);
#else
gtk_misc_set_alignment (GTK_MISC (priv->time_label), 0, 0);
#endif

priv->weather_icon = gtk_image_new ();
gtk_widget_set_valign (priv->weather_icon, GTK_ALIGN_START);
Expand Down
6 changes: 1 addition & 5 deletions applets/clock/clock-utils.c
Expand Up @@ -72,13 +72,9 @@ clock_utils_display_help (GtkWidget *widget,
uri = g_strdup_printf ("help:%s/%s", doc_id, link_id);
else
uri = g_strdup_printf ("help:%s", doc_id);
#if GTK_CHECK_VERSION (3, 22, 0)

gtk_show_uri_on_window (NULL, uri,
gtk_get_current_event_time (), &error);
#else
gtk_show_uri (gtk_widget_get_screen (widget), uri,
gtk_get_current_event_time (), &error);
#endif
g_free (uri);

if (error &&
Expand Down
65 changes: 0 additions & 65 deletions applets/clock/clock.c
Expand Up @@ -258,10 +258,6 @@ calculate_minimum_width (GtkWidget *widget,
PangoContext *pango_context;
PangoLayout *layout;
int width, height;
#if !GTK_CHECK_VERSION (3, 20, 0)
int focus_width = 0;
int focus_pad = 0;
#endif
GtkStyleContext *style_context;
GtkStateFlags state;
GtkBorder padding;
Expand All @@ -278,16 +274,8 @@ calculate_minimum_width (GtkWidget *widget,
state = gtk_widget_get_state_flags (widget);
style_context = gtk_widget_get_style_context (widget);
gtk_style_context_get_padding (style_context, state, &padding);
#if GTK_CHECK_VERSION (3, 20, 0)
width += padding.left + padding.right;
#else
gtk_style_context_get_style (style_context,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);

width += 2 * (focus_width + focus_pad) + padding.left + padding.right;
#endif
return width;
}

Expand Down Expand Up @@ -384,10 +372,6 @@ calculate_minimum_height (GtkWidget *widget,
GtkBorder padding;
PangoContext *pango_context;
PangoFontMetrics *metrics;
#if !GTK_CHECK_VERSION (3, 20, 0)
int focus_width = 0;
int focus_pad = 0;
#endif
int ascent;
int descent;
int thickness;
Expand All @@ -407,12 +391,6 @@ calculate_minimum_height (GtkWidget *widget,
pango_font_metrics_unref (metrics);

gtk_style_context_get_padding (style_context, state, &padding);
#if !GTK_CHECK_VERSION (3, 20, 0)
gtk_style_context_get_style (style_context,
"focus-line-width", &focus_width,
"focus-padding", &focus_pad,
NULL);
#endif

if (orientation == MATE_PANEL_APPLET_ORIENT_UP
|| orientation == MATE_PANEL_APPLET_ORIENT_DOWN) {
Expand All @@ -421,11 +399,7 @@ calculate_minimum_height (GtkWidget *widget,
thickness = padding.left + padding.right;
}

#if GTK_CHECK_VERSION (3, 20, 0)
return PANGO_PIXELS (ascent + descent) + thickness;
#else
return PANGO_PIXELS (ascent + descent) + 2 * (focus_width + focus_pad) + thickness;
#endif
}

static gboolean
Expand Down Expand Up @@ -874,9 +848,7 @@ position_calendar_popup (ClockData *cd)
{
GtkRequisition req;
GtkAllocation allocation;
#if GTK_CHECK_VERSION (3, 22, 0)
GdkDisplay *display;
#endif
GdkScreen *screen;
GdkRectangle monitor;
GdkGravity gravity = GDK_GRAVITY_NORTH_WEST;
Expand All @@ -900,19 +872,11 @@ position_calendar_popup (ClockData *cd)
button_h = allocation.height;

screen = gtk_window_get_screen (GTK_WINDOW (cd->calendar_popup));
#if GTK_CHECK_VERSION (3, 22, 0)
display = gdk_screen_get_display (screen);

n = gdk_display_get_n_monitors (display);
#else
n = gdk_screen_get_n_monitors (screen);
#endif
for (i = 0; i < n; i++) {
#if GTK_CHECK_VERSION (3, 22, 0)
gdk_monitor_get_geometry (gdk_display_get_monitor (display, i), &monitor);
#else
gdk_screen_get_monitor_geometry (screen, i, &monitor);
#endif
if (x >= monitor.x && x <= monitor.x + monitor.width &&
y >= monitor.y && y <= monitor.y + monitor.height) {
found_monitor = TRUE;
Expand Down Expand Up @@ -1308,7 +1272,6 @@ clock_update_text_gravity (GtkWidget *label)
pango_context_set_base_gravity (context, PANGO_GRAVITY_AUTO);
}

#if GTK_CHECK_VERSION (3, 20, 0)
static inline void
force_no_button_padding (GtkWidget *widget)
{
Expand All @@ -1328,30 +1291,6 @@ force_no_button_padding (GtkWidget *widget)

gtk_widget_set_name (widget, "clock-applet-button");
}
#else
static inline void
force_no_focus_padding (GtkWidget *widget)
{
static gboolean first_time = TRUE;
GtkCssProvider *provider;

if (first_time) {
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider,
"#clock-applet-button {\n"
" -GtkWidget-focus-line-width: 0px;\n"
" -GtkWidget-focus-padding: 0px; }",
-1, NULL);
gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
first_time = FALSE;
}

gtk_widget_set_name (widget, "clock-applet-button");
}
#endif

static GtkWidget *
create_main_clock_button (void)
Expand All @@ -1361,11 +1300,7 @@ create_main_clock_button (void)
button = gtk_toggle_button_new ();
gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);

#if GTK_CHECK_VERSION (3, 20, 0)
force_no_button_padding (button);
#else
force_no_focus_padding (button);
#endif

return button;
}
Expand Down
11 changes: 1 addition & 10 deletions applets/fish/fish.c
Expand Up @@ -152,13 +152,9 @@ static void show_help(FishApplet* fish, const char* link_id)
uri = g_strdup_printf ("help:%s/%s", FISH_HELP_DOC, link_id);
else
uri = g_strdup_printf ("help:%s", FISH_HELP_DOC);
#if GTK_CHECK_VERSION (3, 22, 0)

gtk_show_uri_on_window (NULL, uri,
gtk_get_current_event_time (), &error);
#else
gtk_show_uri (gtk_widget_get_screen (GTK_WIDGET (fish)), uri,
gtk_get_current_event_time (), &error);
#endif
g_free (uri);

if (error &&
Expand Down Expand Up @@ -889,13 +885,8 @@ static void display_fortune_dialog(FishApplet* fish)
gtk_label_set_ellipsize (GTK_LABEL (fish->fortune_label),
PANGO_ELLIPSIZE_MIDDLE);
fish->fortune_cmd_label = gtk_label_new ("");
#if GTK_CHECK_VERSION (3, 16, 0)
gtk_label_set_xalign (GTK_LABEL (fish->fortune_cmd_label), 0.0);
gtk_label_set_yalign (GTK_LABEL (fish->fortune_cmd_label), 0.5);
#else
gtk_misc_set_alignment (GTK_MISC (fish->fortune_cmd_label),
0, 0.5);
#endif

vbox = gtk_dialog_get_content_area (GTK_DIALOG (fish->fortune_dialog));
gtk_box_pack_start (GTK_BOX (vbox),
Expand Down
30 changes: 0 additions & 30 deletions applets/notification_area/main.c
Expand Up @@ -111,11 +111,7 @@ static void help_cb(GtkAction* action, NaTrayApplet* applet)
#define NA_HELP_DOC "mate-user-guide"

uri = g_strdup_printf("help:%s/%s", NA_HELP_DOC, "panels-notification-area");
#if GTK_CHECK_VERSION (3, 22, 0)
gtk_show_uri_on_window (NULL, uri, gtk_get_current_event_time (), &error);
#else
gtk_show_uri(gtk_widget_get_screen(GTK_WIDGET(applet)), uri, gtk_get_current_event_time(), &error);
#endif
g_free(uri);

if (error && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
Expand Down Expand Up @@ -300,26 +296,6 @@ na_tray_applet_focus (GtkWidget *widget,
return GTK_WIDGET_CLASS (na_tray_applet_parent_class)->focus (widget, direction);
}

#if !GTK_CHECK_VERSION (3, 20, 0)
static inline void
force_no_focus_padding (GtkWidget *widget)
{
GtkCssProvider *provider;

provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider,
"NaTrayApplet {\n"
" -GtkWidget-focus-line-width: 0px;\n"
" -GtkWidget-focus-padding: 0px;\n"
"}",
-1, NULL);
gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
}
#endif

static void
na_tray_applet_class_init (NaTrayAppletClass *class)
{
Expand Down Expand Up @@ -361,9 +337,7 @@ na_tray_applet_class_init (NaTrayAppletClass *class)

g_type_class_add_private (class, sizeof (NaTrayAppletPrivate));

#if GTK_CHECK_VERSION (3, 20, 0)
gtk_widget_class_set_css_name (widget_class, "na-tray-applet");
#endif
}

static void
Expand All @@ -390,10 +364,6 @@ na_tray_applet_init (NaTrayApplet *applet)

mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet),
MATE_PANEL_APPLET_HAS_HANDLE|MATE_PANEL_APPLET_EXPAND_MINOR);

#if !GTK_CHECK_VERSION (3, 20, 0)
force_no_focus_padding (GTK_WIDGET (applet));
#endif
}

static gboolean
Expand Down
4 changes: 2 additions & 2 deletions applets/notification_area/status-notifier/sn-dbus-menu.c
Expand Up @@ -187,11 +187,11 @@ get_layout_cb (GObject *source_object,

g_hash_table_remove_all (menu->items);
layout_parse (menu, layout, GTK_MENU (menu));
#if GTK_CHECK_VERSION (3, 22, 0)

/* Reposition menu to accomodate any size changes */
/* Menu size never changes with GTK 3.20 or earlier */
gtk_menu_reposition(GTK_MENU(menu));
#endif

g_variant_unref (layout);
}

Expand Down
2 changes: 0 additions & 2 deletions applets/notification_area/status-notifier/sn-item-v0.c
Expand Up @@ -1372,9 +1372,7 @@ sn_item_v0_class_init (SnItemV0Class *v0_class)

widget_class->size_allocate = sn_item_v0_size_allocate;

#if GTK_CHECK_VERSION (3, 20, 0)
gtk_widget_class_set_css_name (widget_class, "sn-item");
#endif

install_properties (object_class);
}
Expand Down

0 comments on commit ab79877

Please sign in to comment.