static void hd_bookmark_widgets_constructed (GObject *object) { HDBookmarkWidgetsPrivate *priv = HD_BOOKMARK_WIDGETS (object)->priv; gchar *user_bookmarks, *user_bookmarks_uri; GnomeVFSResult result; if (G_OBJECT_CLASS (hd_bookmark_widgets_parent_class)->constructed) G_OBJECT_CLASS (hd_bookmark_widgets_parent_class)->constructed (object); /* Create the bookmark paths if they do not exist yet */ set_bookmark_files_path (); user_bookmarks = g_build_filename (g_get_home_dir (), MYBOOKMARKS, NULL); user_bookmarks_uri = gnome_vfs_get_uri_from_local_path (user_bookmarks); result = gnome_vfs_monitor_add (&priv->user_bookmarks_handle, user_bookmarks_uri, GNOME_VFS_MONITOR_FILE, hd_bookmark_widgets_bookmark_files_changed, object); if (result != GNOME_VFS_OK) g_debug ("Could not add monitor for user bookmark file. %s", gnome_vfs_result_to_string (result)); priv->parse_idle_id = gdk_threads_add_idle ((GSourceFunc) hd_bookmark_widgets_parse_bookmark_files, object); g_free (user_bookmarks); g_free (user_bookmarks_uri); }
void gth_monitor_add_uri (GthMonitor *monitor, const char *uri) { GthMonitorPrivateData *priv = monitor->priv; GnomeVFSMonitorHandle *monitor_handle; GnomeVFSResult result; GList *item; if (uri == NULL) return; item = find_monitor_from_uri (priv->vfs_monitors, uri); if (item != NULL) { MonitorHandle *mh = item->data; monitor_handle_ref (mh); return; } debug (DEBUG_INFO, "MONITOR URI: %s", uri); result = gnome_vfs_monitor_add (&monitor_handle, uri, GNOME_VFS_MONITOR_DIRECTORY, directory_changed, monitor); if (result == GNOME_VFS_OK) { MonitorHandle *mh = monitor_handle_new (monitor_handle, uri); priv->vfs_monitors = g_list_prepend (priv->vfs_monitors, mh); } priv->monitor_enabled = TRUE; }
int main (int argc, char **argv) { GnomeVFSResult result; gchar *text_uri = "/tmp/"; GnomeVFSMonitorHandle *handle; if (! gnome_vfs_init ()) { fprintf (stderr, "Cannot initialize gnome-vfs.\n"); return 1; } if (argc == 2) { text_uri = argv[1]; } result = gnome_vfs_monitor_add (&handle, text_uri, GNOME_VFS_MONITOR_DIRECTORY, callback, "user data"); printf ("handle is %p\n", handle); show_result (result, "monitor_add", text_uri); g_timeout_add (1000, timeout_cb, NULL); if (result == GNOME_VFS_OK) { main_loop = g_main_loop_new (NULL, TRUE); g_main_loop_run (main_loop); g_main_loop_unref (main_loop); } g_free (text_uri); return 0; }
static int hcp_init_monitor (HCPAppList *al, const gchar *path) { GnomeVFSResult ret; g_return_val_if_fail (al, GNOME_VFS_ERROR_GENERIC); g_return_val_if_fail (HCP_IS_APP_LIST (al), GNOME_VFS_ERROR_GENERIC); g_return_val_if_fail (path, GNOME_VFS_ERROR_GENERIC); ret = gnome_vfs_monitor_add (&al->priv->monitor, path, GNOME_VFS_MONITOR_DIRECTORY, (GnomeVFSMonitorCallback) hcp_monitor_callback_f, al); if (ret != GNOME_VFS_OK) { return ret; } return GNOME_VFS_OK; }
static void monitor_places(gpointer callback, gpointer data, gpointer box) { GnomeVFSMonitorHandle * handle; Monitor_place = g_malloc(sizeof(Monitor_places)); Monitor_place->data = data; Monitor_place->callback = callback; Monitor_place->box = box; const char *homedir = g_getenv("HOME"); if (!homedir) homedir = g_get_home_dir(); char * filename = g_strdup_printf("%s/.gtk-bookmarks", homedir); if (gnome_vfs_monitor_add(&handle, filename, GNOME_VFS_MONITOR_FILE, monitor_places_callback, Monitor_place) != GNOME_VFS_OK) { printf("attempt to monitor '%s' failed \n", filename); } g_free(filename); }
void hn_others_button_register_monitors (HNOthersButton * button) { gchar *dir; gchar *file = NULL; gchar *conf_file; conf_file = g_build_filename (g_get_home_dir (), USER_MENU_DIR, MENU_FILE, NULL); /* We copy SYSTEMWIDE_MENU_FILE to always track the changes */ if (!g_file_test (conf_file, G_FILE_TEST_EXISTS)) if (g_file_get_contents (HD_DESKTOP_MENU_PATH "/" MENU_FILE, &file, NULL, NULL)) { g_file_set_contents (conf_file, file, -1, NULL); } g_free (file); /* Watch systemwide menu conf */ if (gnome_vfs_monitor_add (&button->priv->system_dir_monitor, HD_DESKTOP_MENU_PATH, GNOME_VFS_MONITOR_DIRECTORY, (GnomeVFSMonitorCallback) hn_others_button_dir_changed, button) != GNOME_VFS_OK) { g_warning ("Others_menu_initialize_menu: " "failed setting monitor callback " "for systemwide menu conf." ); } /* Have to get the directory from the path because the USER_MENU_FILE define might contain directory (it does, in fact). */ dir = g_path_get_dirname (conf_file); g_mkdir (dir, 0755); if (dir && *dir) { if (gnome_vfs_monitor_add (&button->priv->home_dir_monitor, dir, GNOME_VFS_MONITOR_DIRECTORY, (GnomeVFSMonitorCallback) hn_others_button_dir_changed, button) != GNOME_VFS_OK) { g_warning ("Others_menu_initialize_menu: " "failed setting monitor callback " "for user specific menu conf." ); } } else { g_warning ("Others_menu_initialize_menu: " "failed to create directory '%s'", dir); } g_free (dir); g_free (conf_file); /* Monitor the .desktop directories, so we can regenerate the menu * when a new application is installed */ if (gnome_vfs_monitor_add (&button->priv->desktop_dir_monitor, HD_DESKTOP_ENTRY_PATH, GNOME_VFS_MONITOR_DIRECTORY, (GnomeVFSMonitorCallback) hn_others_button_dir_changed, button) != GNOME_VFS_OK) { g_warning ("Others_menu_initialize_menu: " "failed setting monitor callback " "for .desktop directory." ); } /* Monitor the hildon .desktop directories, so we can regenerate the * menu when a new application is installed */ if (gnome_vfs_monitor_add (&button->priv->desktop_dir_monitor, HD_DESKTOP_ENTRY_PATH "/hildon", GNOME_VFS_MONITOR_DIRECTORY, (GnomeVFSMonitorCallback) hn_others_button_dir_changed, button) != GNOME_VFS_OK) { g_warning ("Others_menu_initialize_menu: " "failed setting monitor callback " "for .desktop directory." ); } }