gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] [gnunet-gtk] branch master updated: replacing deprecated gt


From: gnunet
Subject: [GNUnet-SVN] [gnunet-gtk] branch master updated: replacing deprecated gtk_widget_override_* functions with modern ones
Date: Sun, 27 Nov 2016 10:30:16 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository gnunet-gtk.

The following commit(s) were added to refs/heads/master by this push:
     new c840c86  replacing deprecated gtk_widget_override_* functions with 
modern ones
c840c86 is described below

commit c840c86c74538679db6545a169a09599bda94533
Author: Christian Grothoff <address@hidden>
AuthorDate: Sun Nov 27 10:30:07 2016 +0100

    replacing deprecated gtk_widget_override_* functions with modern ones
---
 src/setup/gnunet-setup-options.c | 257 +++++++++++++++++++++++++--------------
 1 file changed, 169 insertions(+), 88 deletions(-)

diff --git a/src/setup/gnunet-setup-options.c b/src/setup/gnunet-setup-options.c
index 4028bfa..cac4b74 100644
--- a/src/setup/gnunet-setup-options.c
+++ b/src/setup/gnunet-setup-options.c
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2010-2014 GNUnet e.V.
+     Copyright (C) 2010-2014, 2016 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -84,8 +84,11 @@ struct PortSpecification
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-load_yes_no (const void *cls, const char *section, const char *option,
-             const char *value, GObject * widget,
+load_yes_no (const void *cls,
+            const char *section,
+            const char *option,
+             const char *value,
+            GObject * widget,
              const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   GtkToggleButton *button;
@@ -190,8 +193,11 @@ load_yes_no_check_tcp_stealth (const void *cls,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-save_yes_no (const void *cls, const char *section, const char *option,
-             GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg)
+save_yes_no (const void *cls,
+            const char *section,
+            const char *option,
+             GObject * widget,
+            struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   GtkToggleButton *button;
   gboolean mode;
@@ -218,8 +224,11 @@ save_yes_no (const void *cls, const char *section, const 
char *option,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-load_filename (const void *cls, const char *section, const char *option,
-               const char *value, GObject * widget,
+load_filename (const void *cls,
+              const char *section,
+              const char *option,
+               const char *value,
+              GObject * widget,
                const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   GtkFileChooser *chooser;
@@ -273,11 +282,14 @@ save_filename (const void *cls,
  * @param value value as a string
  * @param widget widget to initialize
  * @param cfg configuration handle
- * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-load_text (const void *cls, const char *section, const char *option,
-           const char *value, GObject * widget,
+load_text (const void *cls,
+          const char *section,
+          const char *option,
+           const char *value,
+          GObject * widget,
            const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   GtkEntry *entry;
@@ -301,8 +313,11 @@ load_text (const void *cls, const char *section, const 
char *option,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-save_text (const void *cls, const char *section, const char *option,
-           GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg)
+save_text (const void *cls,
+          const char *section,
+          const char *option,
+           GObject * widget,
+          struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   GtkEntry *entry;
   const gchar *txt;
@@ -326,11 +341,14 @@ save_text (const void *cls, const char *section, const 
char *option,
  * @param value value as a string
  * @param widget widget to initialize
  * @param cfg configuration handle
- * @return GNUNET_OK on success, GNUNET_SYSERR if there was a problem
+ * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-load_combo_text (const void *cls, const char *section, const char *option,
-                 const char *value, GObject * widget,
+load_combo_text (const void *cls,
+                const char *section,
+                const char *option,
+                 const char *value,
+                GObject * widget,
                  const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   GtkComboBoxText *cb;
@@ -354,8 +372,11 @@ load_combo_text (const void *cls, const char *section, 
const char *option,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-save_combo_text (const void *cls, const char *section, const char *option,
-                 GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg)
+save_combo_text (const void *cls,
+                const char *section,
+                const char *option,
+                 GObject * widget,
+                struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   GtkComboBox *cb;
   gchar *c;
@@ -383,8 +404,11 @@ save_combo_text (const void *cls, const char *section, 
const char *option,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-load_number (const void *cls, const char *section, const char *option,
-             const char *value, GObject * widget,
+load_number (const void *cls,
+            const char *section,
+            const char *option,
+             const char *value,
+            GObject * widget,
              const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   GtkSpinButton *spin;
@@ -411,8 +435,11 @@ load_number (const void *cls, const char *section, const 
char *option,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-save_number (const void *cls, const char *section, const char *option,
-             GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg)
+save_number (const void *cls,
+            const char *section,
+            const char *option,
+             GObject * widget,
+            struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   GtkSpinButton *spin;
 
@@ -467,14 +494,15 @@ get_port_spinbutton (unsigned int i)
   GtkSpinButton *spinbt;
   gboolean mode;
 
-  if (port_specifications[i].spinbutton_name == NULL ||
-      port_specifications[i].checkbutton_name == NULL)
+  if ( (NULL == port_specifications[i].spinbutton_name) ||
+       (NULL == port_specifications[i].checkbutton_name) )
     return NULL;
   cb_name = port_specifications[i].checkbutton_name;
   widget = GTK_WIDGET (GNUNET_SETUP_get_object (cb_name));
   if (widget == NULL)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Widget `%s' not found\n"),
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               _("Widget `%s' not found\n"),
                 cb_name);
     return NULL;
   }
@@ -494,7 +522,8 @@ get_port_spinbutton (unsigned int i)
   widget = GTK_WIDGET (GNUNET_SETUP_get_object (sb_name));
   if (widget == NULL)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Widget `%s' not found\n"),
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+               _("Widget `%s' not found\n"),
                 sb_name);
     return NULL;
   }
@@ -520,35 +549,53 @@ static void
 highlight_port_collisions (const void *cls,
                            GObject *widget)
 {
+  static GtkCssProvider *conflict_provider;
   unsigned int i;
   unsigned int j;
   unsigned int port;
   GtkSpinButton *spinbt_i;
   GtkSpinButton *spinbt_j;
-  GdkRGBA color;
-  GdkRGBA *pcolor;
   int found;
   char *tooltip;
 
-  gdk_rgba_parse (&color, INVALID_INPUT_COLOR);
+  if (NULL == conflict_provider)
+  {
+    conflict_provider = gtk_css_provider_new ();
+    
+    gtk_css_provider_load_from_data (conflict_provider,
+                                    ".conflict {\n color: rgba(255, 0.0, 0.0, 
255);\n}",
+                                    -1,
+                                    NULL);
+    for (i = 0;
+        NULL != port_specifications[i].spinbutton_name;
+        i++)
+    {
+      spinbt_i = get_port_spinbutton (i);
+      if (NULL == spinbt_i)
+       continue;
+      gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET 
(spinbt_i)),
+                                     GTK_STYLE_PROVIDER (conflict_provider),
+                                     GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    }
+  }
   for (i = 0;
-       port_specifications[i].spinbutton_name != NULL;
+       NULL != port_specifications[i].spinbutton_name;
        i++)
   {
     spinbt_i = get_port_spinbutton (i);
-    if (spinbt_i == NULL)
+    if (NULL == spinbt_i)
       continue;
-    else
-      port = gtk_spin_button_get_value_as_int (spinbt_i);
+    port = gtk_spin_button_get_value_as_int (spinbt_i);
 
     found = GNUNET_NO;
     for (j = 0;
-         port_specifications[j].spinbutton_name != NULL;
+         NULL != port_specifications[j].spinbutton_name;
          j++)
     {
-      if (i == j) continue;
+      if (i == j)
+       continue;
       spinbt_j = get_port_spinbutton (j);
-      if (spinbt_j == NULL)
+      if (NULL == spinbt_j)
         continue;
       if (port == gtk_spin_button_get_value_as_int (spinbt_j))
       {
@@ -558,23 +605,22 @@ highlight_port_collisions (const void *cls,
     }
     if (GNUNET_YES == found)
     {
-      pcolor = &color;
-      GNUNET_asprintf (&tooltip, _("This port is already occupied by %s."),
+      gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET 
(spinbt_i)),
+                                  "conflict");
+      GNUNET_asprintf (&tooltip,
+                      _("This port is already occupied by %s."),
                       port_specifications[j].owner_name);
+      gtk_widget_set_tooltip_text (GTK_WIDGET (spinbt_i),
+                                  tooltip);
+      GNUNET_free (tooltip);
     }
     else
     {
-      pcolor = NULL;
-      tooltip = GNUNET_strdup ("");
+      gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET 
(spinbt_i)),
+                                     "conflict");
+      gtk_widget_set_tooltip_text (GTK_WIDGET (spinbt_i),
+                                  "");
     }
-    gtk_widget_override_color (GTK_WIDGET (spinbt_i),
-                               GTK_STATE_NORMAL, pcolor);
-    gtk_widget_override_color (GTK_WIDGET (spinbt_i),
-                            GTK_STATE_ACTIVE, pcolor);
-    gtk_widget_override_color (GTK_WIDGET (spinbt_i),
-                            GTK_STATE_SELECTED, pcolor);
-    gtk_widget_set_tooltip_text (GTK_WIDGET (spinbt_i), tooltip);
-    GNUNET_free (tooltip);
   }
 }
 
@@ -589,9 +635,8 @@ static void
 validate_v4_policy (const void *cls,
                     GObject *widget)
 {
+  static GtkCssProvider *invalid_syntax_provider;
   GtkEntry *entry;
-  GdkRGBA color;
-  GdkRGBA *pcolor;
   gboolean invalid;
   const char *text;
   char *r;
@@ -603,27 +648,38 @@ validate_v4_policy (const void *cls,
   invalid =  ( (strlen (text) > 0) &&
                ( (NULL == r) ||
                  (text[strlen(text)-1] != ';') ) );
-  gdk_rgba_parse (&color, INVALID_INPUT_COLOR);
   if (invalid)
   {
-    pcolor = &color;
+    if (NULL == invalid_syntax_provider)
+    {
+      invalid_syntax_provider = gtk_css_provider_new ();
+      
+      gtk_css_provider_load_from_data (invalid_syntax_provider,
+                                      ".syntax_error {\n color: rgba(255, 0.0, 
0.0, 255);\n}",
+                                      -1,
+                                      NULL);
+      gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET 
(entry)),
+                                     GTK_STYLE_PROVIDER 
(invalid_syntax_provider),
+                                     GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    }
+    gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET 
(entry)),
+                                "syntax_error");
     GNUNET_asprintf (&tooltip,
                      _("Invalid policy."));
+    gtk_widget_set_tooltip_text (GTK_WIDGET (widget),
+                                tooltip);
+    GNUNET_free (tooltip);
   }
   else
   {
-    pcolor = NULL;
-    tooltip = GNUNET_strdup ("");
+    if (NULL != invalid_syntax_provider)
+    {
+      gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET 
(entry)),
+                                     "syntax_error");
+    }
+    gtk_widget_set_tooltip_text (GTK_WIDGET (widget),
+                                "");
   }
-  gtk_widget_override_background_color (GTK_WIDGET (widget),
-                                        GTK_STATE_NORMAL, pcolor);
-  gtk_widget_override_background_color (GTK_WIDGET (widget),
-                                        GTK_STATE_ACTIVE, pcolor);
-  gtk_widget_override_background_color (GTK_WIDGET (widget),
-                                        GTK_STATE_SELECTED, pcolor);
-  gtk_widget_set_tooltip_text (GTK_WIDGET (widget),
-                               tooltip);
-  GNUNET_free (tooltip);
   GNUNET_free_non_null (r);
 }
 
@@ -638,9 +694,8 @@ static void
 validate_v6_policy (const void *cls,
                     GObject *widget)
 {
+  static GtkCssProvider *invalid_syntax_provider;
   GtkEntry *entry;
-  GdkRGBA color;
-  GdkRGBA *pcolor;
   gboolean invalid;
   const char *text;
   char *r;
@@ -652,27 +707,37 @@ validate_v6_policy (const void *cls,
   invalid =  ( (strlen (text) > 0) &&
                ( (NULL == r) ||
                  (text[strlen(text)-1] != ';') ) );
-  gdk_rgba_parse (&color, INVALID_INPUT_COLOR);
   if (invalid)
   {
-    pcolor = &color;
+    if (NULL == invalid_syntax_provider)
+    {
+      invalid_syntax_provider = gtk_css_provider_new ();
+      gtk_css_provider_load_from_data (invalid_syntax_provider,
+                                      ".syntax_error {\n color: rgba(255, 0.0, 
0.0, 255);\n}",
+                                      -1,
+                                      NULL);
+      gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET 
(entry)),
+                                     GTK_STYLE_PROVIDER 
(invalid_syntax_provider),
+                                     GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+    }
+    gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET 
(entry)),
+                                "syntax_error");
     GNUNET_asprintf (&tooltip,
                      _("Invalid policy."));
+    gtk_widget_set_tooltip_text (GTK_WIDGET (widget),
+                                tooltip);
+    GNUNET_free (tooltip);
   }
   else
   {
-    pcolor = NULL;
-    tooltip = GNUNET_strdup ("");
+    if (NULL != invalid_syntax_provider)
+    {
+      gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET 
(entry)),
+                                     "syntax_error");
+    }
+    gtk_widget_set_tooltip_text (GTK_WIDGET (widget),
+                                "");
   }
-  gtk_widget_override_background_color (GTK_WIDGET (widget),
-                                        GTK_STATE_NORMAL, pcolor);
-  gtk_widget_override_background_color (GTK_WIDGET (widget),
-                                        GTK_STATE_ACTIVE, pcolor);
-  gtk_widget_override_background_color (GTK_WIDGET (widget),
-                                        GTK_STATE_SELECTED, pcolor);
-  gtk_widget_set_tooltip_text (GTK_WIDGET (widget),
-                               tooltip);
-  GNUNET_free (tooltip);
   GNUNET_free_non_null (r);
 }
 
@@ -690,8 +755,11 @@ validate_v6_policy (const void *cls,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-load_option_list (const void *cls, const char *section, const char *option,
-                  const char *value, GObject * widget,
+load_option_list (const void *cls,
+                 const char *section,
+                 const char *option,
+                  const char *value,
+                 GObject * widget,
                   const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   const char *word = cls;
@@ -732,8 +800,11 @@ load_option_list (const void *cls, const char *section, 
const char *option,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-save_option_list (const void *cls, const char *section, const char *option,
-                  GObject * widget, struct GNUNET_CONFIGURATION_Handle *cfg)
+save_option_list (const void *cls, 
+                 const char *section,
+                 const char *option,
+                  GObject * widget,
+                 struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   const char *word = cls;
   GtkToggleButton *button;
@@ -762,7 +833,8 @@ save_option_list (const void *cls, const char *section, 
const char *option,
  * @return TRUE to stop other handlers from being invoked
  */
 gboolean
-GNUNET_setup_treeview_key_press_event_cb (GtkTreeView * tv, GdkEventKey * 
event,
+GNUNET_setup_treeview_key_press_event_cb (GtkTreeView * tv,
+                                         GdkEventKey * event,
                                           gpointer user_data)
 {
   GtkListStore *ls;
@@ -812,8 +884,11 @@ GNUNET_setup_treeview_key_press_event_cb (GtkTreeView * 
tv, GdkEventKey * event,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-load_string_list_store (const void *cls, const char *section,
-                        const char *option, const char *value, GObject * 
widget,
+load_string_list_store (const void *cls,
+                       const char *section,
+                        const char *option,
+                       const char *value,
+                       GObject * widget,
                         const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   char *t;
@@ -826,13 +901,17 @@ load_string_list_store (const void *cls, const char 
*section,
     return GNUNET_SYSERR;
   t = GNUNET_strdup (value);
   for (w = strtok (t, " "); w != NULL; w = strtok (NULL, " "))
-    gtk_list_store_insert_with_values (ls, &iter, G_MAXINT,
+    gtk_list_store_insert_with_values (ls,
+                                      &iter,
+                                      G_MAXINT,
                                        GNUNET_GTK_SETUP_HOSTLIST_URL_MC_URL, w,
                                        
GNUNET_GTK_SETUP_HOSTLIST_URL_MC_EDITABLE,
                                        FALSE,
                                        -1);
   GNUNET_free (t);
-  gtk_list_store_insert_with_values (ls, &iter, G_MAXINT,
+  gtk_list_store_insert_with_values (ls,
+                                    &iter,
+                                    G_MAXINT,
                                      GNUNET_GTK_SETUP_HOSTLIST_URL_MC_URL, "",
                                      GNUNET_GTK_SETUP_HOSTLIST_URL_MC_EDITABLE,
                                      TRUE,
@@ -853,8 +932,10 @@ load_string_list_store (const void *cls, const char 
*section,
  * @return #GNUNET_OK on success, #GNUNET_SYSERR if there was a problem
  */
 static int
-save_string_list_store (const void *cls, const char *section,
-                        const char *option, GObject * widget,
+save_string_list_store (const void *cls,
+                       const char *section,
+                        const char *option,
+                       GObject * widget,
                         struct GNUNET_CONFIGURATION_Handle *cfg)
 {
   GtkTreeModel *tm;

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]