window-commands.c 74.5 KB
Newer Older
1
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
2
/*
3
 *  Copyright © 2000-2004 Marco Pesenti Gritti
4
 *  Copyright © 2009 Collabora Ltd.
Iulian Radu's avatar
Iulian Radu committed
5
 *  Copyright © 2016 Iulian-Gabriel Radu
6
 *  Copyright © 2011, 2017 Igalia S.L.
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
7
 *
Michael Catanzaro's avatar
Michael Catanzaro committed
8 9 10
 *  This file is part of Epiphany.
 *
 *  Epiphany is free software: you can redistribute it and/or modify
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
11
 *  it under the terms of the GNU General Public License as published by
Michael Catanzaro's avatar
Michael Catanzaro committed
12 13
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
14
 *
Michael Catanzaro's avatar
Michael Catanzaro committed
15
 *  Epiphany is distributed in the hope that it will be useful,
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
16 17 18 19 20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
Michael Catanzaro's avatar
Michael Catanzaro committed
21
 *  along with Epiphany.  If not, see <http://www.gnu.org/licenses/>.
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
22 23
 */

24
#include "config.h"
25

26
#include "window-commands.h"
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
27

28
#include "ephy-add-bookmark-popover.h"
29
#include "ephy-bookmarks-export.h"
30 31
#include "ephy-bookmarks-import.h"
#include "ephy-bookmarks-manager.h"
32
#include "ephy-debug.h"
33
#include "ephy-embed-container.h"
34
#include "ephy-embed-prefs.h"
35
#include "ephy-embed-shell.h"
36
#include "ephy-embed-utils.h"
37
#include "ephy-embed.h"
Arnaud B.'s avatar
Arnaud B. committed
38
#include "ephy-encoding-dialog.h"
39
#include "ephy-favicon-helpers.h"
40
#include "ephy-file-chooser.h"
41
#include "ephy-file-helpers.h"
42
#include "ephy-find-toolbar.h"
43
#include "ephy-flatpak-utils.h"
44
#include "ephy-gui.h"
45
#include "ephy-header-bar.h"
46
#include "ephy-history-dialog.h"
47
#include "ephy-link.h"
48 49 50
#include "ephy-location-entry.h"
#include "ephy-notebook.h"
#include "ephy-prefs.h"
51
#include "ephy-session.h"
52 53
#include "ephy-settings.h"
#include "ephy-shell.h"
54
#include "ephy-string.h"
55
#include "ephy-web-app-utils.h"
56
#include "ephy-zoom.h"
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
57

58
#include <gio/gio.h>
59
#include <glib.h>
60
#include <glib/gi18n.h>
61
#include <gtk/gtk.h>
62
#include <libnotify/notify.h>
63
#include <libsoup/soup.h>
64
#include <string.h>
65
#include <webkit2/webkit2.h>
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
66

67
#define DEFAULT_ICON_SIZE 192
68
#define FAVICON_SIZE 16
69

70 71 72 73 74
void
window_cmd_new_window (GSimpleAction *action,
                       GVariant      *parameter,
                       gpointer       user_data)
{
75 76
  EphyWindow *new_window;
  EphyShell *shell = ephy_shell_get_default ();
77

78 79 80 81 82 83
  if (ephy_embed_shell_get_mode (EPHY_EMBED_SHELL (shell)) == EPHY_EMBED_SHELL_MODE_INCOGNITO) {
    ephy_open_default_instance_window ();
    return;
  }

  new_window = ephy_window_new ();
84
  ephy_link_open (EPHY_LINK (new_window), NULL, NULL, EPHY_LINK_HOME_PAGE);
85 86 87 88 89 90 91 92 93 94
}

void
window_cmd_new_incognito_window (GSimpleAction *action,
                                 GVariant      *parameter,
                                 gpointer       user_data)
{
  ephy_open_incognito_window (NULL);
}

95 96 97
const gchar *import_option_names[2] = {
  N_("GVDB File"),
  N_("Firefox")
98 99
};

100 101 102 103 104 105 106 107 108 109 110
static void
combo_box_changed_cb (GtkComboBox *combo_box,
                      GtkButton   *button)
{
  int active;

  g_assert (GTK_IS_COMBO_BOX (combo_box));
  g_assert (GTK_IS_BUTTON (button));

  active = gtk_combo_box_get_active (combo_box);
  if (active == 0)
111
    gtk_button_set_label (button, _("Ch_oose File…"));
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
  else if (active == 1)
    gtk_button_set_label (button, _("I_mport"));
}

static gchar *
get_path (GIOChannel *channel)
{
  gchar *line;
  gchar *path;
  gsize length;

  do {
    g_io_channel_read_line (channel, &line, &length, NULL, NULL);

    if (g_str_has_prefix (line, "Path")) {
      path = g_strdup (line);

      /* Extract value (e.g. Path=Value\n -> Value) */
      path = strchr (path, '=');
      path++;
      path[strcspn (path, "\n")] = 0;

      g_free (line);
      return path;
    }

    g_free (line);
    /* Until '\n' */
  } while (length != 1);

  return NULL;
}

static GSList *
get_firefox_profiles (void)
{
  GIOChannel *channel;
  GSList *profiles = NULL;
  gchar *filename;
  gchar *line;
  gchar *profile;
  int count = 0;
  gsize length;

  filename = g_build_filename (g_get_home_dir (),
                               FIREFOX_PROFILES_DIR,
                               FIREFOX_PROFILES_FILE,
                               NULL);
  channel = g_io_channel_new_file (filename, "r", NULL);
  g_free (filename);

163 164 165
  if (channel) {
    do {
      g_io_channel_read_line (channel, &line, &length, NULL, NULL);
166

167 168 169
      profile = g_strdup_printf ("[Profile%d]\n", count);
      if (g_strcmp0 (line, profile) == 0) {
        profiles = g_slist_append (profiles, get_path (channel));
170

171 172 173 174 175
        count++;
      }
      g_free (profile);
      g_free (line);
    } while (length != 0);
176

177 178
    g_io_channel_unref (channel);
  }
179

180 181 182
  return profiles;
}

183 184 185 186 187 188 189 190
static GtkTreeModel *
create_tree_model (void)
{
  enum {
    TEXT_COL
  };
  GtkListStore *list_store;
  GtkTreeIter iter;
191 192
  GSList *firefox_profiles;
  gboolean has_firefox_profile;
193 194
  int i;

195 196 197 198 199 200

  /* Check if user has a firefox profile*/
  firefox_profiles = get_firefox_profiles ();
  has_firefox_profile = g_slist_length (firefox_profiles) > 0;
  g_slist_free (firefox_profiles);

201 202
  list_store = gtk_list_store_new (1, G_TYPE_STRING);
  for (i = G_N_ELEMENTS (import_option_names) - 1; i >= 0; i--) {
203 204 205 206 207 208
    /* Skip Firefox option if user doesn't have a Firefox profile */
    if (g_strcmp0 (import_option_names[i], _("Firefox")) == 0) {
      if (!has_firefox_profile)
        continue;
    }

209 210 211 212 213 214 215 216 217
    gtk_list_store_prepend (list_store, &iter);
    gtk_list_store_set (list_store, &iter,
                        TEXT_COL, _(import_option_names[i]),
                        -1);
  }

  return GTK_TREE_MODEL (list_store);
}

