コード例 #1
0
ファイル: fm-path-entry.c プロジェクト: gilir/libfm-debian
static void fm_path_entry_changed(GtkEditable *editable)
{
    FmPathEntry *entry = FM_PATH_ENTRY(editable);
    FmPathEntryPrivate *priv  = FM_PATH_ENTRY_GET_PRIVATE(entry);
    const gchar *original_key = gtk_entry_get_text( GTK_ENTRY(entry) );
    /* len of directory part */
    gint key_dir_len;
    gchar *last_slash = strrchr(original_key, G_DIR_SEPARATOR);

    if( priv->in_change || !priv->path )
        return;

    /* not path -> keep current completion model */
    if( last_slash == NULL )
        return;

    /* Check if path entry is not part of current completion folder model */
    key_dir_len = last_slash - original_key;
    if( !fm_path_equal_str(priv->path, original_key, key_dir_len) )
    {
        gchar* new_path = g_path_get_dirname(original_key);
        FmPath *new_fm_path = fm_path_new(new_path);
        g_free(new_path);
        if( new_fm_path != NULL )
        {
            /* set hidden parameter based on prev. model */
            /* FIXME: this is not very good */
            gboolean show_hidden = priv->completion_model ? fm_folder_model_get_show_hidden(priv->completion_model) : FALSE;
            if(priv->completion_model)
                g_object_unref(priv->completion_model);
            if(priv->model && fm_path_equal(priv->model->dir->dir_path, new_fm_path))
            {
                if(priv->path)
                    fm_path_unref(priv->path);
                priv->path = fm_path_ref(priv->model->dir->dir_path);
                fm_path_unref(new_fm_path);
                priv->completion_model = g_object_ref(priv->model);
            }
            else
            {
                FmFolder *new_fm_folder = fm_folder_get_for_path(new_fm_path);
                FmFolderModel *new_fm = fm_folder_model_new(new_fm_folder, show_hidden);
                g_object_unref(new_fm_folder);
                priv->completion_model = new_fm;
                if(priv->path)
                    fm_path_unref(priv->path);
                priv->path = new_fm_path;
            }
            gtk_entry_completion_set_model( priv->completion, GTK_TREE_MODEL(priv->completion_model) );
        }
        else
        {
            /* FIXME: Handle invalid Paths */
            g_warning("Invalid Path: %s", new_path);
        }
    }
}
コード例 #2
0
ファイル: test-fm-path.c プロジェクト: geekless/libfm
static void test_predefined_paths()
{
    FmPath* path;
    char* tmp;

    path = fm_path_new_for_uri("trash:///");
    g_assert(path == fm_path_get_trash());
    fm_path_unref(path);

    path = fm_path_new_for_uri("trash:///xxx");
    g_assert(path->parent == fm_path_get_trash());
    fm_path_unref(path);

    path = fm_path_new_for_uri("menu://");
    g_assert(path == fm_path_get_apps_menu());
    fm_path_unref(path);

    path = fm_path_new_for_uri("menu://applications");
    g_assert(path == fm_path_get_apps_menu());
    fm_path_unref(path);

    path = fm_path_new_for_uri("menu://applications/test/");
    g_assert(path->parent == fm_path_get_apps_menu());
    fm_path_unref(path);

/*
    path = fm_path_new_for_path(g_get_home_dir());
    g_assert(path == fm_path_get_home());
    fm_path_unref(path);

    tmp = g_build_filename(g_get_home_dir(), "xxxx", "xx", NULL);
    path = fm_path_new_for_path(tmp);
    g_debug("path->name=%s", path->parent->parent->name);
    g_assert(path->parent->parent == fm_path_get_home());
    fm_path_unref(path);
    g_free(tmp);

    path = fm_path_new_for_path(g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP));
    g_assert(path == fm_path_get_desktop());
    fm_path_unref(path);

    tmp = g_build_filename(g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP), "xxxx", "xx", NULL);
    path = fm_path_new_for_path(tmp);
    g_assert(path->parent->parent == fm_path_get_desktop());
    fm_path_unref(path);
    g_free(tmp);
*/
}
コード例 #3
0
ファイル: fm-path.c プロジェクト: afilmore/libfmcore
/**
 * fm_path_new_for_uri
 * @path_name: a URI with special characters escaped.
 * Encoded URI such as http://wiki.lxde.org/zh/%E9%A6%96%E9%A0%81
 * will be unescaped.
 *
 * You can call fm_path_to_uri () to convert a FmPath to a escaped URI
 * string.
 *
 * Returns: a newly created FmPath for the path. You have to call
 * fm_path_unref () when it's no longer needed.
 */
