cropper
changeset 1:80535e4deaa4
nicer code formating
author | meillo@marmaro.de |
---|---|
date | Tue, 04 Dec 2007 20:23:25 +0100 |
parents | ca9155129253 |
children | e359bea4c8ac |
files | callbacks.c callbacks.h interface.c interface.h main.c support.c support.h |
diffstat | 7 files changed, 115 insertions(+), 259 deletions(-) [+] |
line diff
1.1 --- a/callbacks.c Tue Dec 04 16:48:51 2007 +0100 1.2 +++ b/callbacks.c Tue Dec 04 20:23:25 2007 +0100 1.3 @@ -1,7 +1,3 @@ 1.4 -#ifdef HAVE_CONFIG_H 1.5 -# include <config.h> 1.6 -#endif 1.7 - 1.8 #include <gtk/gtk.h> 1.9 1.10 #include "callbacks.h" 1.11 @@ -9,119 +5,73 @@ 1.12 #include "support.h" 1.13 1.14 1.15 -void 1.16 -on_none1_activate (GtkMenuItem *menuitem, 1.17 - gpointer user_data) 1.18 -{ 1.19 +void on_none1_activate (GtkMenuItem* menuitem, gpointer user_data) { 1.20 1.21 } 1.22 1.23 1.24 -void 1.25 -on_square1_activate (GtkMenuItem *menuitem, 1.26 - gpointer user_data) 1.27 -{ 1.28 +void on_square1_activate (GtkMenuItem* menuitem, gpointer user_data) { 1.29 1.30 } 1.31 1.32 1.33 -void 1.34 -on_4x3__book__dvd_1_activate (GtkMenuItem *menuitem, 1.35 - gpointer user_data) 1.36 -{ 1.37 +void on_4x3__book__dvd_1_activate (GtkMenuItem* menuitem, gpointer user_data) { 1.38 1.39 } 1.40 1.41 1.42 -void 1.43 -on_4x6__postcard_1_activate (GtkMenuItem *menuitem, 1.44 - gpointer user_data) 1.45 -{ 1.46 +void on_4x6__postcard_1_activate (GtkMenuItem* menuitem, gpointer user_data) { 1.47 1.48 } 1.49 1.50 1.51 -void 1.52 -on_5x1_activate (GtkMenuItem *menuitem, 1.53 - gpointer user_data) 1.54 -{ 1.55 +void on_5x1_activate (GtkMenuItem* menuitem, gpointer user_data) { 1.56 1.57 } 1.58 1.59 1.60 -void 1.61 -on_8x1_activate (GtkMenuItem *menuitem, 1.62 - gpointer user_data) 1.63 -{ 1.64 +void on_8x1_activate (GtkMenuItem* menuitem, gpointer user_data) { 1.65 1.66 } 1.67 1.68 1.69 -void 1.70 -on_custom1_activate (GtkMenuItem *menuitem, 1.71 - gpointer user_data) 1.72 -{ 1.73 +void on_custom1_activate (GtkMenuItem* menuitem, gpointer user_data) { 1.74 1.75 } 1.76 1.77 1.78 -void 1.79 -on_ratio_w_spinbutton_value_changed (GtkSpinButton *spinbutton, 1.80 - gpointer user_data) 1.81 -{ 1.82 +void on_ratio_w_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { 1.83 1.84 } 1.85 1.86 1.87 -void 1.88 -on_ratio_w_spinbutton_change_value (GtkSpinButton *spinbutton, 1.89 - GtkScrollType scroll, 1.90 - gpointer user_data) 1.91 -{ 1.92 +void on_ratio_w_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { 1.93 1.94 } 1.95 1.96 1.97 -void 1.98 -on_ratio_swap_button_clicked (GtkButton *button, 1.99 - gpointer user_data) 1.100 -{ 1.101 +void on_ratio_swap_button_clicked (GtkButton* button, gpointer user_data) { 1.102 1.103 } 1.104 1.105 1.106 -void 1.107 -on_ratio_h_spinbutton_change_value (GtkSpinButton *spinbutton, 1.108 - GtkScrollType scroll, 1.109 - gpointer user_data) 1.110 -{ 1.111 +void on_ratio_h_spinbutton_change_value (GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data) { 1.112 1.113 } 1.114 1.115 1.116 -void 1.117 -on_ratio_h_spinbutton_value_changed (GtkSpinButton *spinbutton, 1.118 - gpointer user_data) 1.119 -{ 1.120 +void on_ratio_h_spinbutton_value_changed (GtkSpinButton* spinbutton, gpointer user_data) { 1.121 1.122 } 1.123 1.124 1.125 -gboolean 1.126 -on_cropper_window_delete_event (GtkWidget *widget, 1.127 - GdkEvent *event, 1.128 - gpointer user_data) 1.129 -{ 1.130 - 1.131 - g_print ("delete event occurred\n"); 1.132 - return FALSE; 1.133 +gboolean on_cropper_window_delete_event (GtkWidget* widget, GdkEvent *event, gpointer user_data) { 1.134 + g_print("thanks for using the program - visit http://prog.marmaro.de\n"); 1.135 + return FALSE; 1.136 } 1.137 1.138 1.139 -void 1.140 -on_cropper_window_destroy (GtkObject *object, 1.141 - gpointer user_data) 1.142 -{ 1.143 +void on_cropper_window_destroy (GtkObject* object, gpointer user_data) { 1.144 gtk_main_quit(); 1.145 } 1.146
2.1 --- a/callbacks.h Tue Dec 04 16:48:51 2007 +0100 2.2 +++ b/callbacks.h Tue Dec 04 20:23:25 2007 +0100 2.3 @@ -1,65 +1,32 @@ 2.4 #include <gtk/gtk.h> 2.5 2.6 2.7 -void 2.8 -on_none1_activate (GtkMenuItem *menuitem, 2.9 - gpointer user_data); 2.10 +void on_none1_activate(GtkMenuItem* menuitem, gpointer user_data); 2.11 2.12 -void 2.13 -on_square1_activate (GtkMenuItem *menuitem, 2.14 - gpointer user_data); 2.15 +void on_square1_activate(GtkMenuItem* menuitem, gpointer user_data); 2.16 2.17 -void 2.18 -on_4x3__book__dvd_1_activate (GtkMenuItem *menuitem, 2.19 - gpointer user_data); 2.20 +void on_4x3__book__dvd_1_activate(GtkMenuItem* menuitem, gpointer user_data); 2.21 2.22 -void 2.23 -on_4x6__postcard_1_activate (GtkMenuItem *menuitem, 2.24 - gpointer user_data); 2.25 +void on_4x6__postcard_1_activate(GtkMenuItem* menuitem, gpointer user_data); 2.26 2.27 -void 2.28 -on_5x1_activate (GtkMenuItem *menuitem, 2.29 - gpointer user_data); 2.30 +void on_5x1_activate(GtkMenuItem* menuitem, gpointer user_data); 2.31 2.32 -void 2.33 -on_8x1_activate (GtkMenuItem *menuitem, 2.34 - gpointer user_data); 2.35 +void on_8x1_activate(GtkMenuItem* menuitem, gpointer user_data); 2.36 2.37 -void 2.38 -on_custom1_activate (GtkMenuItem *menuitem, 2.39 - gpointer user_data); 2.40 +void on_custom1_activate(GtkMenuItem* menuitem, gpointer user_data); 2.41 2.42 -void 2.43 -on_cropper_window_destroy (GtkObject *object, 2.44 - gpointer user_data); 2.45 +void on_cropper_window_destroy(GtkObject* object, gpointer user_data); 2.46 2.47 -void 2.48 -on_ratio_w_spinbutton_value_changed (GtkSpinButton *spinbutton, 2.49 - gpointer user_data); 2.50 +void on_ratio_w_spinbutton_value_changed(GtkSpinButton* spinbutton, gpointer user_data); 2.51 2.52 -void 2.53 -on_ratio_w_spinbutton_change_value (GtkSpinButton *spinbutton, 2.54 - GtkScrollType scroll, 2.55 - gpointer user_data); 2.56 +void on_ratio_w_spinbutton_change_value(GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data); 2.57 2.58 -void 2.59 -on_ratio_swap_button_clicked (GtkButton *button, 2.60 - gpointer user_data); 2.61 +void on_ratio_swap_button_clicked(GtkButton* button, gpointer user_data); 2.62 2.63 -void 2.64 -on_ratio_h_spinbutton_change_value (GtkSpinButton *spinbutton, 2.65 - GtkScrollType scroll, 2.66 - gpointer user_data); 2.67 +void on_ratio_h_spinbutton_change_value(GtkSpinButton* spinbutton, GtkScrollType scroll, gpointer user_data); 2.68 2.69 -void 2.70 -on_ratio_h_spinbutton_value_changed (GtkSpinButton *spinbutton, 2.71 - gpointer user_data); 2.72 +void on_ratio_h_spinbutton_value_changed(GtkSpinButton* spinbutton, gpointer user_data); 2.73 2.74 -gboolean 2.75 -on_cropper_window_delete_event (GtkWidget *widget, 2.76 - GdkEvent *event, 2.77 - gpointer user_data); 2.78 +gboolean on_cropper_window_delete_event(GtkWidget* widget, GdkEvent *event, gpointer user_data); 2.79 2.80 -void 2.81 -on_cropper_window_destroy (GtkObject *object, 2.82 - gpointer user_data); 2.83 +void on_cropper_window_destroy(GtkObject* object, gpointer user_data);
3.1 --- a/interface.c Tue Dec 04 16:48:51 2007 +0100 3.2 +++ b/interface.c Tue Dec 04 20:23:25 2007 +0100 3.3 @@ -1,11 +1,3 @@ 3.4 -/* 3.5 - * DO NOT EDIT THIS FILE - it is generated by Glade. 3.6 - */ 3.7 - 3.8 -#ifdef HAVE_CONFIG_H 3.9 -# include <config.h> 3.10 -#endif 3.11 - 3.12 #include <sys/types.h> 3.13 #include <sys/stat.h> 3.14 #include <unistd.h> 3.15 @@ -418,6 +410,7 @@ 3.16 gtk_widget_show (image1); 3.17 gtk_container_add (GTK_CONTAINER (crop_zoom_fit_button), image1); 3.18 3.19 + 3.20 g_signal_connect ((gpointer) cropper_window, "delete_event", 3.21 G_CALLBACK (on_cropper_window_delete_event), 3.22 NULL);
4.1 --- a/interface.h Tue Dec 04 16:48:51 2007 +0100 4.2 +++ b/interface.h Tue Dec 04 20:23:25 2007 +0100 4.3 @@ -1,6 +1,3 @@ 4.4 -/* 4.5 - * DO NOT EDIT THIS FILE - it is generated by Glade. 4.6 - */ 4.7 #include<gtk/gtk.h> 4.8 4.9 -GtkWidget* create_cropper_window (void); 4.10 +GtkWidget* create_cropper_window(void);
5.1 --- a/main.c Tue Dec 04 16:48:51 2007 +0100 5.2 +++ b/main.c Tue Dec 04 20:23:25 2007 +0100 5.3 @@ -1,20 +1,9 @@ 5.4 -/* 5.5 - * Initial main.c file generated by Glade. Edit as required. 5.6 - * Glade will not overwrite this file. 5.7 - */ 5.8 - 5.9 -#ifdef HAVE_CONFIG_H 5.10 -# include <config.h> 5.11 -#endif 5.12 - 5.13 #include <gtk/gtk.h> 5.14 5.15 #include "interface.h" 5.16 #include "support.h" 5.17 5.18 -int 5.19 -main (int argc, char *argv[]) 5.20 -{ 5.21 +int main (int argc, char *argv[]) { 5.22 GtkWidget *cropper_window; 5.23 5.24 gtk_set_locale (); 5.25 @@ -22,11 +11,6 @@ 5.26 5.27 add_pixmap_directory ("/usr/share/pixmaps"); 5.28 5.29 - /* 5.30 - * The following code was added by Glade to create one of each component 5.31 - * (except popup menus), just so that you see something after building 5.32 - * the project. Delete any components that you don't want shown initially. 5.33 - */ 5.34 cropper_window = create_cropper_window (); 5.35 gtk_widget_show (cropper_window); 5.36
6.1 --- a/support.c Tue Dec 04 16:48:51 2007 +0100 6.2 +++ b/support.c Tue Dec 04 20:23:25 2007 +0100 6.3 @@ -1,11 +1,3 @@ 6.4 -/* 6.5 - * DO NOT EDIT THIS FILE - it is generated by Glade. 6.6 - */ 6.7 - 6.8 -#ifdef HAVE_CONFIG_H 6.9 -# include <config.h> 6.10 -#endif 6.11 - 6.12 #include <sys/types.h> 6.13 #include <sys/stat.h> 6.14 #include <unistd.h> 6.15 @@ -16,129 +8,118 @@ 6.16 6.17 #include "support.h" 6.18 6.19 -GtkWidget* 6.20 -lookup_widget (GtkWidget *widget, 6.21 - const gchar *widget_name) 6.22 -{ 6.23 - GtkWidget *parent, *found_widget; 6.24 6.25 - for (;;) 6.26 - { 6.27 - if (GTK_IS_MENU (widget)) 6.28 - parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); 6.29 - else 6.30 - parent = widget->parent; 6.31 - if (!parent) 6.32 - parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); 6.33 - if (parent == NULL) 6.34 - break; 6.35 - widget = parent; 6.36 - } 6.37 +GtkWidget* lookup_widget(GtkWidget* widget, const gchar* widget_name) { 6.38 + GtkWidget* parent; 6.39 + GtkWidget* found_widget; 6.40 6.41 - found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), 6.42 - widget_name); 6.43 - if (!found_widget) 6.44 + for (;;) { 6.45 + if (GTK_IS_MENU (widget)) { 6.46 + parent = gtk_menu_get_attach_widget (GTK_MENU (widget)); 6.47 + } else { 6.48 + parent = widget->parent; 6.49 + } 6.50 + if (!parent) { 6.51 + parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey"); 6.52 + } 6.53 + if (parent == NULL) { 6.54 + break; 6.55 + } 6.56 + widget = parent; 6.57 + } 6.58 + 6.59 + found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name); 6.60 + if (!found_widget) { 6.61 g_warning ("Widget not found: %s", widget_name); 6.62 + } 6.63 return found_widget; 6.64 } 6.65 6.66 + 6.67 static GList *pixmaps_directories = NULL; 6.68 6.69 /* Use this function to set the directory containing installed pixmaps. */ 6.70 -void 6.71 -add_pixmap_directory (const gchar *directory) 6.72 -{ 6.73 - pixmaps_directories = g_list_prepend (pixmaps_directories, 6.74 - g_strdup (directory)); 6.75 +void add_pixmap_directory(const gchar* directory) { 6.76 + pixmaps_directories = g_list_prepend (pixmaps_directories, g_strdup (directory)); 6.77 } 6.78 6.79 /* This is an internally used function to find pixmap files. */ 6.80 -static gchar* 6.81 -find_pixmap_file (const gchar *filename) 6.82 -{ 6.83 - GList *elem; 6.84 +static gchar* find_pixmap_file(const gchar* filename) { 6.85 + GList* elem; 6.86 6.87 /* We step through each of the pixmaps directory to find it. */ 6.88 elem = pixmaps_directories; 6.89 - while (elem) 6.90 - { 6.91 - gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, 6.92 - G_DIR_SEPARATOR_S, filename); 6.93 - if (g_file_test (pathname, G_FILE_TEST_EXISTS)) 6.94 - return pathname; 6.95 - g_free (pathname); 6.96 - elem = elem->next; 6.97 - } 6.98 + while (elem) { 6.99 + gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, G_DIR_SEPARATOR_S, filename); 6.100 + if (g_file_test (pathname, G_FILE_TEST_EXISTS)) { 6.101 + return pathname; 6.102 + } 6.103 + g_free (pathname); 6.104 + elem = elem->next; 6.105 + } 6.106 return NULL; 6.107 } 6.108 6.109 + 6.110 /* This is an internally used function to create pixmaps. */ 6.111 -GtkWidget* 6.112 -create_pixmap (GtkWidget *widget, 6.113 - const gchar *filename) 6.114 -{ 6.115 - gchar *pathname = NULL; 6.116 - GtkWidget *pixmap; 6.117 +GtkWidget* create_pixmap(GtkWidget* widget, const gchar* filename) { 6.118 + gchar* pathname = NULL; 6.119 + GtkWidget* pixmap; 6.120 6.121 - if (!filename || !filename[0]) 6.122 - return gtk_image_new (); 6.123 + if (!filename || !filename[0]) { 6.124 + return gtk_image_new (); 6.125 + } 6.126 6.127 pathname = find_pixmap_file (filename); 6.128 6.129 - if (!pathname) 6.130 - { 6.131 - g_warning ("Couldn't find pixmap file: %s", filename); 6.132 - return gtk_image_new (); 6.133 - } 6.134 + if (!pathname) { 6.135 + g_warning ("Couldn't find pixmap file: %s", filename); 6.136 + return gtk_image_new (); 6.137 + } 6.138 6.139 pixmap = gtk_image_new_from_file (pathname); 6.140 - g_free (pathname); 6.141 + g_free(pathname); 6.142 return pixmap; 6.143 } 6.144 6.145 + 6.146 /* This is an internally used function to create pixmaps. */ 6.147 -GdkPixbuf* 6.148 -create_pixbuf (const gchar *filename) 6.149 -{ 6.150 - gchar *pathname = NULL; 6.151 - GdkPixbuf *pixbuf; 6.152 - GError *error = NULL; 6.153 +GdkPixbuf* create_pixbuf(const gchar* filename) { 6.154 + gchar* pathname = NULL; 6.155 + GdkPixbuf* pixbuf; 6.156 + GError* error = NULL; 6.157 6.158 - if (!filename || !filename[0]) 6.159 - return NULL; 6.160 + if (!filename || !filename[0]) { 6.161 + return NULL; 6.162 + } 6.163 6.164 - pathname = find_pixmap_file (filename); 6.165 + pathname = find_pixmap_file(filename); 6.166 6.167 - if (!pathname) 6.168 - { 6.169 - g_warning ("Couldn't find pixmap file: %s", filename); 6.170 - return NULL; 6.171 - } 6.172 + if (!pathname) { 6.173 + g_warning ("Couldn't find pixmap file: %s", filename); 6.174 + return NULL; 6.175 + } 6.176 6.177 pixbuf = gdk_pixbuf_new_from_file (pathname, &error); 6.178 - if (!pixbuf) 6.179 - { 6.180 - fprintf (stderr, "Failed to load pixbuf file: %s: %s\n", 6.181 - pathname, error->message); 6.182 - g_error_free (error); 6.183 - } 6.184 - g_free (pathname); 6.185 + if (!pixbuf) { 6.186 + fprintf(stderr, "Failed to load pixbuf file: %s: %s\n", pathname, error->message); 6.187 + g_error_free(error); 6.188 + } 6.189 + g_free(pathname); 6.190 return pixbuf; 6.191 } 6.192 6.193 + 6.194 /* This is used to set ATK action descriptions. */ 6.195 -void 6.196 -glade_set_atk_action_description (AtkAction *action, 6.197 - const gchar *action_name, 6.198 - const gchar *description) 6.199 -{ 6.200 - gint n_actions, i; 6.201 +void glade_set_atk_action_description(AtkAction* action, const gchar* action_name, const gchar* description) { 6.202 + gint n_actions 6.203 + gint i; 6.204 6.205 n_actions = atk_action_get_n_actions (action); 6.206 - for (i = 0; i < n_actions; i++) 6.207 - { 6.208 - if (!strcmp (atk_action_get_name (action, i), action_name)) 6.209 - atk_action_set_description (action, i, description); 6.210 - } 6.211 + for (i = 0; i < n_actions; i++) { 6.212 + if (!strcmp (atk_action_get_name (action, i), action_name)) { 6.213 + atk_action_set_description (action, i, description); 6.214 + } 6.215 + } 6.216 } 6.217
7.1 --- a/support.h Tue Dec 04 16:48:51 2007 +0100 7.2 +++ b/support.h Tue Dec 04 20:23:25 2007 +0100 7.3 @@ -1,16 +1,6 @@ 7.4 -/* 7.5 - * DO NOT EDIT THIS FILE - it is generated by Glade. 7.6 - */ 7.7 - 7.8 -#ifdef HAVE_CONFIG_H 7.9 -# include <config.h> 7.10 -#endif 7.11 - 7.12 #include <gtk/gtk.h> 7.13 7.14 -/* 7.15 - * Public Functions. 7.16 - */ 7.17 +/* Public Functions */ 7.18 7.19 /* 7.20 * This function returns a widget in a component created by Glade. 7.21 @@ -18,27 +8,21 @@ 7.22 * or alternatively any widget in the component, and the name of the widget 7.23 * you want returned. 7.24 */ 7.25 -GtkWidget* lookup_widget (GtkWidget *widget, 7.26 - const gchar *widget_name); 7.27 +GtkWidget* lookup_widget(GtkWidget* widget, const gchar* widget_name); 7.28 7.29 7.30 /* Use this function to set the directory containing installed pixmaps. */ 7.31 -void add_pixmap_directory (const gchar *directory); 7.32 +void add_pixmap_directory(const gchar* directory); 7.33 7.34 7.35 -/* 7.36 - * Private Functions. 7.37 - */ 7.38 +/* Private Functions */ 7.39 + 7.40 7.41 /* This is used to create the pixmaps used in the interface. */ 7.42 -GtkWidget* create_pixmap (GtkWidget *widget, 7.43 - const gchar *filename); 7.44 +GtkWidget* create_pixmap(GtkWidget* widget, const gchar* filename); 7.45 7.46 /* This is used to create the pixbufs used in the interface. */ 7.47 -GdkPixbuf* create_pixbuf (const gchar *filename); 7.48 +GdkPixbuf* create_pixbuf(const gchar* filename); 7.49 7.50 /* This is used to set ATK action descriptions. */ 7.51 -void glade_set_atk_action_description (AtkAction *action, 7.52 - const gchar *action_name, 7.53 - const gchar *description); 7.54 - 7.55 +void glade_set_atk_action_description(AtkAction* action, const gchar* action_name, const gchar* description);