Example #1
0
bool wxDirButton::Create( wxWindow *parent, wxWindowID id,
                        const wxString &label, const wxString &path,
                        const wxString &message, const wxString &wildcard,
                        const wxPoint &pos, const wxSize &size,
                        long style, const wxValidator& validator,
                        const wxString &name )
{
    if (!(style & wxDIRP_USE_TEXTCTRL))
    {
        // VERY IMPORTANT: this code is identic to relative code in wxFileButton;
        //                 if you find a problem here, fix it also in wxFileButton !

        if (!PreCreation( parent, pos, size ) ||
            !wxControl::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
                                    validator, name))
        {
            wxFAIL_MSG( wxT("wxDirButtonGTK creation failed") );
            return false;
        }

        // create the dialog associated with this button
        SetWindowStyle(style);
        m_message = message;
        m_wildcard = wildcard;
        if ((m_dialog = CreateDialog()) == NULL)
            return false;
        SetPath(path);

        // little trick used to avoid problems when there are other GTK windows 'grabbed':
        // GtkFileChooserDialog won't be responsive to user events if there is another
        // window which called gtk_grab_add (and this happens if e.g. a wxDialog is running
        // in modal mode in the application - see wxDialogGTK::ShowModal).
        // An idea could be to put the grab on the m_dialog->m_widget when the GtkFileChooserButton
        // is clicked and then remove it as soon as the user closes the dialog itself.
        // Unfortunately there's no way to hook in the 'clicked' event of the GtkFileChooserButton,
        // thus we add grab on m_dialog->m_widget when it's shown and remove it when it's
        // hidden simply using its "show" and "hide" events - clean & simple :)
        g_signal_connect(m_dialog->m_widget, "show", G_CALLBACK(gtk_grab_add), NULL);
        g_signal_connect(m_dialog->m_widget, "hide", G_CALLBACK(gtk_grab_remove), NULL);


        // NOTE: we deliberately ignore the given label as GtkFileChooserButton
        //       use as label the currently selected file
        m_widget = gtk_file_chooser_button_new_with_dialog( m_dialog->m_widget );
        g_object_ref(m_widget);

        // GtkFileChooserButton signals
        g_signal_connect(m_widget, "current-folder-changed",
                         G_CALLBACK(gtk_dirbutton_currentfolderchanged_callback), this);

        m_parent->DoAddChild( this );

        PostCreation(size);
        SetInitialSize(size);
    }
    else
        return wxGenericDirButton::Create(parent, id, label, path, message, wildcard,
                                          pos, size, style, validator, name);
    return true;
}
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE title, action, backend;
    GtkWidget* widget;

    rb_scan_args(argc, argv, "12", &title, &action, &backend);

    if (TYPE(title) == T_STRING) {
        if (NIL_P(backend)){
            widget = gtk_file_chooser_button_new(RVAL2CSTR(title),
                                                 RVAL2GENUM(action, GTK_TYPE_FILE_CHOOSER_ACTION));
        } else {
            widget = gtk_file_chooser_button_new_with_backend(RVAL2CSTR(title), 
                                                              RVAL2GENUM(action, 
                                                                         GTK_TYPE_FILE_CHOOSER_ACTION),
                                                              RVAL2CSTR(backend));
        }
    } else {
        widget = gtk_file_chooser_button_new_with_dialog(GTK_WIDGET(RVAL2GOBJ(title)));
    }

    RBGTK_INITIALIZE(self, widget);
    return Qnil;
}
Example #3
0
static GtkWidget *xml_file_selector(GtkWidget *vbox, GtkWidget *main_dialog)
{
	GtkWidget *hbox, *frame, *chooser, *dialog;
	GtkFileFilter *filter;

	hbox = gtk_hbox_new(FALSE, 6);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);

	frame = gtk_frame_new("XML file name");
	gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 3);
	dialog = gtk_file_chooser_dialog_new("Open XML File",
		GTK_WINDOW(main_window),
		GTK_FILE_CHOOSER_ACTION_OPEN,
		GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
		GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
		NULL);
	gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), FALSE);

	filter = gtk_file_filter_new();
	gtk_file_filter_add_pattern(filter, "*.xml");
	gtk_file_filter_add_pattern(filter, "*.XML");
	gtk_file_filter_add_pattern(filter, "*.sda");
	gtk_file_filter_add_pattern(filter, "*.SDA");
	gtk_file_filter_add_mime_type(filter, "text/xml");
	gtk_file_filter_set_name(filter, "XML file");
	gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);

	chooser = gtk_file_chooser_button_new_with_dialog(dialog);
	g_signal_connect(G_OBJECT(chooser), "file-set", G_CALLBACK(on_file_set), main_dialog);

	gtk_file_chooser_button_set_width_chars(GTK_FILE_CHOOSER_BUTTON(chooser), 30);
	gtk_container_add(GTK_CONTAINER(frame), chooser);

	return chooser;
}
Example #4
0
/*#
    @method new_with_dialog GtkFileChooserButton
    @brief Creates a GtkFileChooserButton widget which uses dialog as its file-picking window.
    @param dialog the widget to use as dialog
    @return a new button widget.

    Note that dialog must be a GtkDialog (or subclass) which implements the
    GtkFileChooser interface and must not have GTK_DIALOG_DESTROY_WITH_PARENT set.

    Also note that the dialog needs to have its confirmative button added with
    response GTK_RESPONSE_ACCEPT or GTK_RESPONSE_OK in order for the button to
    take over the file selected in the dialog.
 */