218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275
static gchar *
show_profile_selector (GtkWidget *parent, GSList *profiles)
{
  GtkWidget *selector;
  GtkWidget *list_box;
  GtkWidget *suggested;
  GtkWidget *content_area;
  GSList *l;
  int response;
  gchar *selected_profile = NULL;

  selector = gtk_dialog_new_with_buttons (_("Select Profile"),
                                          GTK_WINDOW (parent),
                                          GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
                                          _("_Cancel"),
                                          GTK_RESPONSE_CANCEL,
                                          _("_Select"),
                                          GTK_RESPONSE_OK,
                                          NULL);
  gtk_dialog_set_default_response (GTK_DIALOG (selector), GTK_RESPONSE_OK);

  suggested = gtk_dialog_get_widget_for_response (GTK_DIALOG (selector), GTK_RESPONSE_OK);
  gtk_style_context_add_class (gtk_widget_get_style_context (suggested),
                               GTK_STYLE_CLASS_SUGGESTED_ACTION);

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (selector));
  gtk_container_set_border_width (GTK_CONTAINER (content_area), 5);
  gtk_widget_set_valign (content_area, GTK_ALIGN_CENTER);

  list_box = gtk_list_box_new ();
  for (l = profiles; l != NULL; l = l->next) {
    const gchar *profile = l->data;
    GtkWidget *label;

    label = gtk_label_new (strchr (profile, '.') + 1);
    g_object_set_data (G_OBJECT (label), "profile_path", g_strdup (profile));
    gtk_widget_set_margin_top (label, 6);
    gtk_widget_set_margin_bottom (label, 6);
    gtk_list_box_insert (GTK_LIST_BOX (list_box), label, -1);
  }
  gtk_container_add (GTK_CONTAINER (content_area), list_box);

  gtk_widget_show_all (content_area);

  response = gtk_dialog_run (GTK_DIALOG (selector));
  if (response == GTK_RESPONSE_OK) {
    GtkListBoxRow *row;
    GtkWidget *row_widget;

    row = gtk_list_box_get_selected_row (GTK_LIST_BOX (list_box));
    row_widget = gtk_bin_get_child (GTK_BIN (row));
    selected_profile = g_object_get_data (G_OBJECT (row_widget), "profile_path");
  }
  gtk_widget_destroy (selector);

  return selected_profile;
}

276 277 278 279 280 281
static void
dialog_bookmarks_import_cb (GtkDialog   *dialog,
                            int          response,
                            GtkComboBox *combo_box)
{
  EphyBookmarksManager *manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
282
  GtkFileChooser *file_chooser_dialog;
283 284 285
  GtkWidget *import_info_dialog;
  int active;
  int chooser_response;
286
  gboolean imported = FALSE;
287 288 289 290 291 292

  if (response == GTK_RESPONSE_OK) {
    active = gtk_combo_box_get_active (combo_box);
    if (active == 0) {
      GtkFileFilter *filter;

293 294 295 296 297 298 299
      file_chooser_dialog = GTK_FILE_CHOOSER (gtk_file_chooser_native_new (_("Choose File"),
                                                                           GTK_WINDOW (dialog),
                                                                           GTK_FILE_CHOOSER_ACTION_OPEN,
                                                                           _("I_mport"),
                                                                           _("_Cancel")));
      gtk_file_chooser_set_show_hidden (file_chooser_dialog, TRUE);

300 301
      filter = gtk_file_filter_new ();
      gtk_file_filter_add_pattern (filter, "*.gvdb");
302
      gtk_file_chooser_set_filter (file_chooser_dialog, filter);
303

304 305
      chooser_response = gtk_native_dialog_run (GTK_NATIVE_DIALOG (file_chooser_dialog));
      if (chooser_response == GTK_RESPONSE_ACCEPT) {
306 307 308
        GError *error = NULL;
        char *filename;

309
        gtk_native_dialog_hide (GTK_NATIVE_DIALOG (file_chooser_dialog));
310

311
        filename = gtk_file_chooser_get_filename (file_chooser_dialog);
312 313 314 315 316 317 318 319 320 321 322 323 324 325
        imported = ephy_bookmarks_import (manager, filename, &error);
        g_free (filename);

        import_info_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
                                                     GTK_DIALOG_MODAL,
                                                     imported ? GTK_MESSAGE_INFO : GTK_MESSAGE_WARNING,
                                                     GTK_BUTTONS_OK,
                                                     "%s",
                                                     imported ? _("Bookmarks successfully imported!") :
                                                                error->message);
        gtk_dialog_run (GTK_DIALOG (import_info_dialog));

        gtk_widget_destroy (import_info_dialog);
      }
326
      g_object_unref (file_chooser_dialog);
327 328 329
    } else if (active == 1) {
      GError *error = NULL;
      GSList *profiles;
330
      gchar *profile = NULL;
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
      int num_profiles;

      profiles = get_firefox_profiles ();

      /* Import default profile */
      num_profiles = g_slist_length (profiles);
      if (num_profiles == 1) {
        imported = ephy_bookmarks_import_from_firefox (manager, profiles->data, &error);
      } else if (num_profiles > 1) {
        profile = show_profile_selector (GTK_WIDGET (dialog), profiles);
        if (profile) {
          imported = ephy_bookmarks_import_from_firefox (manager, profile, &error);
          g_free (profile);
        }
      } else {
        g_assert_not_reached ();
      }

      g_slist_free (profiles);
350

351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367
      /* If there are multiple profiles, but the user didn't select one in
       * the profile (he pressed Cancel), don't display the import info dialog
       * as no import took place
       */
      if (profile) {
        import_info_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog),
                                                     GTK_DIALOG_MODAL,
                                                     imported ? GTK_MESSAGE_INFO : GTK_MESSAGE_WARNING,
                                                     GTK_BUTTONS_OK,
                                                     "%s",
                                                     imported ? _("Bookmarks successfully imported!") :
                                                                error->message);
        gtk_dialog_run (GTK_DIALOG (import_info_dialog));
        gtk_widget_destroy (import_info_dialog);
      }
      if (error)
        g_error_free (error);
368
    }
369 370 371

    if (imported)
      gtk_widget_destroy (GTK_WIDGET (dialog));
372 373 374 375 376
  } else if (response == GTK_RESPONSE_CANCEL) {
    gtk_widget_destroy (GTK_WIDGET (dialog));
  }
}

377 378 379 380 381
void
window_cmd_import_bookmarks (GSimpleAction *action,
                             GVariant      *parameter,
                             gpointer       user_data)
{
382 383 384 385 386 387 388 389 390
  EphyWindow *window = EPHY_WINDOW (user_data);
  GtkWidget *dialog;
  GtkWidget *content_area;
  GtkWidget *hbox;
  GtkWidget *label;
  GtkWidget *combo_box;
  GtkTreeModel *tree_model;
  GtkCellRenderer *cell_renderer;

391
  dialog = gtk_dialog_new_with_buttons (_("Import Bookmarks"),
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416
                                        GTK_WINDOW (window),
                                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
                                        _("_Cancel"),
                                        GTK_RESPONSE_CANCEL,
                                        _("Ch_oose File"),
                                        GTK_RESPONSE_OK,
                                        NULL);
  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  gtk_widget_set_valign (content_area, GTK_ALIGN_CENTER);
  gtk_widget_set_margin_start (content_area, 25);
  gtk_widget_set_margin_end (content_area, 25);
  gtk_container_set_border_width (GTK_CONTAINER (content_area), 5);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);

  label = gtk_label_new (_("From:"));
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);

  tree_model = create_tree_model ();
  combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (tree_model));
  g_object_unref (tree_model);
  gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), 0);

417 418 419 420
  g_signal_connect (GTK_COMBO_BOX (combo_box), "changed",
                    G_CALLBACK (combo_box_changed_cb),
                    gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK));

421 422 423 424 425 426 427 428
  cell_renderer = gtk_cell_renderer_text_new ();
  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), cell_renderer, TRUE);
  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell_renderer,
                                  "text", 0, NULL);
  gtk_box_pack_start (GTK_BOX (hbox), combo_box, TRUE, TRUE, 0);

  gtk_container_add (GTK_CONTAINER (content_area), hbox);

429 430 431 432 433
  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
  g_signal_connect (dialog, "response",
                    G_CALLBACK (dialog_bookmarks_import_cb),
                    GTK_COMBO_BOX (combo_box));

