示例#1
0
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);
}
示例#2
0
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
            fp = popen(buf, "r");
#endif
            if (!fp) {
                printf("can't execute \"%s\"\n", buf);
            } else {
                i = 0;
                while(fgets(buf, sizeof(buf), fp) != NULL) {
                    /* fru-dump not installed */
                    if (strstr(buf, "not found"))
                        printf("no fru-tools installed\n");
                    if (strstr(buf, "wrote") && strstr(buf, "bytes to") && strstr(buf, eeprom))
                        i = 1;
                }
                pclose(fp);
            }
            fp = fopen(".serialnum", "w");
            if (fp) {
                fprintf(fp, "%c%s", gtk_combo_box_get_active(GTK_COMBO_BOX(fru_file_list)), serial);
                fclose(fp);
            }
        }
        break;
    case GTK_RESPONSE_DELETE_EVENT:
        break;
    default:
        printf("unknown response %d in %s\n", result, __func__);
        break;
    }
    gtk_widget_hide(GTK_WIDGET(dialogs.serial_num));

    g_free(filename);
    return i;
}
示例#3
0
文件: gui.c 项目: shareef12/spoon
void update_inFile() {
    char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(inFile_chooser));
    gtk_entry_set_text(GTK_ENTRY(inFile_entry), filename);
}
static void
xml_planner_plugin_export (GtkAction *action,
			   gpointer   user_data)
{
	PlannerPlugin     *plugin;
	MrpProject        *project;
	GError            *error = NULL;
	GtkWidget         *file_chooser;
	GtkWidget         *dialog;
	gint               response;
	gchar             *filename = NULL;
	gchar             *real_filename;
	gchar             *last_dir;

	plugin = PLANNER_PLUGIN (user_data);

 try_again:

	file_chooser = gtk_file_chooser_dialog_new (_("Export"),
						    GTK_WINDOW (plugin->main_window),
						    GTK_FILE_CHOOSER_ACTION_SAVE,
						    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
						    GTK_STOCK_SAVE, GTK_RESPONSE_OK,
						    NULL);
	gtk_window_set_modal (GTK_WINDOW (file_chooser), TRUE);

	last_dir = get_last_dir ();
	gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (file_chooser), last_dir);
	g_free (last_dir);

	response = gtk_dialog_run (GTK_DIALOG (file_chooser));
	if (response == GTK_RESPONSE_OK) {
		filename = gtk_file_chooser_get_filename (
			GTK_FILE_CHOOSER (file_chooser));
	}

	gtk_widget_destroy (file_chooser);

	if (filename) {
		if (!g_str_has_suffix (filename, ".mrproject") && !g_str_has_suffix (filename, ".planner")) {
			/* Add the old extension for old format files. */
			real_filename = g_strconcat (filename, ".mrproject", NULL);
		} else {
			real_filename = g_strdup (filename);
		}

		if (g_file_test (real_filename, G_FILE_TEST_EXISTS)) {
			dialog = gtk_message_dialog_new (GTK_WINDOW (plugin->main_window),
							 GTK_DIALOG_MODAL |
							 GTK_DIALOG_DESTROY_WITH_PARENT,
							 GTK_MESSAGE_WARNING,
							 GTK_BUTTONS_YES_NO,
							 _("File \"%s\" exists, "
							   "do you want to overwrite it?"),
							 real_filename);

			response = gtk_dialog_run (GTK_DIALOG (dialog));
			gtk_widget_destroy (dialog);

			switch (response) {
			case GTK_RESPONSE_YES:
				break;
			default:
				g_free (real_filename);
				goto try_again;
			}
		}
	}

	if (!filename) {
		return;
	}

	project = planner_window_get_project (plugin->main_window);

	if (!mrp_project_export (project, real_filename,
				 "Planner XML pre-0.12",
				 TRUE,
				 &error)) {
		g_warning ("Error while export to Planner XML: %s", error->message);
	}

	last_dir = g_path_get_dirname (real_filename);
	planner_conf_set_string (CONF_MAIN_LAST_XML_EXPORT_DIR, last_dir, NULL);
	g_free (last_dir);

	g_free (real_filename);
	g_free (filename);
}
static void
on_create_patch_series_dialog_response (GtkDialog *dialog, gint response_id, 
										GitUIData *data)
{
	GtkWidget *patch_series_origin_check;
	GtkWidget *patch_series_branch_combo;
	GtkWidget *patch_series_file_chooser_button;
	GtkWidget *patch_series_signoff_check;
	GtkTreeModel *branch_combo_model;
	gchar *branch;
	gchar *output_directory;
	GtkTreeIter iter;
	GitFormatPatchCommand *format_patch_command;
	
	if (response_id == GTK_RESPONSE_OK)
	{	
		patch_series_origin_check = GTK_WIDGET (gtk_builder_get_object (data->bxml, 
		                                              				    "patch_series_origin_check"));
		patch_series_branch_combo = GTK_WIDGET (gtk_builder_get_object (data->bxml, 
																	    "patch_series_branch_combo"));
		patch_series_file_chooser_button = GTK_WIDGET (gtk_builder_get_object (data->bxml, 
																			   "patch_series_file_chooser_button"));
		patch_series_signoff_check = GTK_WIDGET (gtk_builder_get_object (data->bxml, 
																		 "patch_series_signoff_check"));
		branch_combo_model = GTK_TREE_MODEL (gtk_builder_get_object (data->bxml,
		                                                             "branch_combo_model"));
		
		if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (patch_series_origin_check)))
		    branch = g_strdup ("origin");
		else
		{
			gtk_combo_box_get_active_iter (GTK_COMBO_BOX (patch_series_branch_combo), 
									   &iter);
			gtk_tree_model_get (branch_combo_model, &iter, 0, &branch, -1);
		}
		    
		output_directory = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (patch_series_file_chooser_button));
		
		format_patch_command = git_format_patch_command_new (data->plugin->project_root_directory,
															 output_directory,
															 branch,
															 gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (patch_series_signoff_check)));
		
		g_free (branch);
		g_free (output_directory);
		
		git_create_message_view (data->plugin);
		
		g_signal_connect (G_OBJECT (format_patch_command), "command-finished",
						  G_CALLBACK (on_git_command_finished),
						  data->plugin);
		
		g_signal_connect (G_OBJECT (format_patch_command), "data-arrived",
						  G_CALLBACK (on_git_command_info_arrived),
						  data->plugin);
		
		anjuta_command_start (ANJUTA_COMMAND (format_patch_command));
	}
	
	gtk_widget_destroy (GTK_WIDGET (dialog));
	git_ui_data_free (data);
}
示例#6
0
void
ps_to_stdout (GtkButton * button, gpointer user_data)
{
  GtkWidget *dialog, *hbox, *stock, *table, *local_entry2, *label;

  gint response;

  dialog =
    gtk_dialog_new_with_buttons ("Interactive Dialog", GTK_WINDOW (user_data),
				 GTK_DIALOG_MODAL |
				 GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK,
				 GTK_RESPONSE_OK, GTK_STOCK_CANCEL,
				 GTK_RESPONSE_CANCEL, NULL);

  hbox = gtk_hbox_new (FALSE, 8);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, FALSE, FALSE,
		      0);

  stock =
    gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION,
			      GTK_ICON_SIZE_DIALOG);
  gtk_box_pack_start (GTK_BOX (hbox), stock, FALSE, FALSE, 0);

  table = gtk_table_new (1, 1, FALSE);
  gtk_table_set_row_spacings (GTK_TABLE (table), 4);
  gtk_table_set_col_spacings (GTK_TABLE (table), 4);
  gtk_box_pack_start (GTK_BOX (hbox), table, TRUE, TRUE, 0);
  label = gtk_label_new_with_mnemonic ("Multiply");
  gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);
  local_entry2 = gtk_entry_new ();
  gtk_table_attach_defaults (GTK_TABLE (table), local_entry2, 1, 2, 0, 1);
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), local_entry2);
  gtk_widget_show_all (hbox);
  response = gtk_dialog_run (GTK_DIALOG (dialog));
  if (response == GTK_RESPONSE_OK)
    {
      PrimBuf prb;
      pr_scale psc;
      double koef;

      sscanf (gtk_entry_get_text (GTK_ENTRY (local_entry2)), "%lf", &koef);
      psc.K = koef;
      prb = get_request (REQ_PRIMITIVES);
      if (prb != NULL)
	{
	  GtkWidget *filew;

	  filew =
	    gtk_file_chooser_dialog_new ("Open xml file", NULL,
					 GTK_FILE_CHOOSER_ACTION_SAVE,
					 GTK_STOCK_CANCEL,
					 GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE,
					 GTK_RESPONSE_ACCEPT, NULL);
	  if (gtk_dialog_run (GTK_DIALOG (filew)) == GTK_RESPONSE_ACCEPT)
	    {
	      char *filename;
	      FILE *fp;
	      filename =
		gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (filew));
	      fp = fopen (filename, "w");
	      if (fp)
		{
		  setlocale (LC_NUMERIC, "C");
		  prp_step_by_step_ps (fp, psc, prb);
		  fclose (fp);
		  setlocale (LC_NUMERIC, "");
		}
	      else
		fprintf (stderr, "Can\'t open file: %s\n", filename);
	    }
	  gtk_widget_destroy (filew);
	}
    }

  gtk_widget_destroy (dialog);
}
void ExportWindow_init( ExportWindow* ew, Scene* scene )
{
    GtkWidget *dialog = gtk_file_chooser_dialog_new ("Exporter la scene", NULL, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
    gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
    GtkFileFilter* filtre = gtk_file_filter_new();
    gtk_file_filter_add_pattern( GTK_FILE_FILTER (filtre), "*.png");
    gtk_file_filter_add_pattern( GTK_FILE_FILTER (filtre), "*.pdf");
    gtk_file_filter_add_pattern( GTK_FILE_FILTER (filtre), "*.svg");
    gtk_file_chooser_set_filter( GTK_FILE_CHOOSER(dialog), GTK_FILE_FILTER(filtre) );

    ew->comboBox = gtk_combo_box_new_text();
    gtk_combo_box_append_text( GTK_COMBO_BOX( ew->comboBox ), "png" );
    gtk_combo_box_append_text( GTK_COMBO_BOX( ew->comboBox ), "svg" );
    gtk_combo_box_append_text( GTK_COMBO_BOX( ew->comboBox ), "pdf" );
    gtk_file_chooser_set_extra_widget( GTK_FILE_CHOOSER(dialog), ew->comboBox );
    gtk_combo_box_set_active( GTK_COMBO_BOX( ew->comboBox ), 0 );
    g_signal_emit_by_name( GTK_OBJECT( ew->comboBox ), "changed", NULL );

    if( gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT )
    {
        char *filename = NULL;
        filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
        filename = (char*)realloc( filename, ( strlen(filename) + 4 ) * sizeof( char ) );
        filename = strcat( filename,"." );
        filename = strcat( filename, gtk_combo_box_get_active_text( GTK_COMBO_BOX( ew->comboBox ) ) );

        printf( "Exportation : %s\n", filename );

        cairo_surface_t *surface = NULL; /*Surface sur laquelle on va dessiner*/
        cairo_t *cr = NULL; /*COntexte associé à la surface */

        if( strcmp( filename, "" ) != 0 ) /*On test si le nom a été renseigné */
        {
            if( strcmp( gtk_combo_box_get_active_text( GTK_COMBO_BOX( ew->comboBox ) ), "png" ) == 0 )
            {
                surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, scene->dWidth, scene->dHeight);
                cr = cairo_create (surface);
                Scene_clear_scene(scene , cr, 1, 1, 1); /* Nettoyage de la scene */
                Scene_dessiner_scene( scene, cr ); /*Dessin de tous les objets*/
                cairo_surface_write_to_png(surface, filename ); /* Projection sur une surfae PNG*/
                cairo_surface_destroy(surface);
                g_free (filename);
                gtk_widget_destroy (dialog);
            }
            else if(strcmp( gtk_combo_box_get_active_text( GTK_COMBO_BOX( ew->comboBox ) ), "pdf" ) == 0 )
            {
                surface  = cairo_pdf_surface_create( filename, scene->dWidth, scene->dHeight);
                cr = cairo_create(surface);
                Scene_clear_scene(scene , cr, 1, 1, 1); /* Nettoyage de la scene */
                Scene_dessiner_scene( scene, cr ); /*Dessin de tous les objets*/
                cairo_surface_destroy(surface);
                g_free (filename);
                gtk_widget_destroy (dialog);
            }
            else if(strcmp( gtk_combo_box_get_active_text( GTK_COMBO_BOX( ew->comboBox ) ), "svg" ) == 0 )
            {
                surface = cairo_svg_surface_create( filename, scene->dWidth, scene->dHeight );
                cr = cairo_create(surface);
                Scene_clear_scene(scene , cr, 1, 1, 1); /* Nettoyage de la scene */
                Scene_dessiner_scene( scene, cr ); /*Dessin de tous les objets*/
                cairo_surface_destroy(surface);
                g_free (filename);
                gtk_widget_destroy (dialog);
            }


            cairo_destroy( cr );
        }
        else
        {
            GtkWidget* avertissement =
                gtk_message_dialog_new( NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_WARNING, GTK_BUTTONS_OK, "Veuillez entrer un nom de fichier" );

            if( gtk_dialog_run ( GTK_DIALOG ( avertissement ) ) == GTK_RESPONSE_OK )
            {
                gtk_widget_destroy( avertissement );

            }
        }

    }
    else
    {
        gtk_widget_destroy (dialog);
    }

}
示例#8
0
文件: filedlg.c 项目: AmiGanguli/dia
/**
 * 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));
}
示例#9
0
文件: filedlg.c 项目: AmiGanguli/dia
/**
 * 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);
}
示例#10
0
static void
save_avatar_menu_activate_cb (GtkWidget *widget,
                              EmpathyContactWidget *information)
{
  GtkWidget *dialog;
  EmpathyAvatar *avatar;
  gchar *ext = NULL, *filename;

  dialog = gtk_file_chooser_dialog_new (_("Save Avatar"),
      NULL,
      GTK_FILE_CHOOSER_ACTION_SAVE,
      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
      GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
      NULL);

  gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
      TRUE);

  /* look for the avatar extension */
  avatar = empathy_contact_get_avatar (information->contact);
  if (avatar->format != NULL)
    {
      gchar **splitted;

      splitted = g_strsplit (avatar->format, "/", 2);
      if (splitted[0] != NULL && splitted[1] != NULL)
          ext = g_strdup (splitted[1]);

      g_strfreev (splitted);
    }
  else
    {
      /* Avatar was loaded from the cache so was converted to PNG */
      ext = g_strdup ("png");
    }

  if (ext != NULL)
    {
      gchar *id;

      id = tp_escape_as_identifier (empathy_contact_get_id (
            information->contact));

      filename = g_strdup_printf ("%s.%s", id, ext);
      gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), filename);

      g_free (id);
      g_free (ext);
      g_free (filename);
    }

  if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
    {
      GError *error = NULL;

      filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));

      if (!empathy_avatar_save_to_file (avatar, filename, &error))
        {
          /* Save error */
          GtkWidget *error_dialog;

          error_dialog = gtk_message_dialog_new (NULL, 0,
              GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
              _("Unable to save avatar"));

          gtk_message_dialog_format_secondary_text (
              GTK_MESSAGE_DIALOG (error_dialog), "%s", error->message);

          g_signal_connect (error_dialog, "response",
              G_CALLBACK (gtk_widget_destroy), NULL);

          gtk_window_present (GTK_WINDOW (error_dialog));

          g_clear_error (&error);
        }

      g_free (filename);
    }

  gtk_widget_destroy (dialog);
}
示例#11
0
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);
				return;
			case -3:
				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]),"O");
				gtk_label_set_text(GTK_LABEL(gui->statu[4]),"X");
				gtk_widget_show_all(gui->window);
				return;	
		}
		gtk_label_set_text(GTK_LABEL(gui->statu[2]),"O");
		gtk_label_set_text(GTK_LABEL(gui->statu[3]),"O");
		gtk_label_set_text(GTK_LABEL(gui->statu[4]),"O");
		gtk_widget_show_all(gui->window);
		
		
		n = MAIL_Headr(sockfd,gui->from,gui->to,gui->c_to,gui->cc,gui->c_cc,gui->bcc,gui->c_bcc,gui->subject,gui->c_file);
		if(n==-1){
			close(sockfd);
			printf("Close SimpleMail.\n");
			gtk_label_set_text(GTK_LABEL(gui->statu[5]),"X");
			gtk_widget_show_all(gui->window);
			return;
		}
		gtk_label_set_text(GTK_LABEL(gui->statu[5]),"O");
		gtk_widget_show_all(gui->window);
		
		
		MAIL_body(sockfd,gui->mailbody,gui->c_file);
		Attachment(sockfd,gui->file,gui->c_file);
		gtk_label_set_text(GTK_LABEL(gui->statu[6]),"O");
		
		
		n = EOM(sockfd,gui->c_file);
		if(n==-1){
			close(sockfd);
			printf("Close SimpleMail.\n");
			gtk_label_set_text(GTK_LABEL(gui->statu[7]),"X");
			gtk_widget_show_all(gui->window);
			return;
		}
		gtk_label_set_text(GTK_LABEL(gui->statu[7]),"O");
		gtk_widget_show_all(gui->window);
		
		
		n = QUIT(sockfd);
		if(n==-1){
			close(sockfd);
			printf("Close SimpleMail.\n");
			return;
		}
		
		printf("Send mail.\n");
		close(sockfd);	
	}
	
}
示例#12
0
/*! \brief Create dialog to exchange picture objects
 *  \par Function Description
 *  This function opens a file chooser and replaces all pictures of the selections
 *  with the new picture.
 *
 *  \todo Maybe merge this dialog function with picture_selection_dialog()
 */