static FmPath *_fm_path_new_for_uri_internal (const char *uri, gboolean need_unescape)
{
    FmPath *path, *root;
    const char *rel_path;
    
    if (!uri || !*uri)
        return fm_path_ref (root_path);

    root = _fm_path_new_uri_root (uri, strlen (uri), &rel_path, need_unescape);
    
    if (*rel_path)
    {
        if (need_unescape)
            rel_path = g_uri_unescape_string (rel_path, NULL);
        
        path = fm_path_new_relative (root, rel_path);
        fm_path_unref (root);
        
        if (need_unescape)
            g_free ((char*)rel_path);
    }
    else
    {
        path = root;
    }
    return path;
}
コード例 #4
0
ファイル: fm-folder-config.c プロジェクト: dforsi/libfm
/**
 * fm_folder_config_open
 * @path: path to get config
 *
 * Searches for settings in the cache that are specific to @path. Locks
 * the cache. Returned descriptor can be used for access to settings.
 *
 * Returns: (transfer full): new configuration descriptor.
 *
 * Since: 1.2.0
 */
FmFolderConfig *fm_folder_config_open(FmPath *path)
{
    FmFolderConfig *fc = g_slice_new(FmFolderConfig);
    FmPath *sub_path;

    fc->changed = FALSE;
    /* clear .directory file first */
    sub_path = fm_path_new_child(path, ".directory");
    fc->filepath = fm_path_to_str(sub_path);
    fm_path_unref(sub_path);
    if (g_file_test(fc->filepath, G_FILE_TEST_EXISTS))
    {
        fc->kf = g_key_file_new();
        if (g_key_file_load_from_file(fc->kf, fc->filepath,
                                      G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS,
                                      NULL) &&
            g_key_file_has_group(fc->kf, "File Manager"))
        {
            fc->group = "File Manager";
            return fc;
        }
        g_key_file_free(fc->kf);
    }
    g_free(fc->filepath);
    fc->filepath = NULL;
    fc->group = fm_path_to_str(path);
    G_LOCK(cache);
    fc->kf = fc_cache;
    return fc;
}
コード例 #5
0
ファイル: fm-path-entry.c プロジェクト: geekless/libfm
static void fm_path_entry_paste_and_go(GtkMenuItem *menuitem, GtkEntry *entry)
{
    GtkClipboard* clipboard = gtk_clipboard_get_for_display(
        gtk_widget_get_display (GTK_WIDGET (menuitem)),GDK_SELECTION_CLIPBOARD);

    gchar* full_path = gtk_clipboard_wait_for_text(clipboard);

    if (full_path)
    {

        FmPathEntryPrivate *priv  = FM_PATH_ENTRY_GET_PRIVATE(entry);

        if(priv->path)
            fm_path_unref(priv->path);

        /* special handling for home dir */
        if(full_path[0] == '~' && full_path[1] == G_DIR_SEPARATOR)
            priv->path = fm_path_new_relative(fm_path_get_home(), full_path + 2);
        else if(full_path[0] == '~' && full_path[1] == 0)
            priv->path = fm_path_ref(fm_path_get_home());
        else
            priv->path = fm_path_new_for_str(full_path);

        gchar * disp_name = fm_path_display_name(priv->path, FALSE);
        gtk_entry_set_text(entry, disp_name);
        g_free(disp_name);

        gtk_editable_set_position(GTK_EDITABLE(entry), -1);

        g_free(full_path);

        fm_path_entry_activate(FM_PATH_ENTRY(entry));
    }
}
コード例 #6
0
ファイル: fm-path-entry.c プロジェクト: geekless/libfm
static void  fm_path_entry_on_activate(GtkEntry *entry, gpointer user_data)
{
    FmPathEntryPrivate *priv  = FM_PATH_ENTRY_GET_PRIVATE(entry);
    const char* full_path;
    char* disp_name;
    /* convert current path string to FmPath here */

    full_path = gtk_entry_get_text(entry);
    if(priv->path)
        fm_path_unref(priv->path);

    /* special handling for home dir */
    if(full_path[0] == '~' && full_path[1] == G_DIR_SEPARATOR)
        priv->path = fm_path_new_relative(fm_path_get_home(), full_path + 2);
    else if(full_path[0] == '~' && full_path[1] == 0)
        priv->path = fm_path_ref(fm_path_get_home());
    else
        priv->path = fm_path_new_for_str(full_path);

    disp_name = fm_path_display_name(priv->path, FALSE);
    gtk_entry_set_text(entry, disp_name);
    g_free(disp_name);

    gtk_editable_set_position(GTK_EDITABLE(entry), -1);
}
コード例 #7
0
ファイル: test-fm-path.c プロジェクト: geekless/libfm
static void test_parsing(FmPathFunc func, const char* str, const char** expected, int n_expected)
{
    GSList* elements = NULL, *l;
    int i;
    FmPath *path, *element;
    g_print("\ntry to parse \'%s\':\n[", str);
    path = func(str);

    for(element = path; element; element = element->parent)
        elements = g_slist_prepend(elements, element);

    for(i = 0, l = elements; l; l=l->next, ++i)
    {
        g_assert_cmpint(i, <, n_expected);
        element = (FmPath*)l->data;
        g_print("\'%s\'", element->name);
        if(l->next)
            g_print(", ");
        g_assert_cmpstr(element->name, ==, expected[i]);
    }
    g_slist_free(elements);
    g_print("]\n");

    g_assert_cmpint(i, ==, n_expected);

    fm_path_unref(path);
}
コード例 #8
0
ファイル: fm-bookmarks.c プロジェクト: juergenhoetzel/libfm
void free_item(FmBookmarkItem* item)
{
    if(item->name != item->path->name)
        g_free(item->name);
    fm_path_unref(item->path);
    g_slice_free(FmBookmarkItem, item);
}
コード例 #9
0
ファイル: fm-places-model.c プロジェクト: geekless/libfm
void on_mount_added(GVolumeMonitor* vm, GMount* mount, gpointer user_data)
{
    FmPlacesModel* model = FM_PLACES_MODEL(user_data);
    GVolume* vol = g_mount_get_volume(mount);
    if(vol)
    {
        FmPlaceItem *item;
        GtkTreeIter it;
        item = find_vol(model, vol, &it);
        if(item && item->type == FM_PLACES_ITEM_VOL && !item->fi->path)
        {
            GtkTreePath* tp;
            GFile* gf = g_mount_get_root(mount);
            FmPath* path = fm_path_new_for_gfile(gf);
            g_debug("mount path: %s", path->name);
            g_object_unref(gf);
            fm_file_info_set_path(item->fi, path);
            if(path)
                fm_path_unref(path);
            item->vol_mounted = TRUE;

            /* inform the view to update mount indicator */
            tp = gtk_tree_model_get_path(GTK_TREE_MODEL(model), &it);
            gtk_tree_model_row_changed(GTK_TREE_MODEL(model), tp, &it);
            gtk_tree_path_free(tp);
        }
        g_object_unref(vol);
    }
}
コード例 #10
0
ファイル: libfm-demo.c プロジェクト: Gontxal0/libfm
int main(int argc, char** argv)
{
	FmMainWin* w;
	gtk_init(&argc, &argv);

	fm_gtk_init(NULL);

    /* for debugging RTL */
    /* gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL); */

	w = fm_main_win_new();
	gtk_window_set_default_size(GTK_WINDOW(w), 640, 480);
	gtk_widget_show(GTK_WIDGET(w));

    if(argc > 1)
    {
        FmPath* path = fm_path_new_for_commandline_arg(argv[1]);
        fm_main_win_chdir(w, path);
        fm_path_unref(path);
    }

	gtk_main();

    fm_finalize();

	return 0;
}
コード例 #11
0
ファイル: fm-folder.c プロジェクト: engla/libfm
FmFolder*    fm_folder_get_for_gfile    (GFile* gf)
{
    FmPath* path = fm_path_new_for_gfile(gf);
    FmFolder* folder = fm_folder_new_internal(path, gf);
    fm_path_unref(path);
    return folder;
}
コード例 #12
0
ファイル: fm-folder.c プロジェクト: engla/libfm
FmFolder* fm_folder_get_for_path_name(const char* path)
{
    FmPath* fm_path = fm_path_new_for_str(path);
    FmFolder* folder = fm_folder_get_internal(fm_path, NULL);
    fm_path_unref(fm_path);
    return folder;
}
コード例 #13
0
ファイル: fm-path-entry.c プロジェクト: gilir/libfm-debian
void fm_path_entry_set_model(FmPathEntry *entry, FmPath* path, FmFolderModel* model)
{
    FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry);
    /* FIXME: should we use UTF-8 encoded display name here? */
    gchar *path_str = fm_path_display_name(path, FALSE);
    if(priv->path)
        fm_path_unref(priv->path);
    priv->path = fm_path_ref(path);

    if( priv->model )
        g_object_unref( priv->model );
    if( priv->completion_model )
        g_object_unref(priv->completion_model);
    if(model)
    {
        priv->model = g_object_ref(model);
        priv->completion_model = g_object_ref(model);
        gtk_entry_set_completion(GTK_ENTRY(entry), priv->completion);
    }
    else
    {
        priv->model = NULL;
        priv->completion_model = NULL;
        gtk_entry_set_completion(GTK_ENTRY(entry), NULL);
    }
    gtk_entry_completion_set_model( priv->completion, (GtkTreeModel*)priv->completion_model );
    priv->in_change = TRUE;
    gtk_entry_set_text(GTK_ENTRY(entry), path_str);
    priv->in_change = FALSE;
    gtk_editable_set_position(GTK_EDITABLE(entry), -1);
    g_free(path_str);
}
コード例 #14
0
ファイル: libfm-demo.c プロジェクト: engla/libfm
int main(int argc, char** argv)
{
	GtkWidget* w;
	gtk_init(&argc, &argv);

	fm_gtk_init(NULL);

    /* for debugging RTL */
    /* gtk_widget_set_default_direction(GTK_TEXT_DIR_RTL); */

	w = fm_main_win_new();
	gtk_window_set_default_size(GTK_WINDOW(w), 640, 480);
	gtk_widget_show(w);

    if(argc > 1)
    {
        FmPath* path = fm_path_new(argv[1]);
        fm_main_win_chdir(FM_MAIN_WIN(w), path);
        fm_path_unref(path);
    }

	gtk_main();

    fm_finalize();

	return 0;
}
コード例 #15
0
ファイル: fm-file-launcher.c プロジェクト: Gontxal0/libfm
static FmFileInfo *_fetch_file_info_for_shortcut(const char *target,
                                                 GAppLaunchContext* ctx,
                                                 FmFileLauncher* launcher,
                                                 gpointer user_data)
{
    FmFileInfoJob *job;
    QueryErrorData data;
    FmFileInfo *fi;
    FmPath *path;

    job = fm_file_info_job_new(NULL, 0);
    /* bug #3614794: the shortcut target is a commandline argument */
    path = fm_path_new_for_commandline_arg(target);
    fm_file_info_job_add(job, path);
    fm_path_unref(path);
    data.ctx = ctx;
    data.launcher = launcher;
    data.user_data = user_data;
    g_signal_connect(job, "error", G_CALLBACK(on_query_target_info_error), &data);
    fi = NULL;
    if (fm_job_run_sync_with_mainloop(FM_JOB(job)))
        fi = fm_file_info_ref(fm_file_info_list_peek_head(job->file_infos));
    g_signal_handlers_disconnect_by_func(job, on_query_target_info_error, &data);
    g_object_unref(job);
    return fi;
}
コード例 #16
0
ファイル: fm-folder-view.c プロジェクト: afilmore/lxmanager
static void fm_folder_view_finalize(GObject *object)
{
    FmFolderView *self;

    g_return_if_fail(object != NULL);
    g_return_if_fail(IS_FM_FOLDER_VIEW(object));

    self = FM_FOLDER_VIEW(object);
    if(self->folder)
    {
        g_object_unref(self->folder);
        if( self->model )
            g_object_unref(self->model);
    }
    g_object_unref(self->dnd_src);
    g_object_unref(self->dnd_dest);

    if(self->cwd)
        fm_path_unref(self->cwd);

    g_signal_handlers_disconnect_by_func(fm_config, on_single_click_changed, object);

    cancel_pending_row_activated(self);

    if(self->icon_size_changed_handler)
        g_signal_handler_disconnect(fm_config, self->icon_size_changed_handler);

    if (G_OBJECT_CLASS(fm_folder_view_parent_class)->finalize)
        (* G_OBJECT_CLASS(fm_folder_view_parent_class)->finalize)(object);
}
コード例 #17
0
ファイル: main-win.c プロジェクト: gilir/libfm-debian
void fm_main_win_chdir_by_name(FmMainWin* win, const char* path_str)
{
    FmPath* path;
    gtk_entry_set_text(GTK_ENTRY(win->location), path_str);
    path = fm_path_new(path_str);
    fm_folder_view_chdir(FM_FOLDER_VIEW(win->folder_view), path);
    fm_path_unref(path);
}
コード例 #18
0
ファイル: fm-file-info-job.c プロジェクト: YustasSwamp/libfm
/**
 * fm_file_info_job_add_gfile
 * @job: a job to add file
 * @gf: a file descriptor to add to query list
 *
 * Adds a path @gf to query list for the @job.
 *
 * This API may only be called before starting the @job.
 *
 * Since: 0.1.0
 */