434
  gtk_widget_show_all (dialog);
435 436 437 438 439 440 441
}

void
window_cmd_export_bookmarks (GSimpleAction *action,
                             GVariant      *parameter,
                             gpointer       user_data)
{
442
  EphyBookmarksManager *manager = ephy_shell_get_bookmarks_manager (ephy_shell_get_default ());
443
  GtkFileChooser *dialog;
444 445 446 447 448
  GtkWidget *export_info_dialog;
  int chooser_response;
  gboolean exported;
  GtkFileFilter *filter;

449 450 451 452 453 454
  dialog = GTK_FILE_CHOOSER (gtk_file_chooser_native_new (_("Choose File"),
                                                          GTK_WINDOW (user_data),
                                                          GTK_FILE_CHOOSER_ACTION_SAVE,
                                                          _("_Save"),
                                                          _("_Cancel")));
  gtk_file_chooser_set_show_hidden (dialog, TRUE);
455 456

  /* Translators: Only translate the part before ".gvdb" (e.g. "bookmarks") */
457 458 459 460 461
  gtk_file_chooser_set_current_name (dialog, _("bookmarks.gvdb"));

  filter = gtk_file_filter_new ();
  gtk_file_filter_add_pattern (filter, "*.gvdb");
  gtk_file_chooser_set_filter (dialog, filter);
462

463 464
  chooser_response = gtk_native_dialog_run (GTK_NATIVE_DIALOG (dialog));
  if (chooser_response == GTK_RESPONSE_ACCEPT) {
465 466 467
    GError *error = NULL;
    char *filename;

468
    gtk_native_dialog_hide (GTK_NATIVE_DIALOG (dialog));
469

470
    filename = gtk_file_chooser_get_filename (dialog);
471 472 473
    exported = ephy_bookmarks_export (manager, filename, &error);
    g_free (filename);

474
    export_info_dialog = gtk_message_dialog_new (GTK_WINDOW (user_data),
475 476 477 478 479 480 481 482 483
                                                 GTK_DIALOG_MODAL,
                                                 exported ? GTK_MESSAGE_INFO : GTK_MESSAGE_WARNING,
                                                 GTK_BUTTONS_OK,
                                                 "%s",
                                                 exported ? _("Bookmarks successfully exported!") :
                                                            error->message);
    gtk_dialog_run (GTK_DIALOG (export_info_dialog));
    gtk_widget_destroy (export_info_dialog);
  }
484

485
  g_object_unref (dialog);
486 487
}

488 489 490 491 492
void
window_cmd_show_history (GSimpleAction *action,
                         GVariant      *parameter,
                         gpointer       user_data)
{
493
  GtkWidget *dialog;
494

495
  dialog = ephy_shell_get_history_dialog (ephy_shell_get_default ());
496

497 498
  if (GTK_WINDOW (user_data) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
    gtk_window_set_transient_for (GTK_WINDOW (dialog),
499
                                  GTK_WINDOW (user_data));
500
  gtk_window_present (GTK_WINDOW (dialog));
501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528
}

void
window_cmd_show_preferences (GSimpleAction *action,
                             GVariant      *parameter,
                             gpointer       user_data)
{
  GtkWindow *dialog;

  dialog = GTK_WINDOW (ephy_shell_get_prefs_dialog (ephy_shell_get_default ()));

  if (GTK_WINDOW (user_data) != gtk_window_get_transient_for (dialog))
    gtk_window_set_transient_for (dialog,
                                  GTK_WINDOW (user_data));

  gtk_window_present (dialog);
}

void
window_cmd_show_shortcuts (GSimpleAction *action,
                           GVariant      *parameter,
                           gpointer       user_data)
{
  static GtkWidget *shortcuts_window;

  if (shortcuts_window == NULL) {
    GtkBuilder *builder;

529
    builder = gtk_builder_new_from_resource ("/org/gnome/epiphany/gtk/shortcuts-dialog.ui");
530 531 532 533 534 535 536 537 538 539
    shortcuts_window = GTK_WIDGET (gtk_builder_get_object (builder, "shortcuts-dialog"));

    g_signal_connect (shortcuts_window,
                      "destroy",
                      G_CALLBACK (gtk_widget_destroyed),
                      &shortcuts_window);

    g_object_unref (builder);
  }

540 541
  if (gtk_window_get_transient_for (GTK_WINDOW (shortcuts_window)) != GTK_WINDOW (user_data))
    gtk_window_set_transient_for (GTK_WINDOW (shortcuts_window), GTK_WINDOW (user_data));
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563

  gtk_window_present (GTK_WINDOW (shortcuts_window));
}

void
window_cmd_show_help (GSimpleAction *action,
                      GVariant      *parameter,
                      gpointer       user_data)
{
  ephy_gui_help (GTK_WIDGET (user_data), NULL);
}

#define ABOUT_GROUP "About"

void
window_cmd_show_about (GSimpleAction *action,
                       GVariant      *parameter,
                       gpointer       user_data)
{
  EphyWindow *window = EPHY_WINDOW (user_data);
  char *comments = NULL;
  GKeyFile *key_file;
564
  GBytes *bytes;
565 566 567 568 569
  GError *error = NULL;
  char **list, **authors, **contributors, **past_authors, **artists, **documenters;
  gsize n_authors, n_contributors, n_past_authors, n_artists, n_documenters, i, j;

  key_file = g_key_file_new ();
570 571
  bytes = g_resources_lookup_data ("/org/gnome/epiphany/about.ini", 0, NULL);
  if (!g_key_file_load_from_data (key_file, g_bytes_get_data (bytes, NULL), -1, 0, &error)) {
572 573 574 575
    g_warning ("Couldn't load about data: %s\n", error->message);
    g_error_free (error);
    return;
  }
576
  g_bytes_unref (bytes);
577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636

  list = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Authors",
                                     &n_authors, NULL);
  contributors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Contributors",
                                             &n_contributors, NULL);
  past_authors = g_key_file_get_string_list (key_file, ABOUT_GROUP, "PastAuthors",
                                             &n_past_authors, NULL);

#define APPEND(_to, _from) \
  _to[i++] = g_strdup (_from);

#define APPEND_STRV_AND_FREE(_to, _from) \
  if (_from) \
  { \
    for (j = 0; _from[j] != NULL; ++j) \
    { \
      _to[i++] = _from[j]; \
    } \
    g_free (_from); \
  }

  authors = g_new (char *, (list ? n_authors : 0) +
                   (contributors ? n_contributors : 0) +
                   (past_authors ? n_past_authors : 0) + 7 + 1);
  i = 0;
  APPEND_STRV_AND_FREE (authors, list);
  APPEND (authors, "");
  APPEND (authors, _("Contact us at:"));
  APPEND (authors, "<epiphany-list@gnome.org>");
  APPEND (authors, "");
  APPEND (authors, _("Contributors:"));
  APPEND_STRV_AND_FREE (authors, contributors);
  APPEND (authors, "");
  APPEND (authors, _("Past developers:"));
  APPEND_STRV_AND_FREE (authors, past_authors);
  authors[i++] = NULL;

  list = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Artists", &n_artists, NULL);

  artists = g_new (char *, (list ? n_artists : 0) + 4 + 1);
  i = 0;
  APPEND_STRV_AND_FREE (artists, list);
  artists[i++] = NULL;

  list = g_key_file_get_string_list (key_file, ABOUT_GROUP, "Documenters", &n_documenters, NULL);

  documenters = g_new (char *, (list ? n_documenters : 0) + 3 + 1);
  i = 0;
  APPEND_STRV_AND_FREE (documenters, list);
  APPEND (documenters, "");
  APPEND (documenters, _("Contact us at:"));
  APPEND (documenters, "<gnome-doc-list@gnome.org>");
  documenters[i++] = NULL;