void picture_change_filename_dialog (GschemToplevel *w_current)
{
  TOPLEVEL *toplevel = gschem_toplevel_get_toplevel (w_current);
  gchar *filename;
  gboolean result;
  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;

    /* Actually update the pictures */
    result = o_picture_exchange (w_current, filename, &error);

    if (!result) {
      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 replace pictures: %s"),
				       error->message);
      /* Wait for any user response */
      gtk_dialog_run (GTK_DIALOG (dialog));

      g_error_free (error);
      gtk_widget_destroy(dialog);
    } else {
      gschem_toplevel_page_content_changed (w_current, toplevel->page_current);
    }
    g_free (filename);
  }

  i_update_toolbar(w_current);
  if (w_current->pfswindow) {
    gtk_widget_destroy(w_current->pfswindow);
    w_current->pfswindow=NULL;
  }
}
示例#13
0
/*! \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;
  }
}
示例#14
0
  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);
      }
    }

    gtk_widget_destroy(dialog);
    if (gdkParentWindow)
      g_object_unref(gdkParentWindow);

    // Pump gtk+ events to finally hide the dialog from the screen
    while (gtk_events_pending())
      gtk_main_iteration();

    return (res == GTK_RESPONSE_ACCEPT);
  }
示例#15
0
String XojOpenDlg::showOpenDialog(GtkWindow * win, Settings * settings, bool pdf, bool & attachPdf) {

    GtkWidget * dialog = gtk_file_chooser_dialog_new(_("Open file"), win, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                         GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL);

    gtk_file_chooser_set_local_only(GTK_FILE_CHOOSER(dialog), true);

    GtkFileFilter *filterAll = gtk_file_filter_new();
    gtk_file_filter_set_name(filterAll, _("All files"));
    gtk_file_filter_add_pattern(filterAll, "*");

    GtkFileFilter *filterXoj = gtk_file_filter_new();
    gtk_file_filter_set_name(filterXoj, _("Xournal files"));
    gtk_file_filter_add_pattern(filterXoj, "*.xoj");

    GtkFileFilter *filterPdf = gtk_file_filter_new();
    gtk_file_filter_set_name(filterPdf, _("PDF files"));
    gtk_file_filter_add_pattern(filterPdf, "*.pdf");
    gtk_file_filter_add_pattern(filterPdf, "*.PDF");

    GtkFileFilter *filterSupported = gtk_file_filter_new();
    gtk_file_filter_set_name(filterSupported, _("Supported files"));
    gtk_file_filter_add_pattern(filterSupported, "*.xoj");
    gtk_file_filter_add_pattern(filterSupported, "*.pdf");
    gtk_file_filter_add_pattern(filterSupported, "*.PDF");

    if (!pdf) {
        gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filterSupported);
        gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filterXoj);
    }
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filterPdf);
    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filterAll);

    if (!settings->getLastSavePath().isEmpty()) {
        gtk_file_chooser_set_current_folder_uri(GTK_FILE_CHOOSER(dialog), settings->getLastSavePath().c_str());
    }

    GtkWidget * attachOpt = NULL;
    if (pdf) {
        attachOpt = gtk_check_button_new_with_label(_("Attach file to the journal"));
        gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(attachOpt), FALSE);
        gtk_file_chooser_set_extra_widget(GTK_FILE_CHOOSER(dialog), attachOpt);
    }

    GtkWidget * image = gtk_image_new();
    gtk_file_chooser_set_preview_widget(GTK_FILE_CHOOSER(dialog), image);
    g_signal_connect(dialog, "update-preview", G_CALLBACK(updatePreviewCallback), NULL);


    gtk_window_set_transient_for(GTK_WINDOW(dialog), win);
    if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) {
        gtk_widget_destroy(dialog);
        return NULL;
    }
    char * name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));

    if (attachOpt) {
        attachPdf = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(attachOpt));
    }

    String filename = name;
    char * folder = gtk_file_chooser_get_current_folder_uri(GTK_FILE_CHOOSER(dialog));
    settings->setLastSavePath(folder);
    g_free(folder);
    g_free(name);

    gtk_widget_destroy(dialog);

    return filename;
}
示例#16
0
bool RunLinuxDialog()
{
	GtkWidget *dialog;
	GtkWidget *main_box, *central_box, *advance_box, *res_box, *hw_box, *sw_box, *shader_box;
	GtkWidget  *native_box, *fsaa_box, *resxy_box, *renderer_box, *interlace_box, *threads_box, *filter_box;
	GtkWidget *hw_table, *shader_table, *res_frame, *hw_frame, *sw_frame, *shader_frame;
	GtkWidget *interlace_combo_box, *threads_spin;
	GtkWidget *interlace_label, *threads_label, *native_label,  *fsaa_label, *rexy_label, *render_label, *filter_label;

	GtkWidget *fsaa_combo_box, *render_combo_box, *filter_combo_box;
	GtkWidget *shader, *shader_conf, *shader_label, *shader_conf_label;
	GtkWidget *shadeboost_check, *paltex_check, *fba_check, *aa_check,  *native_res_check, *fxaa_check, *shaderfx_check;
	GtkWidget *sb_contrast, *sb_brightness, *sb_saturation;
	GtkWidget *resx_spin, *resy_spin;

	GtkWidget *hack_table, *hack_skipdraw_label, *hack_box, *hack_frame;
	GtkWidget *hack_alpha_check, *hack_date_check, *hack_offset_check, *hack_skipdraw_spin, *hack_msaa_check, *hack_sprite_check, * hack_wild_check, *hack_enble_check, *hack_logz_check;
	GtkWidget *hack_tco_label, *hack_tco_entry;
	GtkWidget *gl_box, *gl_frame, *gl_table;

	GtkWidget *notebook, *page_label[2];

	int return_value;

	GdkPixbuf* logo_pixmap;
	GtkWidget *logo_image;

	/* Create the widgets */
	dialog = gtk_dialog_new_with_buttons (
		"GSdx Config",
		NULL, /* parent window*/
		(GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT),
		"OK", GTK_RESPONSE_ACCEPT,
		"Cancel", GTK_RESPONSE_REJECT,
		NULL);

	// The main area for the whole dialog box.
	main_box = gtk_vbox_new(false, 5);
	central_box = gtk_vbox_new(false, 5);
	advance_box = gtk_vbox_new(false, 5);

	// The Internal resolution frame and container.
	res_box = gtk_vbox_new(false, 5);
	res_frame = gtk_frame_new ("OpenGL Internal Resolution (can cause glitches)");
	gtk_container_add(GTK_CONTAINER(res_frame), res_box);

	// The extra shader setting frame/container/table
	shader_box = gtk_vbox_new(false, 5);
	shader_frame = gtk_frame_new("Custom Shader Settings");
	gtk_container_add(GTK_CONTAINER(shader_frame), shader_box);
	shader_table = gtk_table_new(8,2, false);
	gtk_container_add(GTK_CONTAINER(shader_box), shader_table);

	// The hardware mode frame, container, and table.
	hw_box = gtk_vbox_new(false, 5);
	hw_frame = gtk_frame_new ("Hardware Mode Settings");
	gtk_container_add(GTK_CONTAINER(hw_frame), hw_box);
	hw_table = gtk_table_new(5,2, false);
	gtk_container_add(GTK_CONTAINER(hw_box), hw_table);

	// The software mode frame and container. (It doesn't have enough in it for a table.)
	sw_box = gtk_vbox_new(false, 5);
	sw_frame = gtk_frame_new ("Software Mode Settings");
	gtk_container_add(GTK_CONTAINER(sw_frame), sw_box);

	// The hack frame and container.
	hack_box = gtk_hbox_new(false, 5);
	hack_frame = gtk_frame_new ("Hacks");
	gtk_container_add(GTK_CONTAINER(hack_frame), hack_box);
	hack_table = gtk_table_new(3,3, false);
	gtk_container_add(GTK_CONTAINER(hack_box), hack_table);

	// Grab a logo, to make things look nice.
	logo_pixmap = gdk_pixbuf_from_pixdata(&gsdx_ogl_logo, false, NULL);
	logo_image = gtk_image_new_from_pixbuf(logo_pixmap);
	gtk_box_pack_start(GTK_BOX(main_box), logo_image, true, true, 0);

	// Create the renderer combo box and label, and stash them in a box.
	render_label = gtk_label_new ("Renderer:");
	render_combo_box = CreateRenderComboBox();
	renderer_box = gtk_hbox_new(false, 5);
	// Use gtk_box_pack_start instead of gtk_container_add so it lines up nicely.
	gtk_box_pack_start(GTK_BOX(renderer_box), render_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(renderer_box), render_combo_box, false, false, 5);

	// Create the interlace combo box and label, and stash them in a box.
	interlace_label = gtk_label_new ("Interlacing (F5):");
	interlace_combo_box = CreateInterlaceComboBox();
	interlace_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(interlace_box), interlace_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(interlace_box), interlace_combo_box, false, false, 5);

	// Create the filter combo box.
	filter_label = gtk_label_new ("Texture Filtering:");
	filter_combo_box = CreateFilterComboBox();
	filter_box = gtk_hbox_new(false, 5);
	gtk_box_pack_start(GTK_BOX(filter_box), filter_label, false, false, 5);
	gtk_box_pack_start(GTK_BOX(filter_box), filter_combo_box, false, false, 0);

	// 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);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_tco_label, 0, 1, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(hack_table), hack_tco_entry, 1, 2, 4, 5);

	// Create our checkboxes.
	shadeboost_check = gtk_check_button_new_with_label("Shade boost");
	paltex_check     = gtk_check_button_new_with_label("Allow 8 bits textures");
	fba_check        = gtk_check_button_new_with_label("Alpha correction (FBA)");
	aa_check         = gtk_check_button_new_with_label("Edge anti-aliasing (AA1)");
	fxaa_check       = gtk_check_button_new_with_label("Fxaa shader");
	shaderfx_check   = gtk_check_button_new_with_label("External shader");

	// Set the checkboxes.
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shadeboost_check), theApp.GetConfig("shadeboost", 1));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(paltex_check), theApp.GetConfig("paltex", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fba_check), theApp.GetConfig("fba", 1));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fxaa_check), theApp.GetConfig("fxaa", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shaderfx_check), theApp.GetConfig("shaderfx", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(native_res_check), theApp.GetConfig("nativeres", 0));

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_alpha_check), theApp.GetConfig("UserHacks_AlphaHack", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_offset_check), theApp.GetConfig("UserHacks_HalfPixelOffset", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_date_check), theApp.GetConfig("UserHacks_DateGL4", 0));

	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_enble_check), theApp.GetConfig("UserHacks", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_msaa_check), theApp.GetConfig("UserHacks_MSAA", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_wild_check), theApp.GetConfig("UserHacks_WildHack", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_sprite_check), theApp.GetConfig("UserHacks_SpriteHack", 0));
	gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_logz_check), theApp.GetConfig("logz", 1));

	// Shadeboost scale
