[Xfce4-commits] <xfce4-xkb-plugin:master> Set string function parameters which are not modified as const.

Jérôme Guelfucci noreply at xfce.org
Fri Apr 29 10:24:01 CEST 2011


Updating branch refs/heads/master
         to 979a1a2bc2bce620d2b430582105c936f8d42f9a (commit)
       from e678e90a8f4ffeeea492042916aeed1f5387a63a (commit)

commit 979a1a2bc2bce620d2b430582105c936f8d42f9a
Author: Jérôme Guelfucci <jeromeg at xfce.org>
Date:   Fri Apr 29 09:28:11 2011 +0200

    Set string function parameters which are not modified as const.

 panel-plugin/xkb-cairo.c     |    4 ++--
 panel-plugin/xkb-cairo.h     |    6 +++---
 panel-plugin/xkb-callbacks.c |    6 ++----
 panel-plugin/xkb-config.c    |    4 ++--
 panel-plugin/xkb-config.h    |   36 ++++++++++++++++++------------------
 panel-plugin/xkb-util.c      |   10 ++++++----
 panel-plugin/xkb-util.h      |   10 +++++-----
 7 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/panel-plugin/xkb-cairo.c b/panel-plugin/xkb-cairo.c
index e5f1df1..eeb18ac 100644
--- a/panel-plugin/xkb-cairo.c
+++ b/panel-plugin/xkb-cairo.c
@@ -64,7 +64,7 @@ gint font_sizes[113] = {
 
 void
 xkb_cairo_draw_flag (cairo_t *cr,
-                     gchar *group_name,
+                     const gchar *group_name,
                      gint panel_size,
                      gint actual_width,
                      gint actual_height,
@@ -143,7 +143,7 @@ xkb_cairo_draw_flag (cairo_t *cr,
 
 void
 xkb_cairo_draw_label (cairo_t *cr,
-                      gchar *group_name,
+                      const gchar *group_name,
                       gint panel_size,
                       gint actual_width,
                       gint actual_height,
diff --git a/panel-plugin/xkb-cairo.h b/panel-plugin/xkb-cairo.h
index 6103a05..90c9996 100644
--- a/panel-plugin/xkb-cairo.h
+++ b/panel-plugin/xkb-cairo.h
@@ -4,7 +4,7 @@
  *
  * Parts of this program comes from the XfKC tool:
  * Copyright (C) 2006 Gauvain Pocentek <gauvainpocentek at gmail.com>
- * 
+ *
  * A part of this file comes from the gnome keyboard capplet (control-center):
  * Copyright (C) 2003 Sergey V. Oudaltsov <svu at users.sourceforge.net>
  *
@@ -35,7 +35,7 @@
 #include <pango/pangocairo.h>
 
 void        xkb_cairo_draw_flag     (cairo_t *cr,
-                                     gchar *flag_name,
+                                     const gchar *flag_name,
                                      gint panel_size,
                                      gint actual_width,
                                      gint actual_height,
@@ -45,7 +45,7 @@ void        xkb_cairo_draw_flag     (cairo_t *cr,
                                      GdkColor fgcolor);
 
 void        xkb_cairo_draw_label    (cairo_t *cr,
-                                     gchar *group_name,
+                                     const gchar *group_name,
                                      gint panel_size,
                                      gint actual_width,
                                      gint actual_height,
diff --git a/panel-plugin/xkb-callbacks.c b/panel-plugin/xkb-callbacks.c
index 4e13eaf..e7eaeac 100644
--- a/panel-plugin/xkb-callbacks.c
+++ b/panel-plugin/xkb-callbacks.c
@@ -99,7 +99,7 @@ xkb_plugin_layout_image_exposed (GtkWidget *widget,
                                  GdkEventExpose *event,
                                  t_xkb *xkb)
 {
-    gchar *group_name;
+    const gchar *group_name;
     cairo_t *cr;
     GtkStyle *style;
     GdkColor fgcolor;
@@ -116,8 +116,6 @@ xkb_plugin_layout_image_exposed (GtkWidget *widget,
 
     if (xkb->display_type == DISPLAY_TYPE_IMAGE)
     {
-        group_name = xkb_config_get_group_name (-1);
-
         xkb_cairo_draw_flag (cr, group_name,
                 xfce_panel_plugin_get_size (xkb->plugin),
                 actual_hsize, actual_vsize,
@@ -171,7 +169,7 @@ xkb_plugin_tooltip_image_exposed (GtkWidget *widget,
                                   GdkEventExpose *event,
                                   t_xkb *xkb)
 {
-    gchar *group_name;
+    const gchar *group_name;
     cairo_t *cr;
     /*GtkStyle *style;*/
     /*GdkColor fgcolor;*/
diff --git a/panel-plugin/xkb-config.c b/panel-plugin/xkb-config.c
index adf8927..da89b6b 100644
--- a/panel-plugin/xkb-config.c
+++ b/panel-plugin/xkb-config.c
@@ -465,7 +465,7 @@ xkb_config_get_group_count (void)
     return config->group_count;
 }
 
-gchar*
+const gchar*
 xkb_config_get_group_name (gint group)
 {
     g_assert (config != NULL);
@@ -479,7 +479,7 @@ xkb_config_get_group_name (gint group)
     return config->group_names[group];
 }
 
-gchar*
+const gchar*
 xkb_config_get_variant (gint group)
 {
     g_assert (config != NULL);
diff --git a/panel-plugin/xkb-config.h b/panel-plugin/xkb-config.h
index fb87184..3281471 100644
--- a/panel-plugin/xkb-config.h
+++ b/panel-plugin/xkb-config.h
@@ -62,28 +62,28 @@ typedef void        (*XkbCallback)                  (gint current_group,
                                                      gboolean groups_changed,
                                                      gpointer user_data);
 
-gboolean    xkb_config_initialize                   (t_xkb_settings *settings,
-                                                     XkbCallback callback,
-                                                     gpointer data);
-void        xkb_config_finalize                     (void);
-void        kbd_config_free                         (t_xkb_kbd_config *kbd_config);
-gboolean    xkb_config_update_settings              (t_xkb_settings *settings);
-gint        xkb_config_get_group_count              (void);
-gchar*      xkb_config_get_group_name               (gint group);
-gchar*      xkb_config_get_variant                  (gint group);
-gboolean    xkb_config_set_group                    (gint group);
-gboolean    xkb_config_next_group                   (void);
-gint        xkb_config_variant_index_for_group      (gint group);
-
-void        xkb_config_window_changed               (guint new_window_id,
-                                                     guint application_id);
-void        xkb_config_application_closed           (guint application_id);
-void        xkb_config_window_closed                (guint window_id);
+gboolean          xkb_config_initialize                   (t_xkb_settings *settings,
+                                                           XkbCallback callback,
+                                                           gpointer data);
+void              xkb_config_finalize                     (void);
+void              kbd_config_free                         (t_xkb_kbd_config *kbd_config);
+gboolean          xkb_config_update_settings              (t_xkb_settings *settings);
+gint              xkb_config_get_group_count              (void);
+const gchar*      xkb_config_get_group_name               (gint group);
+const gchar*      xkb_config_get_variant                  (gint group);
+gboolean          xkb_config_set_group                    (gint group);
+gboolean          xkb_config_next_group                   (void);
+gint              xkb_config_variant_index_for_group      (gint group);
+
+void              xkb_config_window_changed               (guint new_window_id,
+                                                           guint application_id);
+void              xkb_config_application_closed           (guint application_id);
+void              xkb_config_window_closed                (guint window_id);
 
 /* TODO: remove this function - xkl structures should not be used outside xkb-config */
 XklConfigRegistry*
-            xkb_config_get_xkl_registry             (void);
-gint        xkb_config_get_max_layout_number        (void);
+                  xkb_config_get_xkl_registry             (void);
+gint              xkb_config_get_max_layout_number        (void);
 
 #ifdef DEBUG
 
diff --git a/panel-plugin/xkb-util.c b/panel-plugin/xkb-util.c
index 34d0c15..61b5edf 100644
--- a/panel-plugin/xkb-util.c
+++ b/panel-plugin/xkb-util.c
@@ -31,7 +31,7 @@
 #include "xkb-config.h" // TODO : REMOVE THIS
 
 gchar*
-xkb_util_get_flag_filename (gchar* group_name)
+xkb_util_get_flag_filename (const gchar* group_name)
 {
     gchar* filename;
 
@@ -44,7 +44,7 @@ xkb_util_get_flag_filename (gchar* group_name)
 }
 
 gchar*
-xkb_util_get_layout_string (gchar *group_name, gchar *variant)
+xkb_util_get_layout_string (const gchar *group_name, const gchar *variant)
 {
     gchar *layout;
 
@@ -64,9 +64,9 @@ xkb_util_get_layout_string (gchar *group_name, gchar *variant)
 }
 
 gchar*
-xkb_util_normalize_group_name (gchar* group_name)
+xkb_util_normalize_group_name (const gchar* group_name)
 {
-    gchar *c = group_name;
+    gchar *c = g_strdup (group_name);
     gchar *result;
     gint cut_length;
     gint index_of_na = -1;
@@ -97,6 +97,8 @@ xkb_util_normalize_group_name (gchar* group_name)
 
     result = g_strndup (group_name, cut_length);
 
+    g_free (c);
+
     return result;
 }
 
diff --git a/panel-plugin/xkb-util.h b/panel-plugin/xkb-util.h
index 4379676..92cc9ca 100644
--- a/panel-plugin/xkb-util.h
+++ b/panel-plugin/xkb-util.h
@@ -4,7 +4,7 @@
  *
  * Parts of this program comes from the XfKC tool:
  * Copyright (C) 2006 Gauvain Pocentek <gauvainpocentek at gmail.com>
- * 
+ *
  * A part of this file comes from the gnome keyboard capplet (control-center):
  * Copyright (C) 2003 Sergey V. Oudaltsov <svu at users.sourceforge.net>
  *
@@ -30,11 +30,11 @@
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 
-gchar*      xkb_util_get_flag_filename      (gchar* group_name);
+gchar*      xkb_util_get_flag_filename      (const gchar* group_name);
 
-gchar*      xkb_util_get_layout_string      (gchar* group_name,
-                                             gchar* variant);
-gchar*      xkb_util_normalize_group_name   (gchar* group_name);
+gchar*      xkb_util_get_layout_string      (const gchar* group_name,
+                                             const gchar* variant);
+gchar*      xkb_util_normalize_group_name   (const gchar* group_name);
 
 #endif
 



More information about the Xfce4-commits mailing list