Exemplo n.º 1
0
static WidgetInfo *
create_path_editor (void)
{
  GtkWidget *vbox;
  GtkWidget *editor;
  GtkWidget *align;
  gchar     *config = gimp_config_build_data_path ("patterns");
  gchar     *path   = gimp_config_path_expand (config, TRUE, NULL);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  align = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
  editor = gimp_path_editor_new ("Path Editor", path);
  gtk_widget_set_size_request (editor, -1, 240);
  gtk_container_add (GTK_CONTAINER (align), editor);
  gtk_box_pack_start (GTK_BOX (vbox), align, TRUE, TRUE, 0);
  gtk_box_pack_start (GTK_BOX (vbox),
                      gtk_label_new ("Path Editor"), FALSE, FALSE, 0);

  g_free (path);
  g_free (config);

  return new_widget_info ("gimp-widget-path-editor", vbox, ASIS);
}
Exemplo n.º 2
0
static gboolean
fontsel_directories_dialog (GtkWidget    *parent,
                            const gchar  *message,
			    gchar       **path)
{
  GtkWidget *dialog;
  GtkWidget *path_editor;
  GtkWidget *label;
  gchar     *new_path = NULL;

  dialog = gimp_dialog_new (_("Configure Font Search Path"), "font-path",
                            parent,
                            GTK_DIALOG_DESTROY_WITH_PARENT,
                            gimp_standard_help_func, "plug-in-freetype",

			    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
			    GTK_STOCK_OK,     GTK_RESPONSE_OK,

			    NULL);

  if (message)
    {
      label = gtk_label_new (message);
      gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
      gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
      gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
      gtk_misc_set_padding (GTK_MISC (label), 12, 12);
      gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
			  label, FALSE, FALSE, 0);
    }

  path_editor = gimp_path_editor_new (_("Choose a folder"), *path);
  gtk_container_set_border_width (GTK_CONTAINER (path_editor), 12);
  gtk_widget_set_usize (GTK_WIDGET (path_editor), -1, 240);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
		      path_editor, TRUE, TRUE, 0);

  label = gtk_label_new (_("You may specify multiple folders here."));
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_misc_set_padding (GTK_MISC (label), 12, 12);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
		      label, FALSE, FALSE, 0);

  gtk_widget_show_all (dialog);

  if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK)
    new_path = gimp_path_editor_get_path (GIMP_PATH_EDITOR (path_editor));

  gtk_widget_destroy (dialog);

  if (new_path && (!*path ||
                   strcmp (*path, new_path) != 0 ||
                   strcmp (*path, DEFAULT_FONTPATH) == 0))
    {
      g_free (*path);
      *path = new_path;
      gimp_gimprc_set (FONTPATH_TOKEN, *path);

      return TRUE;
    }

  return FALSE;
}