#undef APPEND
#undef APPEND_STRV_AND_FREE

  g_key_file_free (key_file);

  comments = g_strdup_printf (_("A simple, clean, beautiful view of the web.\n"
637
                                "Powered by WebKitGTK+ %d.%d.%d"),
638 639 640 641 642 643 644 645
                              webkit_get_major_version (),
                              webkit_get_minor_version (),
                              webkit_get_micro_version ());

  gtk_show_about_dialog (window ? GTK_WINDOW (window) : NULL,
                         "program-name", _("Web"),
                         "version", VERSION,
                         "copyright", "Copyright © 2002–2004 Marco Pesenti Gritti\n"
646
                         "Copyright © 2003–2017 The Web Developers",
647 648 649 650 651 652 653 654 655 656 657 658 659
                         "artists", artists,
                         "authors", authors,
                         "comments", comments,
                         "documenters", documenters,
                         /* Translators: This is a special message that shouldn't be translated
                          * literally. It is used in the about box to give credits to
                          * the translators.
                          * Thus, you should translate it to your name and email address.
                          * You should also include other translators who have contributed to
                          * this translation; in that case, please write each of them on a separate
                          * line seperated by newlines (\n).
                          */
                         "translator-credits", _("translator-credits"),
Michael Catanzaro's avatar
Michael Catanzaro committed
660
                         "logo-icon-name", "org.gnome.Epiphany",
661 662
                         "website", "https://wiki.gnome.org/Apps/Web",
                         "website-label", _("Web Website"),
Michael Catanzaro's avatar
Michael Catanzaro committed
663
                         "license-type", GTK_LICENSE_GPL_3_0,
664 665 666 667 668 669 670 671 672 673 674 675 676 677
                         "wrap-license", TRUE,
                         NULL);

  g_free (comments);
  g_strfreev (artists);
  g_strfreev (authors);
  g_strfreev (documenters);
}

void
window_cmd_quit (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
{
678
  ephy_shell_try_quit (ephy_shell_get_default ());
679 680 681 682 683 684 685
}

void
window_cmd_reopen_closed_tab (GSimpleAction *action,
                              GVariant      *parameter,
                              gpointer       user_data)
{
686 687 688 689
  EphySession *session = ephy_shell_get_session (ephy_shell_get_default ());

  g_assert (session != NULL);
  ephy_session_undo_close_tab (session);
690 691
}

692 693
void
window_cmd_navigation (GSimpleAction *action,
694
                       GVariant      *parameter,
695 696 697 698 699 700 701 702 703 704 705
                       gpointer       user_data)
{
  EphyWindow *window = EPHY_WINDOW (user_data);
  EphyEmbed *embed;
  WebKitWebView *web_view;

  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
  g_return_if_fail (embed != NULL);

  web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);

706
  if (strstr (g_action_get_name (G_ACTION (action)), "back")) {
707 708 709 710 711 712 713 714 715 716
    webkit_web_view_go_back (web_view);
    gtk_widget_grab_focus (GTK_WIDGET (embed));
  } else {
    webkit_web_view_go_forward (web_view);
    gtk_widget_grab_focus (GTK_WIDGET (embed));
  }
}

void
window_cmd_navigation_new_tab (GSimpleAction *action,
717
                               GVariant      *parameter,
718 719 720 721 722 723 724 725 726 727 728
                               gpointer       user_data)
{
  EphyWindow *window = EPHY_WINDOW (user_data);
  EphyEmbed *embed;
  WebKitWebView *web_view;

  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
  g_return_if_fail (embed != NULL);

  web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);

729
  if (strstr (g_action_get_name (G_ACTION (action)), "back")) {
730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767
      const char *back_uri;
      WebKitBackForwardList *history;
      WebKitBackForwardListItem *back_item;

      history = webkit_web_view_get_back_forward_list (web_view);
      back_item = webkit_back_forward_list_get_back_item (history);
      back_uri = webkit_back_forward_list_item_get_original_uri (back_item);

      embed = ephy_shell_new_tab (ephy_shell_get_default (),
                                  EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
                                  NULL,
                                  0);

      web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
      webkit_web_view_load_uri (web_view, back_uri);
      gtk_widget_grab_focus (GTK_WIDGET (embed));
  } else {
      const char *forward_uri;
      WebKitBackForwardList *history;
      WebKitBackForwardListItem *forward_item;

      /* Forward history is not copied when opening
         a new tab, so get the forward URI manually
         and load it */
      history = webkit_web_view_get_back_forward_list (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
      forward_item = webkit_back_forward_list_get_forward_item (history);
      forward_uri = webkit_back_forward_list_item_get_original_uri (forward_item);

      embed = ephy_shell_new_tab (ephy_shell_get_default (),
                                  EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
                                  embed,
                                  0);

      web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
      webkit_web_view_load_uri (web_view, forward_uri);
  }
}

