telegnome r16 - in trunk: . doc/C macros src



Author: cjwatson
Date: Thu Feb 21 10:19:03 2008
New Revision: 16
URL: http://svn.gnome.org/viewvc/telegnome?rev=16&view=rev

Log:
Initial conversion to GNOME 2.
* configure.in (AM_ACLOCAL_INCLUDE): Remove.
(GNOME_INIT): Call GNOME_COMMON_INIT instead.
(GNOME_DEBUG_CHECK, GNOME_COMPILE_WARNINGS): Add.
(GNOME_X_CHECKS): Remove.
(PKG_CHECK_MODULES): Check for glib-2.0 and libgnomeui-2.0.
(AM_GNU_GETTEXT): Call AM_GLIB_GNU_GETTEXT instead.
(AM_GLIB_DEFINE_LOCALEDIR): Call this instead of doing it by hand.
(AC_CONFIG_FILES): Remove macros/Makefile.
* src/Makefile.am (INCLUDES): Use AM_CPPFLAGS instead. Remove explicit
definition of GNOMELOCALEDIR, now handled by configure. Add
TELEGNOME_CFLAGS.
(LINK_FLAGS): Remove gdk_pixbuf and gnomecanvaspixbuf linkage.
(telegnome_LDADD): Remove GNOMEUI_LIBS. Add TELEGNOME_LIBS.
* src/channel.c: Tweak gnome.h inclusion. Remove unused alloc_count
declaration.
* src/gui.c (new_gui, new_toolbar, create_channel_menu): Remove unused
declarations.
(new_gui): GNOME_DOCK_TOP is now BONOBO_DOCK_TOP. Explicitly
initialise gui.logo_timer in all cases.
(gui_save_session, get_the_page): Return void instead of gint.
(new_toolbar): Adjust for new gtk_toolbar_new signature. Use GTK+ 2
stock widgets. Cast signal functions for gtk_toolbar_append_item.
(load_channels_from_config, cb_quit): Free channel list in a way that
doesn'\''t generate compiler warnings.
(refresh_channel_menu): Use g_object_unref instead of
gtk_widget_destroy.
(new_entry): Split gtk_entry_new_with_max_length into gtk_entry_new
and gtk_entry_set_max_length.
(get_the_page, gui_logo_timer): Guard gui.logo_timer removal against
invalid timers.
(cb_about): Adjust for new gnome_about_new signature.
(cb_drag): Constify entry.
(cb_keypress): Only grab the focus if the entry didn'\''t already have
it. Return 0 rather than 1 to let GTK+ update the visible text.
* src/gui.h (get_the_page): Update prototype.
* src/http.c (get_page_entry): Constify argument.
* src/http.h (get_page_entry): Update prototype.
* src/main.c (main): Call gnome_program_init instead of gnome_init.
* src/pixpack.c (pixpack_draw): Remove.
(pixpack_class_init): Don'\''t set draw handler.
(pixpack_destroy): Use g_object_unref instead of gdk_pixbuf_unref.
Make safer against repeated calls.
(pixpack_paint): Clear the correct area. Use g_object_unref instead of
gdk_pixbuf_unref.
(pixpack_expose): Return gboolean instead of gint.
(pixpack_load_image_file): gdk_pixbuf_new_from_file takes a GError
now.
(pixpack_get_autosize): Fix assertion to return a value.
* src/pixpack.h (pixpack_set_autosize): Add prototype.
* src/prefs.c (fill_channel_list): gtk_clist_set_row_data_full wants a
GtkDestroyNotify, not a GtkSignalFunc.
(construct_channels_page, prefs_channel_move_up_cb)
(prefs_channel_move_down_cb, prefs_channel_edit_cb): Remove unused
declarations.
(prefs_cancel_cb): Use g_object_unref instead of gtk_widget_destroy.
* src/view.c (tele_view_new): Remove unused declarations.
(tele_view_update_pixmap): Fix file existence test.
(tele_view_free): Use g_object_unref rather than gtk_widget_destroy.
* src/view.h: Include libgnomecanvas/gnome-canvas.h rather than
libgnomeui/gnome-canvas.h.
* macros/gnome-ghttp-check.m4: Move temporarily to ...
* acinclude.m4: ... here. This will go away once we convert to a
different HTTP library, but in the meantime this lets us get rid of
the macros directory.
* macros: Remove.
* Makefile.am (SUBDIRS): Remove macros.
(macros/macros.dep): Remove rebuild rule.
* autogen.sh: Use gnome-autogen.sh.

