本文整理汇总了C++中GTK_FILE_CHOOSER函数的典型用法代码示例。如果您正苦于以下问题:C++ GTK_FILE_CHOOSER函数的具体用法?C++ GTK_FILE_CHOOSER怎么用?C++ GTK_FILE_CHOOSER使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GTK_FILE_CHOOSER函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: choose_picture
static void
choose_picture(AvatarManipulation *self)
{
AvatarManipulationPrivate *priv = AVATAR_MANIPULATION_GET_PRIVATE(self);
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
GtkFileFilter *filter = gtk_file_filter_new ();
gint res;
auto preview = gtk_image_new();
GtkWidget *ring_main_window = gtk_widget_get_toplevel(GTK_WIDGET(self));
auto dialog = gtk_file_chooser_dialog_new (_("Open Avatar Image"),
GTK_WINDOW(ring_main_window),
action,
_("_Cancel"),
GTK_RESPONSE_CANCEL,
_("_Open"),
GTK_RESPONSE_ACCEPT,
NULL);
/* add filters */
gtk_file_filter_add_pattern (filter,"*.png");
gtk_file_filter_add_pattern (filter,"*.jpg");
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER(dialog),filter);
/* add an image preview inside the file choose */
gtk_file_chooser_set_preview_widget (GTK_FILE_CHOOSER(dialog), preview);
g_signal_connect (GTK_FILE_CHOOSER(dialog), "update-preview", G_CALLBACK (update_preview_cb), preview);
/* start the file chooser */
res = gtk_dialog_run (GTK_DIALOG(dialog)); /* blocks until the dialog is closed */
if (res == GTK_RESPONSE_ACCEPT) {
if(auto filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER (dialog))) {
GError* error = nullptr; /* initialising to null avoid trouble... */
auto picture = gdk_pixbuf_new_from_file_at_size (filename, VIDEO_WIDTH, VIDEO_HEIGHT, &error);
if (!error) {
/* reset crop area */
if (priv->crop_area)
gtk_container_remove(GTK_CONTAINER(priv->vbox_crop_area), priv->crop_area);
priv->crop_area = cc_crop_area_new();
gtk_widget_show(priv->crop_area);
gtk_box_pack_start(GTK_BOX(priv->vbox_crop_area), priv->crop_area, TRUE, TRUE, 0);
cc_crop_area_set_picture(CC_CROP_AREA(priv->crop_area), picture);
g_object_unref(picture);
set_state(self, AVATAR_MANIPULATION_STATE_EDIT);
} else {
g_warning("(choose_picture) failed to load pixbuf from file: %s", error->message);
g_error_free(error);
}
g_free(filename);
} else {
g_warning("(choose_picture) filename empty");
}
}
gtk_widget_destroy(dialog);
}
开发者ID:savoirfairelinux,项目名称:ring-client-gnome,代码行数:63,代码来源:avatarmanipulation.cpp
示例2: file_export_response_callback
/**
* A button hit in the Export Dialog
*/
static void
file_export_response_callback(GtkWidget *fs,
gint response,
gpointer user_data)
{
char *filename;
Diagram *dia;
DiaExportFilter *ef;
struct stat statbuf;
dia = g_object_get_data (G_OBJECT (fs), "user_data");
g_assert (dia);
if (response == GTK_RESPONSE_ACCEPT) {
gint index;
diagram_update_extents(dia);
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs));
if (g_stat(filename, &statbuf) == 0) {
GtkWidget *dialog = NULL;
dialog = gtk_message_dialog_new (GTK_WINDOW(fs),
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File already exists"));
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
_("The file '%s' already exists.\n"
"Do you want to overwrite it?"), dia_message_filename(filename));
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_YES) {
/* if not overwrite allow to select another filename */
gtk_widget_destroy(dialog);
g_free (filename);
return;
}
gtk_widget_destroy(dialog);
}
index = gtk_combo_box_get_active (GTK_COMBO_BOX(user_data));
if (index >= 0)
persistence_set_integer ("export-filter", index);
ef = efilter_by_index (index - 1, NULL);
if (!ef)
ef = filter_guess_export_filter(filename);
if (ef) {
DiaContext *ctx = dia_context_new (_("Export"));
g_object_ref(dia->data);
dia_context_set_filename (ctx, filename);
ef->export_func(dia->data, ctx,
filename, dia->filename, ef->user_data);
g_object_unref(dia->data);
dia_context_release (ctx);
} else
message_error(_("Could not determine which export filter\n"
"to use to save '%s'"), dia_message_filename(filename));
g_free (filename);
}
g_object_unref (dia); /* drop our diagram reference */
gtk_widget_destroy(exportdlg);
}
开发者ID:AmiGanguli,项目名称:dia,代码行数:68,代码来源:filedlg.c
示例3: RunLinuxDialog
//.........这里部分代码省略.........
// Create the threading spin box and label, and stash them in a box. (Yes, we do a lot of that.)
threads_label = gtk_label_new("Extra rendering threads:");
threads_spin = gtk_spin_button_new_with_range(0,100,1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(threads_spin), theApp.GetConfig("extrathreads", 0));
threads_box = gtk_hbox_new(false, 0);
gtk_box_pack_start(GTK_BOX(threads_box), threads_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(threads_box), threads_spin, false, false, 5);
// A bit of funkiness for the resolution box.
native_label = gtk_label_new("Original PS2 Resolution: ");
native_res_check = gtk_check_button_new_with_label("Native");
native_box = gtk_hbox_new(false, 5);
gtk_box_pack_start(GTK_BOX(native_box), native_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(native_box), native_res_check, false, false, 5);
fsaa_label = gtk_label_new("Or Use Scaling:");
fsaa_combo_box = CreateMsaaComboBox();
fsaa_box = gtk_hbox_new(false, 5);
gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_combo_box, false, false, 5);
rexy_label = gtk_label_new("Custom Resolution:");
resx_spin = gtk_spin_button_new_with_range(256,8192,1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(resx_spin), theApp.GetConfig("resx", 1024));
resy_spin = gtk_spin_button_new_with_range(256,8192,1);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(resy_spin), theApp.GetConfig("resy", 1024));
resxy_box = gtk_hbox_new(false, 5);
gtk_box_pack_start(GTK_BOX(resxy_box), rexy_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(resxy_box), resx_spin, false, false, 5);
gtk_box_pack_start(GTK_BOX(resxy_box), resy_spin, false, false, 5);
// shader fx entry
shader = gtk_file_chooser_button_new("Select an external shader", GTK_FILE_CHOOSER_ACTION_OPEN);
shader_conf = gtk_file_chooser_button_new("Then select a config", GTK_FILE_CHOOSER_ACTION_OPEN);
shader_label = gtk_label_new("External shader glsl");
shader_conf_label = gtk_label_new("External shader conf");
// Create our hack settings.
hack_alpha_check = gtk_check_button_new_with_label("Alpha Hack");
hack_date_check = gtk_check_button_new_with_label("Date Hack");
hack_offset_check = gtk_check_button_new_with_label("Offset Hack");
hack_skipdraw_label = gtk_label_new("Skipdraw:");
hack_skipdraw_spin = gtk_spin_button_new_with_range(0,1000,1);
hack_enble_check = gtk_check_button_new_with_label("Enable User Hacks");
hack_wild_check = gtk_check_button_new_with_label("Wild arm Hack");
hack_sprite_check = gtk_check_button_new_with_label("Sprite Hack");
hack_msaa_check = gtk_check_button_new_with_label("Msaa Hack");
hack_tco_label = gtk_label_new("Texture Offset: 0x");
hack_tco_entry = gtk_entry_new();
hack_logz_check = gtk_check_button_new_with_label("Log Depth Hack");
gtk_spin_button_set_value(GTK_SPIN_BUTTON(hack_skipdraw_spin), theApp.GetConfig("UserHacks_SkipDraw", 0));
set_hex_entry(hack_tco_entry, theApp.GetConfig("UserHacks_TCOffset", 0));
// Tables are strange. The numbers are for their position: left, right, top, bottom.
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_alpha_check, 0, 1, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_offset_check, 1, 2, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_sprite_check, 0, 1, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_wild_check, 1, 2, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_logz_check, 0, 1, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_date_check, 1, 2, 2, 3);
// Note: MSAA is not implemented yet. I disable it to make the table square
//gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_msaa_check, 2, 3, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_label, 0, 1, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_skipdraw_spin, 1, 2, 3, 4);
开发者ID:Anoth3rone,项目名称:pcsx2,代码行数:67,代码来源:GSLinuxDialog.cpp
示例4: gtk_widget_show
void GtkToolkitFileChooser::OpenDialog(X11Types::Window parent, ToolkitFileChooserListener* result_listener)
{
gtk_widget_show(m_dialog);
XSetTransientForHint(GDK_WINDOW_XDISPLAY(gtk_widget_get_window(m_dialog)),
GDK_WINDOW_XID(gtk_widget_get_window(m_dialog)), parent);
if (m_action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
GtkUtils::SetResourceName(m_dialog, "directorychooserdialog");
else
GtkUtils::SetResourceName(m_dialog, "filechooserdialog");
int response_id;
while(1)
{
m_open_dialog = true;
response_id = gtk_dialog_run(GTK_DIALOG(m_dialog));
m_open_dialog = false;
if (response_id == GTK_RESPONSE_ACCEPT)
{
m_selected_filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(m_dialog));
m_active_directory = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(m_dialog));
if (m_action == GTK_FILE_CHOOSER_ACTION_SAVE)
{
// BIG FAT TEST for saving. The file selector (or at least some versions of it)
// allows users entering an existing directory and accepts this as a valid filename
// Do not allow that as we have code that can call OpFile::Delete(TRUE) before saving
// the file. See DSK-318398
if (!VerifySaveFiles())
{
GtkWidget* dialog = m_dialog;
m_dialog = 0;
ResetData();
m_dialog = dialog;
continue;
}
}
}
break;
}
/* Note that gtk sends GTK_RESPONSE_DELETE_EVENT if the dialog is
* closed, including if the user presses the Escape button.
*/
if (response_id == GTK_RESPONSE_ACCEPT || response_id == GTK_RESPONSE_CANCEL || response_id == GTK_RESPONSE_DELETE_EVENT)
{
m_can_destroy = false;
result_listener->OnChoosingDone(this);
m_can_destroy = true;
if (m_request_destroy)
{
delete this; // Calls ResetData() in destructor
return;
}
}
ResetData();
GtkUtils::ProcessEvents();
if (response_id == RESPONSE_KILL_DIALOG)
delete this;
}
开发者ID:prestocore,项目名称:browser,代码行数:64,代码来源:GtkFileChooser.cpp
示例5: file_save_as_response_callback
/**
* Respond to a button press (also destroy) in the save as dialog.
*/
static void
file_save_as_response_callback(GtkWidget *fs,
gint response,
gpointer user_data)
{
char *filename;
Diagram *dia;
struct stat stat_struct;
if (response == GTK_RESPONSE_ACCEPT) {
dia = g_object_get_data (G_OBJECT(fs), "user_data");
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs));
if (!filename) {
/* Not getting a filename looks like a contract violation in Gtk+ to me.
* Still Dia would be crashing (bug #651949) - instead simply go back to the dialog. */
gtk_window_present (GTK_WINDOW (fs));
return;
}
if (g_stat(filename, &stat_struct) == 0) {
GtkWidget *dialog = NULL;
char *utf8filename = NULL;
if (!g_utf8_validate(filename, -1, NULL)) {
utf8filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
if (utf8filename == NULL) {
message_warning(_("Some characters in the filename are neither UTF-8\n"
"nor your local encoding.\nSome things will break."));
}
}
if (utf8filename == NULL) utf8filename = g_strdup(filename);
dialog = gtk_message_dialog_new (GTK_WINDOW(fs),
GTK_DIALOG_MODAL, GTK_MESSAGE_QUESTION,
GTK_BUTTONS_YES_NO,
_("File already exists"));
gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
_("The file '%s' already exists.\n"
"Do you want to overwrite it?"), utf8filename);
g_free(utf8filename);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_YES);
if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_YES) {
/* don't hide/destroy the dialog, but simply go back to it */
gtk_window_present (GTK_WINDOW (fs));
gtk_widget_destroy(dialog);
g_free (filename);
return;
}
gtk_widget_destroy(dialog);
}
dia->data->is_compressed = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(user_data));
diagram_update_extents(dia);
{
DiaContext *ctx = dia_context_new (_("Save as"));
diagram_set_filename(dia, filename);
dia_context_set_filename (ctx, filename);
if (diagram_save(dia, filename, ctx))
recent_file_history_add(filename);
dia_context_release (ctx);
}
g_free (filename);
}
/* if we have our own reference, drop it before destroy */
if ((dia = g_object_get_data (G_OBJECT(fs), "user_data")) != NULL) {
g_object_set_data (G_OBJECT(fs), "user_data", NULL);
g_object_unref (dia);
}
/* if we destroy it gtk_dialog_run wont give the response */
if (!g_object_get_data (G_OBJECT(fs), "dont-destroy"))
gtk_widget_destroy(GTK_WIDGET(fs));
}
开发者ID:AmiGanguli,项目名称:dia,代码行数:79,代码来源:filedlg.c
示例6: main
//.........这里部分代码省略.........
GdkGeometry geo = {
-1, -1, 1024, 768, -1, -1, 10, 10, 0, 0, GDK_GRAVITY_NORTH_WEST
};
GdkWindowHints geo_mask;
geo_mask = GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE | GDK_HINT_BASE_SIZE;
gtk_window_set_geometry_hints( GTK_WINDOW(widget), widget, &geo, geo_mask);
width = ghb_settings_get_int(ud->settings, "window_width");
height = ghb_settings_get_int(ud->settings, "window_height");
gtk_window_resize(GTK_WINDOW(widget), width, height);
gtk_widget_show(widget);
/*
* Filter objects in GtkBuilder xml
* Unfortunately, GtkFilter is poorly supported by GtkBuilder,
* so a lot of the setup must happen in code.
SourceFilterAll
SourceFilterVideo
SourceFilterTS
SourceFilterMPG
SourceFilterEVO
SourceFilterVOB
SourceFilterMKV
SourceFilterMP4
SourceFilterAVI
SourceFilterMOV
SourceFilterOGG
SourceFilterFLV
SourceFilterWMV
*/
// Add filters to source chooser
GtkFileFilter *filter;
GtkFileChooser *chooser;
chooser = GTK_FILE_CHOOSER(GHB_WIDGET(ud->builder, "source_dialog"));
filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterAll"));
gtk_file_filter_set_name(filter, "All");
gtk_file_filter_add_pattern(filter, "*");
gtk_file_chooser_add_filter(chooser, filter);
filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVideo"));
gtk_file_filter_set_name(filter, "Video");
gtk_file_filter_add_mime_type(filter, "video/*");
gtk_file_chooser_add_filter(chooser, filter);
filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterTS"));
gtk_file_filter_set_name(filter, "TS");
gtk_file_filter_add_pattern(filter, "*.ts");
gtk_file_filter_add_pattern(filter, "*.TS");
gtk_file_filter_add_pattern(filter, "*.m2ts");
gtk_file_filter_add_pattern(filter, "*.M2TS");
gtk_file_chooser_add_filter(chooser, filter);
filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterMPG"));
gtk_file_filter_set_name(filter, "MPG");
gtk_file_filter_add_pattern(filter, "*.mpg");
gtk_file_filter_add_pattern(filter, "*.MPG");
gtk_file_filter_add_pattern(filter, "*.mepg");
gtk_file_filter_add_pattern(filter, "*.MEPG");
gtk_file_chooser_add_filter(chooser, filter);
filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterEVO"));
gtk_file_filter_set_name(filter, "EVO");
gtk_file_filter_add_pattern(filter, "*.evo");
gtk_file_filter_add_pattern(filter, "*.EVO");
gtk_file_chooser_add_filter(chooser, filter);
filter = GTK_FILE_FILTER(GHB_OBJECT(ud->builder, "SourceFilterVOB"));
gtk_file_filter_set_name(filter, "VOB");
gtk_file_filter_add_pattern(filter, "*.vob");
gtk_file_filter_add_pattern(filter, "*.VOB");
gtk_file_chooser_add_filter(chooser, filter);
开发者ID:E32vb051LS4f9,项目名称:HandBrake,代码行数:67,代码来源:main.c
示例7: sendMail
void sendMail(GtkWidget* widget,struct GUI *gui){
char addr[16];
int sockfd;
int n,i;
/* Reset Statu Label */
for(i=0;i<8;i++){
gtk_label_set_text(GTK_LABEL(gui->statu[i]),"-");
}
/* Get host and port */
gui->host = (char *)gtk_entry_get_text(GTK_ENTRY(gui->iptHost));
gui->port = (char *)gtk_entry_get_text(GTK_ENTRY(gui->iptPort));
/* Get From */
gui->from = (char *)gtk_entry_get_text(GTK_ENTRY(gui->iptFrom));
/* Get To */
for(i=0;i<gui->c_to;i++){
gui->to[i] = (char *)gtk_entry_get_text(GTK_ENTRY(gui->iptTo[i]));
}
/* Get Cc */
for(i=0;i<gui->c_cc;i++){
gui->cc[i] = (char *)gtk_entry_get_text(GTK_ENTRY(gui->iptCc[i]));
}
/* Get Bcc */
for(i=0;i<gui->c_bcc;i++){
gui->bcc[i] = (char *)gtk_entry_get_text(GTK_ENTRY(gui->iptBcc[i]));
}
/* Get Subject */
gui->subject = (char *)gtk_entry_get_text(GTK_ENTRY(gui->iptSubject));
/* Get Mailbody file */
gui->mailbody = (char *)gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(gui->btnOpenmail));
/* Get Attachment files */
for(i=0;i<gui->c_file;i++){
gui->file[i] = (char *)gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(gui->btnOpenfile[i]));
}
if(strcmp(gui->host,"")==0||strcmp(gui->port,"")==0){
gtk_label_set_text(GTK_LABEL(gui->statu[0]),"X");
gtk_widget_show_all(gui->window);
printf("host or port is (are) null string\n");
return;
}
/* Connect to mail server */
sockfd = connectToHost(gui->host,gui->port,addr);
if(sockfd==-1){
/* Connect Fail */
printf("Connect to host %s:%s fail\n",gui->host,gui->port);
gtk_label_set_text(GTK_LABEL(gui->statu[0]),"X");
gtk_widget_show_all(gui->window);
return;
}else{
printf("Connect to host %s(%s):%s\n",gui->host,addr,gui->port);
n = HELO(sockfd);
if(n==-1){
close(sockfd);
printf("Close SimpleMail.\n");
gtk_label_set_text(GTK_LABEL(gui->statu[0]),"X");
gtk_widget_show_all(gui->window);
return;
}
gtk_label_set_text(GTK_LABEL(gui->statu[0]),"O");
gtk_widget_show_all(gui->window);
n = MAIL(sockfd,gui->from);
if(n==-1){
close(sockfd);
printf("Close SimpleMail.\n");
gtk_label_set_text(GTK_LABEL(gui->statu[1]),"X");
gtk_widget_show_all(gui->window);
return;
}
gtk_label_set_text(GTK_LABEL(gui->statu[1]),"O");
gtk_widget_show_all(gui->window);
n = RCPT(sockfd,gui->to,gui->c_to,gui->cc,gui->c_cc,gui->bcc,gui->c_bcc);
switch(n){
case -1:
close(sockfd);
printf("Close SimpleMail.\n");
gtk_label_set_text(GTK_LABEL(gui->statu[2]),"X");
gtk_widget_show_all(gui->window);
return;
case -2:
close(sockfd);
printf("Close SimpleMail.\n");
gtk_label_set_text(GTK_LABEL(gui->statu[2]),"O");
gtk_label_set_text(GTK_LABEL(gui->statu[3]),"X");
gtk_widget_show_all(gui->window);
//.........这里部分代码省略.........
开发者ID:ChunHungLiu,项目名称:ntu-homeworks,代码行数:101,代码来源:SMCF_GUI.c
示例8: write_fru
static size_t write_fru(char *eeprom)
{
gint result;
const char *serial, *file;
char *ser_num, *filename;
time_t frutime;
FILE *fp = NULL;
size_t i;
time_t tmp;
struct tm *tmp2;
char buf[256];
int j, n;
struct dirent **namelist;
GtkListStore *store;
n = scandir(FRU_FILES, &namelist, 0, alphasort);
/* No fru files, don't bother */
if (n < 0) {
printf("didn't find FRU_Files in %s at %s(%s)\n", FRU_FILES, __FILE__, __func__);
return 0;
}
g_object_set(dialogs.serial_num, "secondary_text", eeprom, NULL);
filename = g_malloc(PATH_MAX);
ser_num = malloc(128);
memset(ser_num, 0, 128);
fp = fopen(".serialnum", "r");
if (fp) {
i = fread(ser_num, 1, 128, fp);
if (!ferror(fp) && (i == 128 || feof(fp)))
gtk_entry_set_text(GTK_ENTRY(serial_num), (const gchar*)&ser_num[1]);
fclose(fp);
}
store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(fru_file_list)));
gtk_list_store_clear(store);
for (j = 0; j < n; j++) {
if (namelist[j]->d_type == DT_REG && str_endswith(namelist[j]->d_name, ".bin"))
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(fru_file_list), namelist[j]->d_name);
free(namelist[j]);
}
free(namelist);
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(fru_file_list), "Other...");
gtk_combo_box_set_active(GTK_COMBO_BOX(fru_file_list), ser_num[0]);
free(ser_num);
frutime = mins_since_jan_1_1996();
tmp = min2date(frutime);
tmp2 = gmtime(&tmp);
strftime(buf, sizeof(buf), "%a %b %d %H:%M %Y", tmp2);
gtk_entry_set_text(GTK_ENTRY(fru_date), buf);
get_serial_and_file:
result = gtk_dialog_run(GTK_DIALOG(dialogs.serial_num));
i = 0;
switch (result) {
case GTK_RESPONSE_OK:
serial = gtk_entry_get_text(GTK_ENTRY(serial_num));
if (strlen(serial) == 0) {
create_blocking_popup(GTK_MESSAGE_INFO, GTK_BUTTONS_OK,
"", "Serial number required");
goto get_serial_and_file;
}
file = gtk_combo_box_get_active_text(GTK_COMBO_BOX(fru_file_list));
if (strncmp(file, "Other...", 8) != 0) {
snprintf(filename, PATH_MAX, FRU_FILES "%s", file);
} else {
/* manually choose fru file */
GtkWidget *dialog;
dialog = gtk_file_chooser_dialog_new("Select FRU file",
GTK_WINDOW(dialogs.serial_num),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
NULL);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
}
gtk_widget_destroy(dialog);
}
if (filename) {
fflush(NULL);
sprintf(buf, "fru-dump -i %s -o %s -s %s -d %d 2>&1",
filename, eeprom, serial, (unsigned int)frutime);
#if DEBUG
printf("%s\n", buf);
#else
//.........这里部分代码省略.........
开发者ID:tinglic,项目名称:iio-oscilloscope,代码行数:101,代码来源:dialogs.c
示例9: picture_selection_dialog
/*! \brief Creates the add image dialog
* \par Function Description
* This function creates the add image dialog and loads the selected picture.
*/
void picture_selection_dialog (GschemToplevel *w_current)
{
TOPLEVEL *toplevel = gschem_toplevel_get_toplevel (w_current);
gchar *filename;
GdkPixbuf *pixbuf;
GError *error = NULL;
w_current->pfswindow = gtk_file_chooser_dialog_new (_("Select a picture file..."),
GTK_WINDOW(w_current->main_window),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL,
GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN,
GTK_RESPONSE_ACCEPT,
NULL);
/* Set the alternative button order (ok, cancel, help) for other systems */
gtk_dialog_set_alternative_button_order(GTK_DIALOG(w_current->pfswindow),
GTK_RESPONSE_ACCEPT,
GTK_RESPONSE_CANCEL,
-1);
if (w_current->pixbuf_filename)
gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(w_current->pfswindow),
w_current->pixbuf_filename);
if (gtk_dialog_run (GTK_DIALOG (w_current->pfswindow)) == GTK_RESPONSE_ACCEPT) {
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (w_current->pfswindow));
gtk_widget_destroy(w_current->pfswindow);
w_current->pfswindow=NULL;
pixbuf = gdk_pixbuf_new_from_file (filename, &error);
if (!pixbuf) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (w_current->main_window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
_("Failed to load picture: %s"),
error->message);
/* Wait for any user response */
gtk_dialog_run (GTK_DIALOG (dialog));
g_error_free (error);
gtk_widget_destroy(dialog);
}
else {
#if DEBUG
printf("Picture loaded succesfully.\n");
#endif
o_invalidate_rubber(w_current);
i_update_middle_button(w_current, i_callback_add_picture, _("Picture"));
w_current->inside_action = 0;
o_picture_set_pixbuf(w_current, pixbuf, filename);
gschem_toplevel_page_content_changed (w_current, toplevel->page_current);
i_set_state(w_current, DRAWPICTURE);
}
g_free (filename);
}
i_update_toolbar(w_current);
if (w_current->pfswindow) {
gtk_widget_destroy(w_current->pfswindow);
w_current->pfswindow=NULL;
}
}
开发者ID:blueantst,项目名称:geda-gaf,代码行数:75,代码来源:o_picture.c
示例10: _lib_import_single_image_callback
static void _lib_import_single_image_callback(GtkWidget *widget,gpointer user_data)
{
GtkWidget *win = dt_ui_main_window(darktable.gui->ui);
GtkWidget *filechooser = gtk_file_chooser_dialog_new (_("import image"),
GTK_WINDOW (win),
GTK_FILE_CHOOSER_ACTION_OPEN,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
(char *)NULL);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(filechooser), TRUE);
char *last_directory = dt_conf_get_string("ui_last/import_last_directory");
if(last_directory != NULL)
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (filechooser), last_directory);
char *cp, **extensions, ext[1024];
GtkFileFilter *filter;
filter = GTK_FILE_FILTER(gtk_file_filter_new());
extensions = g_strsplit(dt_supported_extensions, ",", 100);
for(char **i=extensions; *i!=NULL; i++)
{
snprintf(ext, 1024, "*.%s", *i);
gtk_file_filter_add_pattern(filter, ext);
gtk_file_filter_add_pattern(filter, cp=g_ascii_strup(ext, -1));
g_free(cp);
}
g_strfreev(extensions);
gtk_file_filter_set_name(filter, _("supported images"));
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filechooser), filter);
filter = GTK_FILE_FILTER(gtk_file_filter_new());
gtk_file_filter_add_pattern(filter, "*");
gtk_file_filter_set_name(filter, _("all files"));
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(filechooser), filter);
GtkWidget *preview = gtk_image_new();
gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(filechooser), preview);
g_signal_connect(filechooser, "update-preview", G_CALLBACK (_lib_import_update_preview), preview);
dt_lib_import_metadata_t metadata;
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (filechooser), _lib_import_get_extra_widget(&metadata, FALSE));
if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT)
{
dt_conf_set_string("ui_last/import_last_directory", gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER (filechooser)));
_lib_import_evaluate_extra_widget(&metadata, FALSE);
char *filename = NULL;
dt_film_t film;
GSList *list = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (filechooser));
GSList *it = list;
int id = 0;
int filmid = 0;
/* reset filter to display all images, otherwise view may remain empty */
dt_view_filter_reset_to_show_all(darktable.view_manager);
while(it)
{
filename = (char *)it->data;
gchar *directory = g_path_get_dirname((const gchar *)filename);
filmid = dt_film_new(&film, directory);
id = dt_image_import(filmid, filename, TRUE);
if(!id) dt_control_log(_("error loading file `%s'"), filename);
g_free (filename);
g_free (directory);
it = g_slist_next(it);
}
if(id)
{
dt_film_open(filmid);
// make sure buffers are loaded (load full for testing)
dt_mipmap_buffer_t buf;
dt_mipmap_cache_read_get(darktable.mipmap_cache, &buf, id, DT_MIPMAP_FULL, DT_MIPMAP_BLOCKING);
if(!buf.buf)
{
dt_control_log(_("file has unknown format!"));
}
else
{
dt_mipmap_cache_read_release(darktable.mipmap_cache, &buf);
DT_CTL_SET_GLOBAL(lib_image_mouse_over_id, id);
dt_ctl_switch_mode_to(DT_DEVELOP);
}
}
}
gtk_widget_destroy(metadata.frame);
gtk_widget_destroy (filechooser);
gtk_widget_queue_draw(dt_ui_center(darktable.gui->ui));
}
开发者ID:ealasu,项目名称:darktable,代码行数:92,代码来源:import.c
示例11: _lib_import_folder_callback
static void _lib_import_folder_callback(GtkWidget *widget,gpointer user_data)
{
GtkWidget *win = dt_ui_main_window(darktable.gui->ui);
GtkWidget *filechooser = gtk_file_chooser_dialog_new (_("import film"),
GTK_WINDOW (win),
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
(char *)NULL);
gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(filechooser), TRUE);
char *last_directory = dt_conf_get_string("ui_last/import_last_directory");
if(last_directory != NULL)
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER (filechooser), last_directory);
dt_lib_import_metadata_t metadata;
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (filechooser), _lib_import_get_extra_widget(&metadata, TRUE));
// run the dialog
if (gtk_dialog_run (GTK_DIALOG (filechooser)) == GTK_RESPONSE_ACCEPT)
{
dt_conf_set_string("ui_last/import_last_directory", gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER (filechooser)));
_lib_import_evaluate_extra_widget(&metadata, TRUE);
char *filename = NULL, *first_filename = NULL;
GSList *list = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (filechooser));
GSList *it = list;
/* reset filter to display all images, otherwise view may remain empty */
dt_view_filter_reset_to_show_all(darktable.view_manager);
/* for each selected folder add import job */
while(it)
{
filename = (char *)it->data;
dt_film_import(filename);
if (!first_filename)
{
first_filename = g_strdup(filename);
if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (metadata.recursive)))
first_filename = dt_util_dstrcat(first_filename, "%%");
}
g_free (filename);
it = g_slist_next(it);
}
/* update collection to view import */
if (first_filename)
{
dt_conf_set_int("plugins/lighttable/collect/num_rules", 1);
dt_conf_set_int("plugins/lighttable/collect/item0", 0);
dt_conf_set_string("plugins/lighttable/collect/string0",first_filename);
dt_collection_update_query(darktable.collection);
g_free(first_filename);
}
g_slist_free (list);
}
gtk_widget_destroy(metadata.frame);
gtk_widget_destroy (filechooser);
gtk_widget_queue_draw(dt_ui_center(darktable.gui->ui));
}
开发者ID:ealasu,项目名称:darktable,代码行数:64,代码来源:import.c
示例12: show
bool show(Display* parent) override {
static std::string s_lastUsedDir;
if (s_lastUsedDir.empty())
s_lastUsedDir = g_get_user_special_dir(G_USER_DIRECTORY_DESKTOP);
const char* okLabel;
GtkFileChooserAction action;
switch (m_type) {
case Type::OpenFile:
case Type::OpenFiles:
action = GTK_FILE_CHOOSER_ACTION_OPEN;
okLabel = "_Open";
break;
case Type::OpenFolder:
action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
okLabel = "_Open Folder";
break;
case Type::SaveFile:
action = GTK_FILE_CHOOSER_ACTION_SAVE;
okLabel = "_Save";
break;
}
// GtkWindow* gtkParent = nullptr;
GtkWidget* dialog = gtk_file_chooser_dialog_new(
m_title.c_str(),
nullptr,
action,
"_Cancel", GTK_RESPONSE_CANCEL,
okLabel, GTK_RESPONSE_ACCEPT,
nullptr);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
GtkFileChooser* chooser = GTK_FILE_CHOOSER(dialog);
m_chooser = chooser;
if (m_type == Type::SaveFile)
gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
else if (m_type == Type::OpenFiles)
gtk_file_chooser_set_select_multiple(chooser, true);
if (m_type != Type::OpenFolder) {
setupFilters(base::get_file_extension(m_filename));
setupPreview();
}
if (m_initialDir.empty())
gtk_file_chooser_set_current_folder(chooser, s_lastUsedDir.c_str());
else
gtk_file_chooser_set_current_folder(chooser, m_initialDir.c_str());
if (!m_filename.empty()) {
std::string fn = m_filename;
// Add default extension
if (m_type == Type::SaveFile && base::get_file_extension(fn).empty()) {
fn.push_back('.');
fn += m_defExtension;
}
gtk_file_chooser_set_current_name(chooser, fn.c_str());
}
// Setup the "parent" display as the parent of the dialog (we've
// to convert a X11 Window into a GdkWindow to do this).
GdkWindow* gdkParentWindow = nullptr;
if (parent) {
GdkWindow* gdkWindow = gtk_widget_get_root_window(dialog);
gdkParentWindow =
gdk_x11_window_foreign_new_for_display(
gdk_window_get_display(gdkWindow),
(::Window)parent->nativeHandle());
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER_ON_PARENT);
gdk_window_set_transient_for(gdkWindow, gdkParentWindow);
}
else {
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
}
// Show the dialog
gint res = gtk_dialog_run(GTK_DIALOG(dialog));
if (res == GTK_RESPONSE_ACCEPT) {
s_lastUsedDir = gtk_file_chooser_get_current_folder(chooser);
m_filename = gtk_file_chooser_get_filename(chooser);
if (m_type == Type::OpenFiles) {
GSList* list = gtk_file_chooser_get_filenames(chooser);
g_slist_foreach(
list,
[](void* fn, void* userdata){
auto self = (FileDialogGTK*)userdata;
self->m_filenames.push_back((char*)fn);
g_free(fn);
}, this);
g_slist_free(list);
}
}
//.........这里部分代码省略.........
开发者ID:imeteora,项目名称:aseprite,代码行数:101,代码来源:native_dialogs.cpp
示例13: ags_machine_open_extended_response_callback
void
ags_machine_open_extended_response_callback(GtkWidget *widget, gint response, AgsMachine *machine)
{
GtkFileChooserDialog *file_chooser;
AgsFileSelection *file_selection;
GtkCheckButton *overwrite;
GtkCheckButton *create;
GSList *filenames;
gchar *current_folder;
GError *error;
file_chooser = (GtkFileChooserDialog *) gtk_widget_get_toplevel(widget);
if(response == GTK_RESPONSE_ACCEPT){
filenames = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(file_chooser));
overwrite = g_object_get_data((GObject *) widget, "overwrite\0");
create = g_object_get_data((GObject *) widget, "create\0");
current_folder = gtk_file_chooser_get_current_folder(GTK_FILE_CHOOSER(file_chooser));
//TODO:JK: you need to check against recently used
//TODO:JK: add more file types to AgsFileSelection
/* check for supported packed audio files */
file_selection = (AgsFileSelection *) gtk_file_chooser_get_extra_widget(GTK_FILE_CHOOSER(file_chooser));
if(file_selection != NULL && g_strcmp0(file_selection->directory, current_folder)){
gtk_widget_destroy(GTK_WIDGET(file_selection));
file_selection = NULL;
}
if(file_selection == NULL ||
(AGS_FILE_SELECTION_COMPLETED & (file_selection->flags)) == 0){
if((AGS_MACHINE_ACCEPT_SOUNDFONT2 & (machine->file_input_flags)) != 0){
GDir *current_directory;
GList *new_entry, *old_entry;
GSList *slist;
gchar *current_filename;
slist = filenames;
new_entry = NULL;
while(slist != NULL){
if(g_str_has_suffix(slist->data,
".sf2\0")){
AgsFileSelectionEntry *entry;
entry = ags_file_selection_entry_alloc();
entry->filename = slist->data;
new_entry = g_list_prepend(new_entry,
entry);
}
slist = slist->next;
}
old_entry = NULL;
if(file_selection == NULL){
if(new_entry != NULL){
file_selection = ags_file_selection_new();
gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(file_chooser),
GTK_WIDGET(file_selection));
ags_file_selection_set_entry(file_selection,
new_entry);
ags_connectable_connect(AGS_CONNECTABLE(file_selection));
gtk_widget_show_all(GTK_WIDGET(file_selection));
return;
}
}else if(AGS_IS_FILE_SELECTION(file_selection)){
GList *really_new_entry;
GList *list;
old_entry = file_selection->entry;
list = new_entry;
really_new_entry = NULL;
/* check against existing entries */
if(new_entry != NULL){
while(list != NULL){
if(g_list_find(old_entry, list->data) == NULL){
really_new_entry = g_list_prepend(really_new_entry,
list->data);
}else{
free(list->data);
}
list = list->next;
}
g_list_free(new_entry);
}
ags_file_selection_set_entry(file_selection,
//.........这里部分代码省略.........
开发者ID:weedlight,项目名称:ags,代码行数:101,代码来源:ags_machine_callbacks.c
示例14: save_dialog_response_cb
static void
save_dialog_response_cb (GtkDialog * dialog,
gint response_id, GtrWindow * window)
{
GError *error = NULL;
GtrPo *po;
GtrTab *tab;
gchar *filename;
GFile *location;
GtrStatusbar *status;
tab = GTR_TAB (g_object_get_data (G_OBJECT (dialog), GTR_TAB_SAVE_AS));
g_return_if_fail (GTK_IS_FILE_CHOOSER (dialog));
po = gtr_tab_get_po (tab);
if (response_id != GTK_RESPONSE_ACCEPT)
{
gtk_widget_destroy (GTK_WIDGET (dialog));
return;
}
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
g_return_if_fail (filename != NULL);
location = g_file_new_for_path (filename);
g_free (filename);
gtk_widget_destroy (GTK_WIDGET (dialog));
if (po != NULL)
{
gtr_po_set_location (po, location);
g_object_unref (location);
gtr_po_save_file (po, &error);
if (error)
{
GtkWidget *dialog;
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_WARNING,
GTK_BUTTONS_OK,
"%s", error->message);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
g_clear_error (&error);
return;
}
/* We have to change the state of the tab */
gtr_po_set_state (po, GTR_PO_STATE_SAVED);
/* Flash a message */
status = GTR_STATUSBAR (gtr_window_get_statusbar (window));
gtr_statusbar_flash_message (status, 0, _("File saved."));
}
g_object_unref (location);
}
开发者ID:chavaone,项目名称:gtranslator,代码行数:62,代码来源:gtr-actions-file.c
示例15: impl_constructed
static void
impl_constructed (GObject *object)
{
RBImportDialog *dialog;
RhythmDBQuery *query;
GtkBuilder *builder;
GSettings *settings;
char **locations;
RB_CHAIN_GOBJECT_METHOD (rb_import_dialog_parent_class, constructed, object);
dialog = RB_IMPORT_DIALOG (object);
g_object_get (dialog->priv->shell,
"db", &dialog->priv->db,
"shell-player", &dialog->priv->shell_player,
NULL);
/* create entry types */
dialog->priv->entry_type = g_object_new (rb_import_dialog_entry_type_get_type (),
"db", dialog->priv->db,
"name", "import-dialog",
NULL);
dialog->priv->ignore_type = g_object_new (rb_import_dialog_ignore_type_get_type (),
"db", dialog->priv->db,
"name", "import-dialog-ignore",
NULL);
rhythmdb_register_entry_type (dialog->priv->db, dialog->priv->entry_type);
rhythmdb_register_entry_type (dialog->priv->db, dialog->priv->ignore_type);
builder = rb_builder_load ("import-dialog.ui", NULL);
dialog->priv->import_button = GTK_WIDGET (gtk_builder_get_object (builder, "import-button"));
g_signal_connect_object (dialog->priv->import_button, "clicked", G_CALLBACK (import_clicked_cb), dialog, 0);
gtk_widget_set_sensitive (dialog->priv->import_button, FALSE);
dialog->priv->copy_check = GTK_WIDGET (gtk_builder_get_object (builder, "copy-check"));
g_signal_connect (gtk_builder_get_object (builder, "close-button"),
"clicked",
G_CALLBACK (close_clicked_cb),
dialog);
dialog->priv->file_chooser = GTK_WIDGET (gtk_builder_get_object (builder, "file-chooser-button"));
/* select the first library location, since the default may be
* the user's home dir or / or something that will take forever to scan.
*/
settings = g_settings_new ("org.gnome.rhythmbox.rhythmdb");
locations = g_settings_get_strv (settings, "locations");
if (locations[0] != NULL) {
dialog->priv->current_uri = g_strdup (locations[0]);
} else {
dialog->priv->current_uri = g_filename_to_uri (rb_music_dir (), NULL, NULL);
}
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog->priv->file_chooser),
dialog->priv->current_uri);
g_strfreev (locations);
g_object_unref (settings);
g_signal_connect_object (dialog->priv->file_chooser, "selection-changed", G_CALLBACK (current_folder_changed_cb), dialog, 0);
/* not sure why we have to set this, it should be the default */
gtk_widget_set_vexpand (gtk_widget_get_parent (dialog->priv->file_chooser), FALSE);
dialog->priv->info_bar_container = GTK_WIDGET (gtk_builder_get_object (builder, "info-bar-container"));
/* set up entry view */
dialog->priv->entry_view = rb_entry_view_new (dialog->priv->db, G_OBJECT (dialog->priv->shell_player), TRUE, FALSE);
g_signal_connect (dialog->priv->entry_view, "entry-activated", G_CALLBACK (entry_activated_cb), dialog);
g_signal_connect (dialog->priv->entry_view, "selection-changed", G_CALLBACK (selection_changed_cb), dialog);
rb_entry_view_append_column (dialog->priv->entry_view, RB_ENTRY_VIEW_CO
|
请发表评论