768
void
769 770 771
window_cmd_stop (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
Michael Catanzaro's avatar
Michael Catanzaro committed
772
{
773
  EphyWindow *window = EPHY_WINDOW (user_data);
Michael Catanzaro's avatar
Michael Catanzaro committed
774 775 776 777 778 779
  EphyEmbed *embed;

  embed = ephy_embed_container_get_active_child
            (EPHY_EMBED_CONTAINER (window));
  g_return_if_fail (embed != NULL);

780
  gtk_widget_grab_focus (GTK_WIDGET (embed));
Michael Catanzaro's avatar
Michael Catanzaro committed
781

782
  webkit_web_view_stop_loading (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
783 784
}

785 786 787
static gboolean
event_with_shift (void)
{
Michael Catanzaro's avatar
Michael Catanzaro committed
788 789 790
  GdkEvent *event;
  GdkEventType type = 0;
  guint state = 0;
791

Michael Catanzaro's avatar
Michael Catanzaro committed
792 793 794
  event = gtk_get_current_event ();
  if (event) {
    type = event->type;
795

Michael Catanzaro's avatar
Michael Catanzaro committed
796 797 798 799 800
    if (type == GDK_BUTTON_RELEASE) {
      state = event->button.state;
    } else if (type == GDK_KEY_PRESS || type == GDK_KEY_RELEASE) {
      state = event->key.state;
    }
801

Michael Catanzaro's avatar
Michael Catanzaro committed
802 803
    gdk_event_free (event);
  }
804

Michael Catanzaro's avatar
Michael Catanzaro committed
805
  return (state & GDK_SHIFT_MASK) != 0;
806 807
}

Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
808
void
809 810 811
window_cmd_reload (GSimpleAction *action,
                   GVariant      *parameter,
                   gpointer       user_data)
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
812
{
813
  EphyWindow *window = EPHY_WINDOW (user_data);
Michael Catanzaro's avatar
Michael Catanzaro committed
814
  EphyEmbed *embed;
815
  WebKitWebView *view;
Michael Catanzaro's avatar
Michael Catanzaro committed
816 817 818 819

  embed = ephy_embed_container_get_active_child
            (EPHY_EMBED_CONTAINER (window));
  g_return_if_fail (embed != NULL);
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
820

Michael Catanzaro's avatar
Michael Catanzaro committed
821
  gtk_widget_grab_focus (GTK_WIDGET (embed));
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
822

823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849
  view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
  if (event_with_shift ())
    webkit_web_view_reload_bypass_cache (view);
  else
    webkit_web_view_reload (view);
}

void window_cmd_combined_stop_reload (GSimpleAction *action,
                                      GVariant      *parameter,
                                      gpointer       user_data)
{
  GActionGroup *action_group;
  GAction *gaction;
  GVariant *state;

  action_group = gtk_widget_get_action_group (GTK_WIDGET (user_data), "toolbar");

  state = g_action_get_state (G_ACTION (action));
  /* If loading */
  if (g_variant_get_boolean (state))
    gaction = g_action_map_lookup_action (G_ACTION_MAP (action_group), "stop");
  else
    gaction = g_action_map_lookup_action (G_ACTION_MAP (action_group), "reload");

  g_action_activate (gaction, NULL);

  g_variant_unref (state);
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
850 851
}

852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868
void
window_cmd_page_menu (GSimpleAction *action,
                      GVariant      *parameter,
                      gpointer       user_data)

{
  EphyWindow *window = EPHY_WINDOW (user_data);
  EphyHeaderBar *header_bar;
  GtkMenuButton *button;
  GtkPopover *popover;

  header_bar = EPHY_HEADER_BAR (ephy_window_get_header_bar (window));
  button = GTK_MENU_BUTTON (ephy_header_bar_get_page_menu_button (header_bar));
  popover = gtk_menu_button_get_popover (button);
  gtk_popover_popup (popover);
}

Iulian Radu's avatar
Iulian Radu committed
869
void
870 871 872
window_cmd_new_tab (GSimpleAction *action,
                    GVariant      *parameter,
                    gpointer       user_data)
Iulian Radu's avatar
Iulian Radu committed
873 874 875 876
{
  EphyWindow *window = user_data;

  ephy_link_open (EPHY_LINK (window),
877 878
                  NULL, NULL,
                  EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO);
Iulian Radu's avatar
Iulian Radu committed
879 880
}

Iulian Radu's avatar
Iulian Radu committed
881
static void
882
open_response_cb (GtkNativeDialog *dialog, int response, EphyWindow *window)
Iulian Radu's avatar
Iulian Radu committed
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899
{
  if (response == GTK_RESPONSE_ACCEPT) {
    char *uri, *converted;

    uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
    if (uri != NULL) {
      converted = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL);

      if (converted != NULL) {
        ephy_window_load_url (window, converted);
      }

      g_free (converted);
      g_free (uri);
    }
  }

900
  g_object_unref (dialog);
Iulian Radu's avatar
Iulian Radu committed
901 902 903
}

void
904 905 906
window_cmd_open (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
Iulian Radu's avatar
Iulian Radu committed
907 908
{
  EphyWindow *window = user_data;
909
  GtkFileChooser *dialog;
Iulian Radu's avatar
Iulian Radu committed
910

911 912 913 914
  dialog = ephy_create_file_chooser (_("Open"),
                                     GTK_WIDGET (window),
                                     GTK_FILE_CHOOSER_ACTION_OPEN,
                                     EPHY_FILE_FILTER_ALL_SUPPORTED);
Iulian Radu's avatar
Iulian Radu committed
915 916 917 918

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

919
  gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
Iulian Radu's avatar
Iulian Radu committed
920 921
}

922
typedef struct {
Michael Catanzaro's avatar
Michael Catanzaro committed
923 924 925 926 927 928 929
  EphyWebView *view;
  GtkWidget *image;
  GtkWidget *entry;
  GtkWidget *spinner;
  GtkWidget *box;
  char *icon_href;
  GdkRGBA icon_rgba;
930 931 932 933 934
} EphyApplicationDialogData;

static void
ephy_application_dialog_data_free (EphyApplicationDialogData *data)
{
Michael Catanzaro's avatar
Michael Catanzaro committed
935 936
  g_free (data->icon_href);
  g_slice_free (EphyApplicationDialogData, data);
937 938
}

939 940 941 942 943 944 945 946 947
static void
rounded_rectangle (cairo_t *cr,
                   gdouble  aspect,
                   gdouble  x,
                   gdouble  y,
                   gdouble  corner_radius,
                   gdouble  width,
                   gdouble  height)
{
Michael Catanzaro's avatar
Michael Catanzaro committed
948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979
  gdouble radius;
  gdouble degrees;

  radius = corner_radius / aspect;
  degrees = G_PI / 180.0;

  cairo_new_sub_path (cr);
  cairo_arc (cr,
             x + width - radius,
             y + radius,
             radius,
             -90 * degrees,
             0 * degrees);
  cairo_arc (cr,
             x + width - radius,
             y + height - radius,
             radius,
             0 * degrees,
             90 * degrees);
  cairo_arc (cr,
             x + radius,
             y + height - radius,
             radius,
             90 * degrees,
             180 * degrees);
  cairo_arc (cr,
             x + radius,
             y + radius,
             radius,
             180 * degrees,
             270 * degrees);
  cairo_close_path (cr);
980 981 982
}

static GdkPixbuf *
Michael Catanzaro's avatar
Michael Catanzaro committed
983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053
frame_pixbuf (GdkPixbuf *pixbuf,
              GdkRGBA   *rgba,
              int        width,
              int        height)
{
  GdkPixbuf *framed;
  cairo_surface_t *surface;
  cairo_t *cr;
  int frame_width;
  int radius;

  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
                                        width, height);
  cr = cairo_create (surface);

  frame_width = 0;
  radius = 20;

  rounded_rectangle (cr,
                     1.0,
                     frame_width + 0.5,
                     frame_width + 0.5,
                     radius,
                     width - frame_width * 2 - 1,
                     height - frame_width * 2 - 1);
  if (rgba != NULL)
    cairo_set_source_rgba (cr,
                           rgba->red,
                           rgba->green,
                           rgba->blue,
                           rgba->alpha);
  else
    cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.3);
  cairo_fill_preserve (cr);

  if (pixbuf != NULL) {
    GdkPixbuf *scaled;
    int w;
    int h;

    w = gdk_pixbuf_get_width (pixbuf);
    h = gdk_pixbuf_get_height (pixbuf);

    if (w < 48 || h < 48) {
      scaled = gdk_pixbuf_scale_simple (pixbuf, w * 3, h * 3, GDK_INTERP_NEAREST);
    } else if (w > width || h > height) {
      double ws, hs, s;

      ws = (double)width / w;
      hs = (double)height / h;
      s = MIN (ws, hs);
      scaled = gdk_pixbuf_scale_simple (pixbuf, w * s, h * s, GDK_INTERP_BILINEAR);
    } else {
      scaled = g_object_ref (pixbuf);
    }

    w = gdk_pixbuf_get_width (scaled);
    h = gdk_pixbuf_get_height (scaled);

    gdk_cairo_set_source_pixbuf (cr, scaled,
                                 (width - w) / 2,
                                 (height - h) / 2);
    g_object_unref (scaled);
    cairo_fill (cr);
  }

  framed = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
  cairo_destroy (cr);
  cairo_surface_destroy (surface);

  return framed;
1054 1055
}

1056
static void
1057
set_image_from_favicon (EphyApplicationDialogData *data)
1058
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1059 1060
  GdkPixbuf *icon = NULL;
  cairo_surface_t *icon_surface = webkit_web_view_get_favicon (WEBKIT_WEB_VIEW (data->view));
1061

Michael Catanzaro's avatar
Michael Catanzaro committed
1062 1063
  if (icon_surface)
    icon = ephy_pixbuf_get_from_surface_scaled (icon_surface, 0, 0);
1064

Michael Catanzaro's avatar
Michael Catanzaro committed
1065 1066
  if (icon != NULL) {
    GdkPixbuf *framed;
1067

Michael Catanzaro's avatar
Michael Catanzaro committed
1068 1069 1070 1071 1072
    framed = frame_pixbuf (icon, NULL, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
    g_object_unref (icon);
    gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), framed);
    g_object_unref (framed);
  }
1073 1074 1075 1076
}

static void
set_app_icon_from_filename (EphyApplicationDialogData *data,
Michael Catanzaro's avatar
Michael Catanzaro committed
1077
                            const char                *filename)
1078
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1079 1080
  GdkPixbuf *pixbuf;
  GdkPixbuf *framed;
1081

1082
  pixbuf = gdk_pixbuf_new_from_file_at_size (filename, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE, NULL);
Michael Catanzaro's avatar
Michael Catanzaro committed
1083 1084
  if (pixbuf == NULL)
    return;
1085

