/*
  void new_window_cb(GtkMozEmbed *embed, GtkMozEmbed **newEmbed, guint chromemask, MinimoBrowser *browser)
  {
  //	open_new_tab_cb (NULL, browser);
  //	gtk_moz_embed_load_url(GTK_MOZ_EMBED(browser->mozEmbed), gMinimoLinkMessageURL );
  //	show_hide_tabs_cb (NULL, browser);
  MinimoBrowser *newBrowser = new_gtk_browser(chromemask);
  gtk_widget_set_usize(newBrowser->mozEmbed, 240, 320);
  *newEmbed = GTK_MOZ_EMBED(newBrowser->mozEmbed);
  }
*/
void location_changed_cb(GtkMozEmbed *embed, GtkLabel* label)
{
  char *newLocation;
  
  newLocation = gtk_moz_embed_get_location(embed);
  if (newLocation) {
    
    gtk_label_set_text(label, newLocation);
    add_to_history(newLocation);
    g_free(newLocation);
  }
}
Exemple #2
0
static void location_cb (GtkMozEmbed *embed, WebBrowserObject *browser)
{
    browser->FireEvent("OnLocationChange");
    char *location = gtk_moz_embed_get_location(embed);
    if (location) {
        int pos = 0;
        systemObject->Log(0, "location: %s", location);
        gtk_editable_delete_text(GTK_EDITABLE(browser->urlEntry), 0, -1);
        gtk_editable_insert_text(GTK_EDITABLE(browser->urlEntry), location, strlen(location), &pos);
        g_free(location);
    }
    browser->BrowserButtons();
}
void contentlister_request(erIpcCmd_t command, Ereader * browser)
{
    char   *item = NULL;
    int     category;
    char   *location = NULL;
    int     index;

    BR_IPCPRINTF("command %d", command.cc);

    switch (command.cc)
    {
    case ccVwrStore:
        BR_IPCPRINTF("STORE - nArg %d", command.nArg);
        //check the argument just to besure
        if (command.nArg == 3)
        {
            for (index = 0; index < command.nArg; index++)
            {
                BR_IPCPRINTF("command.arg[%d]=%s", index, command.arg[index]);
            }

            category = atoi(command.arg[1]);
            item = command.arg[2];

            if ((browser) && (browser->mozEmbed))
            {
                BR_IPCPRINTF("gtk_moz_embed_get_location");
                location = gtk_moz_embed_get_location(GTK_MOZ_EMBED(browser->mozEmbed));

                if (location)
                {
                    BR_IPCPRINTF("category=%d item=%s location=%s", category, item, location);
                    contentlister_store_item_location(category, item, location);
                    // gtk_moz_embed_get_location used g_strdup
                    g_free(location);
                }
            }
        }
        else
        {
            BR_WARNPRINTF("ccVwrStore invalid argument count %d", command.nArg);
        }
        break;
    default:
        BR_IPCPRINTF("UNHANDLED COMMAND %d", command.cc);
        break;
    }
    return;
}
Exemple #4
0
static void net_start_cb (GtkMozEmbed *embed, WebBrowserObject *browser)
{
    browser->Lock();
    char *location = gtk_moz_embed_get_location(embed);
    systemObject->Log(0, "start: %s", location);
    g_free(location);
    browser->Unlock();
    browser->FireEvent("OnStart");
    gtk_widget_set_sensitive(browser->stopButton, TRUE);
    gtk_widget_set_sensitive(browser->reloadButton, FALSE);
    browser->loadPercent = 0;
    browser->bytesLoaded = 0;
    browser->maxBytesLoaded = 0;
    browser->SetStatus(0);
}
// Generate filename given the URL of the currently viewed URL
// The memory allocated to store this name should be allocated by the calling routing
// "length" is curently not used, working with fixed max length MAX_FILE_NAME
static int selection_file_get_name(GtkMozEmbed * b, char *name, unsigned int length)
{
    char   *url = NULL;
    char   *ptr_1 = NULL;
    char   *ptr_2 = NULL;
    char    filename[MAX_FILE_NAME];

    //retrieve the URL of the HTML page
    url = gtk_moz_embed_get_location(GTK_MOZ_EMBED(b));

    if (url)
    {
        BR_LOGPRINTF("url %s", url);

        ptr_1 = strchr(url, ':');
        ptr_2 = strrchr(url, '.');

        // both ':' and '.' should appear in the url, 
        // the html filename lenght (ptr_2 - ptr_1) should fit in the 
        // filename (- extension size)

        if (ptr_1 && ptr_2 && ((ptr_2 - ptr_1) < MAX_FILE_NAME - strlen("sel")))
        {
            ptr_1 = ptr_1 + 3;  // don't include ://
            strcpy(filename, ptr_1);
            ptr_2 = strrchr(filename, '.');
            strcpy(++ptr_2, "sel");
            BR_LOGPRINTF("file name %s", filename);

            if (strlen(filename) < length)
            {
                strcpy(name, filename);
                BR_LOGPRINTF("returning %s", name);
                return 0;
            }
        }
        else
        {
            BR_ERRORPRINTF("file name problem");
        }

        g_free(url);
    }
    return 1;
}
/// Returns the current location.
string MozillaRenderer::getLocation(void)
{
	if ((m_htmlWidget == NULL) ||
		(m_rendering == false))
	{
		return "";
	}

	char *location = gtk_moz_embed_get_location(GTK_MOZ_EMBED(m_htmlWidget));
	if (location == NULL)
	{
		return "";
	}
	string locationStr = location;
	free(location);

	return locationStr;
}
Exemple #7
0
static char *
impl_get_location (GaleonEmbed *embed, 
                   gboolean toplevel,
                   gboolean requested)
{
	char *l;
	nsresult rv;
	GulCString url;
	GaleonWrapper *wrapper;

	wrapper = MOZILLA_EMBED(embed)->priv->wrapper;

	/* FIXME !toplevel requested not implemented */
	
	if (toplevel)
	{
		l = gtk_moz_embed_get_location 
			(GTK_MOZ_EMBED(embed));
	}
	else if (!toplevel)
	{
		rv = wrapper->GetDocumentUrl (url);
		l = (NS_SUCCEEDED (rv) && !url.IsEmpty()) ?
		     g_strdup (url.get()) : NULL;	   	
	}
	else if (requested)
	{
		l = mozilla_embed_get_real_location (MOZILLA_EMBED (embed));
   	
	}

	/* LOAD HACK: If we are trying to load a url, and we didn't
	 * manage it (the location is still "about:blank"), return the
	 * attempted url to the caller, so that they know the right thing */
	MozillaEmbed *membed = MOZILLA_EMBED (embed);
	if (!membed->priv->loaded_url && membed->priv->loading_url && l &&
	    !strcmp ("about:blank", l))
	{
		g_free (l);
		l = g_strdup (membed->priv->loading_url);
	}

	return l;
}
Exemple #8
0
/* Work out what the state of the page is, this ensures allows us
 * to notify the application just before the content is rendered
 * so it can restore the zoom level and things like that.
 *
 * This function is blatantly copied from epiphany */