FALCON_FUNC FileChooserButton::new_with_dialog( VMARG )
{
    Item* i_dlg = vm->param( 0 );
#ifndef NO_PARAMETER_CHECK
    if ( !i_dlg || i_dlg->isNil() || !i_dlg->isObject()
        || !IS_DERIVED( i_dlg, GtkWidget ) )
        throw_inv_params( "GtkWidget" );
#endif
    GtkWidget* dlg = (GtkWidget*) COREGOBJECT( i_dlg )->getObject();
    GtkWidget* wdt = gtk_file_chooser_button_new_with_dialog( dlg );
    vm->retval( new Gtk::FileChooserButton(
            vm->findWKI( "GtkFileChooserButton" )->asClass(), (GtkFileChooserButton*) wdt ) );
}
Example #5
0
static void remmina_file_editor_create_ssh_privatekey(RemminaFileEditor* gfe, GtkWidget* table, gint row, gint column)
{
	gchar* s;
	GtkWidget* widget;
	GtkWidget* dialog;
	const gchar* ssh_privatekey;
	RemminaFileEditorPriv* priv = gfe->priv;

	widget = gtk_radio_button_new_with_label_from_widget(
			GTK_RADIO_BUTTON(priv->ssh_auth_password_radio), _("Identity file"));
	g_signal_connect(G_OBJECT(widget), "toggled",
			G_CALLBACK(remmina_file_editor_ssh_auth_publickey_radio_on_toggled), gfe);
	priv->ssh_auth_publickey_radio = widget;
	gtk_widget_show(widget);
	gtk_table_attach(GTK_TABLE(table), widget, column, column + 1, row, row + 1, GTK_FILL, 0, 0, 0);

	dialog = gtk_file_chooser_dialog_new (_("Identity file"), GTK_WINDOW(gfe), GTK_FILE_CHOOSER_ACTION_OPEN,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
			NULL);

	widget = gtk_file_chooser_button_new_with_dialog (dialog);
	s = g_strdup_printf("%s/.ssh", g_get_home_dir ());
	if (g_file_test (s, G_FILE_TEST_IS_DIR))
	{
		gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (widget), s);
	}
	g_free(s);
	gtk_widget_show(widget);
	gtk_table_attach_defaults (GTK_TABLE(table), widget, column + 1, column + 2, row, row + 1);
	priv->ssh_privatekey_chooser = widget;

	ssh_privatekey = remmina_file_get_string (priv->remmina_file, "ssh_privatekey");
	if (ssh_privatekey &&
			g_file_test (ssh_privatekey, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS))
	{
		gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (priv->ssh_privatekey_chooser),
				ssh_privatekey);
	}
	else
	{
		remmina_file_set_string (priv->remmina_file, "ssh_privatekey", NULL);
	}
}
Example #6
0
bool wxFileButton::Create( wxWindow *parent, wxWindowID id,
                        const wxString &label, const wxString &path,
                        const wxString &message, const wxString &wildcard,
                        const wxPoint &pos, const wxSize &size,
                        long style, const wxValidator& validator,
                        const wxString &name )
{
    // we can't use the native button for wxFLP_SAVE pickers as it can only
    // open existing files and there is no way to create a new file using it
    if (!(style & wxFLP_SAVE) && !(style & wxFLP_USE_TEXTCTRL))
    {
        // VERY IMPORTANT: this code is identical to relative code in wxDirButton;
        //                 if you find a problem here, fix it also in wxDirButton !

        if (!PreCreation( parent, pos, size ) ||
            !wxControl::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
                                    validator, name))
        {
            wxFAIL_MSG( wxT("wxFileButton creation failed") );
            return false;
        }

        // create the dialog associated with this button
        // NB: unlike generic implementation, native GTK implementation needs to create
        //     the filedialog here as it needs to use gtk_file_chooser_button_new_with_dialog()
        SetWindowStyle(style);
        m_path = path;
        m_message = message;
        m_wildcard = wildcard;
        if ((m_dialog = CreateDialog()) == NULL)
            return false;

        // little trick used to avoid problems when there are other GTK windows 'grabbed':
        // GtkFileChooserDialog won't be responsive to user events if there is another
        // window which called gtk_grab_add (and this happens if e.g. a wxDialog is running
        // in modal mode in the application - see wxDialogGTK::ShowModal).
        // An idea could be to put the grab on the m_dialog->m_widget when the GtkFileChooserButton
        // is clicked and then remove it as soon as the user closes the dialog itself.
        // Unfortunately there's no way to hook in the 'clicked' event of the GtkFileChooserButton,
        // thus we add grab on m_dialog->m_widget when it's shown and remove it when it's
        // hidden simply using its "show" and "hide" events - clean & simple :)
        g_signal_connect(m_dialog->m_widget, "show", G_CALLBACK(gtk_grab_add), NULL);
        g_signal_connect(m_dialog->m_widget, "hide", G_CALLBACK(gtk_grab_remove), NULL);

        //       use as label the currently selected file
        m_widget = gtk_file_chooser_button_new_with_dialog( m_dialog->m_widget );
        g_object_ref(m_widget);

        // we need to know when the dialog has been dismissed clicking OK...
        // NOTE: the "clicked" signal is not available for a GtkFileChooserButton
        //       thus we are forced to use wxFileDialog's event
        m_dialog->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
                wxCommandEventHandler(wxFileButton::OnDialogOK),
                NULL, this);

        m_parent->DoAddChild( this );

        PostCreation(size);
        SetInitialSize(size);
    }
    else
        return wxGenericFileButton::Create(parent, id, label, path, message, wildcard,
                                           pos, size, style, validator, name);
    return true;
}
Example #7
0
static int _htmlapp_open_dialog(HTMLApp * htmlapp)
{
	int ret;
	GtkWidget * dialog;
	GtkWidget * vbox;
	GtkWidget * hbox;
	GtkWidget * entry;
	GtkWidget * widget;
	GtkFileFilter * filter;
	char const * url = NULL;

	dialog = gtk_dialog_new_with_buttons(_("Open page..."),
			GTK_WINDOW(htmlapp->window),
			GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);
	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
	gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
#if GTK_CHECK_VERSION(2, 14, 0)
	vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
#else
	vbox = GTK_DIALOG(dialog)->vbox;
#endif
	gtk_box_set_spacing(GTK_BOX(vbox), 4);
#if GTK_CHECK_VERSION(3, 0, 0)
	hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 4);