Added:
   trunk/acinclude.m4
Removed:
   trunk/macros/
Modified:
   trunk/   (props changed)
   trunk/ChangeLog
   trunk/Makefile.am
   trunk/autogen.sh
   trunk/configure.in
   trunk/doc/C/   (props changed)
   trunk/src/   (props changed)
   trunk/src/Makefile.am
   trunk/src/channel.c
   trunk/src/gui.c
   trunk/src/gui.h
   trunk/src/http.c
   trunk/src/http.h
   trunk/src/main.c
   trunk/src/pixpack.c
   trunk/src/pixpack.h
   trunk/src/prefs.c
   trunk/src/view.c
   trunk/src/view.h

Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am	(original)
+++ trunk/Makefile.am	Thu Feb 21 10:19:03 2008
@@ -1,4 +1,4 @@
-SUBDIRS=macros src po pixmaps doc
+SUBDIRS=src po pixmaps doc
 
 EXTRA_DIST = config.rpath m4/ChangeLog \
 	$(srcdir)/telegnome.desktop \
@@ -7,10 +7,4 @@
 Internetdir=$(datadir)/gnome/apps/Internet
 Internet_DATA= telegnome.desktop
 
-## to automatically rebuild aclocal.m4 if any of the macros in
-## `macros/' change
- MAINT@include macros/macros.dep
- MAINT@macros/macros.dep: macros/Makefile.am
- MAINT@ cd macros && $(MAKE) macros.dep
-
 ACLOCAL_AMFLAGS = -I m4

Added: trunk/acinclude.m4
==============================================================================
--- (empty file)
+++ trunk/acinclude.m4	Thu Feb 21 10:19:03 2008
@@ -0,0 +1,14 @@
+AC_DEFUN([GNOME_GHTTP_CHECK],[
+	GHTTP_LIB=
+	AC_CHECK_FUNC(connect,,[
+	  AC_CHECK_LIB(socket,connect,
+		GHTTP_LIB="-lsocket $GHTTP_LIB",,$GHTTP_LIB)])
+	AC_CHECK_FUNC(gethostbyname,,[
+ 	  AC_CHECK_LIB(nsl,gethostbyname,
+		GHTTP_LIB="-lnsl $GHTTP_LIB",,$GHTTP_LIB)])
+	AC_CHECK_LIB(ghttp, ghttp_request_new, 
+		GHTTP_LIB="-lghttp $GHTTP_LIB",GHTTP_LIB="",$GHTTP_LIB, ghttp_found=yes)
+
+	AC_SUBST(GHTTP_LIB)
+	AC_PROVIDE([GNOME_GHTTP_CHECK])
+])

Modified: trunk/autogen.sh
==============================================================================
--- trunk/autogen.sh	(original)
+++ trunk/autogen.sh	Thu Feb 21 10:19:03 2008
@@ -14,4 +14,9 @@
     exit 1
 }
 
-. $srcdir/macros/autogen.sh
+which gnome-autogen.sh || {
+    echo "You need to install gnome-common from the GNOME SVN"
+    exit 1
+}
+
+. gnome-autogen.sh

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Thu Feb 21 10:19:03 2008
@@ -7,9 +7,9 @@
 
 AM_MAINTAINER_MODE
 
-AM_ACLOCAL_INCLUDE(macros m4)
-
-GNOME_INIT
+GNOME_COMMON_INIT
+GNOME_DEBUG_CHECK
+GNOME_COMPILE_WARNINGS([maximum])
 
 AC_ISC_POSIX
 AC_PROG_CC
@@ -17,21 +17,19 @@
 AC_HEADER_STDC
 AC_PROG_INSTALL
 
