[gnome-system-monitor] GsmColorButton: Remove a bunch of dead code



commit 0b34e4031e2e7d7971a65228c31fcafbb5e812f4
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Thu Aug 8 15:39:17 2013 +0200

    GsmColorButton: Remove a bunch of dead code

 src/gsm_color_button.c |  154 +++++-------------------------------------------
 src/gsm_color_button.h |    4 -
 src/interface.cpp      |   10 ++--
 src/load-graph.cpp     |    2 +-
 4 files changed, 21 insertions(+), 149 deletions(-)
---
diff --git a/src/gsm_color_button.c b/src/gsm_color_button.c
index 085c78b..65a6cc7 100644
--- a/src/gsm_color_button.c
+++ b/src/gsm_color_button.c
@@ -35,7 +35,6 @@ typedef struct
   gchar *title;                        /* Title for the color selection window */
 
   GdkRGBA color;
-  gboolean sensitive;
   gdouble fraction;            /* Only used by GSMCP_TYPE_PIE */
   guint type;
   cairo_surface_t *image_buffer;
@@ -54,7 +53,6 @@ enum
   PROP_TITLE,
   PROP_COLOR,
   PROP_TYPE, 
-  PROP_SENSITIVE
 };
 
 /* Signals */
@@ -76,20 +74,12 @@ static void gsm_color_button_set_property (GObject * object, guint param_id,
 static void gsm_color_button_get_property (GObject * object, guint param_id,
                                           GValue * value,
                                           GParamSpec * pspec);
-static void gsm_color_button_realize (GtkWidget * widget);
 static void gsm_color_button_get_preferred_width (GtkWidget * widget,
                                                   gint * minimum,
                                                   gint * natural);
 static void gsm_color_button_get_preferred_height (GtkWidget * widget,
                                                    gint * minimum,
                                                    gint * natural);
-static void gsm_color_button_size_allocate (GtkWidget * widget,
-                                           GtkAllocation * allocation);
-static void gsm_color_button_unrealize (GtkWidget * widget);
-static void gsm_color_button_state_changed (GtkWidget * widget,
-                                           GtkStateType previous_state);
-static void gsm_color_button_style_set (GtkWidget * widget,
-                                       GtkStyle * previous_style);
 static gint gsm_color_button_pressed (GtkWidget * widget,
                                      GdkEventButton * event);
 static gint gsm_color_button_released (GtkWidget * widget,
@@ -136,20 +126,13 @@ gsm_color_button_class_init (GsmColorButtonClass * klass)
   gobject_class->get_property = gsm_color_button_get_property;
   gobject_class->set_property = gsm_color_button_set_property;
   gobject_class->finalize = gsm_color_button_finalize;
-  widget_class->state_changed = gsm_color_button_state_changed;
   widget_class->get_preferred_width  = gsm_color_button_get_preferred_width;
   widget_class->get_preferred_height = gsm_color_button_get_preferred_height;
-  widget_class->size_allocate = gsm_color_button_size_allocate;
-  widget_class->realize = gsm_color_button_realize;
-  widget_class->unrealize = gsm_color_button_unrealize;
-  widget_class->style_set = gsm_color_button_style_set;
   widget_class->button_release_event = gsm_color_button_released;
   widget_class->button_press_event = gsm_color_button_pressed;
   widget_class->enter_notify_event = gsm_color_button_enter_notify;
   widget_class->leave_notify_event = gsm_color_button_leave_notify;
 
-  klass->color_set = NULL;
-
   g_object_class_install_property (gobject_class,
                                   PROP_PERCENTAGE,
                                   g_param_spec_double ("fraction",
@@ -176,29 +159,19 @@ gsm_color_button_class_init (GsmColorButtonClass * klass)
                                                       G_PARAM_READWRITE));
                                
   g_object_class_install_property (gobject_class,
-                                  PROP_SENSITIVE,
-                                  g_param_spec_boolean ("sensitive",
-                                                      _("Sensitive"),
-                                                      _("The sensitivity value"),
-                                                      TRUE,
-                                                      G_PARAM_READWRITE));
-
-  g_object_class_install_property (gobject_class,
                                   PROP_TYPE,
                                   g_param_spec_uint ("type", _("Type"),
                                                      _("Type of color picker"),
                                                      0, 4, 0,
                                                      G_PARAM_READWRITE));
 
-  color_button_signals[COLOR_SET] = g_signal_new ("color_set",
-                                                 G_TYPE_FROM_CLASS
-                                                 (gobject_class),
-                                                 G_SIGNAL_RUN_FIRST,
-                                                 G_STRUCT_OFFSET
-                                                 (GsmColorButtonClass,
-                                                  color_set), NULL, NULL,
-                                                 g_cclosure_marshal_VOID__VOID,
-                                                 G_TYPE_NONE, 0);
+  color_button_signals[COLOR_SET] = g_signal_new ("color-set",
+                                                  G_TYPE_FROM_CLASS
+                                                  (gobject_class),
+                                                  G_SIGNAL_RUN_FIRST,
+                                                  0, NULL, NULL,
+                                                  g_cclosure_marshal_VOID__VOID,
+                                                  G_TYPE_NONE, 0);
 }
 
 
@@ -248,8 +221,9 @@ render (GtkWidget * widget)
   gint width, height;
   gdouble radius, arc_start, arc_end;
   gdouble highlight_factor;
+  gboolean sensitive = gtk_widget_get_sensitive (widget);
 
-  if (priv->sensitive && priv->highlight > 0 ) {
+  if (sensitive && priv->highlight > 0) {
     highlight_factor = 0.125 * priv->highlight;
 
     color->red = MIN (1.0, color->red + highlight_factor);
@@ -257,7 +231,7 @@ render (GtkWidget * widget)
     color->blue = MIN (1.0, color->blue + highlight_factor) ;
     
     color->green = MIN (1.0, color->green + highlight_factor);
-  } else if (!priv->sensitive) {
+  } else if (!sensitive) {
     GtkStyleContext *context = gtk_widget_get_style_context (widget);
     
     gtk_style_context_get_color (context, GTK_STATE_FLAG_INSENSITIVE, color);
@@ -419,13 +393,6 @@ draw (GtkWidget * widget, cairo_t * cr, gpointer data)
 }
 
 static void
-gsm_color_button_realize (GtkWidget * widget)
-{
-  GTK_WIDGET_CLASS (gsm_color_button_parent_class)->realize (widget);
-  render (widget);
-}
-
-static void
 gsm_color_button_get_preferred_width (GtkWidget * widget,
                                       gint      * minimum,
                                       gint      * natural)
@@ -450,44 +417,6 @@ gsm_color_button_get_preferred_height (GtkWidget * widget,
 }
 
 static void
-gsm_color_button_size_allocate (GtkWidget * widget,
-                               GtkAllocation * allocation)
-{
-  g_return_if_fail (widget != NULL || allocation != NULL);
-  g_return_if_fail (GSM_IS_COLOR_BUTTON (widget));
-
-  gtk_widget_set_allocation (widget, allocation);
-
-  if (gtk_widget_get_realized (widget))
-    {
-      gdk_window_move_resize (gtk_widget_get_window (widget), allocation->x, allocation->y,
-                             allocation->width, allocation->height);
-    }
-}
-
-static void
-gsm_color_button_unrealize (GtkWidget * widget)
-{
-
-  GTK_WIDGET_CLASS (gsm_color_button_parent_class)->unrealize (widget);
-}
-
-static void
-gsm_color_button_style_set (GtkWidget * widget, GtkStyle * previous_style)
-{
-
-  GTK_WIDGET_CLASS (gsm_color_button_parent_class)->style_set (widget,
-                                                              previous_style);
-
-}
-
-static void
-gsm_color_button_state_changed (GtkWidget * widget,
-                               GtkStateType previous_state)
-{
-}
-
-static void
 gsm_color_button_drag_data_received (GtkWidget * widget,
                                     GdkDragContext * context,
                                     gint x,
@@ -501,8 +430,7 @@ gsm_color_button_drag_data_received (GtkWidget * widget,
 
   gint length;
   guint16 *dropped;
-  if (!priv->sensitive) 
-    return;
+
   length = gtk_selection_data_get_length (selection_data);
 
   if (length < 0)
@@ -557,8 +485,6 @@ gsm_color_button_drag_begin (GtkWidget * widget,
                             GdkDragContext * context, gpointer data)
 {
   GsmColorButtonPrivate *priv = gsm_color_button_get_instance_private (GSM_COLOR_BUTTON (data));
-  if (!priv->sensitive) 
-    return;
   set_color_icon (context, &priv->color);
 }
 
@@ -571,8 +497,7 @@ gsm_color_button_drag_data_get (GtkWidget * widget,
 {
   GsmColorButtonPrivate *priv = gsm_color_button_get_instance_private (color_button);
   guint16 dropped[4];
-  if (!priv->sensitive) 
-    return;
+
   dropped[0] = priv->color.red;
   dropped[1] = priv->color.green;
   dropped[2] = priv->color.blue;
@@ -597,7 +522,6 @@ gsm_color_button_init (GsmColorButton * color_button)
   priv->title = g_strdup (_("Pick a Color"));  /* default title */
   priv->in_button = FALSE;
   priv->button_down = FALSE;
-  priv->sensitive = TRUE;
   
   gtk_drag_dest_set (GTK_WIDGET (color_button),
                     GTK_DEST_DEFAULT_MOTION |
@@ -647,7 +571,7 @@ GtkWidget *
 gsm_color_button_new (const GdkRGBA * color, guint type)
 {
   return g_object_new (GSM_TYPE_COLOR_BUTTON, "color", color, "type", type,
-                              "visible", TRUE, "sensitive", TRUE, NULL);
+                              "visible", TRUE, NULL);
 }
 
 static void
@@ -692,9 +616,6 @@ gsm_color_button_clicked (GtkWidget * widget, GdkEventButton * event)
   GsmColorButton *color_button = GSM_COLOR_BUTTON (widget);
   GsmColorButtonPrivate *priv = gsm_color_button_get_instance_private (color_button);
 
-  /* insensitive color buttons can not be clicked */
-  if (!priv->sensitive) 
-    return 0;
   /* if dialog already exists, make sure it's shown and raised */
   if (!priv->cc_dialog)
     {
@@ -731,13 +652,8 @@ gsm_color_button_pressed (GtkWidget * widget, GdkEventButton * event)
 {
   GsmColorButtonPrivate *priv = gsm_color_button_get_instance_private (GSM_COLOR_BUTTON (widget));
 
-  if ( (event->type == GDK_BUTTON_PRESS) && (event->button == 1) )
-    {
-      /* insensitive color buttons can not be clicked */
-      if (!priv->sensitive) 
-        return 0;
-      priv->button_down = TRUE;
-    }
+  if ((event->type == GDK_BUTTON_PRESS) && (event->button == 1))
+    priv->button_down = TRUE;
   return 0;
 }
 
@@ -745,9 +661,6 @@ static gint
 gsm_color_button_released (GtkWidget * widget, GdkEventButton * event)
 {
   GsmColorButtonPrivate *priv = gsm_color_button_get_instance_private (GSM_COLOR_BUTTON (widget));
-  /* insensitive color buttons can not be clicked */
-  if (!priv->sensitive) 
-    return 0;
   if (priv->button_down && priv->in_button)
     gsm_color_button_clicked (widget, event);
   priv->button_down = FALSE;
@@ -829,37 +742,6 @@ gsm_color_button_set_fraction (GsmColorButton * color_button,
   g_object_notify (G_OBJECT (color_button), "fraction");
 }
 
-gboolean
-gsm_color_button_get_sensitive (GsmColorButton * color_button)
-{
-  GsmColorButtonPrivate *priv;
-
-  g_return_val_if_fail (GSM_IS_COLOR_BUTTON (color_button), 0);
-
-  priv = gsm_color_button_get_instance_private (color_button);
-
-  return priv->sensitive;
-}
-
-void
-gsm_color_button_set_sensitive (GsmColorButton * color_button,
-                              gboolean sensitive)
-{
-  GsmColorButtonPrivate *priv;
-
-  g_return_if_fail (GSM_IS_COLOR_BUTTON (color_button));
-
-  priv = gsm_color_button_get_instance_private (color_button);
-
-  priv->sensitive = sensitive;
-  
-  gtk_widget_set_tooltip_text (GTK_WIDGET(color_button), sensitive?_("Click to set graph colors"):"");
-  
-  gtk_widget_queue_draw (GTK_WIDGET (color_button));
-  
-  g_object_notify (G_OBJECT (color_button), "sensitive");
-}
-
 void
 gsm_color_button_get_color (GsmColorButton * color_button, GdkRGBA * color)
 {
@@ -951,9 +833,6 @@ gsm_color_button_set_property (GObject * object,
     case PROP_TYPE:
       gsm_color_button_set_cbtype (color_button, g_value_get_uint (value));
       break;
-    case PROP_SENSITIVE:
-      gsm_color_button_set_sensitive (color_button, g_value_get_boolean (value));
-      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
       break;
@@ -977,9 +856,6 @@ gsm_color_button_get_property (GObject * object,
     case PROP_TITLE:
       g_value_set_string (value, gsm_color_button_get_title (color_button));
       break;
-    case PROP_SENSITIVE:
-      g_value_set_boolean (value, gsm_color_button_get_sensitive (color_button));
-      break;  
     case PROP_COLOR:
       gsm_color_button_get_color (color_button, &color);
       g_value_set_boxed (value, &color);
diff --git a/src/gsm_color_button.h b/src/gsm_color_button.h
index c1a922b..3f2f37a 100644
--- a/src/gsm_color_button.h
+++ b/src/gsm_color_button.h
@@ -60,19 +60,15 @@ enum
 struct _GsmColorButtonClass
 {
     GtkDrawingAreaClass parent_class;
-
-    void (*color_set) (GsmColorButton * cp);
 };
 
 GType       gsm_color_button_get_type      (void);
 GtkWidget * gsm_color_button_new           (const GdkRGBA * color, guint type);
 void        gsm_color_button_set_color     (GsmColorButton * color_button, const GdkRGBA * color);
-void        gsm_color_button_set_sensitive (GsmColorButton * color_button, const gboolean sensitive);
 void        gsm_color_button_set_fraction  (GsmColorButton * color_button, const gdouble fraction);
 void        gsm_color_button_set_cbtype    (GsmColorButton * color_button, guint type);
 void        gsm_color_button_get_color     (GsmColorButton * color_button, GdkRGBA * color);
 gdouble     gsm_color_button_get_fraction  (GsmColorButton * color_button);
-gboolean    gsm_color_button_get_sensitive (GsmColorButton * color_button);
 guint       gsm_color_button_get_cbtype    (GsmColorButton * color_button);
 void        gsm_color_button_set_title     (GsmColorButton * color_button, const gchar * title);
 gchar     * gsm_color_button_get_title     (GsmColorButton * color_button);
diff --git a/src/interface.cpp b/src/interface.cpp
index 21a06ed..09f0474 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -219,7 +219,7 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
         }
         gtk_grid_attach(GTK_GRID (cpu_table), temp_hbox, i%cols, i/cols, 1, 1);
         color_picker = gsm_color_button_new (&cpu_graph->colors.at(i), GSMCP_TYPE_CPU);
-        g_signal_connect (G_OBJECT (color_picker), "color_set",
+        g_signal_connect (G_OBJECT (color_picker), "color-set",
                           G_CALLBACK (cb_cpu_color_changed), GINT_TO_POINTER (i));
         gtk_box_pack_start (GTK_BOX (temp_hbox), color_picker, FALSE, TRUE, 0);
         gtk_widget_set_size_request(GTK_WIDGET(color_picker), 32, -1);
@@ -261,7 +261,7 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
     table = GTK_WIDGET (gtk_builder_get_object (builder, "mem_table"));
 
     color_picker = load_graph_get_mem_color_picker(mem_graph);
-    g_signal_connect (G_OBJECT (color_picker), "color_set",
+    g_signal_connect (G_OBJECT (color_picker), "color-set",
                       G_CALLBACK (cb_mem_color_changed), app);
     title_text = g_strdup_printf(title_template, _("Memory"));
     gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
@@ -273,7 +273,7 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
     gtk_grid_attach_next_to (GTK_GRID (table), load_graph_get_labels(mem_graph)->memory, label, 
GTK_POS_BOTTOM, 1, 1);
 
     color_picker = load_graph_get_swap_color_picker(mem_graph);
-    g_signal_connect (G_OBJECT (color_picker), "color_set",
+    g_signal_connect (G_OBJECT (color_picker), "color-set",
                       G_CALLBACK (cb_swap_color_changed), app);
     title_text = g_strdup_printf(title_template, _("Swap"));
     gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
@@ -301,7 +301,7 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
 
     color_picker = gsm_color_button_new (
         &net_graph->colors.at(0), GSMCP_TYPE_NETWORK_IN);
-    g_signal_connect (G_OBJECT (color_picker), "color_set",
+    g_signal_connect (G_OBJECT (color_picker), "color-set",
                       G_CALLBACK (cb_net_in_color_changed), app);
     title_text = g_strdup_printf(title_template, _("Receiving"));
     gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
@@ -316,7 +316,7 @@ create_sys_view (GsmApplication *app, GtkBuilder * builder)
 
     color_picker = gsm_color_button_new (
         &net_graph->colors.at(1), GSMCP_TYPE_NETWORK_OUT);
-    g_signal_connect (G_OBJECT (color_picker), "color_set",
+    g_signal_connect (G_OBJECT (color_picker), "color-set",
                       G_CALLBACK (cb_net_out_color_changed), app);
     title_text = g_strdup_printf(title_template, _("Sending"));
     gsm_color_button_set_title(GSM_COLOR_BUTTON(color_picker), title_text);
diff --git a/src/load-graph.cpp b/src/load-graph.cpp
index a789cb5..8d32e77 100644
--- a/src/load-graph.cpp
+++ b/src/load-graph.cpp
@@ -417,7 +417,7 @@ get_memory (LoadGraph *graph)
                                 GSM_COLOR_BUTTON(graph->swap_color_picker),
                                 swap.used, swap.total, swappercent);
     
-    gsm_color_button_set_sensitive (GSM_COLOR_BUTTON(graph->swap_color_picker), swap.total > 0);
+    gtk_widget_set_sensitive (GTK_WIDGET (graph->swap_color_picker), swap.total > 0);
     
     graph->data[0][0] = mempercent;
     graph->data[0][1] = swap.total>0 ? swappercent : -1.0f;


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