cropper

changeset 10:5e282003f0c1

minor changes; besser indenting
author meillo@marmaro.de
date Thu, 04 Mar 2010 13:54:17 +0100
parents 7e1cf00de1df
children c18ba4ea1514
files callbacks.c interface.c main.c main.h support.c
diffstat 5 files changed, 63 insertions(+), 55 deletions(-) [+]
line diff
     1.1 --- a/callbacks.c	Thu Mar 20 20:01:38 2008 +0100
     1.2 +++ b/callbacks.c	Thu Mar 04 13:54:17 2010 +0100
     1.3 @@ -7,7 +7,7 @@
     1.4  
     1.5  int image_width;
     1.6  int image_height;
     1.7 -float inc = 0.1;
     1.8 +float inc = 0.3;
     1.9  /*
    1.10  void update_spin_button_ratio(GtkWidget* spinbutton) {
    1.11  	g_print("ratio change: %f\n", ratio);
    1.12 @@ -169,7 +169,7 @@
    1.13  	static GdkPixbuf* pixbuf_new;
    1.14  	g_object_unref(pixbuf_new);
    1.15  
    1.16 -	pixbuf_new = gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_HYPER);
    1.17 +	pixbuf_new = gdk_pixbuf_scale_simple(image_buffer, image_width, image_height, GDK_INTERP_BILINEAR);
    1.18  	gtk_image_set_from_pixbuf((GtkImage*) lookup_widget(cropper_window, "image_area"), pixbuf_new);
    1.19  }
    1.20  
    1.21 @@ -227,6 +227,21 @@
    1.22  void on_cropper_window_create(GtkObject* object, gpointer user_data) {
    1.23  	image_width = gdk_pixbuf_get_width(image_buffer);
    1.24  	image_height = gdk_pixbuf_get_height(image_buffer);
    1.25 +
    1.26 +	/*
    1.27 +  image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL);
    1.28 +  image_area = gtk_image_new_from_pixbuf(image_buffer);
    1.29 +
    1.30 +	int w, h;
    1.31 +	GtkWidget* image_a;
    1.32 +
    1.33 +	image_a = (GtkWidget*) lookup_widget(cropper_window, "image_area");
    1.34 +	gdk_drawable_get_size (image_a->window, &w, &h);
    1.35 +
    1.36 +	image_width = w - 200;
    1.37 +	image_height = h - 150;
    1.38 +	set_zoom();
    1.39 +	*/
    1.40  }
    1.41  
    1.42  void on_cropper_window_destroy(GtkObject* object, gpointer user_data) {
     2.1 --- a/interface.c	Thu Mar 20 20:01:38 2008 +0100
     2.2 +++ b/interface.c	Thu Mar 04 13:54:17 2010 +0100
     2.3 @@ -72,7 +72,6 @@
     2.4    GtkWidget *frame1;
     2.5    GtkWidget *vbox7;
     2.6    GtkWidget *nav_container;
     2.7 -  GtkWidget *image_area;
     2.8    GtkWidget *hbox16;
     2.9    GtkWidget *hbox17;
    2.10    GtkWidget *crop_zoom_in_button;
    2.11 @@ -356,6 +355,7 @@
    2.12  /* image_area */
    2.13    image_buffer = gdk_pixbuf_new_from_file(image_filename, NULL);
    2.14    image_area = gtk_image_new_from_pixbuf(image_buffer);
    2.15 +
    2.16    gtk_widget_set_name(image_area, "image_area");
    2.17    gtk_widget_show(image_area);
    2.18    gtk_box_pack_start(GTK_BOX(nav_container), image_area, TRUE, TRUE, 0);
     3.1 --- a/main.c	Thu Mar 20 20:01:38 2008 +0100
     3.2 +++ b/main.c	Thu Mar 04 13:54:17 2010 +0100
     3.3 @@ -6,32 +6,24 @@
     3.4  
     3.5  int main (int argc, char *argv[]) {
     3.6  
     3.7 -	/* printf("argc: %i\nargv[0]: %s\nargv[1]: %s\nargv[2]: %s\n", argc, argv[0], argv[1], argv[2]); */
     3.8 -
     3.9  	/* commandline option handling */
    3.10  	if (argc == 2) {
    3.11 -		if (strcmp(argv[1], "--version") == 0) {
    3.12 -			g_print("cropper - a crop frontend for convert\nversion 0.1\nhttp://prog.marmaro.de\n");
    3.13 -			return(0);
    3.14 -		} else {
    3.15 -			image_filename = argv[1];
    3.16 -		}
    3.17 +		image_filename = argv[1];
    3.18  	} else {
    3.19 -		g_print("usage: cropper <image>\n       cropper --version\n");
    3.20 -		return(1);
    3.21 +		g_print("cropper -- a crop frontend to convert\n");
    3.22 +		g_print("usage: cropper IMAGE\n");
    3.23 +		return 1;
    3.24  	}
    3.25  
    3.26 +	gtk_set_locale();
    3.27 +	gtk_init(&argc, &argv);
    3.28  
    3.29 +	add_pixmap_directory("/usr/share/pixmaps");
    3.30  
    3.31 -  gtk_set_locale ();
    3.32 -  gtk_init (&argc, &argv);
    3.33 +	cropper_window = create_cropper_window();
    3.34 +	gtk_widget_show(cropper_window);
    3.35 +	gtk_main ();
    3.36  
    3.37 -  add_pixmap_directory ("/usr/share/pixmaps");
    3.38 -
    3.39 -  cropper_window = create_cropper_window ();
    3.40 -  gtk_widget_show (cropper_window);
    3.41 -
    3.42 -  gtk_main ();
    3.43 -  return 0;
    3.44 +	return 0;
    3.45  }
    3.46  
     4.1 --- a/main.h	Thu Mar 20 20:01:38 2008 +0100
     4.2 +++ b/main.h	Thu Mar 04 13:54:17 2010 +0100
     4.3 @@ -8,6 +8,7 @@
     4.4  
     4.5  /* from interface.h */
     4.6  GtkWidget* create_cropper_window(void);
     4.7 +GtkWidget *image_area;
     4.8  GdkPixbuf *image_buffer;
     4.9  
    4.10  #endif
     5.1 --- a/support.c	Thu Mar 20 20:01:38 2008 +0100
     5.2 +++ b/support.c	Thu Mar 04 13:54:17 2010 +0100
     5.3 @@ -10,10 +10,10 @@
     5.4  
     5.5  
     5.6  GtkWidget* lookup_widget(GtkWidget* widget, const gchar* widget_name) {
     5.7 -  GtkWidget* parent;
     5.8 +	GtkWidget* parent;
     5.9  	GtkWidget* found_widget;
    5.10  
    5.11 -  for (;;) {
    5.12 +	for (;;) {
    5.13  		if (GTK_IS_MENU (widget)) {
    5.14  			parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
    5.15  		} else {
    5.16 @@ -28,11 +28,11 @@
    5.17  		widget = parent;
    5.18  	}
    5.19  
    5.20 -  found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name);
    5.21 -  if (!found_widget) {
    5.22 -    g_warning ("Widget not found: %s", widget_name);
    5.23 +	found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget), widget_name);
    5.24 +	if (!found_widget) {
    5.25 +		g_warning ("Widget not found: %s", widget_name);
    5.26  	}
    5.27 -  return found_widget;
    5.28 +	return found_widget;
    5.29  }
    5.30  
    5.31  
    5.32 @@ -40,16 +40,16 @@
    5.33  
    5.34  /* Use this function to set the directory containing installed pixmaps. */
    5.35  void add_pixmap_directory(const gchar* directory) {
    5.36 -  pixmaps_directories = g_list_prepend (pixmaps_directories, g_strdup (directory));
    5.37 +	pixmaps_directories = g_list_prepend (pixmaps_directories, g_strdup (directory));
    5.38  }
    5.39  
    5.40  /* This is an internally used function to find pixmap files. */
    5.41  static gchar* find_pixmap_file(const gchar* filename) {
    5.42 -  GList* elem;
    5.43 +	GList* elem;
    5.44  
    5.45 -  /* We step through each of the pixmaps directory to find it. */
    5.46 -  elem = pixmaps_directories;
    5.47 -  while (elem) {
    5.48 +	/* We step through each of the pixmaps directory to find it. */
    5.49 +	elem = pixmaps_directories;
    5.50 +	while (elem) {
    5.51  		gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data, G_DIR_SEPARATOR_S, filename);
    5.52  		if (g_file_test (pathname, G_FILE_TEST_EXISTS)) {
    5.53  			return pathname;
    5.54 @@ -57,66 +57,66 @@
    5.55  		g_free (pathname);
    5.56  		elem = elem->next;
    5.57  	}
    5.58 -  return NULL;
    5.59 +	return NULL;
    5.60  }
    5.61  
    5.62  
    5.63  /* This is an internally used function to create pixmaps. */
    5.64  GtkWidget* create_pixmap(GtkWidget* widget, const gchar* filename) {
    5.65 -  gchar* pathname = NULL;
    5.66 -  GtkWidget* pixmap;
    5.67 +	gchar* pathname = NULL;
    5.68 +	GtkWidget* pixmap;
    5.69  
    5.70 -  if (!filename || !filename[0]) {
    5.71 +	if (!filename || !filename[0]) {
    5.72  		return gtk_image_new ();
    5.73  	}
    5.74  
    5.75 -  pathname = find_pixmap_file (filename);
    5.76 +	pathname = find_pixmap_file (filename);
    5.77  
    5.78 -  if (!pathname) {
    5.79 +	if (!pathname) {
    5.80  		g_warning ("Couldn't find pixmap file: %s", filename);
    5.81  		return gtk_image_new ();
    5.82  	}
    5.83  
    5.84 -  pixmap = gtk_image_new_from_file (pathname);
    5.85 -  g_free(pathname);
    5.86 -  return pixmap;
    5.87 +	pixmap = gtk_image_new_from_file (pathname);
    5.88 +	g_free(pathname);
    5.89 +	return pixmap;
    5.90  }
    5.91  
    5.92  
    5.93  /* This is an internally used function to create pixmaps. */
    5.94  GdkPixbuf* create_pixbuf(const gchar* filename) {
    5.95 -  gchar* pathname = NULL;
    5.96 -  GdkPixbuf* pixbuf;
    5.97 -  GError* error = NULL;
    5.98 +	gchar* pathname = NULL;
    5.99 +	GdkPixbuf* pixbuf;
   5.100 +	GError* error = NULL;
   5.101  
   5.102 -  if (!filename || !filename[0]) {
   5.103 +	if (!filename || !filename[0]) {
   5.104  		return NULL;
   5.105  	}
   5.106  
   5.107 -  pathname = find_pixmap_file(filename);
   5.108 +	pathname = find_pixmap_file(filename);
   5.109  
   5.110 -  if (!pathname) {
   5.111 +	if (!pathname) {
   5.112  		g_warning ("Couldn't find pixmap file: %s", filename);
   5.113  		return NULL;
   5.114  	}
   5.115  
   5.116 -  pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
   5.117 -  if (!pixbuf) {
   5.118 +	pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
   5.119 +	if (!pixbuf) {
   5.120  		fprintf(stderr, "Failed to load pixbuf file: %s: %s\n", pathname, error->message);
   5.121  		g_error_free(error);
   5.122  	}
   5.123 -  g_free(pathname);
   5.124 -  return pixbuf;
   5.125 +	g_free(pathname);
   5.126 +	return pixbuf;
   5.127  }
   5.128  
   5.129  
   5.130  /* This is used to set ATK action descriptions. */
   5.131  void glade_set_atk_action_description(AtkAction* action, const gchar* action_name, const gchar* description) {
   5.132 -  gint n_actions;
   5.133 +	gint n_actions;
   5.134  	gint i;
   5.135  
   5.136 -  n_actions = atk_action_get_n_actions (action);
   5.137 -  for (i = 0; i < n_actions; i++) {
   5.138 +	n_actions = atk_action_get_n_actions (action);
   5.139 +	for (i = 0; i < n_actions; i++) {
   5.140  		if (!strcmp (atk_action_get_name (action, i), action_name)) {
   5.141  			atk_action_set_description (action, i, description);
   5.142  		}