Exemplo n.º 1
0
/*
 * "Save as" dialog.
 */
void
gtr_save_file_as_dialog (GtkAction * action, GtrWindow * window)
{
  GtkWidget *dialog = NULL;
  GtrTab *current_page;
  GtrPo *po;
  GFile *location;
  gchar *uri = NULL;

  if (dialog != NULL)
    {
      gtk_window_present (GTK_WINDOW (dialog));
      return;
    }

  current_page = gtr_window_get_active_tab (window);
  po = gtr_tab_get_po (current_page);

  dialog = gtr_file_chooser_new (GTK_WINDOW (window),
                                 FILESEL_SAVE,
                                 _("Save file as..."),
                                 _gtr_application_get_last_dir (GTR_APP));

  gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
                                                  TRUE);
  g_signal_connect (dialog,
                    "confirm-overwrite",
                    G_CALLBACK (confirm_overwrite_callback), NULL);

  gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);

  /*Set the suggested file */
  location = gtr_po_get_location (po);

  uri = g_file_get_uri (location);

  g_object_unref (location);

  if (uri)
    gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (dialog), uri);

  g_free (uri);

  /*
   * FIXME: If we can't set the uri we should add a default path and name
   */

  g_object_set_data (G_OBJECT (dialog), GTR_TAB_SAVE_AS, current_page);

  g_signal_connect (dialog,
                    "response", G_CALLBACK (save_dialog_response_cb), window);

  gtk_widget_show (GTK_WIDGET (dialog));
}
Exemplo n.º 2
0
static void
gtr_po_get_property (GObject * object,
                     guint prop_id, GValue * value, GParamSpec * pspec)
{
  GtrPo *po = GTR_PO (object);

  switch (prop_id)
    {
    case PROP_LOCATION:
      g_value_take_object (value, gtr_po_get_location (po));
      break;
    case PROP_STATE:
      g_value_set_enum (value, gtr_po_get_state (po));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
      break;
    }
}