Michael Catanzaro's avatar
Michael Catanzaro committed
1086 1087 1088 1089
  framed = frame_pixbuf (pixbuf, &data->icon_rgba, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
  g_object_unref (pixbuf);
  gtk_image_set_from_pixbuf (GTK_IMAGE (data->image), framed);
  g_object_unref (framed);
1090 1091
}

1092
static void
Michael Catanzaro's avatar
Michael Catanzaro committed
1093 1094
download_finished_cb (WebKitDownload            *download,
                      EphyApplicationDialogData *data)
1095
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1096
  char *filename;
1097

Michael Catanzaro's avatar
Michael Catanzaro committed
1098
  gtk_widget_show (data->image);
1099

Michael Catanzaro's avatar
Michael Catanzaro committed
1100 1101 1102
  filename = g_filename_from_uri (webkit_download_get_destination (download), NULL, NULL);
  set_app_icon_from_filename (data, filename);
  g_free (filename);
1103 1104 1105
}

static void
Michael Catanzaro's avatar
Michael Catanzaro committed
1106 1107 1108
download_failed_cb (WebKitDownload            *download,
                    GError                    *error,
                    EphyApplicationDialogData *data)
1109
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1110
  gtk_widget_show (data->image);
1111

Michael Catanzaro's avatar
Michael Catanzaro committed
1112 1113 1114
  g_signal_handlers_disconnect_by_func (download, download_finished_cb, data);
  /* Something happened, default to a page snapshot. */
  set_image_from_favicon (data);
1115
}
1116 1117 1118 1119

static void
download_icon_and_set_image (EphyApplicationDialogData *data)
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
  WebKitDownload *download;
  char *destination, *destination_uri, *tmp_filename;
  EphyEmbedShell *shell = ephy_embed_shell_get_default ();

  download = webkit_web_context_download_uri (ephy_embed_shell_get_web_context (shell),
                                              data->icon_href);
  /* We do not want this download to show up in the UI, so let's
   * set 'ephy-download-set' to make Epiphany think this is
   * already there. */
  /* FIXME: it's probably better to just do this in a clean way
   * instead of using this workaround. */
  g_object_set_data (G_OBJECT (download), "ephy-download-set", GINT_TO_POINTER (TRUE));

  tmp_filename = ephy_file_tmp_filename (".ephy-download-XXXXXX", NULL);
  destination = g_build_filename (ephy_file_tmp_dir (), tmp_filename, NULL);
  destination_uri = g_filename_to_uri (destination, NULL, NULL);
  webkit_download_set_destination (download, destination_uri);
  g_free (destination);
  g_free (destination_uri);
  g_free (tmp_filename);

  g_signal_connect (download, "finished",
                    G_CALLBACK (download_finished_cb), data);
  g_signal_connect (download, "failed",
                    G_CALLBACK (download_failed_cb), data);
1145 1146 1147
}

static void
Michael Catanzaro's avatar
Michael Catanzaro committed
1148 1149 1150 1151 1152 1153 1154 1155
fill_default_application_image_cb (GObject      *source,
                                   GAsyncResult *async_result,
                                   gpointer      user_data)
{
  EphyApplicationDialogData *data = user_data;
  char *uri = NULL;
  GdkRGBA color = { 0.5, 0.5, 0.5, 0.3 };

1156
  ephy_web_view_get_best_web_app_icon_finish (EPHY_WEB_VIEW (source), async_result, &uri, &color, NULL);
Michael Catanzaro's avatar
Michael Catanzaro committed
1157 1158 1159

  data->icon_href = uri;
  data->icon_rgba = color;
1160
  if (data->icon_href != NULL)
Michael Catanzaro's avatar
Michael Catanzaro committed
1161
    download_icon_and_set_image (data);
1162
  else {
Michael Catanzaro's avatar
Michael Catanzaro committed
1163 1164 1165
    gtk_widget_show (data->image);
    set_image_from_favicon (data);
  }
1166 1167
}

1168 1169 1170
static void
fill_default_application_image (EphyApplicationDialogData *data)
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1171
  ephy_web_view_get_best_web_app_icon (data->view, NULL, fill_default_application_image_cb, data);
1172 1173
}

1174
typedef struct {
Michael Catanzaro's avatar
Michael Catanzaro committed
1175 1176
  const char *host;
  const char *name;
1177 1178 1179
} SiteInfo;

static SiteInfo sites[] = {
Michael Catanzaro's avatar
Michael Catanzaro committed
1180 1181 1182 1183 1184
  { "www.facebook.com", "Facebook" },
  { "twitter.com", "Twitter" },
  { "gmail.com", "GMail" },
  { "plus.google.com", "Google+" },
  { "youtube.com", "YouTube" },
1185 1186 1187 1188 1189
};

static char *
get_special_case_application_title_for_host (const char *host)
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1190 1191
  char *title = NULL;
  guint i;
1192

Michael Catanzaro's avatar
Michael Catanzaro committed
1193 1194 1195 1196 1197 1198
  for (i = 0; i < G_N_ELEMENTS (sites) && title == NULL; i++) {
    SiteInfo *info = &sites[i];
    if (strcmp (host, info->host) == 0) {
      title = g_strdup (info->name);
    }
  }
1199

Michael Catanzaro's avatar
Michael Catanzaro committed
1200
  return title;
1201 1202
}

1203
static void
1204
set_default_application_title (EphyApplicationDialogData *data,
Michael Catanzaro's avatar
Michael Catanzaro committed
1205
                               char                      *title)
1206
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1207 1208 1209
  if (title == NULL || title[0] == '\0') {
    SoupURI *uri;
    const char *host;
1210

Michael Catanzaro's avatar
Michael Catanzaro committed
1211 1212
    uri = soup_uri_new (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (data->view)));
    host = soup_uri_get_host (uri);
1213

Michael Catanzaro's avatar
Michael Catanzaro committed
1214 1215
    if (host != NULL && host[0] != '\0')
      title = get_special_case_application_title_for_host (host);
1216

Michael Catanzaro's avatar
Michael Catanzaro committed
1217 1218 1219 1220 1221 1222
    if (title == NULL || title[0] == '\0') {
      if (g_str_has_prefix (host, "www."))
        title = g_strdup (host + strlen ("www."));
      else
        title = g_strdup (host);
    }
1223

Michael Catanzaro's avatar
Michael Catanzaro committed
1224 1225
    soup_uri_free (uri);
  }
1226

Michael Catanzaro's avatar
Michael Catanzaro committed
1227 1228 1229
  if (title == NULL || title[0] == '\0') {
    title = g_strdup (webkit_web_view_get_title (WEBKIT_WEB_VIEW (data->view)));
  }
1230

Michael Catanzaro's avatar
Michael Catanzaro committed
1231 1232
  gtk_entry_set_text (GTK_ENTRY (data->entry), title);
  g_free (title);
1233 1234
}

1235
static void
Michael Catanzaro's avatar
Michael Catanzaro committed
1236 1237 1238
fill_default_application_title_cb (GObject      *source,
                                   GAsyncResult *async_result,
                                   gpointer      user_data)
1239
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1240 1241
  EphyApplicationDialogData *data = user_data;
  char *title;
1242

Michael Catanzaro's avatar
Michael Catanzaro committed
1243 1244
  title = ephy_web_view_get_web_app_title_finish (EPHY_WEB_VIEW (source), async_result, NULL);
  set_default_application_title (data, title);
1245 1246 1247 1248 1249
}

static void
fill_default_application_title (EphyApplicationDialogData *data)
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1250
  ephy_web_view_get_web_app_title (data->view, NULL, fill_default_application_title_cb, data);
1251 1252
}

1253 1254
static void
notify_launch_cb (NotifyNotification *notification,
Michael Catanzaro's avatar
Michael Catanzaro committed
1255 1256
                  char               *action,
                  gpointer            user_data)