void fm_file_info_job_add_gfile(FmFileInfoJob* job, GFile* gf)
{
    FmPath* path = fm_path_new_for_gfile(gf);
    FmFileInfo* fi = fm_file_info_new();
    fm_file_info_set_path(fi, path);
    fm_path_unref(path);
    fm_file_info_list_push_tail_noref(job->file_infos, fi);
}
コード例 #19
0
static void on_browse_btn_clicked(GtkButton* btn, AppChooserData* data)
{
    FmPath* file;
    GtkFileFilter* filter = gtk_file_filter_new();
    char* binary;
    gtk_file_filter_add_custom(filter,
        GTK_FILE_FILTER_FILENAME|GTK_FILE_FILTER_MIME_TYPE, exec_filter_func, NULL, NULL);
    /* gtk_file_filter_set_name(filter, _("Executable files")); */
    file = fm_select_file(GTK_WINDOW(data->dlg), NULL, "/usr/bin", TRUE, FALSE, filter, NULL);

    if (file == NULL)
        return;
    binary = fm_path_to_str(file);
    if (g_str_has_suffix(fm_path_get_basename(file), ".desktop"))
    {
        GKeyFile *kf = g_key_file_new();
        GDesktopAppInfo *info;
        if (g_key_file_load_from_file(kf, binary, 0, NULL) &&
            (info = g_desktop_app_info_new_from_keyfile(kf)) != NULL)
            /* it is a valid desktop entry */
        {
            /* FIXME: it will duplicate the file, how to avoid that? */
            gtk_entry_set_text(data->cmdline,
                               g_app_info_get_commandline(G_APP_INFO(info)));
            gtk_entry_set_text(data->app_name,
                               g_app_info_get_name(G_APP_INFO(info)));
            gtk_toggle_button_set_active(data->use_terminal,
                                         g_key_file_get_boolean(kf, G_KEY_FILE_DESKTOP_GROUP,
                                                                G_KEY_FILE_DESKTOP_KEY_TERMINAL,
                                                                NULL));
            gtk_toggle_button_set_active(data->keep_open,
                                         g_key_file_get_boolean(kf, G_KEY_FILE_DESKTOP_GROUP,
                                                                "X-KeepTerminal",
                                                                NULL));
            g_object_unref(info);
            g_key_file_free(kf);
            fm_path_unref(file);
            return;
        }
        g_key_file_free(kf);
    }
    gtk_entry_set_text(data->cmdline, binary);
    g_free(binary);
    fm_path_unref(file);
}
コード例 #20
0
ファイル: fm-folder-view.c プロジェクト: afilmore/lxmanager
gboolean fm_folder_view_chdir(FmFolderView* fv, FmPath* path)
{
    FmFolderModel* model;
    FmFolder* folder;

    if(fv->folder)
    {
        g_signal_handlers_disconnect_by_func(fv->folder, on_folder_loaded, fv);
        g_signal_handlers_disconnect_by_func(fv->folder, on_folder_unmounted, fv);
        g_signal_handlers_disconnect_by_func(fv->folder, on_folder_err, fv);
        g_object_unref(fv->folder);
        fv->folder = NULL;
        if(fv->model)
        {
            model = FM_FOLDER_MODEL(fv->model);
            g_signal_handlers_disconnect_by_func(model, on_sort_col_changed, fv);
            if(model->dir)
                g_signal_handlers_disconnect_by_func(model->dir, on_folder_err, fv);
            g_object_unref(model);
            fv->model = NULL;
        }
    }

    /* FIXME: the signal handler should be able to cancel the loading. */
    g_signal_emit(fv, signals[DIRECTORY_CHANGED], 0, path);
    if(fv->cwd)
        fm_path_unref(fv->cwd);
    fv->cwd = fm_path_ref(path);

    fv->folder = folder = fm_folder_get(path);
    if(folder)
    {
        /* connect error handler */
        g_signal_connect(folder, "loaded", on_folder_loaded, fv);
        g_signal_connect(folder, "unmount", on_folder_unmounted, fv);
        g_signal_connect(folder, "error", on_folder_err, fv);
        if(fm_folder_get_is_loaded(folder))
            on_folder_loaded(folder, fv);
        else
        {
            switch(fv->mode)
            {
            case FM_FV_LIST_VIEW:
                cancel_pending_row_activated(fv);
                gtk_tree_view_set_model(GTK_TREE_VIEW(fv->view), NULL);
                break;
            case FM_FV_ICON_VIEW:
            case FM_FV_COMPACT_VIEW:
            case FM_FV_THUMBNAIL_VIEW:
                exo_icon_view_set_model(EXO_ICON_VIEW(fv->view), NULL);
                break;
            }
            fv->model = NULL;
        }
    }
    return TRUE;
}
コード例 #21
0
ファイル: fm-path.c プロジェクト: juergenhoetzel/libfm
void fm_path_unref(FmPath* path)
{
	/* g_debug("fm_path_unref: %s, n_ref = %d", fm_path_to_str(path), path->n_ref); */
	if(g_atomic_int_dec_and_test(&path->n_ref))
	{
		if(G_LIKELY(path->parent))
			fm_path_unref(path->parent);
		g_free(path);
	}
}
コード例 #22
0
ファイル: fm-places-model.c プロジェクト: geekless/libfm
static void update_vol(FmPlacesModel* model, FmPlaceItem* item, GtkTreeIter* it, FmFileInfoJob* job)
{
    FmIcon* icon;
    GIcon* gicon;
    char* name;
    GdkPixbuf* pix;
    GMount* mount;
    FmPath* path;

    name = g_volume_get_name(item->vol);
    if(item->fi->icon)
        fm_icon_unref(item->fi->icon);
    gicon = g_volume_get_icon(item->vol);
    icon = fm_icon_from_gicon(gicon);
    item->fi->icon = icon;
    g_object_unref(gicon);

    mount = g_volume_get_mount(item->vol);
    if(mount)
    {
        GFile* gf = g_mount_get_root(mount);
        path = fm_path_new_for_gfile(gf);
        g_object_unref(gf);
        g_object_unref(mount);
        item->vol_mounted = TRUE;
    }
    else
    {
        path = NULL;
        item->vol_mounted = FALSE;
    }

    if(!fm_path_equal(item->fi->path, path))
    {
        fm_file_info_set_path(item->fi, path);
        if(path)
        {
            if(job)
                fm_file_info_job_add(job, path);
            else
            {
                job = fm_file_info_job_new(NULL, FM_FILE_INFO_JOB_FOLLOW_SYMLINK);
                model->jobs = g_slist_prepend(model->jobs, job);
                g_signal_connect(job, "finished", G_CALLBACK(on_file_info_job_finished), model);
                fm_job_run_async(FM_JOB(job));
            }
            fm_path_unref(path);
        }
    }

    pix = fm_icon_get_pixbuf(item->fi->icon, fm_config->pane_icon_size);
    gtk_list_store_set(GTK_LIST_STORE(model), it, FM_PLACES_MODEL_COL_ICON, pix, FM_PLACES_MODEL_COL_LABEL, name, -1);
    g_object_unref(pix);
    g_free(name);
}
コード例 #23
0
ファイル: fm-gtk-utils.c プロジェクト: lxde/libfm
/**
 * fm_move_or_copy_files_to
 * @parent: a window to place progress dialog over it
 * @files: list of files
 * @is_move: %TRUE to move, %FALSE to copy
 *
 * Opens a dialog to choose destination directory. If it was not cancelled
 * by user then moves or copies @files into chosen directory with progress
 * dialog.
 *
 * Before 0.1.15 this call had different arguments.
 *
 * Since: 0.1.0
 */
