Exemplo n.º 1
0
static void
node_added_cb (EphyNode       *parent,
               EphyNode       *child,
               GtkActionGroup *action_group)
{
  GObject *action_object;
  GtkAction *action;
  char name[EPHY_OPEN_TABS_ACTION_NAME_BUFFER_SIZE];
  char accel[256];

  EPHY_OPEN_TABS_ACTION_NAME_PRINTF (name, child);

  /* FIXME !!!! */
  action = gtk_action_new (name, _("Open in New _Tabs"),
                           _("Open the bookmarks in this topic in new tabs"), NULL);
  action_object = (GObject *)action;

  g_object_set_data (action_object, "ephy-node", child);
  g_object_set_data (action_object, "ephy-link", EPHY_LINK (action_group));

  g_signal_connect (action, "activate",
                    G_CALLBACK (activate_cb), NULL);

  g_snprintf (accel, sizeof (accel), "<Actions>/%s/%s",
              gtk_action_group_get_name (action_group),
              name);

  gtk_action_set_accel_path (action, accel);
  gtk_action_group_add_action (action_group, action);
  g_object_unref (action);
}
Exemplo n.º 2
0
static void
notebook_drag_data_received_cb (GtkWidget        *widget,
                                GdkDragContext   *context,
                                int               x,
                                int               y,
                                GtkSelectionData *selection_data,
                                guint             info,
                                guint             time,
                                EphyEmbed        *embed)
{
  EphyWindow *window;
  GtkWidget *notebook;
  GdkAtom target;
  const guchar *data;

  target = gtk_selection_data_get_target (selection_data);
  if (target == gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB"))
    return;

  g_signal_stop_emission_by_name (widget, "drag-data-received");

  if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
                              EPHY_PREFS_LOCKDOWN_ARBITRARY_URL))
    return;

  data = gtk_selection_data_get_data (selection_data);
  if (gtk_selection_data_get_length (selection_data) <= 0 || data == NULL)
    return;

  window = EPHY_WINDOW (gtk_widget_get_toplevel (widget));
  notebook = ephy_window_get_notebook (window);

  if (target == gdk_atom_intern (EPHY_DND_URL_TYPE, FALSE)) {
    char **split;

    /* URL_TYPE has format: url \n title */
    split = g_strsplit ((const gchar *)data, "\n", 2);
    if (split != NULL && split[0] != NULL && split[0][0] != '\0') {
      ephy_link_open (EPHY_LINK (notebook), split[0], embed,
                      embed ? 0 : EPHY_LINK_NEW_TAB);
    }
    g_strfreev (split);
  } else if (target == gdk_atom_intern (EPHY_DND_URI_LIST_TYPE, FALSE)) {
    char **uris;
    int i;

    uris = gtk_selection_data_get_uris (selection_data);
    if (uris == NULL)
      return;

    for (i = 0; i < INSANE_NUMBER_OF_URLS && uris[i] != NULL; i++) {
      embed = ephy_link_open (EPHY_LINK (notebook), uris[i], embed,
                              (embed && i == 0) ? 0 : EPHY_LINK_NEW_TAB);
    }

    g_strfreev (uris);
  } else {
    char *text;

    text = (char *)gtk_selection_data_get_text (selection_data);
    if (text != NULL) {
      char *address;

      address = ephy_embed_utils_normalize_or_autosearch_address (text);
      ephy_link_open (EPHY_LINK (notebook), address, embed,
                      embed ? 0 : EPHY_LINK_NEW_TAB);
      g_free (address);
      g_free (text);
    }
  }
}