-GNOME_X_CHECKS
+PKG_CHECK_MODULES([TELEGNOME], [glib-2.0 libgnomeui-2.0])
 GNOME_GHTTP_CHECK
 
 PROGRAMS_TELEGNOME="telegnome"
 AC_SUBST(PROGRAMS_TELEGNOME)
 
 ALL_LINGUAS="az fr it nl ru sv zh_CN"
-AM_GNU_GETTEXT([external])
-localedir='${prefix}/${DATADIRNAME}/locale'
-AC_SUBST(localedir)
+AM_GLIB_GNU_GETTEXT
+AM_GLIB_DEFINE_LOCALEDIR([GNOMELOCALEDIR])
 
 AC_CONFIG_FILES([Makefile 
 	   pixmaps/Makefile 
 	   src/Makefile
-	   macros/Makefile 
 	   po/Makefile.in
 	   doc/Makefile
 	   doc/C/Makefile

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Thu Feb 21 10:19:03 2008
@@ -1,5 +1,4 @@
-INCLUDES= -I. -I$(srcdir)/ $(GNOME_INCLUDEDIR) \
-	  -DGNOMELOCALEDIR=\""$(datadir)/locale"\"
+AM_CPPFLAGS = -I. -I$(srcdir)/ $(TELEGNOME_CFLAGS)
 
 bin_PROGRAMS=telegnome
 telegnome_SOURCES= \
@@ -19,5 +18,5 @@
 	channel.c \
 	channel.h
 
-LINK_FLAGS= $(GNOME_LIBDIR) $(INTLLIBS) $(GHTTP_LIB) -lgdk_pixbuf -lgnomecanvaspixbuf
-telegnome_LDADD=$(LINK_FLAGS) $(GNOME_LIBDIR) $(GNOMEUI_LIBS)
+LINK_FLAGS= $(GNOME_LIBDIR) $(INTLLIBS) $(GHTTP_LIB)
+telegnome_LDADD=$(LINK_FLAGS) $(GNOME_LIBDIR) $(TELEGNOME_LIBS)

Modified: trunk/src/channel.c
==============================================================================
--- trunk/src/channel.c	(original)
+++ trunk/src/channel.c	Thu Feb 21 10:19:03 2008
@@ -24,10 +24,8 @@
 **  
 */
 
+#include <gnome.h>
 #include "channel.h"
-#include "gnome.h"
-
-static int alloc_count = 0;
 
 Channel *
 channel_new(int id, const char *name, const char *desc, const char *page_url, const char *subpage_url, const char *country)

Modified: trunk/src/gui.c
==============================================================================
--- trunk/src/gui.c	(original)
+++ trunk/src/gui.c	Thu Feb 21 10:19:03 2008
@@ -39,7 +39,7 @@
 gint gui_logo_timer(gpointer g);
 gint gui_pager_timer(gpointer g);
 void gui_restore_session(void);
-gint gui_save_session(void);
+void gui_save_session(void);
 void cb_toggle_paging(GtkWidget *w, gpointer data);
 
 void die (GnomeClient *client, gpointer client_data);
@@ -58,7 +58,7 @@
 GtkWidget *
 new_gui (gchar* startpage) 
 {
-    GtkWidget *app, *toolbar, *vbox, *statusbar;
+    GtkWidget *app, *toolbar, *statusbar;
     
 
     /* the app */
@@ -76,7 +76,7 @@
     /* attach the menu */
     gnome_app_create_menus(GNOME_APP(app), menubar);
 
-    gnome_app_add_toolbar(GNOME_APP(app), GTK_TOOLBAR(toolbar), "nav_toolbar", 0, GNOME_DOCK_TOP, 2, 0, 0);
+    gnome_app_add_toolbar(GNOME_APP(app), GTK_TOOLBAR(toolbar), "nav_toolbar", 0, BONOBO_DOCK_TOP, 2, 0, 0);
 
     /* the view */
     currentview = tele_view_new();
@@ -134,6 +134,8 @@
 
     if (currentview->page_nr >0 )
 	gui.logo_timer = gtk_timeout_add(TG_LOGO_TIMEOUT,gui_logo_timer, NULL);
+    else
+	gui.logo_timer = -1;
     
     /*
     if (GNOME_CLIENT_CONNECTED (gui.client)) {
@@ -223,7 +225,7 @@
     /* g_print("Number: %d/%d\n", currentview->page_nr, currentview->subpage_nr); */
 }
 
-gint gui_save_session(void)
+void gui_save_session(void)
 {
     gnome_config_set_bool("/telegnome/Paging/enabled", gui.page_status);
     gnome_config_set_int("/telegnome/Paging/interval", gui.page_msecs);
@@ -241,10 +243,9 @@
 GtkWidget *
 new_toolbar ()
 {
-    GtkWidget *icon, *zoomlabel, *toolbar, *entry, *p, *hbox, *w;
+    GtkWidget *icon, *toolbar, *entry, *hbox, *w;
     
-    toolbar= gtk_toolbar_new (GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS);
-    gtk_toolbar_set_space_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_SPACE_LINE);
+    toolbar= gtk_toolbar_new();
 
     hbox = gtk_hbox_new(FALSE, 0);
     
@@ -258,31 +259,37 @@
     gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 5);
     gtk_toolbar_append_widget (GTK_TOOLBAR(toolbar), hbox, "", "");
 
-    icon = gnome_stock_pixmap_widget(toolbar, GNOME_STOCK_PIXMAP_JUMP_TO);
+    icon = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO,
+				    GTK_ICON_SIZE_LARGE_TOOLBAR);
     gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), 
 			    NULL,  _("Go To Page"),