void fm_move_or_copy_files_to(GtkWindow* parent, FmPathList* files, gboolean is_move)
{
    FmPath* dest = fm_select_folder(parent, NULL);
    if(dest)
    {
        if(is_move)
            fm_move_files(parent, files, dest);
        else
            fm_copy_files(parent, files, dest);
        fm_path_unref(dest);
    }
}
コード例 #24
0
ファイル: fm-places-view.c プロジェクト: engla/libfm
void activate_row(FmPlacesView* view, guint button, GtkTreePath* tree_path)
{
    GtkTreeIter it;
    if(gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &it, tree_path))
    {
        FmPlaceItem* item;
        FmPath* path;
        gtk_tree_model_get(GTK_TREE_MODEL(model), &it, FM_PLACES_MODEL_COL_INFO, &item, -1);
        if(!item)
            return;
        switch(item->type)
        {
        case FM_PLACES_ITEM_PATH:
            path = fm_path_ref(item->fi->path);
            break;
        case FM_PLACES_ITEM_VOL:
        {
            GFile* gf;
            GMount* mnt = g_volume_get_mount(item->vol);
            if(!mnt)
            {
                GtkWindow* parent = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(view)));
                if(!fm_mount_volume(parent, item->vol, TRUE))
                    return;
                mnt = g_volume_get_mount(item->vol);
                if(!mnt)
                {
                    g_debug("GMount is invalid after successful g_volume_mount().\nThis is quite possibly a gvfs bug.\nSee https://bugzilla.gnome.org/show_bug.cgi?id=552168");
                    return;
                }
            }
            gf = g_mount_get_root(mnt);
            g_object_unref(mnt);
            if(gf)
            {
                path = fm_path_new_for_gfile(gf);
                g_object_unref(gf);
            }
            else
                path = NULL;
            break;
        }
        default:
            return;
        }

        if(path)
        {
            g_signal_emit(view, signals[CHDIR], 0, button, path);
            fm_path_unref(path);
        }
    }
}
コード例 #25
0
ファイル: tab-page.c プロジェクト: Mic92/stuurman
static void on_folder_finish_loading(FmFolder* folder, FmTabPage* page)
{
    FmFolderView* fv = page->folder_view;
    const FmNavHistoryItem* item;
    GtkScrolledWindow* scroll = GTK_SCROLLED_WINDOW(fv);

    /* Note: most of the time, we delay the creation of the 
     * folder model and do it after the whole folder is loaded.
     * That is because adding rows into model is much faster when no handlers
     * are connected to its signals. So we detach the model from folder view
     * and create the model again when it's fully loaded. 
     * This optimization, however, is not used for FmFolder objects
     * with incremental loading (search://) */
    if(fm_folder_view_get_model(fv) == NULL)
    {
        /* create a model for the folder and set it to the view */
        FmFolderModel* model = fm_folder_model_new(folder, app_config->show_hidden);
        fm_folder_view_set_model(fv, model);
        fm_folder_model_set_sort(model, app_config->sort_by,
                                 (app_config->sort_type == GTK_SORT_ASCENDING) ?
                                        FM_SORT_ASCENDING : FM_SORT_DESCENDING);
        g_object_unref(model);
    }
    fm_folder_query_filesystem_info(folder); /* FIXME: is this needed? */

    if (page->select_path_after_chdir)
    {
        fm_folder_view_select_file_path(fv, page->select_path_after_chdir);
        fm_path_unref(page->select_path_after_chdir);
        page->select_path_after_chdir = NULL;
    }


    // fm_path_entry_set_path(entry, path);
    /* scroll to recorded position */
    item = fm_nav_history_get_cur(page->nav_history);
    gtk_adjustment_set_value(gtk_scrolled_window_get_vadjustment(scroll), item->scroll_pos);

    /* update status bar */
    /* update status text */
    g_free(page->status_text[FM_STATUS_TEXT_NORMAL]);
    page->status_text[FM_STATUS_TEXT_NORMAL] = format_status_text(page);
    g_signal_emit(page, signals[STATUS], 0,
                  (guint)FM_STATUS_TEXT_NORMAL,
                  page->status_text[FM_STATUS_TEXT_NORMAL]);

    fm_unset_busy_cursor(GTK_WIDGET(page));
    /* g_debug("finish-loading"); */

    page->loading = FALSE;
    g_object_notify_by_pspec(G_OBJECT(page), props[PROP_LOADING]);
}
コード例 #26
0
/*****************************************************************************************
 *  Create Direct Root Items...
 * 
 * 
 ****************************************************************************************/
