cropper

changeset 15:7dbf3879939a

removed support.*
author meillo@marmaro.de
date Thu, 04 Mar 2010 19:16:10 +0100
parents da18f2d4f92f
children 88b8856fccf5
files Makefile callbacks.c interface.c main.c support.c support.h
diffstat 6 files changed, 42 insertions(+), 180 deletions(-) [+]
line diff
     1.1 --- a/Makefile	Thu Mar 04 18:31:28 2010 +0100
     1.2 +++ b/Makefile	Thu Mar 04 19:16:10 2010 +0100
     1.3 @@ -2,8 +2,8 @@
     1.4  
     1.5  NAME    = cropper
     1.6  
     1.7 -SRC = interface.c callbacks.c support.c main.c
     1.8 -DEP = main.h callbacks.h support.h
     1.9 +SRC = interface.c callbacks.c main.c
    1.10 +DEP = main.h callbacks.h
    1.11  OBJ = ${SRC:.c=.o}
    1.12  
    1.13  CC = gcc
    1.14 @@ -21,10 +21,9 @@
    1.15  	${CC} ${CFLAGS} -c $<
    1.16  
    1.17  
    1.18 -support.o: support.h
    1.19 -interface.o: main.h callbacks.h support.h
    1.20 -callbacks.o: main.h callbacks.h support.h
    1.21 -main.o: main.h support.h
    1.22 +interface.o: main.h callbacks.h
    1.23 +callbacks.o: main.h callbacks.h
    1.24 +main.o: main.h
    1.25  
    1.26  
    1.27  clean:
     2.1 --- a/callbacks.c	Thu Mar 04 18:31:28 2010 +0100
     2.2 +++ b/callbacks.c	Thu Mar 04 19:16:10 2010 +0100
     2.3 @@ -3,7 +3,6 @@
     2.4  #include <gdk/gdkkeysyms.h>
     2.5  #include "main.h"
     2.6  #include "callbacks.h"
     2.7 -#include "support.h"
     2.8  
     2.9  int image_width;
    2.10  int image_height;
     3.1 --- a/interface.c	Thu Mar 04 18:31:28 2010 +0100
     3.2 +++ b/interface.c	Thu Mar 04 19:16:10 2010 +0100
     3.3 @@ -10,7 +10,6 @@
     3.4  
     3.5  #include "main.h"
     3.6  #include "callbacks.h"
     3.7 -#include "support.h"
     3.8  
     3.9  #define GLADE_HOOKUP_OBJECT(component,widget,name) \
    3.10    g_object_set_data_full(G_OBJECT(component), name, \
    3.11 @@ -19,6 +18,43 @@
    3.12  #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
    3.13    g_object_set_data(G_OBJECT(component), name, widget)
    3.14  
    3.15 +
    3.16 +/*
    3.17 + * This function returns a widget in a component created by Glade.
    3.18 + * Call it with the toplevel widget in the component (i.e. a window/dialog),
    3.19 + * or alternatively any widget in the component, and the name of the widget
    3.20 + * you want returned.
    3.21 + */
    3.22 +GtkWidget*
    3.23 +lookup_widget(GtkWidget* widget, const gchar* widget_name)
    3.24 +{
    3.25 +	GtkWidget* parent;
    3.26 +	GtkWidget* found_widget;
    3.27 +
    3.28 +	for (;;) {
    3.29 +		if (GTK_IS_MENU(widget)) {
    3.30 +			parent = gtk_menu_get_attach_widget(GTK_MENU(widget));
    3.31 +		} else {
    3.32 +			parent = widget->parent;
    3.33 +		}
    3.34 +		if (!parent) {
    3.35 +			parent = (GtkWidget*) g_object_get_data(G_OBJECT(widget), "GladeParentKey");
    3.36 +		}
    3.37 +		if (parent == NULL) {
    3.38 +			break;
    3.39 +		}
    3.40 +		widget = parent;
    3.41 +	}
    3.42 +
    3.43 +	found_widget = (GtkWidget*) g_object_get_data(G_OBJECT(widget), widget_name);
    3.44 +	if (!found_widget) {
    3.45 +		g_warning("Widget not found: %s", widget_name);
    3.46 +	}
    3.47 +	return found_widget;
    3.48 +}
    3.49 +
    3.50 +
    3.51 +
    3.52  GtkWidget*
    3.53  create_cropper_window(void)
    3.54  {
     4.1 --- a/main.c	Thu Mar 04 18:31:28 2010 +0100
     4.2 +++ b/main.c	Thu Mar 04 19:16:10 2010 +0100
     4.3 @@ -1,7 +1,6 @@
     4.4  #include <gtk/gtk.h>
     4.5  
     4.6  #include "main.h"
     4.7 -#include "support.h"
     4.8  
     4.9  
    4.10  int
    4.11 @@ -15,16 +14,8 @@
    4.12  	}
    4.13  
    4.14  	image_filename = argv[1];
    4.15 -
    4.16 -/*
    4.17 -	gtk_set_locale();
    4.18 -*/
    4.19  	gtk_init(&argc, &argv);
    4.20  
    4.21 -/*
    4.22 -	add_pixmap_directory("/usr/share/pixmaps");
    4.23 -*/
    4.24 -
    4.25  	cropper_window = create_cropper_window();
    4.26  	gtk_widget_show(cropper_window);
    4.27  	gtk_main();
     5.1 --- a/support.c	Thu Mar 04 18:31:28 2010 +0100
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,135 +0,0 @@
     5.4 -#include <sys/types.h>
     5.5 -#include <sys/stat.h>
     5.6 -#include <unistd.h>
     5.7 -#include <string.h>
     5.8 -#include <stdio.h>
     5.9 -#include <gtk/gtk.h>
    5.10 -#include "support.h"
    5.11 -
    5.12 -static GList *pixmaps_directories = NULL;
    5.13 -
    5.14 -
    5.15 -GtkWidget*
    5.16 -lookup_widget(GtkWidget* widget, const gchar* widget_name)
    5.17 -{
    5.18 -	GtkWidget* parent;
    5.19 -	GtkWidget* found_widget;
    5.20 -
    5.21 -	for (;;) {
    5.22 -		if (GTK_IS_MENU(widget)) {
    5.23 -			parent = gtk_menu_get_attach_widget(GTK_MENU(widget));
    5.24 -		} else {
    5.25 -			parent = widget->parent;
    5.26 -		}
    5.27 -		if (!parent) {
    5.28 -			parent = (GtkWidget*) g_object_get_data(G_OBJECT(widget), "GladeParentKey");
    5.29 -		}
    5.30 -		if (parent == NULL) {
    5.31 -			break;
    5.32 -		}
    5.33 -		widget = parent;
    5.34 -	}
    5.35 -
    5.36 -	found_widget = (GtkWidget*) g_object_get_data(G_OBJECT(widget), widget_name);
    5.37 -	if (!found_widget) {
    5.38 -		g_warning("Widget not found: %s", widget_name);
    5.39 -	}
    5.40 -	return found_widget;
    5.41 -}
    5.42 -
    5.43 -
    5.44 -/* Use this function to set the directory containing installed pixmaps. */
    5.45 -void
    5.46 -add_pixmap_directory(const gchar* directory)
    5.47 -{
    5.48 -	pixmaps_directories = g_list_prepend(pixmaps_directories, g_strdup(directory));
    5.49 -}
    5.50 -
    5.51 -
    5.52 -/* This is an internally used function to find pixmap files. */
    5.53 -static gchar*
    5.54 -find_pixmap_file(const gchar* filename)
    5.55 -{
    5.56 -	GList* elem;
    5.57 -
    5.58 -	/* We step through each of the pixmaps directory to find it. */
    5.59 -	elem = pixmaps_directories;
    5.60 -	while (elem) {
    5.61 -		gchar *pathname = g_strdup_printf("%s%s%s", (gchar*)elem->data, G_DIR_SEPARATOR_S, filename);
    5.62 -		if (g_file_test(pathname, G_FILE_TEST_EXISTS)) {
    5.63 -			return pathname;
    5.64 -		}
    5.65 -		g_free(pathname);
    5.66 -		elem = elem->next;
    5.67 -	}
    5.68 -	return NULL;
    5.69 -}
    5.70 -
    5.71 -
    5.72 -/* This is an internally used function to create pixmaps. */
    5.73 -GtkWidget*
    5.74 -create_pixmap(GtkWidget* widget, const gchar* filename)
    5.75 -{
    5.76 -	gchar* pathname = NULL;
    5.77 -	GtkWidget* pixmap;
    5.78 -
    5.79 -	if (!filename || !filename[0]) {
    5.80 -		return gtk_image_new();
    5.81 -	}
    5.82 -
    5.83 -	pathname = find_pixmap_file(filename);
    5.84 -
    5.85 -	if (!pathname) {
    5.86 -		g_warning("Couldn't find pixmap file: %s", filename);
    5.87 -		return gtk_image_new();
    5.88 -	}
    5.89 -
    5.90 -	pixmap = gtk_image_new_from_file(pathname);
    5.91 -	g_free(pathname);
    5.92 -	return pixmap;
    5.93 -}
    5.94 -
    5.95 -
    5.96 -/* This is an internally used function to create pixmaps. */
    5.97 -GdkPixbuf*
    5.98 -create_pixbuf(const gchar* filename)
    5.99 -{
   5.100 -	gchar* pathname = NULL;
   5.101 -	GdkPixbuf* pixbuf;
   5.102 -	GError* error = NULL;
   5.103 -
   5.104 -	if (!filename || !filename[0]) {
   5.105 -		return NULL;
   5.106 -	}
   5.107 -
   5.108 -	pathname = find_pixmap_file(filename);
   5.109 -
   5.110 -	if (!pathname) {
   5.111 -		g_warning("Couldn't find pixmap file: %s", filename);
   5.112 -		return NULL;
   5.113 -	}
   5.114 -
   5.115 -	pixbuf = gdk_pixbuf_new_from_file(pathname, &error);
   5.116 -	if (!pixbuf) {
   5.117 -		fprintf(stderr, "Failed to load pixbuf file: %s: %s\n", pathname, error->message);
   5.118 -		g_error_free(error);
   5.119 -	}
   5.120 -	g_free(pathname);
   5.121 -	return pixbuf;
   5.122 -}
   5.123 -
   5.124 -
   5.125 -/* This is used to set ATK action descriptions. */
   5.126 -void
   5.127 -glade_set_atk_action_description(AtkAction* action, const gchar* action_name, const gchar* description)
   5.128 -{
   5.129 -	gint n_actions;
   5.130 -	gint i;
   5.131 -
   5.132 -	n_actions = atk_action_get_n_actions(action);
   5.133 -	for (i = 0; i < n_actions; i++) {
   5.134 -		if (!strcmp(atk_action_get_name(action, i), action_name)) {
   5.135 -			atk_action_set_description(action, i, description);
   5.136 -		}
   5.137 -	}
   5.138 -}
     6.1 --- a/support.h	Thu Mar 04 18:31:28 2010 +0100
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,28 +0,0 @@
     6.4 -#include <gtk/gtk.h>
     6.5 -
     6.6 -/* Public Functions  */
     6.7 -
     6.8 -/*
     6.9 - * This function returns a widget in a component created by Glade.
    6.10 - * Call it with the toplevel widget in the component (i.e. a window/dialog),
    6.11 - * or alternatively any widget in the component, and the name of the widget
    6.12 - * you want returned.
    6.13 - */
    6.14 -GtkWidget* lookup_widget(GtkWidget* widget, const gchar* widget_name);
    6.15 -
    6.16 -
    6.17 -/* Use this function to set the directory containing installed pixmaps. */
    6.18 -void add_pixmap_directory(const gchar* directory);
    6.19 -
    6.20 -
    6.21 -/* Private Functions  */
    6.22 -
    6.23 -
    6.24 -/* This is used to create the pixmaps used in the interface. */
    6.25 -GtkWidget* create_pixmap(GtkWidget* widget, const gchar* filename);
    6.26 -
    6.27 -/* This is used to create the pixbufs used in the interface. */
    6.28 -GdkPixbuf* create_pixbuf(const gchar* filename);
    6.29 -
    6.30 -/* This is used to set ATK action descriptions. */
    6.31 -void glade_set_atk_action_description(AtkAction* action, const gchar* action_name, const gchar* description);