#else
	hbox = gtk_hbox_new(FALSE, 4);
#endif
	widget = gtk_label_new(_("Filename: "));
	gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
	entry = gtk_entry_new();
	gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
	/* file chooser */
	widget = gtk_file_chooser_dialog_new(_("Open file..."),
			GTK_WINDOW(dialog), GTK_FILE_CHOOSER_ACTION_OPEN,
			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
	filter = gtk_file_filter_new();
	gtk_file_filter_set_name(filter, _("HTML files"));
	gtk_file_filter_add_mime_type(filter, "text/html");
	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(widget), filter);
	gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(widget), filter);
	filter = gtk_file_filter_new();
	gtk_file_filter_set_name(filter, _("Text files"));
	gtk_file_filter_add_mime_type(filter, "text/plain");
	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(widget), filter);
	filter = gtk_file_filter_new();
	gtk_file_filter_set_name(filter, _("All files"));
	gtk_file_filter_add_pattern(filter, "*");
	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(widget), filter);
	g_signal_connect(widget, "response", G_CALLBACK(
				_open_dialog_on_choose_activate), entry);
	widget = gtk_file_chooser_button_new_with_dialog(widget);
	gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
	gtk_widget_show_all(vbox);
	if(gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
		url = gtk_entry_get_text(GTK_ENTRY(entry));
	gtk_widget_hide(dialog);
	if(url == NULL || strlen(url) == 0)
		ret = -1;
	else
		ret = _htmlapp_open(htmlapp, url);
	gtk_widget_destroy(dialog);
	return ret;
}
Example #8
0
int music_build_element_widgets () {
	int i = 0;
	for (i = 0; i < 9; i++) {
		label_music_info[i] = gtk_label_new(NULL);
		gtk_label_set_width_chars(GTK_LABEL(label_music_info[i]), 15);
		gtk_label_set_max_width_chars(GTK_LABEL(label_music_info[i]), 150);
		gtk_label_set_line_wrap(GTK_LABEL(label_music_info[i]), TRUE);
	}
	separator_music_info = gtk_separator_new(GTK_ORIENTATION_VERTICAL);
	
	for (i = 0; i < 9; i++) {
		label_music_lyric[i] = gtk_label_new(NULL);
		gtk_label_set_max_width_chars(GTK_LABEL(label_music_lyric[i]), 305);
// 		gtk_label_set_line_wrap(GTK_LABEL(label_music_lyric[i]), TRUE);
	}
	gtk_label_set_selectable(GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_use_underline (GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_use_markup (GTK_LABEL(label_music_lyric[4]), TRUE);
	gtk_label_set_pattern (GTK_LABEL(label_music_lyric[4]), "________");
	separator_music_lyric1 =  gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
	separator_music_lyric2 =  gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);

	button_music_start_server = gtk_button_new_with_label("启动服务器");
// 	set_button_music_start_server(button_music_start_server);
	
	button_music_exit_server = gtk_button_new_with_label("关闭服务器");
// 	set_button_music_exit_server(button_music_exit_server);
	
	
	button_music_play = gtk_button_new();
// 	box_music_play = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/play.png");
// 	box_music_pause = button_with_image("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause.png");
	image_music_play = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/play.png");
	image_music_play_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/play_light.png");
	image_music_pause = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause.png");
	image_music_pause_light = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/pause_light.png");
	gtk_button_set_relief(GTK_BUTTON(button_music_play), GTK_RELIEF_NONE);
	set_button_music_play(button_music_play);
	
	button_music_pause = gtk_button_new_with_label("暂停");
// 	set_button_music_pause(button_music_pause);
	
	button_music_unpause = gtk_button_new_with_label("取消暂停");
// 	set_button_music_unpause(button_music_unpause);
	
// 	button_music_stop = gtk_button_new_with_label("停止");
	button_music_stop = gtk_button_new();
	image_music_stop = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/stop.png");
	image_music_stop_light = gtk_image_new_from_file ("/usr/share/raspi_remote_control/ui_images/ui_images_music/stop_light.png");
	gtk_button_set_image(GTK_BUTTON(button_music_stop), image_music_stop);
	gtk_button_set_relief(GTK_BUTTON(button_music_stop), GTK_RELIEF_NONE);
	set_button_music_stop(button_music_stop);
	
// 	button_music_next = gtk_button_new_with_label("下一首");
	button_music_next = gtk_button_new();
	image_music_next = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/next.png");
	image_music_next_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/next_light.png");
	gtk_button_set_image(GTK_BUTTON(button_music_next), image_music_next);
	gtk_button_set_relief(GTK_BUTTON(button_music_next), GTK_RELIEF_NONE);
	set_button_music_next(button_music_next);
	
// 	button_music_pre = gtk_button_new_with_label("上一首");
	button_music_pre = gtk_button_new();
	image_music_pre = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/pre.png");
	image_music_pre_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/pre_light.png");
	gtk_button_set_image (GTK_BUTTON(button_music_pre), image_music_pre);
	gtk_button_set_relief(GTK_BUTTON(button_music_pre), GTK_RELIEF_NONE);
	set_button_music_pre(button_music_pre);
	

	
	
// 	button_music_volume_up = gtk_button_new_with_label("音量+");
// 	set_button_music_volume_up(button_music_volume_up);
	
// 	button_music_volume_silence = gtk_button_new_with_label("静音");
	button_music_silence = gtk_button_new();
	image_music_silence = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/silence.png");
	image_music_silence_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/silence_light.png");
	image_music_unsilence = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/unsilence.png");
	image_music_unsilence_light = gtk_image_new_from_file("/usr/share/raspi_remote_control/ui_images/ui_images_music/unsilence_light.png");
	gtk_button_set_image (GTK_BUTTON(button_music_silence), image_music_silence);
	gtk_button_set_relief(GTK_BUTTON(button_music_silence), GTK_RELIEF_NONE);
	set_button_music_silence(button_music_silence);
	
	button_music_volume = gtk_volume_button_new();
	set_button_music_volume( button_music_volume);
	
	button_music_reset_list = gtk_button_new_with_label("重设列表");
	set_button_music_reset_list(button_music_reset_list);
	
// 	button_music_choose_path = gtk_button_new_with_label("添加路径");
// 	set_button_music_choose_path(button_music_choose_path);
// 	music_path_dialog = gtk_file_chooser_widget_new(GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
	music_path_dialog = gtk_file_chooser_dialog_new ("test_title", NULL, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, "test_button_text", NULL);
	button_music_choose_path = gtk_file_chooser_button_new_with_dialog (music_path_dialog);
	gtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON(button_music_choose_path), "添加路径");
// 	gtk_file_chooser_set_select_multiple (music_path_dialog, TRUE);
	
	
	button_music_delete_path = gtk_button_new_with_label("删除当前路径");
	set_button_music_delete_path(button_music_delete_path);
	
	scale_music_process = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL, 0, 100, 1);
	set_scale_music_process(scale_music_process);
	
	label_music_cur_time = gtk_label_new ("--:--:--");
	label_music_total_time = gtk_label_new ("--:--:--");
	
	switch_music_autonext = gtk_switch_new ();
	set_switch_music_autonext ();
	label_music_autonext = gtk_label_new ("AutoNext: ");
	
	switch_music_repeat = gtk_switch_new ();
	set_switch_music_repeat ();
	label_music_repeat = gtk_label_new ("Repeat: ");
	
	switch_music_shuffle = gtk_switch_new ();
	set_switch_music_shuffle ();
	label_music_shuffle = gtk_label_new ("Shuffle: ");
	
	radio_button_music_mode_shuffle = gtk_radio_button_new (NULL);
	label_music_mode_shuffle = gtk_label_new ("随机:");
	radio_button_music_mode_loop_list = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_loop_list = gtk_label_new ("列表循环:");
	radio_button_music_mode_play_list = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_play_list = gtk_label_new ("播放列表:");
	radio_button_music_mode_loop_one = gtk_radio_button_new_from_widget (GTK_RADIO_BUTTON (radio_button_music_mode_shuffle));
	label_music_mode_loop_one = gtk_label_new ("单曲:");
	spinner_music_mode_changing = gtk_spinner_new ();
	
	set_radio_button_music_mode ();
	
	
	store_music_dir_list = gtk_tree_store_new(dir_n_columns, G_TYPE_STRING);
	tree_view_music_dir_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store_music_dir_list));
	text_renderer_music_dir_list = gtk_cell_renderer_text_new ();
	column_music_dir_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_dir_list, "text", dir_name, NULL);
	gtk_tree_view_column_set_fixed_width(column_music_dir_list, 100);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_dir_list), column_music_dir_list);
	music_dir_list_sw_adj_h = gtk_adjustment_new(100, 0, 100, 1, 1, 50);
	music_dir_list_sw = gtk_scrolled_window_new(NULL, music_dir_list_sw_adj_h);
	gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(music_dir_list_sw), 330);
	gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(music_dir_list_sw), 100);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_SHADOW_NONE);