#if GTK_MAJOR_VERSION < 3
	sb_brightness = gtk_hscale_new_with_range(0, 200, 10);
#else
	sb_brightness = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 200, 10);
#endif
	GtkWidget* sb_brightness_label = gtk_label_new("Shade Boost Brightness");
	gtk_scale_set_value_pos(GTK_SCALE(sb_brightness), GTK_POS_RIGHT);
	gtk_range_set_value(GTK_RANGE(sb_brightness), theApp.GetConfig("ShadeBoost_Brightness", 50));

#if GTK_MAJOR_VERSION < 3
	sb_contrast = gtk_hscale_new_with_range(0, 200, 10);
#else
	sb_contrast = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 200, 10);
#endif
	GtkWidget* sb_contrast_label = gtk_label_new("Shade Boost Contrast");
	gtk_scale_set_value_pos(GTK_SCALE(sb_contrast), GTK_POS_RIGHT);
	gtk_range_set_value(GTK_RANGE(sb_contrast), theApp.GetConfig("ShadeBoost_Contrast", 50));

#if GTK_MAJOR_VERSION < 3
	sb_saturation = gtk_hscale_new_with_range(0, 200, 10);
#else
	sb_saturation = gtk_scale_new_with_range(GTK_ORIENTATION_HORIZONTAL, 0, 200, 10);
