Beispiel #1
0
int MCA_folder(MCExecPoint& ep, const char *p_title, const char *p_prompt, const char *p_initial, unsigned int p_options)
{
	if (!MCModeMakeLocalWindows())
	{
		char *t_resolved_initial_path = MCS_resolvepath(p_initial);
		
		MCRemoteFolderDialog(ep, p_title, p_prompt, t_resolved_initial_path);
		if (t_resolved_initial_path != NULL)
			free(t_resolved_initial_path);
		return 0;
	}
	
	//////////

	GtkWidget *dialog ;
	
	
	dialog = create_open_dialog( p_title == NULL  ? p_prompt : p_title, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER );

	if ( p_initial != NULL ) 
		gtk_file_chooser_set_current_folder ( GTK_FILE_CHOOSER ( dialog ) , MCS_resolvepath(p_initial) );
	
	run_dialog ( dialog, ep) ;
	close_dialog ( dialog ) ;
        
        return (1);
	
}
Beispiel #2
0
int MCA_file_with_types(MCExecPoint& ep, const char *p_title, const char *p_prompt, char * const p_types[], uint4 p_type_count, const char *p_initial, unsigned int p_options)

{
	if (!MCModeMakeLocalWindows())
	{
		bool t_plural = (p_options & MCA_OPTION_PLURAL) != 0;
		char *t_resolved_path = MCS_resolvepath(p_initial);
		char **t_rtypes;
		if (types_to_remote_types(p_types, p_type_count, t_rtypes))
		{
			MCRemoteFileDialog(ep, p_title, p_prompt, t_rtypes, p_type_count * 2, NULL, t_resolved_path, false, t_plural);
			MCCStringArrayFree(t_rtypes, p_type_count * 2);
		}
		delete t_resolved_path;
		return 1;
	}

	//////////

	GtkWidget *dialog ;
	
	
	// Create the file dialog with the correct prompt
	dialog = create_open_dialog ( p_title == NULL  ? p_prompt : p_title, GTK_FILE_CHOOSER_ACTION_OPEN );
	
	// If we have any filters, add them.
	if ( p_type_count > 0 ) 
		add_dialog_filters ( dialog, p_types , p_type_count );

	
	if ( p_options & MCA_OPTION_PLURAL ) 
		gtk_file_chooser_set_select_multiple ( GTK_FILE_CHOOSER ( dialog ) ,true );
	
	// If we have an initial file/folder then set it.
	set_initial_file ( dialog, p_initial, G_last_opened_path ) ;

	// Run the dialog ... this will be replaced with our own loop which will call the REV event handler too.

	run_dialog ( dialog, ep) ;
	
	
	MCresult -> clear();
	MCresult -> copysvalue(get_current_filter_name ( dialog ) );
	
	if (G_last_opened_path != nil)
		g_free(G_last_opened_path);
	G_last_opened_path = gtk_file_chooser_get_current_folder ( GTK_FILE_CHOOSER ( dialog ) ) ;
	
	// All done, close the dialog.
	close_dialog ( dialog ) ;
        return(1);
}
Beispiel #3
0
int MCA_ask_file_with_types(MCExecPoint& ep, const char *p_title, const char *p_prompt, char * const p_types[], uint4 p_type_count, const char *p_initial, unsigned int p_options)
{
	if (!MCModeMakeLocalWindows())
	{
		bool t_plural = (p_options & MCA_OPTION_PLURAL) != 0;
		char *t_resolved_path = MCS_resolvepath(p_initial);
		char **t_rtypes;
		if (types_to_remote_types(p_types, p_type_count, t_rtypes))
		{
			MCRemoteFileDialog(ep, p_title, p_prompt, t_rtypes, p_type_count * 2, NULL, t_resolved_path, true, t_plural);
			MCCStringArrayFree(t_rtypes, p_type_count * 2);
		}
		delete t_resolved_path;
		return 1;
	}

	GtkWidget *dialog ;
	
	dialog = create_open_dialog( p_title == NULL  ? p_prompt : p_title, GTK_FILE_CHOOSER_ACTION_SAVE );

	if ( p_type_count > 0 ) 
		add_dialog_filters ( dialog, p_types , p_type_count );

	// If we are given an initial
	if (p_initial != nil)
	{
		if (MCS_exists(p_initial, True))
		{
			char *t_path;
			t_path = MCS_resolvepath(p_initial);
			gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), t_path);
			delete t_path;
		}
		else
		{
			char *t_folder;
			const char *t_name;
			if (strchr(p_initial, '/') == NULL)
			{
				t_folder = NULL;
				t_name = p_initial;
			}
			else
			{
				t_folder = strdup(p_initial);
				strrchr(t_folder, '/')[0] = '\0';
				t_name = strrchr(p_initial, '/') + 1;
				if (MCS_exists(t_folder, False))
				{
					char *t_new_folder;
					t_new_folder = MCS_resolvepath(t_folder);
					delete t_folder;
					t_folder = t_new_folder;
				}
				else
					t_folder = NULL;
			}
			gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), t_folder == NULL ? G_last_saved_path : t_folder);
			gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), t_name);
			delete t_folder;
		}
	}
	else
	{
		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), G_last_saved_path);
	}
	
	run_dialog ( dialog, ep) ;

	MCresult -> clear();
	MCresult -> copysvalue(get_current_filter_name ( dialog ) );
	

	if (G_last_saved_path != NULL)
		g_free(G_last_saved_path);
	G_last_saved_path = gtk_file_chooser_get_current_folder ( GTK_FILE_CHOOSER ( dialog ) ) ;

	close_dialog ( dialog ) ;
        
        return(1);
	
}
Beispiel #4
0
Datei: menu.c Projekt: yhsesq/yhs
void create_file_menu(Widget parent)
{
    Widget file_menu_pane, file_menu_button, open_butto, open_pane, 
           open_button, view_button, file_sep_1, save_as_button, 
           file_sep_2, print_button, file_sep_3, exit_button,print_pane,
           print_menu_button;

    /* Create the menu pane for the menu */
    file_menu_pane = XmCreatePulldownMenu(parent, "file menu pane", NULL, 0);
    print_pane = XmCreatePulldownMenu(parent, "Print menu pane", NULL, 0);
    /* Populate the menu pane */
    /* Open button */
    open_pane = XmCreatePulldownMenu(file_menu_pane, "open menu pane", NULL, 0);
    open_button = XmCreatePushButton(open_pane, "Open a study of 10 images", NULL, 0);
    XtManageChild(open_button); 
    view_button = XmCreatePushButton(open_pane, "Open a single RAW file", NULL, 0);
    XtManageChild(view_button);

      /* Create the submenus for open.     */
     argcount = 0;
     XtSetArg(args[argcount], XmNsubMenuId, open_pane); argcount++;
     open_butto = XmCreateCascadeButton(file_menu_pane, "Open", args, argcount);
     XtManageChild(open_butto);

    /* Create the open file dialog and add the activation function as
       the open button's activate callback */
    create_open_dialog(parent);
    XtAddCallback(open_button, XmNactivateCallback,
		(XtCallbackProc) activate_open_dialog, (XtPointer) NULL);

     create_view_dialog(parent);
     XtAddCallback(view_button, XmNactivateCallback,
                (XtCallbackProc) activate_view_dialog, (XtPointer) NULL);

    /* Separator 1 */
    file_sep_1 = XmCreateSeparator(file_menu_pane, "file sep 1", NULL, 0);
    XtManageChild(file_sep_1);

    /* Save As button */
    save_as_button = XmCreatePushButton(file_menu_pane, "Save As ...", NULL, 0);
    XtManageChild(save_as_button);

    /* Create the save_as dialog and add the activation function as
       the save_as button's activate callback */
    create_save_as_interface(parent);
    XtAddCallback(save_as_button, XmNactivateCallback,
		(XtCallbackProc) save_as_callback, (XtPointer) NULL);

    /* Separator 3 */
    file_sep_3 = XmCreateSeparator(file_menu_pane, "file sep 3", NULL, 0);
    XtManageChild(file_sep_3);

    /* Print button */
    print_button = XmCreatePushButton(print_pane, "Print f1 => f1.PS", NULL, 0);
    XtManageChild(print_button);
    XtAddCallback(print_button, XmNactivateCallback,
		(XtCallbackProc) print_callback, (XtPointer) NULL);

    /* Separator 2 */
    file_sep_2 = XmCreateSeparator(file_menu_pane, "file sep 2", NULL, 0);
    XtManageChild(file_sep_2);

    /* Exit button */
    exit_button = XmCreatePushButton(file_menu_pane, "Exit ...", NULL, 0);
    XtManageChild(exit_button);

    /* Create the exit dialog and add the activation function as the exit
       button's activate callback */
    create_exit_dialog(parent);
    XtAddCallback(exit_button, XmNactivateCallback,
		(XtCallbackProc) activate_exit_dialog, (XtPointer) NULL);

    /* Create the file cascade button on the menu bar and attach the *
     * file menu pane to it.                                         */
    argcount = 0;
    XtSetArg(args[argcount], XmNsubMenuId, file_menu_pane); argcount++;
    file_menu_button = XmCreateCascadeButton(parent, "File ", 
						args, argcount);
    XtManageChild(file_menu_button);
    argcount = 0;
    XtSetArg(args[argcount], XmNsubMenuId, print_pane); argcount++;
    print_menu_button = XmCreateCascadeButton(parent, "Print ", 
						args, argcount);
    XtManageChild(print_menu_button);
}