-			    NULL, icon, cb_goto_page, NULL);
+			    NULL, icon, GTK_SIGNAL_FUNC(cb_goto_page), NULL);
     
-    icon = gnome_stock_pixmap_widget(toolbar, GNOME_STOCK_PIXMAP_BACK);
+    icon = gtk_image_new_from_stock(GTK_STOCK_GO_BACK,
+				    GTK_ICON_SIZE_LARGE_TOOLBAR);
     gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), 
 			    NULL,  _("Get Previous Page"),
-			    NULL, icon, cb_prev_page, NULL);
+			    NULL, icon, GTK_SIGNAL_FUNC(cb_prev_page), NULL);
     
-    icon = gnome_stock_pixmap_widget(toolbar, GNOME_STOCK_PIXMAP_FORWARD);
+    icon = gtk_image_new_from_stock(GTK_STOCK_GO_FORWARD,
+				    GTK_ICON_SIZE_LARGE_TOOLBAR);
     gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), 
 			    NULL, _("Get Next Page"),
-			    NULL, icon, cb_next_page, NULL);
+			    NULL, icon, GTK_SIGNAL_FUNC(cb_next_page), NULL);
     
-    icon = gnome_stock_pixmap_widget(toolbar, GNOME_STOCK_PIXMAP_HOME);
+    icon = gtk_image_new_from_stock(GTK_STOCK_HOME,
+				    GTK_ICON_SIZE_LARGE_TOOLBAR);
     gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), 
 			    NULL, _("Go to the home page"),
-			    NULL, icon, cb_home, NULL);
+			    NULL, icon, GTK_SIGNAL_FUNC(cb_home), NULL);
     
-    icon = gnome_stock_pixmap_widget(toolbar, GNOME_STOCK_PIXMAP_TIMER);
+    icon = gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY,
+				    GTK_ICON_SIZE_LARGE_TOOLBAR);
     w = gtk_toggle_button_new();
     gui.pagebutton = w;
     gtk_container_add(GTK_CONTAINER(w), icon);
-    gtk_signal_connect(GTK_OBJECT(w), "clicked", cb_toggle_paging, NULL);
+    gtk_signal_connect(GTK_OBJECT(w), "clicked",
+		       GTK_SIGNAL_FUNC(cb_toggle_paging), NULL);
     gtk_toolbar_append_widget(GTK_TOOLBAR(toolbar), w, _("Toggles auto-paging"), NULL);
 
     /* FIXME */ /*
@@ -313,7 +320,11 @@
     Channel *channel;
 
     if (gui.channels != NULL) {
-	g_slist_foreach(gui.channels, (GFunc)channel_free, NULL);
+	GSList *old_channels = gui.channels;
+	while (old_channels != NULL) {
+	    channel_free((Channel *)old_channels->data);
+	    old_channels = g_slist_next(old_channels);
+	}
 	g_slist_free(gui.channels);
 	gui.channels = NULL;
     }
@@ -344,12 +355,9 @@
 GtkWidget *
 create_channel_menu()
 {
-    GtkWidget *menu, *item, *pixmap;
-    int count,i;
+    GtkWidget *menu, *item;
+    int i;
     Channel *channel;
-    
-    GnomeUIInfo channel_menu[TG_MAX_CHANNELS];
-    
 
     g_assert(gui.channels != NULL);
     menu = gtk_menu_new();
@@ -387,7 +395,7 @@
 {
     /* dispose the menu if it was already added */
     if (gui.channel_menu != NULL) {
-	gtk_widget_destroy(gui.channel_menu);
+	g_object_unref(gui.channel_menu);
     }
     
     /* load the channels from disk */
