summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog32
-rw-r--r--components/hardware/nautilus-hardware-view.c12
-rw-r--r--components/music/nautilus-music-view.c26
-rw-r--r--components/services/inventory/lib/eazel-inventory-shared.c2
-rw-r--r--components/services/inventory/nautilus-view/nautilus-inventory-view.c2
-rw-r--r--libnautilus-extensions/nautilus-string.c4
-rw-r--r--libnautilus-private/nautilus-string.c4
-rw-r--r--librsvg/rsvg.c4
-rw-r--r--src/file-manager/Makefile.am2
-rw-r--r--src/file-manager/fm-search-list-view.c26
-rw-r--r--src/file-manager/nautilus-indexing-info.c179
-rw-r--r--src/file-manager/nautilus-indexing-info.h37
12 files changed, 302 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 084053f97..edb3d51f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,35 @@
+Fri Aug 18 21:22:17 2000 George Lebl <jirka@5z.com>
+
+ * components/hardware/nautilus-hardware-view.c
+ (read_proc_info) (extract_info) (get_CPU_description)
+ (get_RAM_description):
+ Use g_strdup instead of strdup
+ (get_CPU_description):
+ Free allocated data when returning due to an error
+
+ * components/music/nautilus-music-view.c
+ (nautilus_music_view_update_from_uri):
+ Initialize clist_entry in a loop, use g_strdup_printf instead
+ of malloc and sprintf, and properly free allocated data after use
+
+ * components/services/inventory/lib/eazel-inventory-shared.c
+ (read_proc_info)
+ components/services/inventory/nautilus-view/nautilus-inventory-view.c
+ (gather_config_button_cb)
+ libnautilus-extensions/nautilus-string.c
+ (nautilus_str_middle_truncate)
+ librsvg/rsvg.c (rsvg_ctx_free):
+ Use g_strdup instead of strdup and g_free instead of free to
+ prevent crashes with glib compiled with --enable-mem-check
+
+ * src/file-manager/Makefile.am,
+ src/file-manager/nautilus-indexing-info.[ch],
+ src/file-manager/fm-search-list-view.c (indexing_info_callback)
+ (real_merge_menus):
+ Bug #1369: Add a dialog for indexing info to the file menu. The
+ dialog shows the last time the indexing was done and allows to
+ update the indexes. Only shown on the file search result dialog
+
2000-08-18 Gene Z. Ragan <gzr@eazel.com>
* libnautilus-extensions/nautilus-volume-monitor.c:
diff --git a/components/hardware/nautilus-hardware-view.c b/components/hardware/nautilus-hardware-view.c
index 66f19bcfc..9a9bd24e5 100644
--- a/components/hardware/nautilus-hardware-view.c
+++ b/components/hardware/nautilus-hardware-view.c
@@ -163,7 +163,7 @@ read_proc_info(const gchar* proc_filename)
}
fclose(thisFile);
- result = strdup(string_data->str);
+ result = g_strdup(string_data->str);
g_string_free(string_data, TRUE);
g_free(path_name);
@@ -199,7 +199,7 @@ extract_info(gchar* data, const gchar *field_name, gint nth)
/* add the requested node if the field was found */
if (field_data == NULL)
return NULL;
- field_data = strdup(field_data);
+ field_data = g_strdup(field_data);
g_strfreev(info_array);
return field_data;
}
@@ -213,12 +213,14 @@ get_CPU_description(gint nth)
GString* string_data = g_string_new("");
char* proc_data = read_proc_info("cpuinfo");
- if(extract_info(proc_data, "processor", nth) == NULL) {
+ temp_str = extract_info(proc_data, "processor", nth);
+ if(temp_str == NULL) {
/* can't find nth processor */
g_free(proc_data);
g_string_free(string_data, TRUE);
return NULL;
}
+ g_free (temp_str);
temp_str = extract_info(proc_data, "model name", nth);
g_string_append(string_data, temp_str);
@@ -236,7 +238,7 @@ get_CPU_description(gint nth)
g_free(temp_str);
g_free(proc_data);
- result = strdup(string_data->str);
+ result = g_strdup(string_data->str);
g_string_free(string_data, TRUE);
return result;
@@ -263,7 +265,7 @@ get_RAM_description (void)
g_free(temp_str);
g_free(proc_data);
- result = strdup(string_data->str);
+ result = g_strdup(string_data->str);
g_string_free(string_data, TRUE);
return result;
diff --git a/components/music/nautilus-music-view.c b/components/music/nautilus-music-view.c
index 0520d4279..a927bd5eb 100644
--- a/components/music/nautilus-music-view.c
+++ b/components/music/nautilus-music-view.c
@@ -1263,24 +1263,15 @@ nautilus_music_view_update_from_uri (NautilusMusicView *music_view, const char *
gtk_clist_clear (GTK_CLIST (music_view->details->song_list));
for (p = song_list; p != NULL; p = p->next) {
+ int i;
info = (SongInfo *) p->data;
+
+ for (i = 0; i < 10; i ++) {
+ clist_entry[i] = NULL;
+ }
- clist_entry[0] = malloc(4);
if (info->track_number > 0)
- sprintf(clist_entry[0], "%d ", info->track_number);
- else
- clist_entry[0] = '\0';
-
- clist_entry[1] = NULL;
- clist_entry[2] = NULL;
- clist_entry[3] = NULL;
- clist_entry[4] = NULL;
- clist_entry[5] = NULL;
- clist_entry[6] = NULL;
- clist_entry[7] = NULL;
- clist_entry[8] = NULL;
- clist_entry[9] = NULL;
-
+ clist_entry[0] = g_strdup_printf("%d ", info->track_number);
if (info->title)
clist_entry[1] = g_strdup(info->title);
if (info->artist)
@@ -1302,6 +1293,11 @@ nautilus_music_view_update_from_uri (NautilusMusicView *music_view, const char *
gtk_clist_append(GTK_CLIST(music_view->details->song_list), clist_entry);
gtk_clist_set_row_data(GTK_CLIST(music_view->details->song_list),
track_index, g_strdup(info->path_uri));
+
+ for (i = 0; i < 10; i ++) {
+ g_free (clist_entry[i]);
+ clist_entry[i] = NULL;
+ }
track_index += 1;
}
diff --git a/components/services/inventory/lib/eazel-inventory-shared.c b/components/services/inventory/lib/eazel-inventory-shared.c
index 9a6812c9d..12240dd5c 100644
--- a/components/services/inventory/lib/eazel-inventory-shared.c
+++ b/components/services/inventory/lib/eazel-inventory-shared.c
@@ -138,7 +138,7 @@ read_proc_info (const char *proc_filename) {
}
fclose (thisFile);
- result = strdup (string_data->str);
+ result = g_strdup (string_data->str);
g_string_free (string_data, TRUE);
g_free (path_name);
diff --git a/components/services/inventory/nautilus-view/nautilus-inventory-view.c b/components/services/inventory/nautilus-view/nautilus-inventory-view.c
index 8d9eefa1a..00cd4bfdc 100644
--- a/components/services/inventory/nautilus-view/nautilus-inventory-view.c
+++ b/components/services/inventory/nautilus-view/nautilus-inventory-view.c
@@ -210,7 +210,7 @@ gather_config_button_cb (GtkWidget *button, NautilusInventoryView *view) {
g_string_append (config_data, buffer);
}
fclose (config_file);
- config_string = strdup (config_data->str);
+ config_string = g_strdup (config_data->str);
g_string_free(config_data, TRUE);
g_free (config_file_name);
diff --git a/libnautilus-extensions/nautilus-string.c b/libnautilus-extensions/nautilus-string.c
index f740190a2..46cc69af4 100644
--- a/libnautilus-extensions/nautilus-string.c
+++ b/libnautilus-extensions/nautilus-string.c
@@ -511,14 +511,14 @@ nautilus_str_middle_truncate (const char *string,
* side)
*/
if (truncate_length < min_truncate_length) {
- return strdup (string);
+ return g_strdup (string);
}
length = strlen (string);
/* Make sure the string is not already small enough. */
if (length <= truncate_length) {
- return strdup (string);
+ return g_strdup (string);
}
/* Find the 'middle' where the truncation will occur. */
diff --git a/libnautilus-private/nautilus-string.c b/libnautilus-private/nautilus-string.c
index f740190a2..46cc69af4 100644
--- a/libnautilus-private/nautilus-string.c
+++ b/libnautilus-private/nautilus-string.c
@@ -511,14 +511,14 @@ nautilus_str_middle_truncate (const char *string,
* side)
*/
if (truncate_length < min_truncate_length) {
- return strdup (string);
+ return g_strdup (string);
}
length = strlen (string);
/* Make sure the string is not already small enough. */
if (length <= truncate_length) {
- return strdup (string);
+ return g_strdup (string);
}
/* Find the 'middle' where the truncation will occur. */
diff --git a/librsvg/rsvg.c b/librsvg/rsvg.c
index d4126809d..35e252d19 100644
--- a/librsvg/rsvg.c
+++ b/librsvg/rsvg.c
@@ -190,12 +190,12 @@ rsvg_ctx_free (RsvgCtx *ctx)
for (i = 0; i < ctx->n_state; i++)
rsvg_state_finalize (&ctx->state[i]);
- free (ctx->state);
+ g_free (ctx->state);
g_hash_table_foreach (ctx->entities, rsvg_ctx_free_helper, NULL);
g_hash_table_destroy (ctx->entities);
- free (ctx);
+ g_free (ctx);
}
static void
diff --git a/src/file-manager/Makefile.am b/src/file-manager/Makefile.am
index 8dec493a6..dc0c31b9c 100644
--- a/src/file-manager/Makefile.am
+++ b/src/file-manager/Makefile.am
@@ -35,6 +35,7 @@ libnautilus_file_manager_la_SOURCES= \
fm-list-view.c \
fm-properties-window.c \
fm-search-list-view.c \
+ nautilus-indexing-info.c \
nautilus-trash-monitor.c \
$(NULL)
@@ -52,6 +53,7 @@ noinst_HEADERS = \
fm-list-view.h \
fm-properties-window.h \
fm-search-list-view.h \
+ nautilus-indexing-info.h \
nautilus-trash-monitor.h \
$(NULL)
diff --git a/src/file-manager/fm-search-list-view.c b/src/file-manager/fm-search-list-view.c
index 832c13036..463ff0c0e 100644
--- a/src/file-manager/fm-search-list-view.c
+++ b/src/file-manager/fm-search-list-view.c
@@ -28,6 +28,7 @@
#include "fm-directory-view.h"
#include "fm-list-view-private.h"
+#include "nautilus-indexing-info.h"
#include <libnautilus-extensions/nautilus-file-attributes.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
@@ -41,6 +42,7 @@
#include <libgnome/gnome-i18n.h>
/* Paths to use when creating & referring to Bonobo menu items */
+#define MENU_PATH_INDEXING_INFO "/File/Indexing Info..."
#define MENU_PATH_REVEAL_IN_NEW_WINDOW "/File/Reveal"
static void fm_search_list_view_initialize (gpointer object,
@@ -258,6 +260,12 @@ real_get_column_specification (FMListView *view,
}
static void
+indexing_info_callback (gpointer ignored, gpointer data)
+{
+ nautilus_indexing_info_show_dialog ();
+}
+
+static void
compute_reveal_item_name_and_sensitivity (GList *selected_files,
gboolean include_accelerator_underbars,
char **return_name,
@@ -409,6 +417,7 @@ real_merge_menus (FMDirectoryView *view)
GList *selected_files;
char *name;
gboolean sensitive;
+ int position;
g_assert (FM_IS_LIST_VIEW (view));
@@ -417,6 +426,23 @@ real_merge_menus (FMDirectoryView *view)
ui_handler = fm_directory_view_get_bonobo_ui_handler (view);
selected_files = fm_directory_view_get_selection (view);
+ /* Indexing Info.. goes right after the Show Properties item that
+ * fm-directory-view places in the File menu.
+ */
+ position = bonobo_ui_handler_menu_get_pos
+ (ui_handler,
+ FM_DIRECTORY_VIEW_MENU_PATH_SHOW_PROPERTIES) + 1,
+ bonobo_ui_handler_menu_new_item
+ (ui_handler,
+ MENU_PATH_INDEXING_INFO,
+ _("Indexing Info..."),
+ _("Show indexing info dialog"),
+ position,
+ BONOBO_UI_HANDLER_PIXMAP_NONE,
+ NULL, 0, 0,
+ (BonoboUIHandlerCallback) indexing_info_callback, NULL);
+
+
compute_reveal_item_name_and_sensitivity (selected_files, TRUE, &name, &sensitive);
/* FIXME bugzilla.eazel.com 1750: need to connect callback */
diff --git a/src/file-manager/nautilus-indexing-info.c b/src/file-manager/nautilus-indexing-info.c
new file mode 100644
index 000000000..4e1ab233e
--- /dev/null
+++ b/src/file-manager/nautilus-indexing-info.c
@@ -0,0 +1,179 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+
+/*
+ * nautilus-indexing-info.c: Indexing Info for the search service
+ *
+ * Copyright (C) 2000 Eazel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Authors: George Lebl <jirka@5z.com>
+ */
+
+#include <config.h>
+#include <gnome.h>
+
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+#include <libnautilus-extensions/nautilus-gdk-extensions.h>
+
+/* FOR THE INCREDIBLE HACK */
+#include <sys/stat.h>
+#include <unistd.h>
+#include <time.h>
+
+#include <libmedusa/medusa-search-service.h>
+#include <libmedusa/medusa-index-service.h>
+
+#include "nautilus-indexing-info.h"
+
+static void
+update_file_index_callback (GtkWidget *widget, gpointer data)
+{
+ char *error = NULL;
+ MedusaIndexingRequestResult result;
+
+ result = medusa_index_service_request_reindex ();
+
+ switch (result) {
+ default:
+ case MEDUSA_INDEXER_REQUEST_OK:
+ error = NULL;
+ break;
+ case MEDUSA_INDEXER_ERROR_BUSY:
+ error = _("Busy");
+ break;
+ case MEDUSA_INDEXER_ERROR_NO_RESPONSE:
+ error = _("No response");
+ break;
+ case MEDUSA_INDEXER_ERROR_NO_INDEXER_PRESENT:
+ error = _("No indexer present");
+ break;
+ }
+
+ if (error != NULL) {
+ char *string;
+ GtkWidget *dialog;
+
+ string = g_strdup_printf (_("Error while trying "
+ "to reindex: %s"),
+ error);
+ dialog = gnome_error_dialog (string);
+ gnome_dialog_run (GNOME_DIALOG (dialog));
+ g_free(string);
+ }
+}
+
+static void
+make_label_bold (GtkWidget *label)
+{
+ GdkFont *bold_font;
+
+ bold_font = nautilus_gdk_font_get_bold (label->style->font);
+
+ if (bold_font != NULL) {
+ nautilus_gtk_widget_set_font (label, bold_font);
+ }
+}
+
+static char *
+get_file_index_time (void)
+{
+ time_t the_time;
+ char *time_str, *p;
+
+ the_time = medusa_index_service_get_last_index_update_time ();
+
+ time_str = g_strdup (ctime (&the_time));
+
+ p = strchr (time_str, '\n');
+ if (p) {
+ *p = '\0';
+ }
+
+ return time_str;
+}
+
+/**
+ * nautilus_indexing_info_show_dialog:
+ *
+ * Show the indexing info dialog. If one is already
+ * running, just raise that one.
+ **/
+void
+nautilus_indexing_info_show_dialog (void)
+{
+ GtkWidget *label, *button;
+ GtkWidget *hbox;
+ static GtkWidget *dialog = NULL;
+ GnomeDialog *gnome_dialog;
+ char *time_str;
+ char *label_str;
+
+ if (medusa_search_service_connection_is_available () != GNOME_VFS_OK) {
+ GtkWidget *error =
+ gnome_error_dialog (_("Search service not available"));
+ gnome_dialog_run (GNOME_DIALOG (error));
+ return;
+ }
+
+ /* A dialog is up already */
+ if (dialog != NULL) {
+ gtk_widget_show_now (dialog);
+ gdk_window_raise (dialog->window);
+ return;
+ }
+
+ dialog = gnome_dialog_new (_("Indexing Info..."),
+ GNOME_STOCK_BUTTON_OK,
+ NULL);
+
+ gnome_dialog = GNOME_DIALOG (dialog);
+
+ gnome_dialog_set_close (gnome_dialog, TRUE /*click_closes*/);
+ gnome_dialog_close_hides (gnome_dialog, FALSE /*just_hide*/);
+
+ gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroyed),
+ &dialog);
+
+ label = gtk_label_new (_("Once a day your files and text content are "
+ "indexed so your searches are fast. If you "
+ "need to update your index now, click on the "
+ "\"Update Now\" button for the appropriate "
+ "index."));
+ gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_box_pack_start (GTK_BOX (gnome_dialog->vbox), label, TRUE, TRUE, 0);
+
+ time_str = get_file_index_time ();
+ label_str = g_strdup_printf (_("Your files were last indexed at %s"),
+ time_str);
+ g_free (time_str);
+ label = gtk_label_new (label_str);
+ make_label_bold (label);
+ gtk_box_pack_start (GTK_BOX (gnome_dialog->vbox), label,
+ FALSE, FALSE, 0);
+
+ hbox = gtk_hbox_new (FALSE, 0);
+ button = gtk_button_new_with_label (_("Update Now"));
+ gtk_signal_connect (GTK_OBJECT (button), "clicked",
+ GTK_SIGNAL_FUNC (update_file_index_callback),
+ NULL);
+ gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (gnome_dialog->vbox), hbox,
+ FALSE, FALSE, 0);
+
+ gtk_widget_show_all (dialog);
+}
diff --git a/src/file-manager/nautilus-indexing-info.h b/src/file-manager/nautilus-indexing-info.h
new file mode 100644
index 000000000..b4c8fe313
--- /dev/null
+++ b/src/file-manager/nautilus-indexing-info.h
@@ -0,0 +1,37 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+
+/*
+ * nautilus-indexing-info.h: Indexing Info for the search service
+ *
+ * Copyright (C) 2000 Eazel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU 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
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * Author: George Lebl <jirka@5z.com>
+ *
+ */
+
+#ifndef NAUTILUS_INDEXING_INFO_H
+#define NAUTILUS_INDEXING_INFO_H
+
+BEGIN_GNOME_DECLS
+
+/* Show the indexing info dialog, If one is already running
+ * just raise that one */
+void nautilus_indexing_info_show_dialog (void);
+
+END_GNOME_DECLS
+
+#endif /* NAUTILUS_INDEXING_INFO_H */