Re: Window naming convention



Hi,

Should be first considered for GTK 2.0 before deciding it goes in
gnome-libs; then you get it more widely used (and it can be named
gtk_window_something so programmers can find it).

Yeah you knew I'd say that. ;-)

Havoc


Chema Celorio <chema celorio com> writes:
> Some time ago we discussed a common way to name windows for gnome
> apps. Althou we didn't reached a consensus on how to named them
> we reached a consensus on abstracting that information in a 
> function inside gnome-libs, where we can later decide how to
> title them.
> 
> So here is a proposed function for this, we also need to
> add a funcition for non-toplevel windows. We could add a
> setting in gnomecc to specify how to name them, Althou I 
> hope we don't as we need to make gnomecc less configurable
> *IF* you ask me.
> 
> 
> gnome_window_toplevel_set_title (GtkWindow *window,
> 				const gchar *doc_name,
> 				const gchar *app_name,
> 				const gchar *extension)
> 
> The extension is needed so that we can trim it off from
> doc_name if we decide to. I'd rathe see "Worksheet - gnumeric" than
> "worksheet.gnumeric - gnumeric", but for some other apps like ghex
> I want to see the extension in the title. So in this model, ghex
> will pass NULL as the extension.
> 
> The way *I* prefer to name my windows is :
> 
> 	doc - app   (if the doc has the default extension of the app) 
> or :
> 	doc.extension - app
> 
> Enclosed is a patch for gnome-libs & gnumeric that implements this 
> function.
> 
> ChemaIndex: libgnomeui/ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/gnome-libs/libgnomeui/ChangeLog,v
> retrieving revision 1.1161.4.91
> diff -u -5 -r1.1161.4.91 ChangeLog
> --- libgnomeui/ChangeLog	2000/10/12 23:52:54	1.1161.4.91
> +++ libgnomeui/ChangeLog	2000/10/16 00:04:52
> @@ -1,5 +1,13 @@
> +2000-10-15  Chema Celorio  <chema celorio com>
> +
> +	* gnome-window.c (gnome_window_toplevel_set_title): new file &
> +	function. apps should use it to set the tile, so that we can
> +	have a unform way of setting the window properties (only the
> +	title for now)
> +	* gnome-window.h: new file
> +
>  2000-10-12  Ettore Perazzoli  <ettore helixcode com>
>  
>  	* gnome-dock-item.c: New args "preferred_width" and
>  	"preferred_height".
>  	(gnome_dock_item_class_init): Set them up.
> Index: libgnomeui/Makefile.am
> ===================================================================
> RCS file: /cvs/gnome/gnome-libs/libgnomeui/Makefile.am,v
> retrieving revision 1.165.4.8
> diff -u -5 -r1.165.4.8 Makefile.am
> --- libgnomeui/Makefile.am	2000/09/27 21:33:54	1.165.4.8
> +++ libgnomeui/Makefile.am	2000/10/16 00:04:52
> @@ -94,10 +94,11 @@
>  	gnome-startup.c			\
>  	gnome-stock.c			\
>          gnome-winhints.c		\
>          gnome-paper-selector.c		\
>  	gnome-procbar.c			\
> +	gnome-window.c			\
>  	gnome-window-icon.c		\
>  	gnometypes.c			\
>  	gtkcauldron.c			\
>  	gtk-clock.c			\
>  	gtk-ted.c			\
> @@ -175,10 +176,11 @@
>  	gnome-types.h			\
>  	gnome-uidefs.h			\
>          gnome-winhints.h		\
>          gnome-paper-selector.h		\
>  	gnome-procbar.h			\
> +	gnome-window.h			\
>  	gnome-window-icon.h		\
>  	gtkcauldron.h			\
>  	gtkdial.h			\
>  	gtk-clock.h			\
>  	gtk-ted.h			\
> Index: libgnomeui/gnome-window.c
> ===================================================================
> RCS file: gnome-window.c
> diff -N gnome-window.c
> --- /dev/null	Tue May  5 16:32:27 1998
> +++ gnome-window.c	Sun Oct 15 20:04:53 2000
> @@ -0,0 +1,71 @@
> +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
> +/*
> + * gnome-window.c: wrappers for setting window properties
> + *
> + * Copyright 2000, Chema Celorio
> + *
> + * This library is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Library General Public
> + * License as published by the Free Software Foundation; either
> + * version 2 of the License, or (at your option) any later version.
> + *
> + * This library is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * Library General Public License for more details.
> + *
> + * You should have received a copy of the GNU Library General Public
> + * License along with this library; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
> + *
> + * Authors:  Chema Celorio <chema celorio com>
> + */
> +
> +
> +#include <config.h>
> +#include <glib.h>
> +#include <gtk/gtkwindow.h>
> +#include <libgnome/gnome-defs.h>
> +
> +#include "gnome-window.h"
> +
> +/**
> + * gnome_window_toplevel_set_title:
> + * @window: A pointer to the toplevel window
> + * @doc_name: the document name with extension (if any)
> + * @app_name: the application name
> + * @extension: the default extension that the application uses.
> + *             NULL if there isn't a default extension.
> + * 
> + * Set the title of a toplevel window. Acording to gnome policy or
> + * (if implemented) to a gnome setting.
> + *
> + **/
> +void
> +gnome_window_toplevel_set_title (GtkWindow *window, const gchar *doc_name,
> +						   const gchar *app_name, const gchar *extension)
> +{
> +	gchar *full_title;
> +	gchar *doc_name_clean = NULL;
> +	
> +	g_return_if_fail (GTK_IS_WINDOW (window));
> +	g_return_if_fail (doc_name != NULL);
> +	g_return_if_fail (app_name != NULL);
> +
> +	/* Remove the extension from the doc_name*/
> +	if (extension != NULL) {
> +		gchar * pos = strstr (doc_name, extension);
> +		if (pos != NULL)
> +			doc_name_clean = g_strndup (doc_name, pos - doc_name);
> +	}
> +
> +	if (!doc_name_clean)
> +		doc_name_clean = g_strdup (doc_name);
> +	
> +	full_title = g_strdup_printf ("%s : %s", doc_name_clean, app_name);
> +	gtk_window_set_title (window, full_title);
> +
> +	g_free (doc_name_clean);
> +	g_free (full_title);
> +}
> +
> Index: libgnomeui/gnome-window.h
> ===================================================================
> RCS file: gnome-window.h
> diff -N gnome-window.h
> --- /dev/null	Tue May  5 16:32:27 1998
> +++ gnome-window.h	Sun Oct 15 20:04:53 2000
> @@ -0,0 +1,36 @@
> +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
> +/*
> + * gnome-window.h: wrappers for setting window properties
> + *
> + * Author:  Chema Celorio <chema celorio com>
> + */
> +
> +/*
> + * These functions are a convenience wrapper for gtk_window_set_title
> + * This allows all the gnome-apps to have a consitent way of setting
> + * the window & dialogs titles. We could also add a configurable way
> + * of setting the windows titles in the future..
> + *
> + * These functions were added with the 1.2.5 release of the GNOME libraries
> + * in Oct, 2000.  This means that not all users will have this functionality
> + * in the GNOME libraries, and should only be used accordingly.  The header file
> + * must be explicitely included, also (#include <libgnomeui/gnome-window.h>).
> + */
> +
> +#ifndef GNOME_WINDOW_H
> +#define GNOME_WINDOW_H
> +
> +#include <gtk/gtkwindow.h>
> +
> +BEGIN_GNOME_DECLS
> +
> +/* set the window title */
> +void gnome_window_toplevel_set_title (GtkWindow *w,
> +				      const gchar *doc_name,
> +				      const gchar *app_name,
> +				      const gchar *extension);
> +
> +
> +END_GNOME_DECLS
> +
> +#endif /* GNOME_WINDOW_H */
> ? Book1.foo
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/gnome/gnumeric/ChangeLog,v
> retrieving revision 1.621
> diff -u -5 -r1.621 ChangeLog
> --- ChangeLog	2000/10/16 00:36:17	1.621
> +++ ChangeLog	2000/10/16 00:58:50
> @@ -1,5 +1,15 @@
> +2000-10-15  Chema Celorio  <chema celorio com>
> +
> +	* src/workbook-view.c (workbook_view_set_title): use the new
> +	gnome_libs function that sets the title for the toplevel
> +	windows.
> +
> +	* src/workbook.c (workbook_set_saveinfo): we don't need to call 
> +	workbook_view_set_filename because workbook_set_filename calls it,
> +	because of this title was beeing set twice.
> +
>  2000-10-15  Jody Goldberg <jgoldberg home com>
>  
>  	* src/sheet.c (sheet_update) : RE_RENDER when a span clac is forced.
>  	  This is a bit brute force for now, but is necessary to force the
>  	  re-rendering of values that may have width dependent formats.
> Index: src/workbook-view.c
> ===================================================================
> RCS file: /cvs/gnome/gnumeric/src/workbook-view.c,v
> retrieving revision 1.33
> diff -u -5 -r1.33 workbook-view.c
> --- src/workbook-view.c	2000/10/11 16:33:23	1.33
> +++ src/workbook-view.c	2000/10/16 00:58:56
> @@ -15,10 +15,11 @@
>  #include "history.h"
>  #include "workbook-private.h"
>  #include "gnumeric-util.h"
>  #include "application.h"
>  #include "sheet.h"
> +#include <libgnomeui/gnome-window.h>
>  #include <gal/widgets/gtk-combo-stack.h>
>  
>  void
>  workbook_view_set_paste_special_state (Workbook *wb, gboolean enable)
>  {
> @@ -164,21 +165,17 @@
>   */
>  void
>  workbook_view_set_title (Workbook const * const wb,
>  			 char const * const title)
>  {
> -	char *full_title;
> -
>  	g_return_if_fail (wb != NULL);
>  	g_return_if_fail (title != NULL);
> -
> -	full_title = g_strconcat (title, _(" : Gnumeric"), NULL);
>  
> - 	gtk_window_set_title (GTK_WINDOW (
> -		workbook_get_toplevel ((Workbook *) wb)), full_title);
> -	g_free (full_title);
> +	gnome_window_toplevel_set_title (GTK_WINDOW (workbook_get_toplevel ((Workbook *) wb)),
> +							   title, "gnumeric", ".gnumeric");
>  }
> +
>  
>  static void
>  cb_update_sheet_view_prefs (gpointer key, gpointer value, gpointer user_data)
>  {
>  	Sheet *sheet = value;
> Index: src/workbook.c
> ===================================================================
> RCS file: /cvs/gnome/gnumeric/src/workbook.c,v
> retrieving revision 1.455
> diff -u -5 -r1.455 workbook.c
> --- src/workbook.c	2000/10/14 17:42:41	1.455
> +++ src/workbook.c	2000/10/16 00:59:05
> @@ -3618,11 +3618,10 @@
>  	if (!workbook_set_filename (wb, name))
>  		return FALSE;
>  	wb->file_format_level = level;
>  	if (save_fn != NULL)
>  	wb->file_save_fn = save_fn ? save_fn : gnumeric_xml_write_workbook;
> -	workbook_view_set_title (wb, g_basename (name));
>  
>  	return TRUE;
>  }
>  
>  void




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