#endif
	GtkWidget* sb_saturation_label = gtk_label_new("Shade Boost Saturation");
	gtk_scale_set_value_pos(GTK_SCALE(sb_saturation), GTK_POS_RIGHT);
	gtk_range_set_value(GTK_RANGE(sb_saturation), theApp.GetConfig("ShadeBoost_Saturation", 50));

	// external shader entry
	gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(shader), theApp.GetConfig("shaderfx_glsl", "dummy.glsl").c_str());
	gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(shader_conf), theApp.GetConfig("shaderfx_conf", "dummy.ini").c_str());

	// Populate all those boxes we created earlier with widgets.
	gtk_container_add(GTK_CONTAINER(res_box), native_box);
	gtk_container_add(GTK_CONTAINER(res_box), fsaa_box);
	gtk_container_add(GTK_CONTAINER(res_box), resxy_box);

	gtk_container_add(GTK_CONTAINER(sw_box), threads_box);
	gtk_container_add(GTK_CONTAINER(sw_box), aa_check);

	// Tables are strange. The numbers are for their position: left, right, top, bottom.
	gtk_table_attach_defaults(GTK_TABLE(shader_table), fxaa_check, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shadeboost_check, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness_label, 0, 1, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness, 1, 2, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast_label, 0, 1, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast, 1, 2, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation_label, 0, 1, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation, 1, 2, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shaderfx_check, 0, 1, 5, 6);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_label, 0, 1, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader, 1, 2, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_conf_label, 0, 1, 7, 8);
	gtk_table_attach_defaults(GTK_TABLE(shader_table), shader_conf, 1, 2, 7, 8);

	// Tables are strange. The numbers are for their position: left, right, top, bottom.
	gtk_table_attach_defaults(GTK_TABLE(hw_table), filter_box, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(hw_table), paltex_check, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(hw_table), fba_check, 1, 2, 1, 2);

	// The GL advance options
	gl_box = gtk_vbox_new(false, 5);
	gl_frame = gtk_frame_new ("OpenGL Very Advanced Custom Settings");
	gtk_container_add(GTK_CONTAINER(gl_frame), gl_box);
	gl_table = gtk_table_new(10, 2, false);
	gtk_container_add(GTK_CONTAINER(gl_box), gl_table);

	GtkWidget* gl_bs_label = gtk_label_new("Buffer Storage:");
	GtkWidget* gl_bs_combo = CreateGlComboBox("override_GL_ARB_buffer_storage");
	GtkWidget* gl_bt_label = gtk_label_new("Bindless Texture:");
	GtkWidget* gl_bt_combo = CreateGlComboBox("override_GL_ARB_bindless_texture");
	GtkWidget* gl_sso_label = gtk_label_new("Separate Shader:");
	GtkWidget* gl_sso_combo = CreateGlComboBox("override_GL_ARB_separate_shader_objects");
	GtkWidget* gl_ss_label = gtk_label_new("Shader Subroutine:");
	GtkWidget* gl_ss_combo = CreateGlComboBox("override_GL_ARB_shader_subroutine");
	GtkWidget* gl_gs_label = gtk_label_new("Geometry Shader:");
	GtkWidget* gl_gs_combo = CreateGlComboBox("override_geometry_shader");
	GtkWidget* gl_ils_label = gtk_label_new("Image Load Store:");
	GtkWidget* gl_ils_combo = CreateGlComboBox("override_GL_ARB_shader_image_load_store");
	GtkWidget* gl_cc_label = gtk_label_new("Clip Control (depth accuracy):");
	GtkWidget* gl_cc_combo = CreateGlComboBox("override_GL_ARB_clip_control");
	GtkWidget* gl_ct_label = gtk_label_new("Clear Texture:");
	GtkWidget* gl_ct_combo = CreateGlComboBox("override_GL_ARB_clear_texture");

	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_gs_label, 0, 1, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_gs_combo, 1, 2, 0, 1);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bs_label, 0, 1, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bs_combo, 1, 2, 1, 2);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bt_label, 0, 1, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_bt_combo, 1, 2, 2, 3);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_sso_label, 0, 1, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_sso_combo, 1, 2, 3, 4);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ss_label, 0, 1, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ss_combo, 1, 2, 4, 5);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ils_label, 0, 1, 5, 6);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ils_combo, 1, 2, 5, 6);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_cc_label, 0, 1, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_cc_combo, 1, 2, 6, 7);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ct_label, 0, 1, 7, 8);
	gtk_table_attach_defaults(GTK_TABLE(gl_table), gl_ct_combo, 1, 2, 7, 8);
	// those one are properly detected so no need a gui
