Commit badc7589 authored by Darin Adler's avatar Darin Adler

Ref and sink the new adapter. (nautilus_adapter_new): Remove unused

	* components/adapter/nautilus-adapter.c:
	(nautilus_adapter_initialize): Ref and sink the new adapter.
	(nautilus_adapter_new): Remove unused CORBA_Environment.
	* components/adapter/nautilus-adapter.h: Whitespace tweak.

	* libnautilus-private/nautilus-directory-metafile.c:
	(nautilus_directory_get_integer_file_metadata):
	* libnautilus-private/nautilus-file.c: (get_id_from_digit_string):
	* libnautilus-private/nautilus-icon-factory.c:
	(parse_attach_points):
	* libnautilus-private/nautilus-thumbnails.c:
	(nautilus_thumbnail_load_framed_image):
	* src/file-manager/fm-icon-view.c:
	(get_stored_icon_position_callback):
	A bunch of places were trying to use %*s to detect whether there
	were stray characters at the end of a string when doing an sscanf.
	I wrote that code. But it doesn't work. A similar technique that
	does work is to use %c, and ignore the parsed character.

	* src/nautilus-search-bar-criterion.c:
	(nautilus_search_uri_get_first_criterion):
	This place wasn't using the %*s at all, so just remove it.
parent 494f382e
2001-09-25 Darin Adler <darin@bentspoon.com>
* components/adapter/nautilus-adapter.c:
(nautilus_adapter_initialize): Ref and sink the new adapter.
(nautilus_adapter_new): Remove unused CORBA_Environment.
* components/adapter/nautilus-adapter.h: Whitespace tweak.
* libnautilus-private/nautilus-directory-metafile.c:
(nautilus_directory_get_integer_file_metadata):
* libnautilus-private/nautilus-file.c: (get_id_from_digit_string):
* libnautilus-private/nautilus-icon-factory.c:
(parse_attach_points):
* libnautilus-private/nautilus-thumbnails.c:
(nautilus_thumbnail_load_framed_image):
* src/file-manager/fm-icon-view.c:
(get_stored_icon_position_callback):
A bunch of places were trying to use %*s to detect whether there
were stray characters at the end of a string when doing an sscanf.
I wrote that code. But it doesn't work. A similar technique that
does work is to use %c, and ignore the parsed character.
* src/nautilus-search-bar-criterion.c:
(nautilus_search_uri_get_first_criterion):
This place wasn't using the %*s at all, so just remove it.
2001-09-24 Fabrice Bellet <fabrice@gnu.org>
* Reviewed by Darin Adler <darin@bentspoon.com> (Bug 44402)
......
......@@ -45,9 +45,9 @@
#include <libnautilus/nautilus-bonobo-ui.h>
struct NautilusAdapterDetails {
NautilusView *nautilus_view;
NautilusView *nautilus_view;
NautilusAdapterEmbedStrategy *embed_strategy;
NautilusAdapterLoadStrategy *load_strategy;
NautilusAdapterLoadStrategy *load_strategy;
guint report_load_underway_id;
guint report_load_progress_id;
guint report_load_complete_id;
......@@ -55,35 +55,30 @@ struct NautilusAdapterDetails {
};
static void nautilus_adapter_load_location_callback (NautilusView *view,
const char *uri,
NautilusAdapter *adapter);
static void nautilus_adapter_stop_loading_callback (NautilusView *view,
NautilusAdapter *adapter);
static void nautilus_adapter_activate_callback (BonoboControl *control,
gboolean state,
NautilusAdapter *adapter);
static void nautilus_adapter_load_location_callback (NautilusView *view,
const char *uri,
NautilusAdapter *adapter);
static void nautilus_adapter_stop_loading_callback (NautilusView *view,
NautilusAdapter *adapter);
static void nautilus_adapter_activate_callback (BonoboControl *control,
gboolean state,
NautilusAdapter *adapter);
static void nautilus_adapter_open_location_callback (NautilusAdapterEmbedStrategy *strategy,
const char *uri,
NautilusAdapter *adapter);
static void nautilus_adapter_load_underway_callback (NautilusAdapter *adapter);
static void nautilus_adapter_load_progress_callback (NautilusAdapter *adapter,
double fraction_complete);
static void nautilus_adapter_load_complete_callback (NautilusAdapter *adapter);
static void nautilus_adapter_load_failed_callback (NautilusAdapter *adapter);
static void nautilus_adapter_initialize_class (NautilusAdapterClass *klass);
static void nautilus_adapter_initialize (NautilusAdapter *server);
static void nautilus_adapter_destroy (GtkObject *object);
static void nautilus_adapter_load_underway_callback (NautilusAdapter *adapter);
static void nautilus_adapter_load_progress_callback (NautilusAdapter *adapter,
double fraction_complete);
static void nautilus_adapter_load_complete_callback (NautilusAdapter *adapter);
static void nautilus_adapter_load_failed_callback (NautilusAdapter *adapter);
static void nautilus_adapter_initialize_class (NautilusAdapterClass *klass);
static void nautilus_adapter_initialize (NautilusAdapter *server);
static void nautilus_adapter_destroy (GtkObject *object);
EEL_DEFINE_CLASS_BOILERPLATE (NautilusAdapter,
nautilus_adapter,
GTK_TYPE_OBJECT)
nautilus_adapter,
GTK_TYPE_OBJECT)
static void
......@@ -91,8 +86,6 @@ nautilus_adapter_initialize_class (NautilusAdapterClass *klass)
{
GtkObjectClass *object_class;
g_assert (NAUTILUS_IS_ADAPTER_CLASS (klass));
object_class = GTK_OBJECT_CLASS (klass);
object_class->destroy = nautilus_adapter_destroy;
......@@ -101,15 +94,9 @@ nautilus_adapter_initialize_class (NautilusAdapterClass *klass)
static void
nautilus_adapter_initialize (NautilusAdapter *adapter)
{
CORBA_Environment ev;
CORBA_exception_init (&ev);
g_assert (NAUTILUS_IS_ADAPTER (adapter));
adapter->details = g_new0 (NautilusAdapterDetails, 1);
CORBA_exception_free (&ev);
gtk_object_ref (GTK_OBJECT (adapter));
gtk_object_sink (GTK_OBJECT (adapter));
}
static void
......@@ -153,20 +140,15 @@ nautilus_adapter_new (Bonobo_Unknown component)
BonoboControl *control;
GtkWidget *bin;
BonoboObject *zoomable;
CORBA_Environment ev;
/* FIXME bugzilla.gnome.org 44405: should be done with
* construct args
*/
CORBA_exception_init (&ev);
adapter = NAUTILUS_ADAPTER (gtk_object_new (NAUTILUS_TYPE_ADAPTER, NULL));
/* Set up a few wrapper framework details */
bin = gtk_widget_new (EEL_TYPE_GENEROUS_BIN, NULL);
bin = gtk_widget_new (EEL_TYPE_GENEROUS_BIN, NULL);
gtk_widget_show (bin);
control = bonobo_control_new (bin);
adapter->details->nautilus_view = nautilus_view_new_from_bonobo_control (control);
......@@ -177,12 +159,9 @@ nautilus_adapter_new (Bonobo_Unknown component)
GTK_OBJECT (adapter));
/* Get the class to handle embedding this kind of component. */
adapter->details->embed_strategy = nautilus_adapter_embed_strategy_get
(component);
adapter->details->embed_strategy = nautilus_adapter_embed_strategy_get (component);
if (adapter->details->embed_strategy == NULL) {
gtk_object_unref (GTK_OBJECT (adapter));
return NULL;
}
......@@ -200,13 +179,9 @@ nautilus_adapter_new (Bonobo_Unknown component)
/* Get the class to handle loading this kind of component. */
adapter->details->load_strategy = nautilus_adapter_load_strategy_get
(component);
adapter->details->load_strategy = nautilus_adapter_load_strategy_get (component);
if (adapter->details->load_strategy == NULL) {
gtk_object_unref (GTK_OBJECT (adapter));
return NULL;
}
......@@ -233,18 +208,14 @@ nautilus_adapter_new (Bonobo_Unknown component)
GTK_OBJECT (adapter));
/* complete the embedding */
gtk_container_add (GTK_CONTAINER (bin),
nautilus_adapter_embed_strategy_get_widget (adapter->details->embed_strategy));
/* hook up view signals. */
gtk_signal_connect (GTK_OBJECT (adapter->details->nautilus_view),
"load_location",
nautilus_adapter_load_location_callback,
adapter);
gtk_signal_connect (GTK_OBJECT (adapter->details->nautilus_view),
"stop_loading",
nautilus_adapter_stop_loading_callback,
......@@ -253,15 +224,12 @@ nautilus_adapter_new (Bonobo_Unknown component)
return adapter;
}
NautilusView *
nautilus_adapter_get_nautilus_view (NautilusAdapter *adapter)
{
return adapter->details->nautilus_view;
}
static void
nautilus_adapter_load_location_callback (NautilusView *view,
const char *location,
......@@ -336,4 +304,3 @@ nautilus_adapter_load_failed_callback (NautilusAdapter *adapter)
{
nautilus_view_report_load_failed (adapter->details->nautilus_view);
}
......@@ -27,7 +27,6 @@
#ifndef NAUTILUS_ADAPTER_H
#define NAUTILUS_ADAPTER_H
#include <gtk/gtklabel.h>
#include <libnautilus/nautilus-view.h>
#define NAUTILUS_TYPE_ADAPTER (nautilus_adapter_get_type ())
......@@ -51,6 +50,6 @@ typedef struct {
GtkType nautilus_adapter_get_type (void);
NautilusAdapter *nautilus_adapter_new (Bonobo_Unknown component);
NautilusView *nautilus_adapter_get_nautilus_view (NautilusAdapter *adapter);
#endif /* NAUTILUS_ADAPTER_H */
......@@ -395,6 +395,7 @@ nautilus_directory_get_integer_file_metadata (NautilusDirectory *directory,
char *result_as_string;
char *default_as_string;
int result;
char c;
default_as_string = g_strdup_printf ("%d", default_metadata);
result_as_string = nautilus_directory_get_file_metadata
......@@ -406,7 +407,7 @@ nautilus_directory_get_integer_file_metadata (NautilusDirectory *directory,
if (result_as_string == NULL) {
result = default_metadata;
} else {
if (sscanf (result_as_string, " %d %*s", &result) != 1) {
if (sscanf (result_as_string, " %d %c", &result, &c) != 1) {
result = default_metadata;
}
g_free (result_as_string);
......
......@@ -3184,13 +3184,14 @@ static gboolean
get_id_from_digit_string (const char *digit_string, uid_t *id)
{
long scanned_id;
char c;
g_assert (id != NULL);
/* Only accept string if it has one integer with nothing
* afterwards.
*/
if (sscanf (digit_string, "%ld%*s", &scanned_id) != 1) {
if (sscanf (digit_string, "%ld%c", &scanned_id, &c) != 1) {
return FALSE;
}
*id = scanned_id;
......@@ -3602,7 +3603,7 @@ nautilus_file_get_settable_group_names (NautilusFile *file)
if (user_id == 0) {
/* Root is allowed to set group to anything. */
result = nautilus_get_group_names_including (NULL);
result = nautilus_get_group_names ();
} else if (user_id == (uid_t) file->details->info->uid) {
/* Owner is allowed to set group to any that owner is member of. */
user_name_string = get_user_name_from_id (user_id);
......
......@@ -937,6 +937,7 @@ static void
parse_attach_points (NautilusEmblemAttachPoints *attach_points, const char *attach_point_string)
{
char **point_array;
char c;
int i, x_offset, y_offset;
attach_points->num_points = 0;
......@@ -950,7 +951,7 @@ parse_attach_points (NautilusEmblemAttachPoints *attach_points, const char *atta
point_array = g_strsplit (attach_point_string, "|", MAX_ATTACH_POINTS);
for (i = 0; point_array[i] != NULL; i++) {
if (sscanf (point_array[i], " %d , %d , %*s", &x_offset, &y_offset) == 2) {
if (sscanf (point_array[i], " %d , %d %c", &x_offset, &y_offset, &c) == 2) {
attach_points->points[attach_points->num_points].x = x_offset;
attach_points->points[attach_points->num_points].y = y_offset;
attach_points->num_points++;
......
......@@ -685,6 +685,7 @@ nautilus_thumbnail_load_framed_image (const char *path, gboolean anti_aliased_fr
gboolean got_frame_offsets;
char *frame_offset_str;
int left_offset, top_offset, right_offset, bottom_offset;
char c;
pixbuf = gdk_pixbuf_new_from_file (path);
if (pixbuf == NULL || pixbuf_is_framed (pixbuf)) {
......@@ -703,8 +704,8 @@ nautilus_thumbnail_load_framed_image (const char *path, gboolean anti_aliased_fr
got_frame_offsets = FALSE;
frame_offset_str = nautilus_theme_get_theme_data ("thumbnails", "FRAME_OFFSETS");
if (frame_offset_str != NULL) {
if (sscanf (frame_offset_str, " %d , %d , %d , %d %*s",
&left_offset, &top_offset, &right_offset, &bottom_offset) == 4) {
if (sscanf (frame_offset_str, " %d , %d , %d , %d %c",
&left_offset, &top_offset, &right_offset, &bottom_offset, &c) == 4) {
got_frame_offsets = TRUE;
}
g_free (frame_offset_str);
......
......@@ -282,6 +282,7 @@ get_stored_icon_position_callback (NautilusIconContainer *container,
char *position_string, *scale_string;
gboolean position_good, scale_good;
char *locale;
char c;
g_assert (NAUTILUS_IS_ICON_CONTAINER (container));
g_assert (NAUTILUS_IS_FILE (file));
......@@ -300,8 +301,8 @@ get_stored_icon_position_callback (NautilusIconContainer *container,
position_string = nautilus_file_get_metadata
(file, NAUTILUS_METADATA_KEY_ICON_POSITION, "");
position_good = sscanf
(position_string, " %d , %d %*s",
&position->x, &position->y) == 2;
(position_string, " %d , %d %c",
&position->x, &position->y, &c) == 2;
g_free (position_string);
/* If it is the desktop directory, maybe the gnome-libs metadata has information about it */
......@@ -310,15 +311,15 @@ get_stored_icon_position_callback (NautilusIconContainer *container,
scale_string = nautilus_file_get_metadata
(file, NAUTILUS_METADATA_KEY_ICON_SCALE, "1");
scale_good = sscanf
(scale_string, " %lf %*s",
&position->scale_x) == 1;
(scale_string, " %lf %c",
&position->scale_x, &c) == 1;
if (scale_good) {
position->scale_y = position->scale_x;
} else {
scale_good = sscanf
(scale_string, " %lf %lf %*s",
(scale_string, " %lf %lf %c",
&position->scale_x,
&position->scale_y) == 2;
&position->scale_y, &c) == 2;
if (!scale_good) {
position->scale_x = 1.0;
position->scale_y = 1.0;
......
......@@ -778,7 +778,7 @@ nautilus_search_uri_get_first_criterion (const char *search_uri)
*/
first_criterion = g_strdup (unescaped_uri);
matches = sscanf (unescaped_uri, "search:[file:///]%s %*s", first_criterion);
matches = sscanf (unescaped_uri, "search:[file:///]%s", first_criterion);
g_free (unescaped_uri);
if (matches == 0) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment