diff options
author | monsta <[email protected]> | 2016-11-22 00:00:24 +0300 |
---|---|---|
committer | monsta <[email protected]> | 2016-11-22 00:00:24 +0300 |
commit | ce1cbb1ec0c2ca72457fedb88aef870b9a5036fd (patch) | |
tree | a149506e95dcde4970f0281867668294d7909091 /applets | |
parent | c1c672e45ffa331677a582289691e079cdde5138 (diff) | |
download | mate-power-manager-ce1cbb1ec0c2ca72457fedb88aef870b9a5036fd.tar.bz2 mate-power-manager-ce1cbb1ec0c2ca72457fedb88aef870b9a5036fd.tar.xz |
move to GTK+3 (>= 3.14), drop GTK+2 code and --with-gtk build option
and require mate-panel >= 1.17
Diffstat (limited to 'applets')
-rw-r--r-- | applets/brightness/Makefile.am | 1 | ||||
-rw-r--r-- | applets/brightness/brightness-applet.c | 119 | ||||
-rw-r--r-- | applets/inhibit/Makefile.am | 1 | ||||
-rw-r--r-- | applets/inhibit/inhibit-applet.c | 49 |
4 files changed, 0 insertions, 170 deletions
diff --git a/applets/brightness/Makefile.am b/applets/brightness/Makefile.am index 026133d..7962787 100644 --- a/applets/brightness/Makefile.am +++ b/applets/brightness/Makefile.am @@ -5,7 +5,6 @@ AM_CPPFLAGS = \ $(CAIRO_CFLAGS) \ $(PANEL_CFLAGS) \ $(LIBNOTIFY_CFLAGS) \ - $(GTKUNIQUE_CFLAGS) \ -DBINDIR=\"$(bindir)\" \ -DMATELOCALEDIR=\""$(datadir)/locale"\" \ -DDATADIR=\"$(datadir)\" \ diff --git a/applets/brightness/brightness-applet.c b/applets/brightness/brightness-applet.c index 5cd7f6b..8e5345d 100644 --- a/applets/brightness/brightness-applet.c +++ b/applets/brightness/brightness-applet.c @@ -85,11 +85,7 @@ static void gpm_applet_check_size (GpmBrightnessApplet *applet); static gboolean gpm_applet_draw_cb (GpmBrightnessApplet *applet); static void gpm_applet_change_background_cb (GpmBrightnessApplet *applet, MatePanelAppletBackgroundType arg1, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_pattern_t *arg2, gpointer data); -#else - GdkColor *arg2, GdkPixmap *arg3, gpointer data); -#endif static void gpm_applet_theme_change_cb (GtkIconTheme *icon_theme, gpointer data); static void gpm_applet_stop_scroll_events_cb (GtkWidget *widget, GdkEvent *event); static gboolean gpm_applet_destroy_popup_cb (GpmBrightnessApplet *applet); @@ -263,16 +259,10 @@ static gboolean gpm_applet_draw_cb (GpmBrightnessApplet *applet) { gint w, h, bg_type; -#if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA color; cairo_t *cr; cairo_pattern_t *pattern; GtkStyleContext *context; -#else - GdkColor color; - GdkGC *gc; - GdkPixmap *background; -#endif GtkAllocation allocation; if (gtk_widget_get_window (GTK_WIDGET(applet)) == NULL) { @@ -295,74 +285,38 @@ gpm_applet_draw_cb (GpmBrightnessApplet *applet) w = allocation.width; h = allocation.height; -#if GTK_CHECK_VERSION (3, 0, 0) cr = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET(applet))); -#else - gc = gdk_gc_new (gtk_widget_get_window (GTK_WIDGET(applet))); -#endif /* draw pixmap background */ -#if GTK_CHECK_VERSION (3, 0, 0) bg_type = mate_panel_applet_get_background (MATE_PANEL_APPLET (applet), &color, &pattern); -#else - bg_type = mate_panel_applet_get_background (MATE_PANEL_APPLET (applet), &color, &background); -#endif if (bg_type == PANEL_PIXMAP_BACKGROUND && !applet->popped) { /* fill with given background pixmap */ -#if GTK_CHECK_VERSION (3, 0, 0) cairo_set_source (cr, pattern); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); -#else - gdk_draw_drawable (gtk_widget_get_window (GTK_WIDGET(applet)), gc, background, 0, 0, 0, 0, w, h); -#endif } /* draw color background */ if (bg_type == PANEL_COLOR_BACKGROUND && !applet->popped) { -#if GTK_CHECK_VERSION (3, 0, 0) gdk_cairo_set_source_rgba (cr, &color); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); -#else - gdk_gc_set_rgb_fg_color (gc,&color); - gdk_gc_set_fill (gc,GDK_SOLID); - gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h); -#endif } /* fill with selected color if popped */ if (applet->popped) { -#if GTK_CHECK_VERSION (3, 0, 0) context = gtk_widget_get_style_context (GTK_WIDGET(applet)); gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED, &color); gdk_cairo_set_source_rgba (cr, &color); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); -#else - color = gtk_rc_get_style (GTK_WIDGET(applet))->bg[GTK_STATE_SELECTED]; - gdk_gc_set_rgb_fg_color (gc,&color); - gdk_gc_set_fill (gc,GDK_SOLID); - gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h); -#endif } /* draw icon at center */ -#if GTK_CHECK_VERSION (3, 0, 0) gdk_cairo_set_source_pixbuf (cr, applet->icon, (w - applet->icon_width)/2, (h - applet->icon_height)/2); cairo_paint (cr); -#else - gdk_draw_pixbuf (gtk_widget_get_window (GTK_WIDGET(applet)), gc, applet->icon, - 0, 0, (w - applet->icon_width)/2, (h - applet->icon_height)/2, - applet->icon_width, applet->icon_height, - GDK_RGB_DITHER_NONE, 0, 0); -#endif -#if GTK_CHECK_VERSION (3, 0, 0) cairo_destroy (cr); -#else - g_object_unref (gc); -#endif return TRUE; } @@ -375,11 +329,7 @@ gpm_applet_draw_cb (GpmBrightnessApplet *applet) static void gpm_applet_change_background_cb (GpmBrightnessApplet *applet, MatePanelAppletBackgroundType arg1, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_pattern_t *arg2, gpointer data) -#else - GdkColor *arg2, GdkPixmap *arg3, gpointer data) -#endif { gtk_widget_queue_draw (GTK_WIDGET (applet)); } @@ -527,11 +477,7 @@ gpm_applet_key_press_cb (GpmBrightnessApplet *applet, GdkEventKey *event) gdk_keyboard_ungrab (GDK_CURRENT_TIME); gdk_pointer_ungrab (GDK_CURRENT_TIME); gtk_grab_remove (GTK_WIDGET(applet)); -#if GTK_CHECK_VERSION (3, 0, 0) gtk_widget_set_state_flags (GTK_WIDGET(applet), GTK_STATE_FLAG_NORMAL, TRUE); -#else - gtk_widget_set_state (GTK_WIDGET(applet), GTK_STATE_NORMAL); -#endif gtk_widget_hide (applet->popup); applet->popped = FALSE; gpm_applet_draw_cb (applet); @@ -602,7 +548,6 @@ gpm_applet_scroll_cb (GpmBrightnessApplet *applet, GdkEventScroll *event) return FALSE; } -#if GTK_CHECK_VERSION (3, 0, 0) /** * on_popup_button_press: * @applet: Brightness applet instance @@ -631,7 +576,6 @@ on_popup_button_press (GtkWidget *widget, return FALSE; } -#endif /** * gpm_applet_create_popup: @@ -649,18 +593,10 @@ gpm_applet_create_popup (GpmBrightnessApplet *applet) /* slider */ if (MATE_PANEL_APPLET_VERTICAL(orientation)) { -#if GTK_CHECK_VERSION (3, 0, 0) applet->slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1); -#else - applet->slider = gtk_hscale_new_with_range (0, 100, 1); -#endif gtk_widget_set_size_request (applet->slider, 100, -1); } else { -#if GTK_CHECK_VERSION (3, 0, 0) applet->slider = gtk_scale_new_with_range (GTK_ORIENTATION_VERTICAL, 0, 100, 1); -#else - applet->slider = gtk_vscale_new_with_range (0, 100, 1); -#endif gtk_widget_set_size_request (applet->slider, -1, 100); } gtk_range_set_inverted (GTK_RANGE(applet->slider), TRUE); @@ -682,17 +618,9 @@ gpm_applet_create_popup (GpmBrightnessApplet *applet) /* box */ if (MATE_PANEL_APPLET_VERTICAL(orientation)) { -#if GTK_CHECK_VERSION (3, 0, 0) box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 1); -#else - box = gtk_hbox_new (FALSE, 1); -#endif } else { -#if GTK_CHECK_VERSION (3, 0, 0) box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 1); -#else - box = gtk_vbox_new (FALSE, 1); -#endif } gtk_box_pack_start (GTK_BOX(box), applet->btn_plus, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX(box), applet->slider, TRUE, TRUE, 0); @@ -705,25 +633,16 @@ gpm_applet_create_popup (GpmBrightnessApplet *applet) /* window */ applet->popup = gtk_window_new (GTK_WINDOW_POPUP); -#if !GTK_CHECK_VERSION (3, 0, 0) - GTK_WIDGET_UNSET_FLAGS (applet->popup, GTK_TOPLEVEL); -#endif gtk_window_set_type_hint (GTK_WINDOW(applet->popup), GDK_WINDOW_TYPE_HINT_UTILITY); -#if !GTK_CHECK_VERSION (3, 0, 0) - gtk_widget_set_parent (applet->popup, GTK_WIDGET(applet)); -#endif gtk_container_add (GTK_CONTAINER(applet->popup), frame); -#if GTK_CHECK_VERSION (3, 0, 0) /* window events */ g_signal_connect (G_OBJECT(applet->popup), "button-press-event", G_CALLBACK (on_popup_button_press), applet); g_signal_connect (G_OBJECT(applet->popup), "key-press-event", G_CALLBACK(gpm_applet_key_press_cb), applet); -#endif -#if GTK_CHECK_VERSION (3, 0, 0) /* Set volume control frame, slider and toplevel window to follow panel volume control theme */ GtkWidget *toplevel = gtk_widget_get_toplevel (frame); GtkStyleContext *context; @@ -733,7 +652,6 @@ gpm_applet_create_popup (GpmBrightnessApplet *applet) GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel)); GdkVisual *visual = gdk_screen_get_rgba_visual(screen); gtk_widget_set_visual(GTK_WIDGET(toplevel), visual); -#endif } /** @@ -747,13 +665,11 @@ gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event) { GtkAllocation allocation, popup_allocation; gint orientation, x, y; -#if GTK_CHECK_VERSION (3, 0, 0) GdkWindow *window; GdkDisplay *display; GdkDeviceManager *device_manager; GdkDevice *pointer; GdkDevice *keyboard; -#endif /* react only to left mouse button */ if (event->button != 1) { @@ -762,36 +678,19 @@ gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event) /* if yet popped, release focus and hide then redraw applet unselected */ if (applet->popped) { -#if !GTK_CHECK_VERSION (3, 0, 0) - gdk_keyboard_ungrab (GDK_CURRENT_TIME); - gdk_pointer_ungrab (GDK_CURRENT_TIME); - gtk_grab_remove (GTK_WIDGET(applet)); - gtk_widget_set_state (GTK_WIDGET(applet), GTK_STATE_NORMAL); -#endif gtk_widget_hide (applet->popup); applet->popped = FALSE; -#if !GTK_CHECK_VERSION (3, 0, 0) - gpm_applet_draw_cb (applet); -#endif gpm_applet_update_tooltip (applet); return TRUE; } -#if GTK_CHECK_VERSION (3, 0, 0) /* don't show the popup if brightness is unavailable */ if (applet->level == -1) { return FALSE; } -#else - /* update UI for current brightness */ - gpm_applet_update_popup_level (applet); -#endif /* otherwise pop */ applet->popped = TRUE; -#if !GTK_CHECK_VERSION (3, 0, 0) - gpm_applet_draw_cb (applet); -#endif /* create a new popup (initial or if panel parameters changed) */ if (applet->popup == NULL) { @@ -839,7 +738,6 @@ gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event) gtk_window_move (GTK_WINDOW (applet->popup), x, y); /* grab input */ -#if GTK_CHECK_VERSION (3, 0, 0) window = gtk_widget_get_window (GTK_WIDGET (applet->popup)); display = gdk_window_get_display (window); device_manager = gdk_display_get_device_manager (display); @@ -853,18 +751,6 @@ gpm_applet_popup_cb (GpmBrightnessApplet *applet, GdkEventButton *event) GDK_OWNERSHIP_NONE, TRUE, GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK, NULL, GDK_CURRENT_TIME); -#else - gtk_widget_grab_focus (GTK_WIDGET(applet)); - gtk_grab_add (GTK_WIDGET(applet)); - gdk_pointer_grab (gtk_widget_get_window (GTK_WIDGET(applet)), TRUE, - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK, - NULL, NULL, GDK_CURRENT_TIME); - gdk_keyboard_grab (gtk_widget_get_window (GTK_WIDGET(applet)), - TRUE, GDK_CURRENT_TIME); - gtk_widget_set_state (GTK_WIDGET(applet), GTK_STATE_SELECTED); -#endif return TRUE; } @@ -1150,13 +1036,8 @@ gpm_brightness_applet_init (GpmBrightnessApplet *applet) /* We use g_signal_connect_after because letting the panel draw * the background is the only way to have the correct * background when a theme defines a background picture. */ -#if GTK_CHECK_VERSION (3, 0, 0) g_signal_connect_after (G_OBJECT(applet), "draw", G_CALLBACK(gpm_applet_draw_cb), NULL); -#else - g_signal_connect_after (G_OBJECT(applet), "expose-event", - G_CALLBACK(gpm_applet_draw_cb), NULL); -#endif g_signal_connect (G_OBJECT(applet), "change-background", G_CALLBACK(gpm_applet_change_background_cb), NULL); diff --git a/applets/inhibit/Makefile.am b/applets/inhibit/Makefile.am index cc5d2d7..111ab2b 100644 --- a/applets/inhibit/Makefile.am +++ b/applets/inhibit/Makefile.am @@ -5,7 +5,6 @@ AM_CPPFLAGS = \ $(CAIRO_CFLAGS) \ $(PANEL_CFLAGS) \ $(LIBNOTIFY_CFLAGS) \ - $(GTKUNIQUE_CFLAGS) \ -DBINDIR=\"$(bindir)\" \ -DMATELOCALEDIR=\""$(datadir)/locale"\" \ -DDATADIR=\"$(datadir)\" \ diff --git a/applets/inhibit/inhibit-applet.c b/applets/inhibit/inhibit-applet.c index 8acec87..1c3f836 100644 --- a/applets/inhibit/inhibit-applet.c +++ b/applets/inhibit/inhibit-applet.c @@ -248,27 +248,16 @@ static gboolean gpm_applet_draw_cb (GpmInhibitApplet *applet) { gint w, h, bg_type; -#if GTK_CHECK_VERSION (3, 0, 0) GdkRGBA color; cairo_t *cr; cairo_pattern_t *pattern; GtkStyleContext *context; -#else - GdkColor color; - GdkGC *gc; - GdkPixmap *background; -#endif GtkAllocation allocation; if (gtk_widget_get_window (GTK_WIDGET(applet)) == NULL) { return FALSE; } -#if !GTK_CHECK_VERSION (3, 0, 0) - /* Clear the window so we can draw on it later */ - gdk_window_clear(gtk_widget_get_window (GTK_WIDGET (applet))); -#endif - /* retrieve applet size */ gpm_applet_get_icon (applet); gpm_applet_check_size (applet); @@ -285,58 +274,29 @@ gpm_applet_draw_cb (GpmInhibitApplet *applet) w = allocation.width; h = allocation.height; -#if GTK_CHECK_VERSION (3, 0, 0) cr = gdk_cairo_create (gtk_widget_get_window (GTK_WIDGET(applet))); -#else - gc = gdk_gc_new (gtk_widget_get_window (GTK_WIDGET(applet))); -#endif /* draw pixmap background */ -#if GTK_CHECK_VERSION (3, 0, 0) bg_type = mate_panel_applet_get_background (MATE_PANEL_APPLET (applet), &color, &pattern); -#else - bg_type = mate_panel_applet_get_background (MATE_PANEL_APPLET (applet), &color, &background); -#endif if (bg_type == PANEL_PIXMAP_BACKGROUND) { /* fill with given background pixmap */ -#if GTK_CHECK_VERSION (3, 0, 0) cairo_set_source (cr, pattern); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); -#else - gdk_draw_drawable (gtk_widget_get_window (GTK_WIDGET(applet)), gc, background, 0, 0, 0, 0, w, h); -#endif } /* draw color background */ if (bg_type == PANEL_COLOR_BACKGROUND) { -#if GTK_CHECK_VERSION (3, 0, 0) gdk_cairo_set_source_rgba (cr, &color); cairo_rectangle (cr, 0, 0, w, h); cairo_fill (cr); -#else - gdk_gc_set_rgb_fg_color (gc,&color); - gdk_gc_set_fill (gc,GDK_SOLID); - gdk_draw_rectangle (gtk_widget_get_window (GTK_WIDGET(applet)), gc, TRUE, 0, 0, w, h); -#endif } /* draw icon at center */ -#if GTK_CHECK_VERSION (3, 0, 0) gdk_cairo_set_source_pixbuf (cr, applet->icon, (w - applet->icon_width)/2, (h - applet->icon_height)/2); cairo_paint (cr); -#else - gdk_draw_pixbuf (gtk_widget_get_window (GTK_WIDGET(applet)), gc, applet->icon, - 0, 0, (w - applet->icon_width)/2, (h - applet->icon_height)/2, - applet->icon_width, applet->icon_height, - GDK_RGB_DITHER_NONE, 0, 0); -#endif -#if GTK_CHECK_VERSION (3, 0, 0) cairo_destroy (cr); -#else - g_object_unref (gc); -#endif return TRUE; } @@ -349,11 +309,7 @@ gpm_applet_draw_cb (GpmInhibitApplet *applet) static void gpm_applet_change_background_cb (GpmInhibitApplet *applet, MatePanelAppletBackgroundType arg1, -#if GTK_CHECK_VERSION (3, 0, 0) cairo_pattern_t *arg2, -#else - GdkColor *arg2, GdkPixmap *arg3, -#endif gpointer data) { gtk_widget_queue_draw (GTK_WIDGET (applet)); @@ -645,13 +601,8 @@ gpm_inhibit_applet_init (GpmInhibitApplet *applet) g_signal_connect (G_OBJECT(applet), "button-press-event", G_CALLBACK(gpm_applet_click_cb), NULL); -#if GTK_CHECK_VERSION (3, 0, 0) g_signal_connect (G_OBJECT(applet), "draw", G_CALLBACK(gpm_applet_draw_cb), NULL); -#else - g_signal_connect (G_OBJECT(applet), "expose-event", - G_CALLBACK(gpm_applet_draw_cb), NULL); -#endif /* We use g_signal_connect_after because letting the panel draw * the background is the only way to have the correct |