// 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_dir_list_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(music_dir_list_sw), tree_view_music_dir_list);
	
	selection_music_dir_list = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view_music_dir_list));
	set_tree_view_music_dir_list ();
	

	store_music_list = gtk_tree_store_new(list_n_columns, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
// 	char file_index[BUFSIZ];
// 	printf("music_list_num is: %s\n", music_list_num);
// 	while (i < music_list_num) {
// // 		printf("%d: %s\n", i, music_list[i]);
// 		sprintf(file_index, "%d", i + 1);
// 		gtk_tree_store_append(store_music_list, &iter_music_list, NULL);
// 		gtk_tree_store_set (store_music_list, &iter_music_list, list_index, file_index, list_title, music_list[i], list_total_sec, "03:00", -1);
// 		i++;
// 	}
// 	
	tree_view_music_list = gtk_tree_view_new_with_model (GTK_TREE_MODEL(store_music_list));
	
	text_renderer_music_list = gtk_cell_renderer_text_new ();
	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_index, NULL);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
	gtk_tree_view_column_set_title(column_music_list, "序号");
	
	text_renderer_music_list = gtk_cell_renderer_text_new ();
	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_title, NULL);
	gtk_tree_view_column_set_fixed_width(column_music_list, 100);
	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
// 	text_renderer_music_list = gtk_cell_renderer_text_new ();
// 	column_music_list = gtk_tree_view_column_new_with_attributes (NULL, text_renderer_music_list, "text", list_total_sec, NULL);
// 	gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view_music_list), column_music_list);
	
	
	
	music_list_sw_adj_h = gtk_adjustment_new(100, 0, 100, 1, 1, 50);
	music_list_sw = gtk_scrolled_window_new(NULL, music_list_sw_adj_h);
	gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(music_list_sw), 370);
	gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(music_list_sw), 200);
	gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(music_list_sw), GTK_SHADOW_NONE);
