[dia/zbrown/gresource-icons: 26/26] Changes proposed in code review



commit 69c0d45c50c3bda8388e4a044c06114f6c75dacb
Author: Zander Brown <zbrown gnome org>
Date:   Wed May 8 22:45:27 2019 +0100

    Changes proposed in code review

 app/.gitignore             |  4 ----
 app/create_object.c        | 17 +++++++----------
 app/cursor.c               |  8 ++++----
 app/cursor.h               |  2 +-
 app/menus.c                |  7 +++++--
 app/modify_tool.c          |  2 +-
 app/toolbox.c              |  5 ++++-
 lib/.gitignore             |  3 ---
 lib/dia_dirs.c             |  7 +++++--
 lib/object.c               |  8 +++++---
 objects/standard/ellipse.c |  2 +-
 11 files changed, 33 insertions(+), 32 deletions(-)
---
diff --git a/app/create_object.c b/app/create_object.c
index a88bf975..8003b129 100644
--- a/app/create_object.c
+++ b/app/create_object.c
@@ -280,6 +280,9 @@ create_create_object_tool(DiaObjectType *objtype, void *user_data,
                          int invert_persistence)
 {
   CreateObjectTool *tool;
+  GdkPixbuf *pixbuf;
+  GdkDisplay *disp;
+  GdkCursor *cursor;
 
   tool = g_new0(CreateObjectTool, 1);
   tool->tool.type = CREATE_OBJECT_TOOL;
@@ -293,19 +296,13 @@ create_create_object_tool(DiaObjectType *objtype, void *user_data,
   tool->moving = FALSE;
   tool->invert_persistence = invert_persistence;
 
-  {
-    GdkDisplay *disp;
-    GdkCursor *cursor;
-
-    disp = gdk_display_get_default ();
+  pixbuf = pixbuf_from_resource ("/org/gnome/Dia/icons/dia-cursor-create.png");
 
-    cursor = gdk_cursor_new_from_pixbuf (disp,
-                                         pixbuf_from_resource ("/org/gnome/Dia/icons/dia-cursor-create.png"),
-                                         0, 0);
+  disp = gdk_display_get_default ();
 
+  cursor = gdk_cursor_new_from_pixbuf (disp, pixbuf, 0, 0);
 
-    ddisplay_set_all_cursor (cursor);
-  }
+  ddisplay_set_all_cursor (cursor);
 
   return (Tool *) tool;
 }
diff --git a/app/cursor.c b/app/cursor.c
index 964357bb..ddb40c76 100644
--- a/app/cursor.c
+++ b/app/cursor.c
@@ -23,7 +23,7 @@
 #include "display.h"
 #include "cursor.h"
 
-static int cursors[MAX_CURSORS] = {
+static int direction_cursors[MAX_CURSORS] = {
   /* for safety reasons these should be last and must be in the same order HANDLE_RESIZE_* */
   GDK_TOP_LEFT_CORNER,     /* CURSOR_DIRECTION_0 + NW */
   GDK_TOP_SIDE,            /* N */
@@ -36,11 +36,11 @@ static int cursors[MAX_CURSORS] = {
 };
 
 GdkCursor *
-direction_cursor (DiaCursorType ctype)
+get_direction_cursor (DiaCursorType ctype)
 {
-  if (ctype >= G_N_ELEMENTS (cursors)) {
+  if (ctype >= G_N_ELEMENTS (direction_cursors)) {
     return NULL;
   }
 
-  return gdk_cursor_new (cursors[ctype]);
+  return gdk_cursor_new (direction_cursors[ctype]);
 }
diff --git a/app/cursor.h b/app/cursor.h
index 2ada50dd..8a8a9285 100644
--- a/app/cursor.h
+++ b/app/cursor.h
@@ -26,4 +26,4 @@ typedef enum {
   MAX_CURSORS
 } DiaCursorType;
 
-GdkCursor *direction_cursor (DiaCursorType ctype);
+GdkCursor *get_direction_cursor (DiaCursorType ctype);
diff --git a/app/menus.c b/app/menus.c
index 42259367..de4d7829 100644
--- a/app/menus.c
+++ b/app/menus.c
@@ -791,11 +791,14 @@ _add_stock_icon_name (GtkIconFactory *factory, const char *name, const gchar *ic
 {
   GdkPixbuf      *pixbuf;
   GtkIconSet     *set;
+  char           *path;
 
-  pixbuf = pixbuf_from_resource (g_strdup_printf ("/org/gnome/Dia/icons/%s.png", icon));
+  path = g_strdup_printf ("/org/gnome/Dia/icons/%s.png", icon);
+  pixbuf = pixbuf_from_resource (path);
   set = gtk_icon_set_new_from_pixbuf (pixbuf);
   gtk_icon_factory_add (factory, name, set);
   g_object_unref (pixbuf);
+  g_free (path);
   pixbuf = NULL;
 }
 
@@ -1220,7 +1223,7 @@ menus_set_recent (GtkActionGroup *actions)
     const gchar* aname = gtk_action_get_name (GTK_ACTION (list->data));
 
     id = gtk_ui_manager_new_merge_id (_ui_manager);
-    recent_merge_ids = g_slist_prepend (recent_merge_ids, GINT_TO_POINTER (id));
+    recent_merge_ids = g_slist_prepend (recent_merge_ids, GUINT_TO_POINTER (id));
 
     gtk_ui_manager_add_ui (_ui_manager, id,
                  recent_path,
diff --git a/app/modify_tool.c b/app/modify_tool.c
index 3931a785..6620a8c8 100644
--- a/app/modify_tool.c
+++ b/app/modify_tool.c
@@ -454,7 +454,7 @@ modify_motion(ModifyTool *tool, GdkEventMotion *event,
       && handle->id >= HANDLE_RESIZE_NW && handle->id <= HANDLE_RESIZE_SE
       && handle_is_clicked(ddisp, handle, &to)
       && g_list_length (ddisp->diagram->data->selected) == 1)
-      ddisplay_set_all_cursor (direction_cursor (CURSOR_DIRECTION_0 + handle->id));
+      ddisplay_set_all_cursor (get_direction_cursor (CURSOR_DIRECTION_0 + handle->id));
     else
       ddisplay_set_all_cursor_name (NULL, "default");
     return; /* Fast path... */
diff --git a/app/toolbox.c b/app/toolbox.c
index aa30f396..3ab867ae 100644
--- a/app/toolbox.c
+++ b/app/toolbox.c
@@ -597,6 +597,7 @@ GdkPixbuf *
 tool_get_pixbuf (ToolButton *tb)
 {
   GdkPixbuf *pixbuf;
+  char      *path;
 
   if (tb->icon_name == NULL) {
     DiaObjectType *type;
@@ -604,7 +605,9 @@ tool_get_pixbuf (ToolButton *tb)
     type = object_get_type ((char *) tb->callback_data.extra_data);
     pixbuf = dia_object_type_get_icon (type);
   } else {
-    pixbuf = pixbuf_from_resource (g_strdup_printf ("/org/gnome/Dia/icons/%s.png", tb->icon_name));
+    path = g_strdup_printf ("/org/gnome/Dia/icons/%s.png", tb->icon_name);
+    pixbuf = pixbuf_from_resource (path);
+    g_free (path);
   }
 
   return pixbuf;
diff --git a/lib/dia_dirs.c b/lib/dia_dirs.c
index 1ccd65ca..9f009d0e 100644
--- a/lib/dia_dirs.c
+++ b/lib/dia_dirs.c
@@ -104,14 +104,17 @@ dia_get_data_directory(const gchar* subdir)
   return returnPath;
 #else
   gchar *base = PKGDATADIR;
+  char  *ret;
   if (g_getenv ("DIA_BASE_PATH") != NULL) {
     /* a small hack cause the final destination and the local path differ */
     base = g_build_filename (g_getenv ("DIA_BASE_PATH"), "data", NULL);
   }
   if (strlen (subdir) == 0)
-    return g_strconcat (base, NULL);
+    ret = g_strconcat (base, NULL);
   else
-    return g_strconcat (base, G_DIR_SEPARATOR_S, subdir, NULL);
+    ret = g_strconcat (base, G_DIR_SEPARATOR_S, subdir, NULL);
+  g_free (base);
+  return ret;
 #endif
 }
 
diff --git a/lib/object.c b/lib/object.c
index f96be603..c0ad00ec 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -1240,12 +1240,14 @@ GdkPixbuf *
 dia_object_type_get_icon (const DiaObjectType *type)
 {
   GdkPixbuf *pixbuf;
-  const gchar **icon_data;
+  const gchar **icon_data = NULL;
 
-  if (type != NULL) {
-    icon_data = type->pixmap;
+  if (type == NULL) {
+    return NULL;
   }
 
+  icon_data = type->pixmap;
+
   if (icon_data == NULL && type->pixmap_file == NULL) {
     return NULL;
   }
diff --git a/objects/standard/ellipse.c b/objects/standard/ellipse.c
index ed1fc9f8..19b4fb15 100644
--- a/objects/standard/ellipse.c
+++ b/objects/standard/ellipse.c
@@ -65,7 +65,7 @@ struct _Ellipse {
   LineStyle line_style;
   real dashlength;
   DiaPattern *pattern;
-  real angle; /*!< between [-45�-45�] to simplify connection point handling */
+  real angle; /*!< between [-45-45] to simplify connection point handling */
 };
 
 static struct _EllipseProperties {


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