#if 0
override_GL_ARB_copy_image = -1
override_GL_ARB_explicit_uniform_location = -1
override_GL_ARB_gpu_shader5 = -1
override_GL_ARB_shading_language_420pack = -1
#endif

	// Handle some nice tab
	notebook = gtk_notebook_new();
	page_label[0] = gtk_label_new("Global Setting");
	page_label[1] = gtk_label_new("Advance Setting");

	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), central_box, page_label[0]);
	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), advance_box, page_label[1]);

	// Put everything in the big box.
	gtk_container_add(GTK_CONTAINER(main_box), renderer_box);
	gtk_container_add(GTK_CONTAINER(main_box), interlace_box);
	gtk_container_add(GTK_CONTAINER(main_box), notebook);

	gtk_container_add(GTK_CONTAINER(central_box), res_frame);
	gtk_container_add(GTK_CONTAINER(central_box), shader_frame);
	gtk_container_add(GTK_CONTAINER(central_box), hw_frame);
	gtk_container_add(GTK_CONTAINER(central_box), sw_frame);

	gtk_container_add(GTK_CONTAINER(advance_box), hack_frame);
	gtk_container_add(GTK_CONTAINER(advance_box), gl_frame);

	// Put the box in the dialog and show it to the world.
	gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box);
	gtk_widget_show_all (dialog);
	return_value = gtk_dialog_run (GTK_DIALOG (dialog));

	if (return_value == GTK_RESPONSE_ACCEPT)
	{
		int mode_height = 0, mode_width = 0;

		mode_width = theApp.GetConfig("ModeWidth", 640);
		mode_height = theApp.GetConfig("ModeHeight", 480);
		theApp.SetConfig("ModeHeight", mode_height);
		theApp.SetConfig("ModeWidth", mode_width);

		// Get all the settings from the dialog box.
		if (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box)) != -1) {
			// Note the value are based on m_gs_renderers vector on GSdx.cpp
			switch (gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box))) {
				case 0: theApp.SetConfig("renderer", 10); break;
				case 1: theApp.SetConfig("renderer", 16); break;
				case 2: theApp.SetConfig("renderer", 11); break;
				case 3: theApp.SetConfig("renderer", 12); break;
				case 4: theApp.SetConfig("renderer", 13); break;
				case 5: theApp.SetConfig("renderer", 17); break;

				// Fallback to SW opengl
				default: theApp.SetConfig("renderer", 13); break;
			}
		}

		if (gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)) != -1)
			theApp.SetConfig( "interlace", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(interlace_combo_box)));

		theApp.SetConfig("extrathreads", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(threads_spin)));

		theApp.SetConfig("filter", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(filter_combo_box)));
		theApp.SetConfig("shadeboost", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shadeboost_check)));
		theApp.SetConfig("paltex", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(paltex_check)));
		theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check)));
		theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check)));
		theApp.SetConfig("fxaa", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fxaa_check)));
		theApp.SetConfig("shaderfx", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(shaderfx_check)));
		theApp.SetConfig("nativeres", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check)));

		theApp.SetConfig("shaderfx_glsl", gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(shader)));
		theApp.SetConfig("shaderfx_conf", gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(shader_conf)));

		theApp.SetConfig("ShadeBoost_Saturation", (int)gtk_range_get_value(GTK_RANGE(sb_saturation)));
		theApp.SetConfig("ShadeBoost_Brightness", (int)gtk_range_get_value(GTK_RANGE(sb_brightness)));
		theApp.SetConfig("ShadeBoost_Contrast", (int)gtk_range_get_value(GTK_RANGE(sb_contrast)));

		theApp.SetConfig("upscale_multiplier", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(fsaa_combo_box))+1);
		theApp.SetConfig("resx", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resx_spin)));
		theApp.SetConfig("resy", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resy_spin)));

		theApp.SetConfig("UserHacks_SkipDraw", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(hack_skipdraw_spin)));
		theApp.SetConfig("UserHacks_HalfPixelOffset", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_offset_check)));
		theApp.SetConfig("UserHacks_AlphaHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_alpha_check)));
		theApp.SetConfig("logz", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_logz_check)));
		theApp.SetConfig("UserHacks_DateGL4", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_date_check)));

		theApp.SetConfig("UserHacks_MSAA", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_msaa_check)));
		theApp.SetConfig("UserHacks_WildHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_wild_check)));
		theApp.SetConfig("UserHacks_SpriteHack", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_sprite_check)));
		theApp.SetConfig("UserHacks", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_enble_check)));
		theApp.SetConfig("UserHacks_TCOffset", get_hex_entry(hack_tco_entry));

		theApp.SetConfig("override_GL_ARB_clear_texture", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ct_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_bindless_texture", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_bt_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_buffer_storage", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_bs_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_separate_shader_objects", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_sso_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_shader_subroutine", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ss_combo)) - 1);
		theApp.SetConfig("override_geometry_shader", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_gs_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_shader_image_load_store", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_ils_combo)) - 1);
		theApp.SetConfig("override_GL_ARB_clip_control", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(gl_cc_combo)) - 1);

		// NOT supported yet
		theApp.SetConfig("msaa", 0);

		// Let's just be windowed for the moment.
		theApp.SetConfig("windowed", 1);

		gtk_widget_destroy (dialog);

		return true;
	}

	gtk_widget_destroy (dialog);

	return false;
}
void CB_PickFile(GtkFileChooserButton *chooser, gpointer user_data)
{
	theApp.SetConfig((char*)user_data, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(chooser)));
}
示例#18
0
//================================================================
  int GUI_Dialog_run (char *dnam, int dnSiz, char *fnam, int fnSiz,
                      GtkWidget *gtkDlg) {
//================================================================
// GUI_Dialog_run         INTERNAL for gtk_dialog_run
  // start waiting; does not return until user clicks button.

  int   i1, iRes;
  char  *p1, *filename;


  iRes = gtk_dialog_run (GTK_DIALOG(gtkDlg));         // wait (modal) !
    printf(" iRes=%d\n",iRes);  // -6=cancel, -3=ACCEPT


  if (iRes == GTK_RESPONSE_ACCEPT) {
    filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (gtkDlg));
    if(!filename) filename =
      gtk_file_chooser_get_preview_filename (GTK_FILE_CHOOSER (gtkDlg));
        printf(" GTK_RESPONSE_ACCEPT |%s|\n",filename);

    if(!filename) {
      TX_Print ("**** ERROR GUI_Dialog_run ****");
      iRes = -3;
      goto L_exit;
    }

  // find p1 = last delimiter
#ifdef _MSC_VER
    p1 = strrchr(filename, '\\');
#else
    p1 = strrchr(filename, '/');
#endif

    // copy out directory
    if(p1) {
      i1 = p1 - filename;
      if(i1 >= dnSiz) {iRes = -2; goto L_exit; }
        // printf(" i1=%d\n",i1);
      strncpy(dnam, filename, i1);
      dnam[i1] = '\0';
    } else {
      // no '/' in filename
      TX_Print ("**** ERROR GUI_Dialog_run - E001 ****");
      iRes = -3;
      goto L_exit;
    }


    // copy out filename
    ++p1;
    if(strlen(p1) >= fnSiz) {iRes = -2; goto L_exit; }
    strcpy(fnam, p1);
    g_free (filename);
    iRes = 0;

  } else {
    iRes = -1;
  }


  L_exit:
  if(gtkDlg) {    // not yet killed from DIR-SYM
    gtk_widget_destroy (gtkDlg);
    gtkDlg = NULL;                 // 2013-05-13
  }

  return iRes;

}
示例#19
0
GThread *tsh_move (gchar **files, svn_client_ctx_t *ctx, apr_pool_t *pool)
{
	struct thread_args *args;
  GtkWidget *dialog;
  gchar *from;
  gchar *to;
  gboolean isdir = TRUE;
  gchar *absolute = NULL;
  DIR *dir;
  FILE *fp;

	from = files?files[0]:"";

  if(!g_path_is_absolute (from))
  {
    //TODO: ".."
    gchar *currdir = g_get_current_dir();
    absolute = g_build_filename(currdir, (from[0] == '.' && (!from[1] || from[1] == G_DIR_SEPARATOR || from[1] == '/'))?&from[1]:from, NULL);
    g_free (currdir);
  }
  dir = opendir(absolute?absolute:from);
  if(dir)
    closedir(dir);
  else if((fp = fopen(absolute?absolute:from, "r")))
  {
    fclose(fp);
    isdir = FALSE;
  }

  dialog = gtk_file_chooser_dialog_new (_("Move To"), NULL,
                               /*isdir?GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER:*/GTK_FILE_CHOOSER_ACTION_SAVE,
                               _("_Cancel"), GTK_RESPONSE_CANCEL,
                               _("_OK"), GTK_RESPONSE_OK,
                               NULL);

  gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), isdir?(absolute?absolute:from):g_path_get_dirname(absolute?absolute:from));

  g_free (absolute);

	if(gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK)
  {
    gtk_widget_destroy (dialog);
    return NULL;
  }

  to = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));

	gtk_widget_destroy (dialog);

  dialog = tsh_notify_dialog_new(_("Move"), NULL, 0);
	g_signal_connect (dialog, "cancel-clicked", tsh_cancel, NULL);
  tsh_dialog_start(GTK_DIALOG(dialog), TRUE);

	ctx->notify_func2 = tsh_notify_func2;
	ctx->notify_baton2 = dialog;

	args = g_malloc (sizeof (struct thread_args));
	args->ctx = ctx;
	args->pool = pool;
  args->dialog = TSH_NOTIFY_DIALOG (dialog);
	args->from = from;
	args->to = to;

	return g_thread_new (NULL, move_thread, args);
}
示例#20
0
static void gfire_game_manager_add_cb(GtkBuilder *p_builder, GtkWidget *p_button)
{
	if(!p_builder)
	{
		purple_debug_error("gfire", "Couldn't access game manager interface.\n");
		return;
	}

	GtkWidget *add_game_entry = GTK_WIDGET(gtk_builder_get_object(p_builder, "add_game_entry"));
	GtkWidget *add_detection_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "add_detection_button"));
	GtkWidget *add_executable_check_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "add_executable_check_button"));
	GtkWidget *add_launch_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "add_launch_button"));

	GtkWidget *add_prefix_entry = GTK_WIDGET(gtk_builder_get_object(p_builder, "add_prefix_entry"));

	const gchar *game_name = gtk_entry_get_text(GTK_ENTRY(add_game_entry));
	gchar *game_detect = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(add_detection_button));
	gboolean game_launch_use_detect = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(add_executable_check_button));
	gchar *game_launch = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(add_launch_button));

	const gchar *game_prefix = gtk_entry_get_text(GTK_ENTRY(add_prefix_entry));

	if (game_name && game_detect && ((!game_launch_use_detect && game_launch) || game_launch_use_detect))
	{
		guint32 game_id;

		game_id = gfire_game_id(game_name);

		if(game_id == 0)
		{
			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_ERROR, _("Manage Games: error"), _("Couldn't add game"),
							  _("There's no such game, please try again."), NULL, NULL);
			g_free(game_detect);
			g_free(game_launch);
			return;
		}

		if(!gfire_game_config_by_id(game_id))
		{
#ifndef _WIN32
			gchar real_game_detect[PATH_MAX];
			realpath(game_detect, real_game_detect);
#else
			gchar *real_game_detect = game_detect;
#endif // _WIN32

			gfire_game_configuration *gconf = gfire_game_configuration_create(game_id, real_game_detect,
																			  game_launch_use_detect ? real_game_detect :
																			  game_launch, game_prefix);

			gfire_games_config = g_list_append(gfire_games_config, gconf);
			gfire_game_config_sort();
			gfire_game_save_config_xml();

			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("Manage Games: game added"),
							  game_name, _("The game has been successfully added."), NULL, NULL);
		}
		else
		{
			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("Manage Games: warning"), _("Game already added"),
						  _("This game is already added, you can configure it if you want."), NULL, NULL);

			g_free(game_launch);
			g_free(game_detect);

			return;
		}

		g_free(game_launch);
		g_free(game_detect);
	}
	else
	{
		purple_notify_message(NULL, PURPLE_NOTIFY_MSG_ERROR, _("Manage Games: error"),
					  _("Couldn't add game"), _("Please try again. Make sure you fill in all fields."), NULL, NULL);
		return;
	}

	gfire_game_manager_reload_ui(p_builder);
}
示例#21
0
static void
fill_connection (EAPMethod *parent, NMConnection *connection)
{
	EAPMethodTLS *method = (EAPMethodTLS *) parent;
	NMSetting8021xCKType key_type = NM_SETTING_802_1X_CK_TYPE_UNKNOWN;
	NMSetting8021x *s_8021x;
	GtkWidget *widget;
	char *filename, *pk_filename, *cc_filename;
	char *password = NULL;
	GError *error = NULL;

	s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
	g_assert (s_8021x);

	if (method->phase2)
		g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, "tls", NULL);
	else
		nm_setting_802_1x_add_eap_method (s_8021x, "tls");

	widget = glade_xml_get_widget (parent->xml, "eap_tls_identity_entry");
	g_assert (widget);
	g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (GTK_ENTRY (widget)), NULL);

	widget = glade_xml_get_widget (parent->xml, "eap_tls_private_key_password_entry");
	g_assert (widget);
	password = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
	if (method->phase2) {
		g_object_set_data_full (G_OBJECT (connection),
		                        NMA_PHASE2_PRIVATE_KEY_PASSWORD_TAG,
		                        password,
		                        (GDestroyNotify) free_password);
	} else {
		g_object_set_data_full (G_OBJECT (connection),
		                        NMA_PRIVATE_KEY_PASSWORD_TAG,
		                        password,
		                        (GDestroyNotify) free_password);
	}

	/* TLS private key */
	widget = glade_xml_get_widget (parent->xml, "eap_tls_private_key_button");
	g_assert (widget);
	pk_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
	g_assert (pk_filename);
	g_object_set_data_full (G_OBJECT (connection),
	                        method->phase2 ? NMA_PATH_PHASE2_PRIVATE_KEY_TAG : NMA_PATH_PRIVATE_KEY_TAG,
	                        g_strdup (pk_filename),
	                        (GDestroyNotify) g_free);
	if (method->phase2) {
		if (!nm_setting_802_1x_set_phase2_private_key_from_file (s_8021x, pk_filename, password, &key_type, &error)) {
			g_warning ("Couldn't read phase2 private key '%s': %s", pk_filename, error ? error->message : "(unknown)");
			g_clear_error (&error);
		}
	} else {
		if (!nm_setting_802_1x_set_private_key_from_file (s_8021x, pk_filename, password, &key_type, &error)) {
			g_warning ("Couldn't read private key '%s': %s", pk_filename, error ? error->message : "(unknown)");
			g_clear_error (&error);
		}
	}

	/* TLS client certificate */
	if (key_type == NM_SETTING_802_1X_CK_TYPE_PKCS12) {
		/* if the key is pkcs#12, the cert is filled with the same data */
		cc_filename = g_strdup (pk_filename);
	} else {
		widget = glade_xml_get_widget (parent->xml, "eap_tls_user_cert_button");
		g_assert (widget);
		cc_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
	}

	g_assert (cc_filename);
	g_object_set_data_full (G_OBJECT (connection),
	                        method->phase2 ? NMA_PATH_PHASE2_CLIENT_CERT_TAG : NMA_PATH_CLIENT_CERT_TAG,
	                        g_strdup (cc_filename),
	                        (GDestroyNotify) g_free);
	g_free (cc_filename);
	g_free (pk_filename);

	/* TLS CA certificate */
	widget = glade_xml_get_widget (parent->xml, "eap_tls_ca_cert_button");
	g_assert (widget);
	filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
	if (filename) {
		g_object_set_data_full (G_OBJECT (connection),
		                        method->phase2 ? NMA_PATH_PHASE2_CA_CERT_TAG : NMA_PATH_CA_CERT_TAG,
		                        g_strdup (filename),
		                        (GDestroyNotify) g_free);
		g_free (filename);
	} else {
		g_object_set_data (G_OBJECT (connection),
		                   method->phase2 ? NMA_PATH_PHASE2_CA_CERT_TAG : NMA_PATH_CA_CERT_TAG,
		                   NULL);
	}

	if (eap_method_get_ignore_ca_cert (parent)) {
		g_object_set_data (G_OBJECT (connection),
		                   method->phase2 ? NMA_PHASE2_CA_CERT_IGNORE_TAG : NMA_CA_CERT_IGNORE_TAG,
		                   GUINT_TO_POINTER (TRUE));
	} else {
		g_object_set_data (G_OBJECT (connection),
		                   method->phase2 ? NMA_PHASE2_CA_CERT_IGNORE_TAG : NMA_CA_CERT_IGNORE_TAG,
		                   NULL);
	}
}
示例#22
0
static void gfire_game_manager_edit_cb(GtkBuilder *p_builder, GtkWidget *p_button)
{

	if (!p_builder)
	{
		purple_debug_error("gfire", "Couldn't access game manager interface.\n");
		return;
	}

	GtkWidget *edit_game_combo = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_game_combo"));
	GtkWidget *edit_detection_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_detection_button"));
	GtkWidget *edit_executable_check_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_executable_check_button"));
	GtkWidget *edit_launch_button = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_launch_button"));
	GtkWidget *edit_prefix_entry = GTK_WIDGET(gtk_builder_get_object(p_builder, "edit_prefix_entry"));

	gchar *game_name = gtk_combo_box_get_active_text(GTK_COMBO_BOX(edit_game_combo));
	gchar *game_detect = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(edit_detection_button));
	gboolean game_launch_use_detect = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(edit_executable_check_button));
	gchar *game_launch = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(edit_launch_button));

	const gchar *game_prefix = gtk_entry_get_text(GTK_ENTRY(edit_prefix_entry));

	if (game_name && game_detect && ((!game_launch_use_detect && game_launch) || game_launch_use_detect))
	{
		guint32 game_id;

		game_id = gfire_game_id(game_name);

		gfire_game_configuration *gconf = (gfire_game_configuration*)gfire_game_config_by_id(game_id);

		if (gconf)
		{
#ifndef _WIN32
			gchar real_game_detect[PATH_MAX];
			realpath(game_detect, real_game_detect);
#else
			gchar *real_game_detect = game_detect;
#endif // _WIN32

			if(gconf->detect_file)
				g_free(gconf->detect_file);

			gconf->detect_file = g_strdup(real_game_detect);

			if(gconf->launch_file)
				g_free(gconf->launch_file);

			gconf->launch_file = g_strdup(game_launch_use_detect ? real_game_detect : game_launch);

			if(gconf->launch_prefix)
				g_free(gconf->launch_prefix);

			gconf->launch_prefix = g_strdup(game_prefix);
		}
		else
		{
			purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("Manage Games: warning"), _("Game launch data not found"),
						  _("This game is not yet added as it seems, please add it first!"), NULL, NULL);
			g_free(game_launch);
			g_free(game_detect);
			g_free(game_name);

			return;
		}

		g_free(game_launch);
		g_free(game_detect);
		g_free(game_name);

		gfire_game_save_config_xml();

		purple_notify_message(NULL, PURPLE_NOTIFY_MSG_INFO, _("Manage Games: game edited"), _("Game edited"), _("The game has been successfully edited."), NULL, NULL);
	}
	else
	{
		purple_notify_message(NULL, PURPLE_NOTIFY_MSG_ERROR, _("Manage Games: error"),
					  _("Couldn't edit game"), _("Please try again. Make sure you fill in all fields."), NULL, NULL);
		return;
	}

	gfire_game_manager_reload_ui(p_builder);
}
示例#23
0
static void apply_conf (GtkWidget *w, ddb_dialog_t *conf) {
    // parse script
    char token[MAX_TOKEN];
    const char *script = conf->layout;
    parser_line = 1;
    while (script = gettoken (script, token)) {
        if (strcmp (token, "property")) {
            fprintf (stderr, "invalid token while loading plugin %s config dialog: %s at line %d\n", conf->title, token, parser_line);
            break;
        }
        char labeltext[MAX_TOKEN];
        script = gettoken_warn_eof (script, labeltext);
        if (!script) {
            break;
        }
        char type[MAX_TOKEN];
        script = gettoken_warn_eof (script, type);
        if (!script) {
            break;
        }

        // skip containers
        if (!strncmp (type, "hbox[", 5) || !strncmp (type, "vbox[", 5)) {
            // skip to ;
            char semicolon[MAX_TOKEN];
            while (script = gettoken_warn_eof (script, semicolon)) {
                if (!strcmp (semicolon, ";")) {
                    break;
                }
            }
            continue;
        }

        // ignore layout options
        char key[MAX_TOKEN];
        const char *skiptokens[] = { "vert", NULL };
        for (;;) {
            script = gettoken_warn_eof (script, key);
            int i = 0;
            for (i = 0; skiptokens[i]; i++) {
                if (!strcmp (key, skiptokens[i])) {
                    break;
                }
            }
            if (!skiptokens[i]) {
                break;
            }
        }
        if (!script) {
            break;
        }
        char def[MAX_TOKEN];
        script = gettoken_warn_eof (script, def);
        if (!script) {
            break;
        }

        // fetch data
        GtkWidget *widget = lookup_widget (w, key);
        if (widget) {
            if (!strcmp (type, "entry") || !strcmp (type, "password")) {
                conf->set_param (key, gtk_entry_get_text (GTK_ENTRY (widget)));
            }
            else if (!strcmp (type, "file")) {
                if (deadbeef->conf_get_int ("gtkui.pluginconf.use_filechooser_button", 0)) {
                    // filechooser
                    conf->set_param (key, gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget)));
                }
                else {
                    conf->set_param (key, gtk_entry_get_text (GTK_ENTRY (widget)));
                }
            }
            else if (!strcmp (type, "checkbox")) {
                conf->set_param (key, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)) ? "1" : "0");
            }
            else if (!strncmp (type, "hscale[", 7) || !strncmp (type, "vscale[", 7)) {
                char s[20];
                snprintf (s, sizeof (s), "%f", gtk_range_get_value (GTK_RANGE (widget)));
                conf->set_param (key, s);
            }
            else if (!strncmp (type, "spinbtn[", 8)) {
                char s[20];
                snprintf (s, sizeof (s), "%f", (float)gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget)));
                conf->set_param (key, s);
            }
            else if (!strncmp (type, "select[", 7)) {
                int n;
                if (1 != sscanf (type+6, "[%d]", &n)) {
                    break;
                }
                for (int i = 0; i < n; i++) {
                    char value[MAX_TOKEN];
                    script = gettoken_warn_eof (script, value);
                    if (!script) {
                        break;
                    }
                }
                if (!script) {
                    break;
                }
                char s[20];
                snprintf (s, sizeof (s), "%d", gtk_combo_box_get_active (GTK_COMBO_BOX (widget)));
                conf->set_param (key, s);
            }
        }

        script = gettoken_warn_eof (script, token);
        if (!script) {
            break;
        }
        if (strcmp (token, ";")) {
            fprintf (stderr, "expected `;' while loading plugin %s config dialog: %s at line %d\n", conf->title, token, parser_line);
            break;
        }
    }
    deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0);
}
示例#24
0
static void gfire_game_manager_update_executable_cb(GtkWidget *p_launch_button, GtkWidget *p_detect_button)
{
	gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(p_launch_button), gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(p_detect_button)));
}
示例#25
0
static void
fill_connection (EAPMethod *parent, NMConnection *connection)
{
	EAPMethodTLS *method = (EAPMethodTLS *) parent;
	NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
	NMSetting8021x *s_8021x;
	NMSettingConnection *s_con;
	GtkWidget *widget;
	char *ca_filename, *pk_filename, *cc_filename;
	const char *password = NULL;
	GError *error = NULL;

	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
	g_assert (s_con);

	s_8021x = NM_SETTING_802_1X (nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X));
	g_assert (s_8021x);

	if (method->phase2)
		g_object_set (s_8021x, NM_SETTING_802_1X_PHASE2_AUTH, "tls", NULL);
	else
		nm_setting_802_1x_add_eap_method (s_8021x, "tls");

	widget = glade_xml_get_widget (parent->xml, "eap_tls_identity_entry");
	g_assert (widget);
	g_object_set (s_8021x, NM_SETTING_802_1X_IDENTITY, gtk_entry_get_text (GTK_ENTRY (widget)), NULL);

	/* TLS private key */
	widget = glade_xml_get_widget (parent->xml, "eap_tls_private_key_password_entry");
	g_assert (widget);
	password = gtk_entry_get_text (GTK_ENTRY (widget));
	g_assert (password);

	widget = glade_xml_get_widget (parent->xml, "eap_tls_private_key_button");
	g_assert (widget);
	pk_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
	g_assert (pk_filename);

	if (method->phase2) {
		if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, pk_filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
			g_warning ("Couldn't read phase2 private key '%s': %s", pk_filename, error ? error->message : "(unknown)");
			g_clear_error (&error);
		}
	} else {
		if (!nm_setting_802_1x_set_private_key (s_8021x, pk_filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
			g_warning ("Couldn't read private key '%s': %s", pk_filename, error ? error->message : "(unknown)");
			g_clear_error (&error);
		}
	}
	g_free (pk_filename);

	/* TLS client certificate */
	if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) {
		/* If the key is pkcs#12 nm_setting_802_1x_set_private_key() already
		 * set the client certificate for us.
		 */
		widget = glade_xml_get_widget (parent->xml, "eap_tls_user_cert_button");
		g_assert (widget);
		cc_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
		g_assert (cc_filename);

		format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
		if (method->phase2) {
			if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, cc_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
				g_warning ("Couldn't read phase2 client certificate '%s': %s", cc_filename, error ? error->message : "(unknown)");
				g_clear_error (&error);
			}
		} else {
			if (!nm_setting_802_1x_set_client_cert (s_8021x, cc_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
				g_warning ("Couldn't read client certificate '%s': %s", cc_filename, error ? error->message : "(unknown)");
				g_clear_error (&error);
			}
		}
		g_free (cc_filename);
	}

	/* TLS CA certificate */
	widget = glade_xml_get_widget (parent->xml, "eap_tls_ca_cert_button");
	g_assert (widget);
	ca_filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));

	format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
	if (method->phase2) {
		if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x, ca_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
			g_warning ("Couldn't read phase2 CA certificate '%s': %s", ca_filename, error ? error->message : "(unknown)");
			g_clear_error (&error);
		}
	} else {
		if (!nm_setting_802_1x_set_ca_cert (s_8021x, ca_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
			g_warning ("Couldn't read CA certificate '%s': %s", ca_filename, error ? error->message : "(unknown)");
			g_clear_error (&error);
		}
	}

	nm_gconf_set_ignore_ca_cert (nm_setting_connection_get_uuid (s_con),
	                             method->phase2,
	                             eap_method_get_ignore_ca_cert (parent));
}
Php::Value GtkFileChooserDialog_::get_filename()
{
	std::string ret = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER(instance));

	return ret;
}
示例#27
0
void send_raw_file(GtkAction *action, gpointer data)
{
	GtkWidget *file_select;

	file_select = gtk_file_chooser_dialog_new(_("Send RAW File"),
	                                          GTK_WINDOW(Fenetre), 
	                                          GTK_FILE_CHOOSER_ACTION_OPEN, 
	                                          GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
	                                          GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
	                                          NULL);

	if(fic_defaut != NULL)
		gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(file_select), fic_defaut);

	if(gtk_dialog_run(GTK_DIALOG(file_select)) == GTK_RESPONSE_ACCEPT)
	{
		gchar *fileName;
		gchar *msg;

		fileName = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(file_select));

		if(!g_file_test(fileName, G_FILE_TEST_IS_REGULAR))
		{
			msg = g_strdup_printf(_("Error opening file\n"));
			show_message(msg, MSG_ERR);
			g_free(msg);
			g_free(fileName);
			gtk_widget_destroy(file_select);
			return;
		}

		Fichier = open(fileName, O_RDONLY);
		if(Fichier != -1)
		{
			GtkWidget *Bouton_annuler, *Box;

			fic_defaut = g_strdup(fileName);
			msg = g_strdup_printf(_("%s : transfer in progress..."), fileName);

			gtk_statusbar_push(GTK_STATUSBAR(StatusBar), id, msg);
			car_written = 0;
			current_buffer_position = 0;
			bytes_read = 0;
			nb_car = lseek(Fichier, 0L, SEEK_END);
			lseek(Fichier, 0L, SEEK_SET);

			Window = gtk_dialog_new();
			gtk_window_set_title(GTK_WINDOW(Window), msg);
			g_free(msg);
			Box = gtk_vbox_new(TRUE, 10);
			gtk_container_add(GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(Window))), Box);
			ProgressBar = gtk_progress_bar_new();

			gtk_box_pack_start(GTK_BOX(Box), ProgressBar, FALSE, FALSE, 5);

			Bouton_annuler = gtk_button_new_with_label(_("Cancel"));
			g_signal_connect(GTK_OBJECT(Bouton_annuler), "clicked", G_CALLBACK(close_all), NULL);

			gtk_container_add(GTK_CONTAINER(gtk_dialog_get_action_area(GTK_DIALOG(Window))), Bouton_annuler);

			g_signal_connect(GTK_OBJECT(Window), "delete_event", G_CALLBACK(close_all), NULL);

			gtk_window_set_default_size(GTK_WINDOW(Window), 250, 100);
			gtk_window_set_modal(GTK_WINDOW(Window), TRUE);
			gtk_widget_show_all(Window);

			add_input();
		}
		else
		{
			msg = g_strdup_printf(_("Cannot read file %s: %s\n"), fileName, strerror(errno));
			show_message(msg, MSG_ERR);
			g_free(msg);
		}
		g_free(fileName);
	}
	gtk_widget_destroy(file_select);
}
示例#28
0
static gboolean
update_connection (NMVpnPluginUiWidgetInterface *iface,
				   NMConnection *connection,
				   GError **error)
{
	StrongswanPluginUiWidget *self = STRONGSWAN_PLUGIN_UI_WIDGET (iface);
	StrongswanPluginUiWidgetPrivate *priv = STRONGSWAN_PLUGIN_UI_WIDGET_GET_PRIVATE (self);
	NMSettingVPN *settings;
	GtkWidget *widget;
	gboolean active;
	char *str;

	if (!check_validity (self, error))
		return FALSE;
	settings = NM_SETTING_VPN (nm_setting_vpn_new ());

	g_object_set (settings, NM_SETTING_VPN_SERVICE_TYPE,
				  NM_DBUS_SERVICE_STRONGSWAN, NULL);

	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "address-entry"));
	str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
	if (str && strlen (str)) {
		nm_setting_vpn_add_data_item (settings, "address", str);
	}

	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "certificate-button"));
	str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
	if (str) {
		nm_setting_vpn_add_data_item (settings, "certificate", str);
	}

	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "method-combo"));
	switch (gtk_combo_box_get_active (GTK_COMBO_BOX (widget)))
	{
		default:
		case 0:
			widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "userkey-button"));
			str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
			if (str) {
				nm_setting_vpn_add_data_item (settings, "userkey", str);
			}
			widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-button"));
			str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
			if (str) {
				nm_setting_vpn_add_data_item (settings, "usercert", str);
			}
			str = "key";
			break;
		case 1:
			widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "usercert-button"));
			str = (char *) gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
			if (str) {
				nm_setting_vpn_add_data_item (settings, "usercert", str);
			}
			str = "agent";
			break;
		case 2:
			str = "smartcard";
			break;
		case 3:
			widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-entry"));
			str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
			if (str && strlen (str)) {
				nm_setting_vpn_add_data_item (settings, "user", str);
			}
			str = "eap";
			break;
		case 4:
			widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "user-entry"));
			str = (char *) gtk_entry_get_text (GTK_ENTRY (widget));
			if (str && strlen (str)) {
				nm_setting_vpn_add_data_item (settings, "user", str);
			}
			str = "psk";
			break;
	}
	nm_setting_vpn_add_data_item (settings, "method", str);

	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "virtual-check"));
	active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
	nm_setting_vpn_add_data_item (settings, "virtual", active ? "yes" : "no");

	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "encap-check"));
	active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
	nm_setting_vpn_add_data_item (settings, "encap", active ? "yes" : "no");

	widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "ipcomp-check"));
	active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
	nm_setting_vpn_add_data_item (settings, "ipcomp", active ? "yes" : "no");

	nm_setting_set_secret_flags (NM_SETTING (settings), "password",
								 NM_SETTING_SECRET_FLAG_AGENT_OWNED, NULL);

	nm_connection_add_setting (connection, NM_SETTING (settings));
	return TRUE;
}
示例#29
0
文件: gui.c 项目: shareef12/spoon
void update_outDir() {
    char *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(outDir_chooser));
    gtk_entry_set_text(GTK_ENTRY(outDir_entry), filename);
}
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);
}