[sysprof/wip/gtk4] Adapt to new gtk+ API changes



commit 4054390a1012597d369275b6fbb88c39d41ee5aa
Author: Timm Bäder <mail baedert org>
Date:   Wed Jan 10 11:17:39 2018 +0100

    Adapt to new gtk+ API changes

 lib/sp-theme-manager.c        |   14 +++++++-------
 lib/sp-visualizer-view.c      |   35 +++++++++++++++++++++++------------
 src/resources/ui/sp-window.ui |    2 +-
 src/sp-application.c          |    6 +++---
 4 files changed, 34 insertions(+), 23 deletions(-)
---
diff --git a/lib/sp-theme-manager.c b/lib/sp-theme-manager.c
index 5cf2108..904b570 100644
--- a/lib/sp-theme-manager.c
+++ b/lib/sp-theme-manager.c
@@ -54,8 +54,8 @@ theme_resource_free (gpointer data)
 
       if (theme_resource->provider != NULL)
         {
-          gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
-                                                        GTK_STYLE_PROVIDER (theme_resource->provider));
+          gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
+                                                         GTK_STYLE_PROVIDER (theme_resource->provider));
           g_clear_object (&theme_resource->provider);
         }
 
@@ -117,17 +117,17 @@ sp_theme_manager_do_reload (gpointer data)
             {
               theme_resource->provider = gtk_css_provider_new ();
               gtk_css_provider_load_from_resource (theme_resource->provider, theme_resource->resource);
-              gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
-                                                         GTK_STYLE_PROVIDER (theme_resource->provider),
-                                                         GTK_STYLE_PROVIDER_PRIORITY_APPLICATION - 1);
+              gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+                                                          GTK_STYLE_PROVIDER (theme_resource->provider),
+                                                          GTK_STYLE_PROVIDER_PRIORITY_APPLICATION - 1);
             }
         }
       else
         {
           if (theme_resource->provider != NULL)
             {
-              gtk_style_context_remove_provider_for_screen (gdk_screen_get_default (),
-                                                            GTK_STYLE_PROVIDER (theme_resource->provider));
+              gtk_style_context_remove_provider_for_display (gdk_display_get_default (),
+                                                             GTK_STYLE_PROVIDER (theme_resource->provider));
               g_clear_object (&theme_resource->provider);
             }
         }