1257
{
Michael Catanzaro's avatar
Michael Catanzaro committed
1258
  char *desktop_file = user_data;
1259

Michael Catanzaro's avatar
Michael Catanzaro committed
1260 1261
  ephy_file_launch_desktop_file (desktop_file, NULL, 0, NULL);
  g_free (desktop_file);
1262 1263
}

1264 1265 1266 1267 1268 1269
static gboolean
confirm_web_application_overwrite (GtkWindow *parent, const char *title)
{
  GtkResponseType response;
  GtkWidget *dialog;

1270
  dialog = gtk_message_dialog_new (parent,
Michael Catanzaro's avatar
Michael Catanzaro committed
1271 1272 1273
                                   GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
                                   GTK_MESSAGE_QUESTION,
                                   GTK_BUTTONS_NONE,
1274
                                   _("A web application named “%s” already exists. Do you want to replace it?"),
Michael Catanzaro's avatar
Michael Catanzaro committed
1275
                                   title);
1276
  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
Michael Catanzaro's avatar
Michael Catanzaro committed
1277 1278 1279 1280 1281
                          _("Cancel"),
                          GTK_RESPONSE_CANCEL,
                          _("Replace"),
                          GTK_RESPONSE_OK,
                          NULL);
1282 1283
  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
                                            _("An application with the same name already exists. Replacing it will "
Michael Catanzaro's avatar
Michael Catanzaro committed
1284
                                              "overwrite it."));
1285 1286 1287 1288 1289 1290 1291 1292 1293
  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
  response = gtk_dialog_run (GTK_DIALOG (dialog));

  gtk_widget_destroy (dialog);

  return response == GTK_RESPONSE_OK;
}

static void
Michael Catanzaro's avatar
Michael Catanzaro committed
1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317
dialog_save_as_application_response_cb (GtkDialog                 *dialog,
                                        gint                       response,
                                        EphyApplicationDialogData *data)
{
  const char *app_name;
  char *desktop_file;
  char *message;
  NotifyNotification *notification;

  if (response == GTK_RESPONSE_OK) {
    app_name = gtk_entry_get_text (GTK_ENTRY (data->entry));

    if (ephy_web_application_exists (app_name)) {
      if (confirm_web_application_overwrite (GTK_WINDOW (dialog), app_name))
        ephy_web_application_delete (app_name);
      else
        return;
    }

    /* Create Web Application, including a new profile and .desktop file. */
    desktop_file = ephy_web_application_create (webkit_web_view_get_uri (WEBKIT_WEB_VIEW (data->view)),
                                                app_name,
                                                gtk_image_get_pixbuf (GTK_IMAGE (data->image)));
    if (desktop_file)
1318
      message = g_strdup_printf (_("The application “%s” is ready to be used"),
Michael Catanzaro's avatar
Michael Catanzaro committed
1319 1320
                                 app_name);
    else
1321
      message = g_strdup_printf (_("The application “%s” could not be created"),
Michael Catanzaro's avatar
Michael Catanzaro committed
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345
                                 app_name);

    notification = notify_notification_new (message,
                                            NULL, NULL);
    g_free (message);

    if (desktop_file) {
      notify_notification_add_action (notification, "launch", _("Launch"),
                                      (NotifyActionCallback)notify_launch_cb,
                                      g_path_get_basename (desktop_file),
                                      NULL);
      notify_notification_set_icon_from_pixbuf (notification, gtk_image_get_pixbuf (GTK_IMAGE (data->image)));
      g_free (desktop_file);
    }

    notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT);
    notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
    notify_notification_set_hint (notification, "desktop-entry", g_variant_new_string ("epiphany"));
    notify_notification_set_hint (notification, "transient", g_variant_new_boolean (TRUE));
    notify_notification_show (notification, NULL);
  }

  ephy_application_dialog_data_free (data);
  gtk_widget_destroy (GTK_WIDGET (dialog));
1346 1347
}

1348
void
1349 1350 1351
window_cmd_save_as_application (GSimpleAction *action,
                                GVariant      *parameter,
                                gpointer       user_data)
Michael Catanzaro's avatar
Michael Catanzaro committed
1352
{
1353
  EphyWindow *window = user_data;
Michael Catanzaro's avatar
Michael Catanzaro committed
1354 1355 1356 1357 1358 1359 1360 1361 1362
  EphyEmbed *embed;
  GtkWidget *dialog, *box, *image, *entry, *content_area;
  GtkWidget *label;
  GtkWidget *spinner;
  EphyWebView *view;
  EphyApplicationDialogData *data;
  GdkPixbuf *pixbuf;
  GtkStyleContext *context;
  char *markup;
1363
  char *escaped_address;
Michael Catanzaro's avatar
Michael Catanzaro committed
1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396

  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
  g_return_if_fail (embed != NULL);

  view = EPHY_WEB_VIEW (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed));

  /* Show dialog with icon, title. */
  dialog = gtk_dialog_new_with_buttons (_("Create Web Application"),
                                        GTK_WINDOW (window),
                                        GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_USE_HEADER_BAR,
                                        _("_Cancel"),
                                        GTK_RESPONSE_CANCEL,
                                        _("C_reate"),
                                        GTK_RESPONSE_OK,
                                        NULL);

  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
  gtk_container_set_border_width (GTK_CONTAINER (dialog), 10);

  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
  gtk_container_add (GTK_CONTAINER (content_area), box);
  gtk_container_set_border_width (GTK_CONTAINER (box), 5);

  image = gtk_image_new ();
  gtk_widget_set_no_show_all (image, TRUE);
  gtk_widget_set_size_request (image, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
  gtk_widget_set_margin_bottom (image, 10);
  gtk_container_add (GTK_CONTAINER (box), image);
  pixbuf = frame_pixbuf (NULL, NULL, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
  gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
  g_object_unref (pixbuf);

  spinner = gtk_spinner_new ();
1397
  gtk_widget_set_size_request (spinner, DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE);
Michael Catanzaro's avatar
Michael Catanzaro committed
1398
  gtk_spinner_start (GTK_SPINNER (spinner));
1399
  gtk_container_add (GTK_CONTAINER (box), spinner);
Michael Catanzaro's avatar
Michael Catanzaro committed
1400 1401 1402 1403 1404 1405
  gtk_widget_show (spinner);

  entry = gtk_entry_new ();
  gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
  gtk_box_pack_start (GTK_BOX (box), entry, FALSE, FALSE, 0);

1406 1407
  escaped_address = g_markup_escape_text (ephy_web_view_get_display_address (view), -1);
  markup = g_strdup_printf ("<small>%s</small>", escaped_address);
Michael Catanzaro's avatar
Michael Catanzaro committed
1408 1409
  label = gtk_label_new (NULL);
  gtk_label_set_markup (GTK_LABEL (label), markup);
1410 1411
  gtk_label_set_ellipsize (GTK_LABEL (label), PANGO_ELLIPSIZE_END);
  gtk_label_set_max_width_chars (GTK_LABEL (label), 40);
Michael Catanzaro's avatar
Michael Catanzaro committed
1412
  g_free (markup);
1413
  g_free (escaped_address);
1414

Michael Catanzaro's avatar
Michael Catanzaro committed
1415 1416 1417 1418 1419 1420 1421 1422 1423 1424
  gtk_box_pack_end (GTK_BOX (box), label, FALSE, FALSE, 0);
  context = gtk_widget_get_style_context (label);
  gtk_style_context_add_class (context, "dim-label");

  data = g_slice_new0 (EphyApplicationDialogData);
  data->view = view;
  data->image = image;
  data->entry = entry;
  data->spinner = spinner;

1425
  g_object_bind_property (image, "visible", spinner, "visible", G_BINDING_INVERT_BOOLEAN);
Michael Catanzaro's avatar
Michael Catanzaro committed
1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436

  fill_default_application_image (data);
  fill_default_application_title (data);

  gtk_widget_show_all (dialog);

  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
  g_signal_connect (dialog, "response",
                    G_CALLBACK (dialog_save_as_application_response_cb),
                    data);
  gtk_widget_show_all (dialog);
1437 1438
}

1439 1440
static char *
get_suggested_filename (EphyEmbed *embed)
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1441
{
1442 1443 1444 1445 1446
  EphyWebView *view;
  char *suggested_filename = NULL;
  const char *mimetype;
  WebKitURIResponse *response;
  WebKitWebResource *web_resource;
1447

1448 1449 1450 1451
  view = ephy_embed_get_web_view (embed);
  web_resource = webkit_web_view_get_main_resource (WEBKIT_WEB_VIEW (view));
  response = webkit_web_resource_get_response (web_resource);
  mimetype = webkit_uri_response_get_mime_type (response);
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1452

1453 1454 1455 1456 1457 1458 1459
  if ((g_ascii_strncasecmp (mimetype, "text/html", 9)) == 0) {
    /* Web Title will be used as suggested filename */
    suggested_filename = g_strconcat (ephy_embed_get_title (embed), ".mhtml", NULL);
  } else {
    suggested_filename = g_strdup (webkit_uri_response_get_suggested_filename (response));
    if (!suggested_filename) {
      SoupURI *soup_uri = soup_uri_new (webkit_web_resource_get_uri (web_resource));
1460 1461
      char *last_slash = strrchr (soup_uri->path, '/');
      suggested_filename = soup_uri_decode (last_slash ? (last_slash + 1) : soup_uri->path);
1462 1463
      soup_uri_free (soup_uri);
    }
Michael Catanzaro's avatar
Michael Catanzaro committed
1464
  }
1465

1466
  return suggested_filename;
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1467 1468
}

Iulian Radu's avatar
Iulian Radu committed
1469
static void
1470
save_response_cb (GtkNativeDialog *dialog, int response, EphyEmbed *embed)
Iulian Radu's avatar
Iulian Radu committed
1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488
{
  if (response == GTK_RESPONSE_ACCEPT) {
    char *uri, *converted;

    uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog));
    if (uri != NULL) {
      converted = g_filename_to_utf8 (uri, -1, NULL, NULL, NULL);

      if (converted != NULL) {
        EphyWebView *web_view = ephy_embed_get_web_view (embed);
        ephy_web_view_save (web_view, converted);
      }

      g_free (converted);
      g_free (uri);
    }
  }

