FmFileMenu

FmFileMenu — Simple context menu for files.

Functions

Types and Values

Description

include : libfm/fm-gtk.h

The FmFileMenu can be used to create context menu on some file(s).

The menu consists of items:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Open
<placeholder name='ph1'/>
------------------------
<placeholder name='ph2'/>
------------------------
AddBookmark
<placeholder name='SendToCategory'/>
------------------------
Cut
Copy
Paste
Del
CopyPath
<placeholder name='MoveCategory'/>
------------------------
Rename
------------------------
<placeholder name='ph3'/>
------------------------
Prop

You can modity the menu replacing placeholders. Note that internally the menu constructor also puts some conditional elements into those placeholders:

  • ph2: 'OpenWith' list+selector (optionally in submenu 'OpenWithMenu');

  • SendToCategory: elements of category 'Send To':

    'Compress' if there is archiver defined;

    'Extract' if this is an archive

  • MoveCategory: 'Hide' or 'Unhide' if the attribute is changeable.

Element 'AddBookmark' is visible only if menu is created for one directory. Element 'Rename' is hidden if menu is created for more than one file or if that file cannot be renamed. Element 'Paste' is visible only if menu is created for one directory and that directory is writable.

Functions

fm_file_menu_new_for_file ()

FmFileMenu *
fm_file_menu_new_for_file (GtkWindow *parent,
                           FmFileInfo *fi,
                           FmPath *cwd,
                           gboolean auto_destroy);

Creates new menu for the file.

Parameters

parent

window to place menu over

 

fi

target file

 

cwd

working directory

 

auto_destroy

TRUE if manu should be destroyed after some action was activated

 

Returns

a new FmFileMenu object.

Since: 0.1.0


fm_file_menu_new_for_files ()

FmFileMenu *
fm_file_menu_new_for_files (GtkWindow *parent,
                            FmFileInfoList *files,
                            FmPath *cwd,
                            gboolean auto_destroy);

Creates new menu for some files list.

Parameters

parent

window to place menu over

 

files

target files

 

cwd

working directory

 

auto_destroy

TRUE if manu should be destroyed after some action was activated

 

Returns

a new FmFileMenu object.

Since: 0.1.0


fm_file_menu_destroy ()

void
fm_file_menu_destroy (FmFileMenu *menu);

Destroys menu object.

Parameters

menu

a menu

 

Since: 0.1.0


fm_file_menu_is_single_file_type ()

gboolean
fm_file_menu_is_single_file_type (FmFileMenu *menu);

Checks if menu was created for files of the same type.

Parameters

menu

a menu

 

Returns

TRUE if menu is single-type.

Since: 0.1.0


fm_file_menu_get_ui ()

GtkUIManager *
fm_file_menu_get_ui (FmFileMenu *menu);

Retrieves UI manager object for menu . Returned data are owned by menu and should be not freed by caller.

Parameters

menu

a menu

 

Returns

UI manager.

[transfer none]

Since: 0.1.0


fm_file_menu_get_action_group ()

GtkActionGroup *
fm_file_menu_get_action_group (FmFileMenu *menu);

Retrieves action group for menu . Returned data are owned by menu and should be not freed by caller.

Parameters

menu

a menu

 

Returns

the action group.

[transfer none]

Since: 0.1.0


fm_file_menu_get_menu ()

GtkMenu *
fm_file_menu_get_menu (FmFileMenu *menu);

Retrieves GtkMenu widget built with GtkUIManager. Returned data are owned by menu and should be not freed by caller.

Parameters

menu

a menu

 

Returns

created GtkMenu widget.

[transfer none]

Since: 0.1.0


fm_file_menu_get_file_info_list ()

FmFileInfoList *
fm_file_menu_get_file_info_list (FmFileMenu *menu);

Retrieves list of files menu was created for. Returned data are owned by menu and should be not freed by caller.

Parameters

menu

a menu

 

Returns

list of files.

[transfer none]

Since: 0.1.0


fm_file_menu_get_cwd ()

FmPath *
fm_file_menu_get_cwd (FmFileMenu *menu);

Retrieves working directory menu was created for. Returned data are owned by menu and should be not freed by caller.

Parameters

menu

a menu

 

Returns

working directory path.

[transfer none]

Since: 1.3.0


fm_file_menu_set_folder_func ()

void
fm_file_menu_set_folder_func (FmFileMenu *menu,
                              FmLaunchFolderFunc func,
                              gpointer user_data);

Sets up function to open folders for menu . Function will be called if action 'Open' was activated for some folder.

Parameters

menu

a menu

 

func

function to open folder

 

user_data

data supplied for func

 

Since: 0.1.0


FmFileMenuUpdatePopup ()

void
(*FmFileMenuUpdatePopup) (GtkWindow *window,
                          GtkUIManager *ui,
                          GString *xml,
                          GtkActionGroup *act_grp,
                          FmFileMenu *menu,
                          FmFileInfoList *files,
                          gboolean single_file);

The callback to update popup menu. It can disable items of menu, add some new, replace actions, etc. depending of the window and files.

Parameters

window

the parent window for popup

 

ui

the object to add interface

 

xml

container where callback should append XML definition

 

act_grp

group of actions to add action

 

menu

the menu descriptor

 

files

list of files for current popup menu

 

single_file

TRUE is menu was created for single file

 

Types and Values

struct FmFileMenuMimeAddonInit

struct FmFileMenuMimeAddonInit {
    void (*init)(void);
    void (*finalize)(void);
    FmFileMenuUpdatePopup update_file_menu_for_mime_type;
};

The init and finalize callbacks are called on application start and exit.

The update_file_menu_for_mime_type callback will be called each time context menu is created for files that have the same context type.

This structure is used for "gtk_menu_mime" module initialization. The key for module of this type is content type (MIME name) to support. No wildcards are supported.

Members

init ()

callback for plugin initialization.

[allow-none]

finalize ()

callback to free resources allocated by init .

[allow-none]

FmFileMenuUpdatePopup update_file_menu_for_mime_type;

callback to update selection context menu.

[allow-none]

Since: 1.2.0


FM_MODULE_gtk_menu_mime_VERSION

#define FM_MODULE_gtk_menu_mime_VERSION 1

fm_module_init_gtk_menu_mime

extern FmFileMenuMimeAddonInit fm_module_init_gtk_menu_mime;

FmFileMenu

typedef struct _FmFileMenu FmFileMenu;