void fm_dir_tree_model_load (FmDirTreeModel *dir_tree_model)
{
    FmPath *path;
    FmFileInfo *file_info;
    FmDirTreeItem *dir_tree_item;
    
    
    // Desktop...
    path = fm_path_get_desktop ();
    file_info = fm_file_info_new_for_path (path);
    fm_file_info_query (file_info, NULL, NULL);
    fm_dir_tree_model_add_root (dir_tree_model, file_info, NULL, TRUE);


    /* Root FileSystem...
    path = fm_path_get_root ();
    file_info = fm_file_info_new_for_path (path);
    fm_file_info_query (file_info, NULL, NULL);
    fm_dir_tree_model_add_root (dir_tree_model, file_info, NULL, TRUE);
    */
    
    // Settings...
    path = fm_path_new_for_uri ("menu://Applications/DesktopSettings");
    file_info = fm_file_info_new_for_path (path);
    fm_file_info_query (file_info, NULL, NULL);
    fm_dir_tree_model_add_root (dir_tree_model, file_info, NULL, FALSE);
    fm_path_unref (path);
    
    // System...
    path = fm_path_new_for_uri ("menu://Applications/System");
    file_info = fm_file_info_new_for_path (path);
    fm_file_info_query (file_info, NULL, NULL);
    fm_dir_tree_model_add_root (dir_tree_model, file_info, NULL, FALSE);
    fm_path_unref (path);
    
    // What's the purpose of weak pointers ??? :-P
    g_object_add_weak_pointer (dir_tree_model, &dir_tree_model);
    return;
}
コード例 #27
0
ファイル: utilities.cpp プロジェクト: zvacet/pcmanfm-qt
FmPathList* pathListFromQUrls(QList<QUrl> urls) {
  QList<QUrl>::const_iterator it;
  FmPathList* pathList = fm_path_list_new();

  for(it = urls.begin(); it != urls.end(); ++it) {
    QUrl url = *it;
    FmPath* path = fm_path_new_for_uri(url.toString().toUtf8());
    fm_path_list_push_tail(pathList, path);
    fm_path_unref(path);
  }

  return pathList;
}
コード例 #28
0
ファイル: fm-path-entry.c プロジェクト: geekless/libfm
void fm_path_entry_set_path(FmPathEntry *entry, FmPath* path)
{
    FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry);
    char* disp_path;

    if(priv->path)
        fm_path_unref(priv->path);
    priv->path = fm_path_ref(path);

    disp_path = fm_path_display_name(path, FALSE);
    /* FIXME: blocks changed signal */
    gtk_entry_set_text(entry, disp_path);
    g_free(disp_path);
}
コード例 #29
0
ファイル: fm-places-view.c プロジェクト: gilir/libfm-debian
static void place_item_free(PlaceItem* item)
{
    switch(item->type)
    {
    case PLACE_PATH:
        fm_path_unref(item->path);
        break;
    case PLACE_VOL:
        g_object_unref(item->vol);
        break;
    }
    if(item->icon)
        fm_icon_unref(item->icon);
    g_slice_free(PlaceItem, item);
}
コード例 #30
0
ファイル: fm-folder-view.c プロジェクト: afilmore/lxmanager
gboolean fm_folder_view_chdir_by_name(FmFolderView* fv, const char* path_str)
{
    gboolean ret;
    FmPath* path;

    if( G_UNLIKELY( !path_str ) )
        return FALSE;

    path = fm_path_new_for_str(path_str);
    if(!path) /* might be a malformed path */
        return FALSE;
    ret = fm_folder_view_chdir(fv, path);
    fm_path_unref(path);
    return ret;
}