Example #1
0
static void
activate_cb (GtkAction *action,
             gpointer   dummy)
{
  GObject *object = G_OBJECT (action);
  EphyLink *link;
  EphyNode *node;
  GPtrArray *children;
  EphyEmbed *embed = NULL;
  const char *url;
  guint i;

  link = g_object_get_data (object, "ephy-link");
  node = g_object_get_data (object, "ephy-node");

  children = ephy_node_get_children (node);
  for (i = 0; i < children->len; ++i) {
    node = g_ptr_array_index (children, i);

    url = ephy_node_get_property_string (node, EPHY_NODE_BMK_PROP_LOCATION);
    embed = ephy_link_open (link, url, embed,
                            EPHY_LINK_NEW_TAB | ephy_link_flags_from_current_event ());
  }
}
Example #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);
    }
  }
}