static void
update_load_state (MozillaEmbed *membed, gint state)
{
	MozillaEmbedPrivate *priv = membed->priv;

	if (state & GTK_MOZ_EMBED_FLAG_IS_NETWORK)
	{
		if (state & GTK_MOZ_EMBED_FLAG_START)
		{
			priv->load_state = MOZILLA_EMBED_LOAD_STARTED;
		}
		else if (state & GTK_MOZ_EMBED_FLAG_STOP)
		{
			priv->load_state = MOZILLA_EMBED_LOAD_STOPPED;
		}
	}
	else if (state & GTK_MOZ_EMBED_FLAG_START &&
	         state & GTK_MOZ_EMBED_FLAG_IS_REQUEST)
	{
		if (priv->load_state == MOZILLA_EMBED_LOAD_REDIRECTING)
		{
			priv->load_state = MOZILLA_EMBED_LOAD_STARTED;
		}
		else if (priv->load_state != MOZILLA_EMBED_LOAD_LOADING)
		{
			priv->load_state = MOZILLA_EMBED_LOAD_LOADING;

			char *address;
			address = gtk_moz_embed_get_location (GTK_MOZ_EMBED (membed));
			g_signal_emit_by_name (membed, "ge_content_change", address);
			g_free (address);
		}
	}
	else if (state & GTK_MOZ_EMBED_FLAG_REDIRECTING &&
	         priv->load_state == MOZILLA_EMBED_LOAD_STARTED)
	{
		priv->load_state = MOZILLA_EMBED_LOAD_REDIRECTING;
	}
}
Exemple #9
0
void
location_changed_cb (GtkMozEmbed *embed, TestGtkBrowser *browser)
{
    char *newLocation;
    int   newPosition = 0;
    g_print("location_changed_cb\n");
    newLocation = gtk_moz_embed_get_location(embed);
    if (newLocation)
    {
        gtk_editable_delete_text(GTK_EDITABLE(browser->urlEntry), 0, -1);
        gtk_editable_insert_text(GTK_EDITABLE(browser->urlEntry),
                                 newLocation, strlen(newLocation), &newPosition);
        g_free(newLocation);
    }
    else
        g_print("failed to get location!\n");
    // always make sure to clear the tempMessage.  it might have been
    // set from the link before a click and we wouldn't have gotten the
    // callback to unset it.
    update_temp_message(browser, 0);
    // update the nav buttons on a location change
    update_nav_buttons(browser);
}
/* Method that create the "save dialog" */
void create_save_document(GtkMenuItem *button, MinimoBrowser *browser, gchar *location) 
{
  GtkWidget *fs, *ok_button, *cancel_button, *hbox;
  GtkWidget *SaveDialog, *scrolled_window;
  OpenDialogParams *dialogParams;
  
  G_CONST_RETURN gchar *file_name = NULL;
  
  g_return_if_fail(browser->mozEmbed != NULL);
  
  if (location)
    location = gtk_moz_embed_get_location(GTK_MOZ_EMBED (browser->mozEmbed));
  
  if (location) file_name = g_basename(location);
  
  dialogParams = (OpenDialogParams*) malloc(sizeof(OpenDialogParams));
  
  fs = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_SAVE);
  SaveDialog = gtk_dialog_new ();
  gtk_widget_set_size_request (SaveDialog, 240, 320);
  gtk_window_set_title (GTK_WINDOW (SaveDialog), ("Save as"));
  gtk_window_set_position (GTK_WINDOW (SaveDialog), GTK_WIN_POS_CENTER_ON_PARENT);
  gtk_window_set_modal (GTK_WINDOW (SaveDialog), TRUE);
  gtk_window_set_default_size (GTK_WINDOW (SaveDialog), 240, 320);
  gtk_window_set_resizable (GTK_WINDOW (SaveDialog), FALSE);
  gtk_window_set_decorated (GTK_WINDOW (SaveDialog), TRUE);
  gtk_window_set_skip_taskbar_hint (GTK_WINDOW (SaveDialog), TRUE);
  gtk_window_set_skip_pager_hint (GTK_WINDOW (SaveDialog), TRUE);
  gtk_window_set_type_hint (GTK_WINDOW (SaveDialog), GDK_WINDOW_TYPE_HINT_DIALOG);
  gtk_window_set_gravity (GTK_WINDOW (SaveDialog), GDK_GRAVITY_NORTH_EAST);
  gtk_window_set_transient_for(GTK_WINDOW(SaveDialog), GTK_WINDOW(browser->topLevelWindow));
  
  scrolled_window = gtk_scrolled_window_new(NULL,NULL);
  gtk_widget_show(scrolled_window);
  gtk_box_pack_start(GTK_BOX(GTK_DIALOG (SaveDialog)->vbox),scrolled_window,TRUE,TRUE,0);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
  
  gtk_scrolled_window_add_with_viewport ( GTK_SCROLLED_WINDOW (scrolled_window) ,fs);
  
  g_object_set_data(G_OBJECT(fs), "minimo", browser);
  
  /* adding extra button into the widget -> 'Ok and Cancel' Button */
  ok_button = gtk_button_new_with_label ("Ok");
  gtk_widget_modify_font(GTK_BIN(ok_button)->child, getOrCreateDefaultMinimoFont());
  
  cancel_button = gtk_button_new_with_label ("Cancel");
  gtk_widget_modify_font(GTK_BIN(cancel_button)->child, getOrCreateDefaultMinimoFont());
  
  hbox = gtk_hbox_new(FALSE, 10);
  gtk_box_pack_start(GTK_BOX (hbox), ok_button, FALSE, TRUE, 10);
  gtk_box_pack_start(GTK_BOX (hbox), cancel_button, FALSE, TRUE, 10);
  gtk_widget_show_all (hbox);
  
  gtk_file_chooser_set_extra_widget ( GTK_FILE_CHOOSER (fs), GTK_WIDGET (hbox));
  
  dialogParams->main_combo= fs;	
  dialogParams->dialog_combo= SaveDialog;
  
  /* connecting callbacks into the extra buttons */
  g_signal_connect(G_OBJECT(ok_button), "clicked", G_CALLBACK(on_save_ok_cb), dialogParams);
  
  gtk_widget_show(fs);
  gtk_widget_show_all(SaveDialog);
  
  return;
}