mirror of https://github.com/GNOME/gimp.git
plug-ins/helpbrowser/dialog.c plug-ins/helpbrowser/domain.[ch] cleanup &
2003-12-04 Michael Natterer <mitch@gimp.org> * plug-ins/helpbrowser/dialog.c * plug-ins/helpbrowser/domain.[ch] * plug-ins/helpbrowser/uri.[ch]: cleanup & whitespace removal.
This commit is contained in:
parent
896b00074a
commit
533c533fb0
|
@ -1,3 +1,9 @@
|
|||
2003-12-04 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* plug-ins/helpbrowser/dialog.c
|
||||
* plug-ins/helpbrowser/domain.[ch]
|
||||
* plug-ins/helpbrowser/uri.[ch]: cleanup & whitespace removal.
|
||||
|
||||
2003-12-04 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/core/gimpimage.h: removed unused "gint proj_level" from the
|
||||
|
|
|
@ -62,8 +62,6 @@ typedef struct
|
|||
|
||||
/* local function prototypes */
|
||||
|
||||
static void close_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void button_callback (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void update_toolbar (void);
|
||||
|
@ -152,7 +150,7 @@ browser_dialog_open (void)
|
|||
gtk_window_set_role (GTK_WINDOW (window), "helpbrowser");
|
||||
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (close_callback),
|
||||
G_CALLBACK (gtk_main_quit),
|
||||
NULL);
|
||||
|
||||
gimp_help_connect (window, gimp_standard_help_func,
|
||||
|
@ -171,6 +169,7 @@ browser_dialog_open (void)
|
|||
button = gtk_button_new_from_stock (GTK_STOCK_HOME);
|
||||
gtk_container_add (GTK_CONTAINER (bbox), button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (button_callback),
|
||||
GINT_TO_POINTER (BUTTON_HOME));
|
||||
|
@ -178,6 +177,7 @@ browser_dialog_open (void)
|
|||
button = gtk_button_new_from_stock (GTK_STOCK_INDEX);
|
||||
gtk_container_add (GTK_CONTAINER (bbox), button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (button_callback),
|
||||
GINT_TO_POINTER (BUTTON_INDEX));
|
||||
|
@ -185,6 +185,7 @@ browser_dialog_open (void)
|
|||
back_button = button = gtk_button_new_from_stock (GTK_STOCK_GO_BACK);
|
||||
gtk_container_add (GTK_CONTAINER (bbox), button);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (button_callback),
|
||||
GINT_TO_POINTER (BUTTON_BACK));
|
||||
|
@ -193,6 +194,7 @@ browser_dialog_open (void)
|
|||
forward_button = button = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD);
|
||||
gtk_container_add (GTK_CONTAINER (bbox), button);
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (button), FALSE);
|
||||
|
||||
g_signal_connect (button, "clicked",
|
||||
G_CALLBACK (button_callback),
|
||||
GINT_TO_POINTER (BUTTON_FORWARD));
|
||||
|
@ -212,6 +214,7 @@ browser_dialog_open (void)
|
|||
help_dnd_target_table,
|
||||
G_N_ELEMENTS (help_dnd_target_table),
|
||||
GDK_ACTION_MOVE | GDK_ACTION_COPY);
|
||||
|
||||
g_signal_connect (drag_source, "drag_begin",
|
||||
G_CALLBACK (drag_begin),
|
||||
NULL);
|
||||
|
@ -309,7 +312,7 @@ browser_dialog_load (const gchar *ref,
|
|||
|
||||
if (strcmp (current_ref, abs))
|
||||
{
|
||||
if (!has_case_prefix (abs, "file:/"))
|
||||
if (! has_case_prefix (abs, "file:/"))
|
||||
{
|
||||
load_remote_page (ref);
|
||||
return;
|
||||
|
@ -338,13 +341,6 @@ browser_dialog_load (const gchar *ref,
|
|||
|
||||
/* private functions */
|
||||
|
||||
static void
|
||||
close_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gtk_main_quit ();
|
||||
}
|
||||
|
||||
static void
|
||||
button_callback (GtkWidget *widget,
|
||||
gpointer data)
|
||||
|
@ -424,9 +420,7 @@ entry_changed_callback (GtkWidget *widget,
|
|||
}
|
||||
|
||||
if (item->count)
|
||||
{
|
||||
g_free (compare_text);
|
||||
}
|
||||
g_free (compare_text);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -632,35 +626,33 @@ history_add (const gchar *ref,
|
|||
const gchar *title)
|
||||
{
|
||||
GList *list;
|
||||
GList *found = NULL;
|
||||
HistoryItem *item;
|
||||
GList *combo_list = NULL;
|
||||
GList *combo_list = NULL;
|
||||
gint title_found_count = 0;
|
||||
|
||||
for (list = history; list && !found; list = list->next)
|
||||
for (list = history; list; list = g_list_next (list))
|
||||
{
|
||||
item = (HistoryItem *) list->data;
|
||||
|
||||
if (strcmp (item->title, title) == 0)
|
||||
if (! strcmp (item->title, title))
|
||||
{
|
||||
if (strcmp (item->ref, ref) != 0)
|
||||
{
|
||||
title_found_count++;
|
||||
continue;
|
||||
}
|
||||
if (! strcmp (item->ref, ref))
|
||||
break;
|
||||
|
||||
found = list;
|
||||
title_found_count++;
|
||||
}
|
||||
}
|
||||
|
||||
if (found)
|
||||
if (list)
|
||||
{
|
||||
item = (HistoryItem *) found->data;
|
||||
history = g_list_remove_link (history, found);
|
||||
item = (HistoryItem *) list->data;
|
||||
|
||||
history = g_list_remove_link (history, list);
|
||||
}
|
||||
else
|
||||
{
|
||||
item = g_new (HistoryItem, 1);
|
||||
|
||||
item->ref = g_strdup (ref);
|
||||
item->title = g_strdup (title);
|
||||
item->count = title_found_count;
|
||||
|
@ -668,16 +660,14 @@ history_add (const gchar *ref,
|
|||
|
||||
history = g_list_prepend (history, item);
|
||||
|
||||
for (list = history; list; list = list->next)
|
||||
for (list = history; list; list = g_list_next (list))
|
||||
{
|
||||
gchar* combo_title;
|
||||
gchar *combo_title;
|
||||
|
||||
item = (HistoryItem *) list->data;
|
||||
|
||||
if (item->count)
|
||||
combo_title = g_strdup_printf ("%s <%i>",
|
||||
item->title,
|
||||
item->count + 1);
|
||||
combo_title = g_strdup_printf ("%s <%i>", item->title, item->count + 1);
|
||||
else
|
||||
combo_title = g_strdup (item->title);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* The GIMP Help Browser
|
||||
* Copyright (C) 1999-2002 Sven Neumann <sven@gimp.org>
|
||||
* Copyright (C) 1999-2003 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* domain.c
|
||||
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -241,8 +242,8 @@ domain_parse (HelpDomain *domain,
|
|||
if (! fp)
|
||||
{
|
||||
g_set_error (error, 0, 0,
|
||||
"Could not open gimp-help.xml mapping file from '%s'",
|
||||
domain->help_uri);
|
||||
"Could not open gimp-help.xml mapping file from '%s': %s",
|
||||
domain->help_uri, g_strerror (errno));
|
||||
g_free (filename);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -326,7 +327,7 @@ domain_parser_end_element (GMarkupParseContext *context,
|
|||
switch (parser->state)
|
||||
{
|
||||
case DOMAIN_START:
|
||||
g_warning ("tips_parser: This shouldn't happen.\n");
|
||||
g_warning ("tips_parser: This shouldn't happen.");
|
||||
break;
|
||||
|
||||
case DOMAIN_IN_HELP:
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* The GIMP Help Browser
|
||||
* Copyright (C) 1999-2002 Sven Neumann <sven@gimp.org>
|
||||
* Copyright (C) 1999-2003 Sven Neumann <sven@gimp.org>
|
||||
* Michael Natterer <mitch@gimp.org>
|
||||
*
|
||||
* domain.h
|
||||
|
|
|
@ -49,7 +49,7 @@ uri_get_type (const gchar *uri)
|
|||
gchar c;
|
||||
const gchar *cptr;
|
||||
UriType type = URI_UNKNOWN;
|
||||
|
||||
|
||||
if (!uri)
|
||||
return type;
|
||||
|
||||
|
@ -59,12 +59,12 @@ uri_get_type (const gchar *uri)
|
|||
if (g_ascii_isalpha (c))
|
||||
{
|
||||
type = URI_RELPATH; /* assume relative path */
|
||||
|
||||
|
||||
while ((c = *cptr++))
|
||||
{
|
||||
if (g_ascii_isalnum (c) || c == '+' || c == '-' || c == '.')
|
||||
continue;
|
||||
|
||||
|
||||
if (c == ':')
|
||||
{
|
||||
/* it was a scheme */
|
||||
|
@ -132,16 +132,16 @@ uri_to_abs (const gchar *uri,
|
|||
gchar *retval = NULL;
|
||||
UriType uri_type = URI_UNKNOWN;
|
||||
UriType base_type = URI_UNKNOWN;
|
||||
|
||||
|
||||
gint base_cnt = 0; /* no of chars to be copied from base URI */
|
||||
gint uri_cnt = 0; /* no of chars to be copied from URI */
|
||||
gint sep_cnt = 0; /* no of chars to be inserted between them */
|
||||
gint path_offset = -1;
|
||||
|
||||
|
||||
const gchar *sep_str = ""; /* string to insert between base and uri */
|
||||
const gchar *part;
|
||||
const gchar *last_segment = NULL;
|
||||
|
||||
|
||||
#ifdef URI_DEBUG
|
||||
g_print ("uri_to_abs (\"%s\", \"%s\")\n", uri, base_uri);
|
||||
#endif
|
||||
|
@ -152,14 +152,14 @@ uri_to_abs (const gchar *uri,
|
|||
* After that it locates the missing parts in the base URI and then
|
||||
* concats everything into a newly allocated string.
|
||||
*/
|
||||
|
||||
|
||||
/* determine the kind of the URIs */
|
||||
uri_type = uri_get_type (uri);
|
||||
|
||||
|
||||
if (uri_type != URI_ABSURI)
|
||||
{
|
||||
base_type = uri_get_type (base_uri);
|
||||
|
||||
|
||||
if (base_type != URI_ABSURI)
|
||||
{
|
||||
g_warning ("base uri is not absolute: '%s'\n", base_uri);
|
||||
|
@ -185,7 +185,7 @@ uri_to_abs (const gchar *uri,
|
|||
/* skip scheme */
|
||||
while ((c = *cptr++) && c != ':')
|
||||
; /* nada */
|
||||
|
||||
|
||||
base_cnt = cptr - base_uri; /* incl : */
|
||||
|
||||
if (*cptr != '/')
|
||||
|
@ -196,7 +196,7 @@ uri_to_abs (const gchar *uri,
|
|||
|
||||
if (uri_type == URI_NETPATH)
|
||||
break;
|
||||
|
||||
|
||||
/* skip authority */
|
||||
if (cptr[0] == '/' && cptr[1] == '/')
|
||||
{
|
||||
|
@ -210,11 +210,11 @@ uri_to_abs (const gchar *uri,
|
|||
base_cnt += cptr - part;
|
||||
}
|
||||
|
||||
path_offset = base_cnt;
|
||||
path_offset = base_cnt;
|
||||
|
||||
if (uri_type == URI_ABSPATH)
|
||||
break;
|
||||
|
||||
|
||||
/* skip path */
|
||||
if (*cptr != '/')
|
||||
{
|
||||
|
@ -224,25 +224,25 @@ uri_to_abs (const gchar *uri,
|
|||
}
|
||||
|
||||
part = cptr;
|
||||
|
||||
|
||||
g_assert (*cptr == '/');
|
||||
|
||||
|
||||
while ((c = *cptr++) && c != '?' && c != '#')
|
||||
{
|
||||
if (c == '/')
|
||||
last_segment = cptr - 1;
|
||||
};
|
||||
|
||||
|
||||
g_assert (last_segment);
|
||||
|
||||
|
||||
cptr = last_segment;
|
||||
|
||||
|
||||
while ((c = *uri) && c == '.' && cptr > part)
|
||||
{
|
||||
gint shift_segment = 0;
|
||||
|
||||
c = uri[1];
|
||||
|
||||
|
||||
if (c == '.' )
|
||||
{
|
||||
c = uri[2];
|
||||
|
@ -252,18 +252,18 @@ uri_to_abs (const gchar *uri,
|
|||
if (c == '/')
|
||||
{
|
||||
uri += 2;
|
||||
}
|
||||
}
|
||||
else if (c == 0 || c == '?' || c == '#')
|
||||
{
|
||||
uri += 1;
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
g_assert (*cptr == '/');
|
||||
|
||||
|
||||
if (shift_segment)
|
||||
{
|
||||
uri += 1;
|
||||
|
@ -271,10 +271,10 @@ uri_to_abs (const gchar *uri,
|
|||
; /* nada */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
base_cnt += cptr - part + 1;
|
||||
break;
|
||||
|
||||
|
||||
case URI_EMPTY:
|
||||
case URI_FRAGMENT:
|
||||
/* use whole base uri */
|
||||
|
@ -285,17 +285,17 @@ uri_to_abs (const gchar *uri,
|
|||
case URI_INVALID:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* do not include fragment part from the URI reference */
|
||||
for (cptr = uri; (c = *cptr) && c != '#'; cptr++)
|
||||
; /* nada */
|
||||
|
||||
uri_cnt = cptr - uri;
|
||||
|
||||
|
||||
/* allocate string and copy characters */
|
||||
|
||||
|
||||
retval = g_new (gchar, base_cnt + sep_cnt + uri_cnt + 1);
|
||||
|
||||
|
||||
if (base_cnt)
|
||||
strncpy (retval, base_uri, base_cnt);
|
||||
|
||||
|
|
|
@ -19,5 +19,5 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
gchar * uri_to_abs (const gchar *uri,
|
||||
gchar * uri_to_abs (const gchar *uri,
|
||||
const gchar *base_uri);
|
||||
|
|
Loading…
Reference in New Issue