cropper

diff support.c @ 1:80535e4deaa4

nicer code formating
author meillo@marmaro.de
date Tue, 04 Dec 2007 20:23:25 +0100
parents ca9155129253
children e359bea4c8ac
line diff
     1.1 --- a/support.c	Tue Dec 04 16:48:51 2007 +0100
     1.2 +++ b/support.c	Tue Dec 04 20:23:25 2007 +0100
     1.3 @@ -1,11 +1,3 @@
     1.4 -/*
     1.5 - * DO NOT EDIT THIS FILE - it is generated by Glade.
     1.6 - */
     1.7 -
     1.8 -#ifdef HAVE_CONFIG_H
     1.9 -#  include <config.h>
    1.10 -#endif
    1.11 -
    1.12  #include <sys/types.h>
    1.13  #include <sys/stat.h>
    1.14  #include <unistd.h>
    1.15 @@ -16,129 +8,118 @@
    1.16  
    1.17  #include "support.h"
    1.18  
    1.19 -GtkWidget*
    1.20 -lookup_widget                          (GtkWidget       *widget,
    1.21 -                                        const gchar     *widget_name)
    1.22 -{
    1.23 -  GtkWidget *parent, *found_widget;
    1.24  
    1.25 -  for (;;)
    1.26 -    {
    1.27 -      if (GTK_IS_MENU (widget))
    1.28 -        parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
    1.29 -      else
    1.30 -        parent = widget->parent;
    1.31 -      if (!parent)
    1.32 -        parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
    1.33 -      if (parent == NULL)
    1.34 -        break;
    1.35 -      widget = parent;
    1.36 -    }
    1.37 +GtkWidget* lookup_widget(GtkWidget* widget, const gchar* widget_name) {
    1.38 +  GtkWidget* parent;
    1.39 +	GtkWidget* found_widget;
    1.40  
    1.41 -  found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
    1.42 -                                                 widget_name);
    1.43 -  if (!found_widget)
    1.44 +  for (;;) {
    1.45 +		if (GTK_IS_MENU (widget)) {
    1.46 +			parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
    1.47 +		} else {
    1.48 +			parent = widget->parent;
    1.49 +		}
    1.50 +		if (!parent) {
    1.51 +			parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
    1.52 +		}
    1.53 +		if (parent == NULL) {
    1.54 +			break;
    1.55 +		}
    1.56 +		widget = parent;
    1.57 +	}
    1.58 +
    1.59 +  found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name);
    1.60 +  if (!found_widget) {
    1.61      g_warning ("Widget not found: %s", widget_name);
    1.62 +	}
    1.63    return found_widget;
    1.64  }
    1.65  
    1.66 +
    1.67  static GList *pixmaps_directories = NULL;
    1.68  
    1.69  /* Use this function to set the directory containing installed pixmaps. */
    1.70 -void
    1.71 -add_pixmap_directory                   (const gchar     *directory)
    1.72 -{
    1.73 -  pixmaps_directories = g_list_prepend (pixmaps_directories,
    1.74 -                                        g_strdup (directory));
    1.75 +void add_pixmap_directory(const gchar* directory) {
    1.76 +  pixmaps_directories = g_list_prepend (pixmaps_directories, g_strdup (directory));
    1.77  }
    1.78  
    1.79  /* This is an internally used function to find pixmap files. */
    1.80 -static gchar*
    1.81 -find_pixmap_file                       (const gchar     *filename)
    1.82 -{
    1.83 -  GList *elem;
    1.84 +static gchar* find_pixmap_file(const gchar* filename) {
    1.85 +  GList* elem;
    1.86  
    1.87    /* We step through each of the pixmaps directory to find it. */
    1.88    elem = pixmaps_directories;
    1.89 -  while (elem)
    1.90 -    {
    1.91 -      gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
    1.92 -                                         G_DIR_SEPARATOR_S, filename);
    1.93 -      if (g_file_test (pathname, G_FILE_TEST_EXISTS))
    1.94 -        return pathname;
    1.95 -      g_free (pathname);
    1.96 -      elem = elem->next;
    1.97 -    }
    1.98 +  while (elem) {
    1.99 +		gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, G_DIR_SEPARATOR_S, filename);
   1.100 +		if (g_file_test (pathname, G_FILE_TEST_EXISTS)) {
   1.101 +			return pathname;
   1.102 +		}
   1.103 +		g_free (pathname);
   1.104 +		elem = elem->next;
   1.105 +	}
   1.106    return NULL;
   1.107  }
   1.108  
   1.109 +
   1.110  /* This is an internally used function to create pixmaps. */
   1.111 -GtkWidget*
   1.112 -create_pixmap                          (GtkWidget       *widget,
   1.113 -                                        const gchar     *filename)
   1.114 -{
   1.115 -  gchar *pathname = NULL;
   1.116 -  GtkWidget *pixmap;
   1.117 +GtkWidget* create_pixmap(GtkWidget* widget, const gchar* filename) {
   1.118 +  gchar* pathname = NULL;
   1.119 +  GtkWidget* pixmap;
   1.120  
   1.121 -  if (!filename || !filename[0])
   1.122 -      return gtk_image_new ();
   1.123 +  if (!filename || !filename[0]) {
   1.124 +		return gtk_image_new ();
   1.125 +	}
   1.126  
   1.127    pathname = find_pixmap_file (filename);
   1.128  
   1.129 -  if (!pathname)
   1.130 -    {
   1.131 -      g_warning ("Couldn't find pixmap file: %s", filename);
   1.132 -      return gtk_image_new ();
   1.133 -    }
   1.134 +  if (!pathname) {
   1.135 +		g_warning ("Couldn't find pixmap file: %s", filename);
   1.136 +		return gtk_image_new ();
   1.137 +	}
   1.138  
   1.139    pixmap = gtk_image_new_from_file (pathname);
   1.140 -  g_free (pathname);
   1.141 +  g_free(pathname);
   1.142    return pixmap;
   1.143  }
   1.144  
   1.145 +
   1.146  /* This is an internally used function to create pixmaps. */
   1.147 -GdkPixbuf*
   1.148 -create_pixbuf                          (const gchar     *filename)
   1.149 -{
   1.150 -  gchar *pathname = NULL;
   1.151 -  GdkPixbuf *pixbuf;
   1.152 -  GError *error = NULL;
   1.153 +GdkPixbuf* create_pixbuf(const gchar* filename) {
   1.154 +  gchar* pathname = NULL;
   1.155 +  GdkPixbuf* pixbuf;
   1.156 +  GError* error = NULL;
   1.157  
   1.158 -  if (!filename || !filename[0])
   1.159 -      return NULL;
   1.160 +  if (!filename || !filename[0]) {
   1.161 +		return NULL;
   1.162 +	}
   1.163  
   1.164 -  pathname = find_pixmap_file (filename);
   1.165 +  pathname = find_pixmap_file(filename);
   1.166  
   1.167 -  if (!pathname)
   1.168 -    {
   1.169 -      g_warning ("Couldn't find pixmap file: %s", filename);
   1.170 -      return NULL;
   1.171 -    }
   1.172 +  if (!pathname) {
   1.173 +		g_warning ("Couldn't find pixmap file: %s", filename);
   1.174 +		return NULL;
   1.175 +	}
   1.176  
   1.177    pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
   1.178 -  if (!pixbuf)
   1.179 -    {
   1.180 -      fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
   1.181 -               pathname, error->message);
   1.182 -      g_error_free (error);
   1.183 -    }
   1.184 -  g_free (pathname);
   1.185 +  if (!pixbuf) {
   1.186 +		fprintf(stderr, "Failed to load pixbuf file: %s: %s\n", pathname, error->message);
   1.187 +		g_error_free(error);
   1.188 +	}
   1.189 +  g_free(pathname);
   1.190    return pixbuf;
   1.191  }
   1.192  
   1.193 +
   1.194  /* This is used to set ATK action descriptions. */
   1.195 -void
   1.196 -glade_set_atk_action_description       (AtkAction       *action,
   1.197 -                                        const gchar     *action_name,
   1.198 -                                        const gchar     *description)
   1.199 -{
   1.200 -  gint n_actions, i;
   1.201 +void glade_set_atk_action_description(AtkAction* action, const gchar* action_name, const gchar* description) {
   1.202 +  gint n_actions
   1.203 +	gint i;
   1.204  
   1.205    n_actions = atk_action_get_n_actions (action);
   1.206 -  for (i = 0; i < n_actions; i++)
   1.207 -    {
   1.208 -      if (!strcmp (atk_action_get_name (action, i), action_name))
   1.209 -        atk_action_set_description (action, i, description);
   1.210 -    }
   1.211 +  for (i = 0; i < n_actions; i++) {
   1.212 +		if (!strcmp (atk_action_get_name (action, i), action_name)) {
   1.213 +			atk_action_set_description (action, i, description);
   1.214 +		}
   1.215 +	}
   1.216  }
   1.217