diff --git a/lib/sp-visualizer-view.c b/lib/sp-visualizer-view.c
index 17a2b2a..4aba778 100644
--- a/lib/sp-visualizer-view.c
+++ b/lib/sp-visualizer-view.c
@@ -312,6 +312,9 @@ sp_visualizer_view_list_button_press_event (SpVisualizerView *self,
                                             SpVisualizerList *list)
 {
   SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
+  guint button;
+  GdkModifierType modifier_state;
+  double x, y;
 
   g_assert (SP_IS_VISUALIZER_VIEW (self));
   g_assert (ev != NULL);
@@ -320,7 +323,9 @@ sp_visualizer_view_list_button_press_event (SpVisualizerView *self,
   if (priv->reader == NULL)
     return GDK_EVENT_PROPAGATE;
 
-  if (ev->button != GDK_BUTTON_PRIMARY)
+  gdk_event_get_button ((GdkEvent*)ev, &button);
+
+  if (button != GDK_BUTTON_PRIMARY)
     {
       if (sp_selection_get_has_selection (priv->selection))
         {
@@ -330,12 +335,16 @@ sp_visualizer_view_list_button_press_event (SpVisualizerView *self,
       return GDK_EVENT_PROPAGATE;
     }
 
-  if ((ev->state & GDK_SHIFT_MASK) == 0)
+  gdk_event_get_state ((GdkEvent *)ev, &modifier_state);
+
+  if ((modifier_state & GDK_SHIFT_MASK) == 0)
     sp_selection_unselect_all (priv->selection);
 
   priv->button_pressed = TRUE;
 
-  priv->drag_begin_at = get_time_from_coordinates (self, ev->x, ev->y);
+  gdk_event_get_coords ((GdkEvent *)ev, &x, &y);
+
+  priv->drag_begin_at = get_time_from_coordinates (self, x, y);
   priv->drag_selection_at = priv->drag_begin_at;
 
   gtk_widget_queue_draw (GTK_WIDGET (self));
@@ -349,12 +358,15 @@ sp_visualizer_view_list_button_release_event (SpVisualizerView *self,
                                               SpVisualizerList *list)
 {
   SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
+  guint button;
 
   g_assert (SP_IS_VISUALIZER_VIEW (self));
   g_assert (ev != NULL);
   g_assert (SP_IS_VISUALIZER_LIST (list));
 
-  if (!priv->button_pressed || ev->button != GDK_BUTTON_PRIMARY)
+  gdk_event_get_button ((GdkEvent*)ev, &button);
+
+  if (!priv->button_pressed || button != GDK_BUTTON_PRIMARY)
     return GDK_EVENT_PROPAGATE;
 
   priv->button_pressed = FALSE;
@@ -379,6 +391,7 @@ sp_visualizer_view_list_motion_notify_event (SpVisualizerView *self,
                                              SpVisualizerList *list)
 {
   SpVisualizerViewPrivate *priv = sp_visualizer_view_get_instance_private (self);
+  double x, y;
 
   g_assert (SP_IS_VISUALIZER_VIEW (self));
   g_assert (ev != NULL);
@@ -387,7 +400,10 @@ sp_visualizer_view_list_motion_notify_event (SpVisualizerView *self,
   if (!priv->button_pressed)
     return GDK_EVENT_PROPAGATE;
 
-  priv->drag_selection_at = get_time_from_coordinates (self, ev->x, ev->y);
+
+  gdk_event_get_coords ((GdkEvent *)ev, &x, &y);
+
+  priv->drag_selection_at = get_time_from_coordinates (self, x, y);
 
   gtk_widget_queue_draw (GTK_WIDGET (self));
 
@@ -398,19 +414,14 @@ static void
 sp_visualizer_view_list_realize_after (SpVisualizerView *self,
                                        SpVisualizerList *list)
 {
-  GdkDisplay *display;
-  GdkWindow *window;
   GdkCursor *cursor;
 
   g_assert (SP_IS_VISUALIZER_VIEW (self));
   g_assert (SP_IS_VISUALIZER_LIST (list));
 
-  window = gtk_widget_get_window (GTK_WIDGET (list));
-  display = gdk_window_get_display (window);
-  cursor = gdk_cursor_new_from_name (display, "text");
+  cursor = gdk_cursor_new_from_name ("text", NULL);
 
-  /* TODO: gtk_widget_set_cursor is still private */
-  /*gdk_window_set_cursor (window, cursor);*/
+  gtk_widget_set_cursor (GTK_WIDGET (self), cursor);
 
   g_clear_object (&cursor);
 }
diff --git a/src/resources/ui/sp-window.ui b/src/resources/ui/sp-window.ui
index 705eb2c..beecd02 100644
--- a/src/resources/ui/sp-window.ui
+++ b/src/resources/ui/sp-window.ui
@@ -7,7 +7,7 @@
     <property name="show-menubar">false</property>
     <child type="titlebar">
       <object class="GtkHeaderBar">
-        <property name="show-close-button">true</property>
+        <property name="show-title-buttons">true</property>
         <property name="visible">true</property>
         <property name="title" translatable="yes">Sysprof</property>
         <child type="title">
diff --git a/src/sp-application.c b/src/sp-application.c
index 0203ac7..6497a9d 100644
--- a/src/sp-application.c
+++ b/src/sp-application.c
@@ -108,9 +108,9 @@ sp_application_startup (GApplication *application)
 
   provider = gtk_css_provider_new ();
   gtk_css_provider_load_from_resource (provider, "/org/gnome/sysprof/theme/shared.css");
-  gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
-                                             GTK_STYLE_PROVIDER (provider),
-                                             GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+  gtk_style_context_add_provider_for_display (gdk_display_get_default (),
+                                              GTK_STYLE_PROVIDER (provider),
+                                              GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 
   for (guint i = 0; default_accels[i].action_name; i++)
     gtk_application_set_accels_for_action (GTK_APPLICATION (application),


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]