// 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_list_sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(music_list_sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
	gtk_container_add(GTK_CONTAINER(music_list_sw), tree_view_music_list);
	
	selection_music_list = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view_music_list));
	set_tree_view_music_list ();
	return 1;
}
Example #9
0
static gboolean
test_button_folder_states_for_action (GtkFileChooserAction action, gboolean use_dialog, gboolean set_folder_on_dialog)
{
  gboolean passed;
  GtkWidget *window;
  GtkWidget *button;
  char *folder;
  GtkWidget *dialog;
  char *current_working_dir;
  gboolean must_have_cwd;

  passed = TRUE;

  current_working_dir = g_get_current_dir ();
  must_have_cwd = !(use_dialog && set_folder_on_dialog);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);

  if (use_dialog)
    {
      dialog = gtk_file_chooser_dialog_new ("Test", NULL, action,
					    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
					    GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
					    NULL);
      button = gtk_file_chooser_button_new_with_dialog (dialog);

      if (set_folder_on_dialog)
	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), g_get_home_dir ());
    }
  else
    {
      button = gtk_file_chooser_button_new ("Test", action);
      dialog = NULL; /* keep gcc happy */
    }

  gtk_container_add (GTK_CONTAINER (window), button);

  /* Pre-map; no folder is set */
  wait_for_idle ();

  folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (button));
  if (must_have_cwd)
    passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
  else
    passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);

  log_test (passed, "test_button_folder_states_for_action(): %s, use_dialog=%d, set_folder_on_dialog=%d, pre-map, %s",
	    get_action_name (action),
	    use_dialog,
	    set_folder_on_dialog,
	    must_have_cwd ? "must have $cwd" : "must have explicit folder");

  /* Map; folder should be set */

  gtk_widget_show_all (window);
  gtk_widget_show_now (window);

  wait_for_idle ();

  folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (button));

  if (must_have_cwd)
    passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
  else
    passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);

  log_test (passed, "test_button_folder_states_for_action(): %s, use_dialog=%d, set_folder_on_dialog=%d, mapped, %s",
	    get_action_name (action),
	    use_dialog,
	    set_folder_on_dialog,
	    must_have_cwd ? "must have $cwd" : "must have explicit folder");
  g_free (folder);

  /* Unmap; folder should be set */

  gtk_widget_hide (window);
  wait_for_idle ();
  folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (button));

  if (must_have_cwd)
    passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
  else
    passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);

  log_test (passed, "test_button_folder_states_for_action(): %s, use_dialog=%d, set_folder_on_dialog=%d, unmapped, %s",
	    get_action_name (action),
	    use_dialog,
	    set_folder_on_dialog,
	    must_have_cwd ? "must have $cwd" : "must have explicit folder");
  g_free (folder);

  /* Re-map; folder should be set */

  gtk_widget_show_now (window);
  folder = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (button));

  if (must_have_cwd)
    passed = passed && (g_strcmp0 (folder, current_working_dir) == 0);
  else
    passed = passed && (g_strcmp0 (folder, g_get_home_dir()) == 0);
  wait_for_idle ();
  log_test (passed, "test_button_folder_states_for_action(): %s, use_dialog=%d, set_folder_on_dialog=%d, re-mapped, %s",
	    get_action_name (action),
	    use_dialog,
	    set_folder_on_dialog,
	    must_have_cwd ? "must have $cwd" : "must have explicit folder");
  g_free (folder);

  g_free (current_working_dir);

  gtk_widget_destroy (window);

  return passed;
}