@@ -407,7 +415,9 @@
 new_entry ()
 {
 	GtkWidget *entry=NULL;
-	entry=gtk_entry_new_with_max_length(TG_PAGE_SIZE + 1 + TG_SUBPAGE_SIZE);
+	entry=gtk_entry_new();
+	gtk_entry_set_max_length(GTK_ENTRY(entry),
+				 TG_PAGE_SIZE + 1 + TG_SUBPAGE_SIZE);
 	
 	/* hack */
 	gtk_widget_set_usize(GTK_WIDGET(entry),
@@ -457,7 +467,7 @@
  * if redraw == TRUE, redraws whole app
  * (needed when zoom_factor has changed)
  */
-gint
+void
 get_the_page(gboolean redraw)
 {
     /* hide the app */
@@ -465,7 +475,9 @@
 	gtk_widget_hide(GTK_WIDGET(gui.app));
     
     /* stop the logo timer */
-    gtk_timeout_remove(gui.logo_timer);
+    if (gui.logo_timer != -1)
+	gtk_timeout_remove(gui.logo_timer);
+    gui.logo_timer = -1;
 
     tele_view_update_page(currentview, &currentview->page_nr, &currentview->subpage_nr);
 
@@ -488,7 +500,11 @@
 
     /* free the channels */
     if (gui.channels != NULL) {
-	g_slist_foreach(gui.channels, (GFunc)channel_free, NULL);
+	GSList *old_channels = gui.channels;
+	while (old_channels != NULL) {
+	    channel_free((Channel *)old_channels->data);
+	    old_channels = g_slist_next(old_channels);
+	}
 	g_slist_free(gui.channels);
 	gui.channels = NULL;
     }
@@ -516,8 +532,8 @@
 
     about= gnome_about_new (PACKAGE, VERSION,
 				_("(c) 1999, 2000 Dirk-Jan C. Binnema, Arjan Scherpenisse"),
-				authors,
 				_("Teletext for GNOME\nReleased under the terms of the GPL"), 
+				authors, NULL, NULL,
 				NULL);
 
     gnome_dialog_set_parent(GNOME_DIALOG(about), GTK_WINDOW(gui.app));
@@ -607,7 +623,7 @@
 cb_drag (GtkWidget *widget, GdkDragContext *context, GtkSelectionData *selection_data,
 	 guint info, guint32 time)
 {
-	gchar *entry;
+	const gchar *entry;
 
 	switch (info) {
 
@@ -626,7 +642,7 @@
 		entry=gtk_entry_get_text(GTK_ENTRY(gui.entry));
 		gtk_selection_data_set(selection_data, 
 				       selection_data->target, 8,
-				       entry, strlen(entry));
+				       (const guchar *)entry, strlen(entry));
 		
 		break;
 	}
@@ -642,7 +658,8 @@
     }
     
     /* g_print("keypress\n"); */
-    gtk_widget_grab_focus(GTK_WIDGET(gui.entry));
+    if (!gtk_widget_is_focus(GTK_WIDGET(gui.entry)))
+	gtk_widget_grab_focus(GTK_WIDGET(gui.entry));
 
     if (gui.kb_status == INPUT_NEW) {
 	gtk_entry_set_text(GTK_ENTRY(gui.entry), "");
@@ -652,7 +669,7 @@
 	gtk_timeout_remove(gui.kb_timer);
     gui.kb_timer = gtk_timeout_add(TG_KB_TIMEOUT, gui_keyboard_timer, NULL);
     gui.kb_status = INPUT_CONTINUED;
-    return 1;
+    return 0;
 }
 
 gint 
@@ -702,7 +719,9 @@
 gint 
 gui_logo_timer(gpointer g) 
 {
-    gtk_timeout_remove(gui.logo_timer);
+    if (gui.logo_timer != -1)
+	gtk_timeout_remove(gui.logo_timer);
+    gui.logo_timer = -1;
     get_the_page(FALSE);
     return 0;
 }

Modified: trunk/src/gui.h
==============================================================================
--- trunk/src/gui.h	(original)
+++ trunk/src/gui.h	Thu Feb 21 10:19:03 2008
@@ -43,7 +43,7 @@
 void print_in_statusbar (const char *buf);
 int update_entry (gint page_nr, gint subpage_nr);
 gint update_pixmap (char *filename, gboolean redraw);
-gint get_the_page(gboolean redraw);
+void get_the_page(gboolean redraw);
 
 
 /* event handler callbacks */

Modified: trunk/src/http.c
==============================================================================
--- trunk/src/http.c	(original)
+++ trunk/src/http.c	Thu Feb 21 10:19:03 2008
@@ -33,27 +33,32 @@
  * get the pagenumber from the entrybox 
  */
 int
-get_page_entry (gchar *page_entry)
+get_page_entry (const gchar *page_entry)
 {	
 	guint page_nr;
 	guint subpage_nr=0;
+	gchar *page_entry_copy = g_strdup(page_entry);
+
 	errno=0;
 
 	/* TODO: Clean this up ;) */
-	if (strlen (page_entry) > 3) {  
+	if (strlen (page_entry_copy) > 3) {  
 		/* split in page and subpage */
-		gchar *subpage_entry= &page_entry[TG_PAGE_SIZE + 1];
-		page_entry[TG_PAGE_SIZE]='\0';
+		gchar *subpage_entry= &page_entry_copy[TG_PAGE_SIZE + 1];
+		page_entry_copy[TG_PAGE_SIZE]='\0';
 		subpage_nr= strtol(subpage_entry,NULL,10);
 	}
    
-	page_nr= strtol(page_entry,NULL,10);
-	if (0 != errno)
+	page_nr= strtol(page_entry_copy,NULL,10);
+	if (0 != errno) {
+		g_free(page_entry_copy);
 		return -1;
+	}
    
 	currentview->page_nr=    page_nr;
 	currentview->subpage_nr= subpage_nr;
 
+	g_free(page_entry_copy);
 	return 0;
 }
 

Modified: trunk/src/http.h
==============================================================================
--- trunk/src/http.h	(original)
+++ trunk/src/http.h	Thu Feb 21 10:19:03 2008
@@ -41,7 +41,7 @@
 
 #define PAGE_MINSIZE 4000 /* min size for file to be considered 'good' result */
 
-int get_page_entry (gchar *page_entry);
+int get_page_entry (const gchar *page_entry);
 gint get_the_image (char **);
 int get_http_query (gchar* buffer, gint page_nr, gint subpage_nr);
 

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Thu Feb 21 10:19:03 2008
@@ -45,7 +45,8 @@
 	bindtextdomain(PACKAGE,GNOMELOCALEDIR);
 	textdomain(PACKAGE);
 
-	gnome_init (PACKAGE, VERSION, argc, argv);
+	gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE, argc, argv,
+			    NULL);
 
 	/* build gui, handle cmd line args */
 	if ((argc >1) && (strlen(argv[1])<6)) {
@@ -59,13 +60,3 @@
 
 	return 0;
 }
-
-
-
-
-
-
-
-
-
-

Modified: trunk/src/pixpack.c
==============================================================================
--- trunk/src/pixpack.c	(original)
+++ trunk/src/pixpack.c	Thu Feb 21 10:19:03 2008
@@ -40,7 +40,6 @@
 static void	pixpack_destroy		( GtkObject	*object );
 static void	pixpack_realize		( GtkWidget *widget );
 static void	pixpack_unrealize	( GtkWidget *widget );
-static void	pixpack_draw		( GtkWidget *widget, GdkRectangle *area );
 static void     pixpack_paint		( PixPack* pixpack, GdkRectangle *area );
 static gint	pixpack_expose		( GtkWidget *widget, GdkEventExpose *event );
 static void	pixpack_size_request	( GtkWidget *widget, GtkRequisition *allocation );
@@ -82,7 +81,6 @@
 
 	widget_class->realize		= pixpack_realize;
 	widget_class->unrealize		= pixpack_unrealize;
-	widget_class->draw		= pixpack_draw;
 	widget_class->expose_event	= pixpack_expose;
 	widget_class->size_request	= pixpack_size_request;
 }
@@ -126,13 +124,15 @@
 
 	pixpack = PIXPACK (object);
 	private = pixpack -> private_data;
+	g_return_if_fail ( private );
 
 	if ( private -> pixbuf )
-		gdk_pixbuf_unref ( private -> pixbuf );
+		g_object_unref ( private -> pixbuf );
 	if ( private -> scaled_pixbuf )
-		gdk_pixbuf_unref ( private -> scaled_pixbuf );
+		g_object_unref ( private -> scaled_pixbuf );
 
 	g_free ( pixpack->private_data );
+	pixpack->private_data = NULL;
 
 	if ( GTK_OBJECT_CLASS(parent_class)->destroy)
 		(*GTK_OBJECT_CLASS(parent_class)->destroy) (object);
@@ -196,26 +196,10 @@
 
 
 static void
-pixpack_draw ( GtkWidget *widget, GdkRectangle *area )
-{
-	PixPack *pixpack;
-	
-	g_return_if_fail ( widget != NULL );
-	g_return_if_fail ( IS_PIXPACK (widget));
-
-	pixpack = PIXPACK(widget);
-	
-	pixpack_paint ( pixpack, area );
-}
-
-
-
-static void
 pixpack_paint ( PixPack* pixpack, GdkRectangle *area )
 {
 	GtkWidget *widget;
 	PixPackPrivate* private;
-	gint height, width, x, y;
 
 	g_return_if_fail ( pixpack != NULL );
 	g_return_if_fail ( IS_PIXPACK ( pixpack ));
@@ -235,14 +219,14 @@
 	if ( ! GTK_WIDGET_DRAWABLE (widget))
 		return;
 
-	gdk_window_clear_area ( widget -> window, x, y, width, height);
+	gdk_window_clear_area ( widget -> window, area->x, area->y, area->width, area->height);
 	gdk_gc_set_clip_rectangle ( widget->style->black_gc, area );
 
 	if ( NULL == private -> pixbuf ) 
 		return;
 
 	if ( private -> scaled_pixbuf )
-		gdk_pixbuf_unref ( private -> scaled_pixbuf );
+		g_object_unref ( private -> scaled_pixbuf );
 	
 	private  -> scaled_pixbuf = gdk_pixbuf_scale_simple (private -> pixbuf, 
 							     area->width, area->height, 
@@ -254,10 +238,11 @@
 }
 
 
-static gint
+static gboolean
 pixpack_expose ( GtkWidget *widget, GdkEventExpose *event )
 {
 	pixpack_paint ( PIXPACK (widget), &event->area );
+	return TRUE;
 }
 
 static void
@@ -279,10 +264,13 @@
 pixpack_load_image_file ( PixPack* pixpack, gchar* filename )
 {
 	PixPackPrivate* private;
+	GError* error = NULL;
+
 	g_return_if_fail ( IS_PIXPACK (pixpack ));
 	private = pixpack -> private_data;
 
-	private -> pixbuf = gdk_pixbuf_new_from_file ( filename );
+	private -> pixbuf = gdk_pixbuf_new_from_file ( filename, &error );
+	/* TODO handle errors */
 	
 	/* this forces a repaint */
 
@@ -308,7 +296,7 @@
 pixpack_get_autosize( PixPack *pixpack )
 {
 	PixPackPrivate* private;
-	g_return_if_fail ( IS_PIXPACK (pixpack ));
+	g_return_val_if_fail ( IS_PIXPACK (pixpack ), FALSE );
 	private = pixpack -> private_data;
     
 	return private -> autosize;

Modified: trunk/src/pixpack.h
==============================================================================
--- trunk/src/pixpack.h	(original)
+++ trunk/src/pixpack.h	Thu Feb 21 10:19:03 2008
@@ -60,6 +60,7 @@
 GtkType		pixpack_get_type	( void );
 void		pixpack_load_image_file ( PixPack* pixpack, gchar* filename );
 GtkWidget*	pixpack_new		( void );
+void		pixpack_set_autosize	( PixPack* pixpack, gboolean value );
 
 
 #ifdef __cplusplus

Modified: trunk/src/prefs.c
==============================================================================
--- trunk/src/prefs.c	(original)
+++ trunk/src/prefs.c	Thu Feb 21 10:19:03 2008
@@ -146,7 +146,7 @@
 	newrow = gtk_clist_append(GTK_CLIST(prefs_window->channel_list), info);
 	gtk_clist_set_row_data_full(GTK_CLIST(prefs_window->channel_list), newrow,
 				    channel,
-				    GTK_SIGNAL_FUNC(channel_free));
+				    (GtkDestroyNotify)(channel_free));
     }
     gtk_clist_thaw(GTK_CLIST(prefs_window->channel_list));
 }
@@ -196,7 +196,7 @@
 GtkWidget *
 construct_channels_page()
 {
-    GtkWidget *hbox, *vbox, *btn, *icon;
+    GtkWidget *hbox, *vbox, *btn;
     char *titles[2] = { N_("Country"), N_("Name") };
     g_assert(prefs_window != NULL);
 
@@ -361,8 +361,6 @@
     GList *list;
     int row;
     
-    Channel *channel = NULL;
-    
     if ((list = GTK_CLIST(prefs_window->channel_list)->selection) == NULL)
 	return;
     row = GPOINTER_TO_INT(list->data);
@@ -380,8 +378,6 @@
     GList *list;
     int row;
     
-    Channel *channel = NULL;
-    
     if ((list = GTK_CLIST(prefs_window->channel_list)->selection) == NULL)
 	return;
     row = GPOINTER_TO_INT(list->data);
@@ -397,7 +393,7 @@
 void
 prefs_cancel_cb(void)
 {
-    gtk_widget_destroy(GTK_WIDGET(prefs_window->box));
+    g_object_unref(prefs_window->box);
     g_free(prefs_window);
     prefs_window = NULL;
 }
@@ -480,9 +476,7 @@
 void prefs_channel_delete_cb(void)
 {
     GList *list;
-    int row, i;
-    
-    Channel *channel = NULL;
+    int row;
     
     if ((list = GTK_CLIST(prefs_window->channel_list)->selection) == NULL)
 	return;

Modified: trunk/src/view.c
==============================================================================
--- trunk/src/view.c	(original)
+++ trunk/src/view.c	Thu Feb 21 10:19:03 2008
@@ -34,7 +34,6 @@
 tele_view_new()
 {
     TeleView *v;
-    GtkWidget *l, *sw;
     
     v = g_malloc(sizeof(TeleView));
 
@@ -69,7 +68,7 @@
 tele_view_update_pixmap(TeleView *view, gchar *filename)
 {
     gint width, height;
-    if (g_file_exists) {
+    if (g_file_test(filename, G_FILE_TEST_EXISTS)) {
 	pixpack_load_image_file( PIXPACK(view->pixpack), filename);
     } else {
 	/* no existing file, resize to a default and print a warning */
@@ -153,7 +152,7 @@
 tele_view_free(TeleView *view)
 {
     /* clean up */
-    gtk_widget_destroy(GTK_WIDGET(view->box));
+    g_object_unref(view->box);
     g_free(view);
 }
 

Modified: trunk/src/view.h
==============================================================================
--- trunk/src/view.h	(original)
+++ trunk/src/view.h	Thu Feb 21 10:19:03 2008
@@ -28,7 +28,7 @@
 #define _VIEW_H_
 
 #include <gnome.h>
-#include <libgnomeui/gnome-canvas.h>
+#include <libgnomecanvas/gnome-canvas.h>
 #include <gdk-pixbuf/gdk-pixbuf.h>
 
 #include "channel.h"



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