1489
  g_object_unref (dialog);
Iulian Radu's avatar
Iulian Radu committed
1490 1491
}

1492
void
1493 1494 1495
window_cmd_save_as (GSimpleAction *action,
                    GVariant      *parameter,
                    gpointer       user_data)
1496
{
1497
  EphyWindow *window = user_data;
Michael Catanzaro's avatar
Michael Catanzaro committed
1498
  EphyEmbed *embed;
1499
  GtkFileChooser *dialog;
1500
  char *suggested_filename;
1501

1502 1503
  embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
  g_return_if_fail (embed != NULL);
1504

1505 1506 1507 1508
  dialog = ephy_create_file_chooser (_("Save"),
                                     GTK_WIDGET (window),
                                     GTK_FILE_CHOOSER_ACTION_SAVE,
                                     EPHY_FILE_FILTER_NONE);
1509

1510
  gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
1511

1512
  suggested_filename = ephy_sanitize_filename (get_suggested_filename (embed));
1513

1514 1515
  gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), suggested_filename);
  g_free (suggested_filename);
1516

1517 1518
  g_signal_connect (dialog, "response",
                    G_CALLBACK (save_response_cb), embed);
1519

1520
  gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog));
1521 1522 1523
}

void
1524 1525 1526
window_cmd_undo (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
1527 1528
{
  EphyWindow *window = user_data;
Michael Catanzaro's avatar
Michael Catanzaro committed
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544
  GtkWidget *widget;
  GtkWidget *embed;
  GtkWidget *location_entry;

  widget = gtk_window_get_focus (GTK_WINDOW (window));
  location_entry = gtk_widget_get_ancestor (widget, EPHY_TYPE_LOCATION_ENTRY);

  if (location_entry) {
    ephy_location_entry_reset (EPHY_LOCATION_ENTRY (location_entry));
  } else {
    embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED);

    if (embed) {
      webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (EPHY_EMBED (embed)), "Undo");
    }
  }
1545 1546 1547
}

void
1548 1549 1550
window_cmd_redo (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
Michael Catanzaro's avatar
Michael Catanzaro committed
1551
{
1552
  EphyWindow *window = user_data;
Michael Catanzaro's avatar
Michael Catanzaro committed
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567
  GtkWidget *widget;
  GtkWidget *embed;
  GtkWidget *location_entry;

  widget = gtk_window_get_focus (GTK_WINDOW (window));
  location_entry = gtk_widget_get_ancestor (widget, EPHY_TYPE_LOCATION_ENTRY);

  if (location_entry) {
    ephy_location_entry_undo_reset (EPHY_LOCATION_ENTRY (location_entry));
  } else {
    embed = gtk_widget_get_ancestor (widget, EPHY_TYPE_EMBED);
    if (embed) {
      webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (EPHY_EMBED (embed)), "Redo");
    }
  }
1568
}
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1569
void
1570 1571 1572
window_cmd_cut (GSimpleAction *action,
                GVariant      *parameter,
                gpointer       user_data)
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1573
{
1574
  EphyWindow *window = user_data;
Michael Catanzaro's avatar
Michael Catanzaro committed
1575
  GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1576

Michael Catanzaro's avatar
Michael Catanzaro committed
1577 1578 1579 1580 1581 1582
  if (GTK_IS_EDITABLE (widget)) {
    gtk_editable_cut_clipboard (GTK_EDITABLE (widget));
  } else {
    EphyEmbed *embed;
    embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
    g_return_if_fail (embed != NULL);
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1583

Michael Catanzaro's avatar
Michael Catanzaro committed
1584 1585
    webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed), WEBKIT_EDITING_COMMAND_CUT);
  }
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1586 1587 1588
}

void
1589 1590 1591
window_cmd_copy (GSimpleAction *action,
                 GVariant      *parameter,
                 gpointer       user_data)
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1592
{
1593
  EphyWindow *window = user_data;
Michael Catanzaro's avatar
Michael Catanzaro committed
1594
  GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1595

Michael Catanzaro's avatar
Michael Catanzaro committed
1596 1597 1598 1599
  if (GTK_IS_EDITABLE (widget)) {
    gtk_editable_copy_clipboard (GTK_EDITABLE (widget));
  } else {
    EphyEmbed *embed;
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1600

Michael Catanzaro's avatar
Michael Catanzaro committed
1601 1602
    embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
    g_return_if_fail (embed != NULL);
1603

Michael Catanzaro's avatar
Michael Catanzaro committed
1604 1605
    webkit_web_view_execute_editing_command (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed), WEBKIT_EDITING_COMMAND_COPY);
  }
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1606 1607 1608
}

void
1609 1610 1611
window_cmd_paste (GSimpleAction *action,
                  GVariant      *parameter,
                  gpointer       user_data)
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1612
{
1613
  EphyWindow *window = user_data;
Michael Catanzaro's avatar
Michael Catanzaro committed
1614
  GtkWidget *widget = gtk_window_get_focus (GTK_WINDOW (window));
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1615

Michael Catanzaro's avatar
Michael Catanzaro committed
1616 1617 1618 1619
  if (GTK_IS_EDITABLE (widget)) {
    gtk_editable_paste_clipboard (GTK_EDITABLE (widget));
  } else {
    EphyEmbed *embed;
Marco Pesenti Gritti's avatar
Marco Pesenti Gritti committed
1620

Michael Catanzaro's avatar
Michael Catanzaro committed
1621 1622