Various Patches
Crispin Flowerday <[email protected]>
| Newsgroups | gmane.comp.web.galeon.devel |
|---|---|
| Message-ID | <1056904677.14398.9.camel@drno> |
Hi, Attached are a few patches to fix a couple of things. 1) Make the Location bar CTRL+Enter aware, it opens the link in a new tab or window (depending on preference) 2) Fix the crash dialog so that if you start galeon with : $ galeon www.slashdot.org and you select 'Dont start' it doesn't start 3) A workaround for crashes on startup on slow / heavily loaded machines. I have spent _ages_ trying to narrow down the exact problem, what happens is that as soon as the main gtk loop is called, we receive a signal from the session manager to die() causing galeon to exit. The best solution I can find is to call all pending events before doing the slow galeon_main_start(). Ephiphany solves this by setting the it's galeon_main_start function to run when the gtk_main loop is idle. It is slightly harder for us as the crash dialog we need a 2 stage start due to the fact that our crash dialog can exit the program. Also this patch moves the gdk_notify_startup_complete() later. GTK will call this function when the first window is opened (which is the recommended way to do it, but it still needs to be called if we use an existing instance. 4) A Patch to fix a few memory leaks and unitialised values. I found all of these using valgrind. At the moment 11k is lost with just opening 1 window and closing it. One big culprit is the statusbar, it doesn't seem to free any of its objects, but I couldn't work out how to get it do that. (g_object_unref and gtk_widget_destroy complained), but it is possible I was doing something wrong. cheers Crispin
galeon_crash_dialog_fix.diff
(text/x-patch, 3.1 KB)
Index: src/session.c
===================================================================
RCS file: /cvs/gnome/galeon/src/session.c,v
retrieving revision 1.153
diff -u -r1.153 session.c
--- src/session.c 19 Jan 2003 16:19:13 -0000 1.153
+++ src/session.c 29 Jun 2003 16:17:44 -0000
@@ -256,7 +256,7 @@
*
* Return value: return false if no window has been opened
**/
-gboolean
+SessionResumeRet
session_autoresume (Session *session)
{
char *saved_session;
@@ -272,7 +272,7 @@
if (!crashed_resume_dialog (session))
{
session->priv->dont_remove_crashed = TRUE;
- return TRUE;
+ return SESSION_ABORT;
}
loaded = TRUE;
@@ -292,7 +292,7 @@
g_free (saved_session);
/* return false if no window has been opened */
- return (session->priv->windows != NULL);
+ return (session->priv->windows != NULL) ? SESSION_LOADED : SESSION_NONE ;
}
static void
Index: src/session.h
===================================================================
RCS file: /cvs/gnome/galeon/src/session.h,v
retrieving revision 1.25
diff -u -r1.25 session.h
--- src/session.h 19 Jan 2003 16:19:13 -0000 1.25
+++ src/session.h 29 Jun 2003 16:17:44 -0000
@@ -58,6 +58,14 @@
void ( *close_window) (Session *session);
};
+
+typedef enum {
+ SESSION_LOADED,
+ SESSION_NONE,
+ SESSION_ABORT
+} SessionResumeRet;
+
+
GType session_get_type (void);
Session *session_new (void);
@@ -70,7 +78,7 @@
void session_save (Session *session,
const char *filename);
-gboolean session_autoresume (Session *session);
+SessionResumeRet session_autoresume (Session *session);
const GList *session_get_windows (Session *session);
Index: src/galeon-automation.c
===================================================================
RCS file: /cvs/gnome/galeon/src/galeon-automation.c,v
retrieving revision 1.19
diff -u -r1.19 galeon-automation.c
--- src/galeon-automation.c 1 May 2003 21:27:40 -0000 1.19
+++ src/galeon-automation.c 29 Jun 2003 16:17:44 -0000
@@ -62,7 +62,7 @@
guint open_in_new_tab : 1;
} GaleonAutomationLoadurlData;
-GSList *postponed_loadurls = NULL;
+static GSList *postponed_loadurls = NULL;
static gboolean initialized = FALSE;
static BonoboObject *
@@ -168,11 +168,25 @@
/* no window open, let's try to autoresume */
if (session_get_windows (session) == NULL)
{
- gboolean res;
+ SessionResumeRet res;
res = session_autoresume (session);
+
+ /* Don't load any windows, the use wants to abort this
+ * instance */
+ if ( res == SESSION_ABORT ) {
+ GSList * iterator;
+ for( iterator = postponed_loadurls ; iterator ; iterator = iterator->next) {
+ GaleonAutomationLoadurlData *data = iterator->data;
+ g_free (data->url);
+ g_free (data);
+ }
+ g_slist_free (postponed_loadurls);
+ return;
+ }
+
/* no need to open the homepage,
* we did already open session windows */
- if (res && postponed_loadurls) {
+ if (res == SESSION_LOADED && postponed_loadurls) {
GSList *last = g_slist_last (postponed_loadurls);
GaleonAutomationLoadurlData *data = last->data;
if (data->url == NULL || *data->url == 0) {
galeon_location_ctrl_enter.diff
(text/x-patch, 4.6 KB)
Index: utils/location-entry.c
===================================================================
RCS file: /cvs/gnome/galeon/utils/location-entry.c,v
retrieving revision 1.14
diff -u -r1.14 location-entry.c
--- utils/location-entry.c 15 Jun 2003 08:01:09 -0000 1.14
+++ utils/location-entry.c 29 Jun 2003 16:08:50 -0000
@@ -122,8 +122,8 @@
G_SIGNAL_RUN_FIRST | G_SIGNAL_RUN_LAST | G_SIGNAL_RUN_CLEANUP,
G_STRUCT_OFFSET (GaleonLocationEntryClass, galeon_location_entry_url_activated),
NULL, NULL,
- galeon_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
+ galeon_marshal_VOID__STRING_INT,
+ G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_BOOLEAN);
}
static gboolean
@@ -328,12 +328,22 @@
const gchar *new_location)
{
GaleonLocationEntryPrivate *p = w->priv;
- int pos;
+ int pos = 0;
gtk_editable_delete_text (GTK_EDITABLE (p->entry), 0, -1);
gtk_editable_insert_text (GTK_EDITABLE (p->entry), new_location, g_utf8_strlen (new_location, -1),
&pos);
}
+static void
+emit_activated_signal (GaleonLocationEntry *w, const char *url, gboolean new_tab_or_window)
+{
+ w->priv->editing = FALSE;
+
+ g_signal_emit (w, GaleonLocationEntrySignals[GALEON_LOCATION_ENTRY_URL_ACTIVATED],
+ 0, url, new_tab_or_window);
+}
+
+
/* this is from the old location entry, need to do the autocompletion before implementing this */
static gboolean
galeon_location_entry_key_press_event_cb (GtkWidget *entry, GdkEventKey *event, GaleonLocationEntry *w)
@@ -359,6 +369,25 @@
suggest = FALSE;
}
+
+ /* Handle any CTRL+Enter events */
+ if ( event->state & GDK_CONTROL_MASK &&
+ ( event->keyval == GDK_KP_Enter || event->keyval == GDK_Return ) )
+ {
+ char *url = gtk_editable_get_chars (GTK_EDITABLE(entry), 0, -1);
+
+ DEBUG_MSG (("In galeon_location_key_press_cb, going to %s\n", url));
+
+ galeon_location_entry_autocompletion_hide_alternatives (w);
+
+ emit_activated_signal (w, url, TRUE);
+
+ g_free (url);
+
+ return TRUE;
+ }
+
+ /* Ingore any CTRL+<key> commands (or backspace commands) */
if ((event->state & GDK_CONTROL_MASK) ||
(event->state == 0 && event->keyval == GDK_BackSpace))
{
@@ -498,14 +527,6 @@
}
static void
-emit_activated_signal (GaleonLocationEntry *w, const char *url)
-{
- w->priv->editing = FALSE;
-
- g_signal_emit (w, GaleonLocationEntrySignals[GALEON_LOCATION_ENTRY_URL_ACTIVATED], 0, url);
-}
-
-static void
galeon_location_entry_activate_cb (GtkEntry *entry, GaleonLocationEntry *w)
{
char *url;
@@ -516,7 +537,7 @@
DEBUG_MSG (("In galeon_location_entry_activate_cb, going to %s\n", url));
- emit_activated_signal (w, url);
+ emit_activated_signal (w, url, FALSE);
g_free (url);
}
@@ -613,7 +634,7 @@
galeon_location_entry_autocompletion_hide_alternatives (w);
- emit_activated_signal (w, url);
+ emit_activated_signal (w, url, FALSE);
}
static void
@@ -672,7 +693,7 @@
if (url && url[0] != '\0')
{
p->hack_for_going_to_the_site_when_clicking_in_the_location_history = FALSE;
- emit_activated_signal (e, url);
+ emit_activated_signal (e, url, FALSE);
g_free (url);
}
}
Index: utils/location-entry.h
===================================================================
RCS file: /cvs/gnome/galeon/utils/location-entry.h,v
retrieving revision 1.3
diff -u -r1.3 location-entry.h
--- utils/location-entry.h 15 Jun 2003 08:01:09 -0000 1.3
+++ utils/location-entry.h 29 Jun 2003 16:08:50 -0000
@@ -49,7 +49,7 @@
GtkHBoxClass parent_class;
/* signals */
- void (*galeon_location_entry_url_activated) (GaleonLocationEntry *w, const gchar *url);
+ void (*galeon_location_entry_url_activated) (GaleonLocationEntry *w, const gchar *url, gboolean new_tab_or_window);
};
/* Remember: fields are public read-only */
Index: src/toolbar.c
===================================================================
RCS file: /cvs/gnome/galeon/src/toolbar.c,v
retrieving revision 1.245
diff -u -r1.245 toolbar.c
--- src/toolbar.c 28 Jun 2003 20:51:53 -0000 1.245
+++ src/toolbar.c 29 Jun 2003 16:08:50 -0000
@@ -220,9 +220,18 @@
}
static void
-toolbar_location_url_activate_cb (GaleonLocationEntry *entry, const gchar *url, GaleonWindow *window)
+toolbar_location_url_activate_cb (GaleonLocationEntry *entry, const gchar *url,
+ gboolean new_tab_or_window, GaleonWindow *window)
{
- galeon_window_load_url (window, url);
+ if (!new_tab_or_window)
+ galeon_window_load_url (window, url);
+ else
+ {
+ /* Open the link in a new tab (or window) */
+ GaleonTab *tab = galeon_window_get_active_tab (window);
+
+ galeon_shell_new_tab (galeon_shell, window, tab, url, 0);
+ }
}
static void
galeon_memleaks_uninitalized_values.diff
(text/plain, 4.9 KB)
--- bookmarks/bookmarks-smart-site-tb-widget.c 28 Jun 2003 17:11:52 -0000 1.23
+++ bookmarks/bookmarks-smart-site-tb-widget.c 29 Jun 2003 16:23:51 -0000
@@ -127,6 +127,10 @@
all_instances = g_slist_remove (all_instances, w);
+ g_free (p->entries);
+ g_free (p->combos);
+ g_free (p->entries_sizes);
+
g_free (p);
G_OBJECT_CLASS (gb_tb_widget_class)->finalize (o);
--- embed/galeon-embed-popup.c 21 Jun 2003 18:37:38 -0000 1.30
+++ embed/galeon-embed-popup.c 29 Jun 2003 16:23:51 -0000
@@ -241,6 +241,11 @@
g_object_unref (G_OBJECT (gep->priv->event));
}
+ if (gep->priv->helper_list)
+ {
+ g_object_unref (G_OBJECT (gep->priv->helper_list));
+ }
+
g_free (gep->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
--- embed/galeon-embed-utils.c 6 Apr 2003 10:25:37 -0000 1.14
+++ embed/galeon-embed-utils.c 29 Jun 2003 16:23:51 -0000
@@ -282,6 +282,8 @@
}
+ for (cl = charsets; cl != NULL; cl = cl->next)
+ g_free (cl->data);
g_list_free (charsets);
g_string_append (xml_string, "</submenu>");
group_index++;
--- mozilla/mozilla-embed-shell.cpp 28 Jun 2003 16:14:01 -0000 1.63
+++ mozilla/mozilla-embed-shell.cpp 29 Jun 2003 16:23:52 -0000
@@ -1096,7 +1096,7 @@
break;
}
#else
- PRBool blocked;
+ PRBool blocked = PR_FALSE;
rv = permissionManager->TestForBlocking(nsDependentCString(url),
type, &blocked);
--- mozilla/mozilla-notifiers.cpp 19 May 2003 03:49:39 -0000 1.17
+++ mozilla/mozilla-notifiers.cpp 29 Jun 2003 16:23:53 -0000
@@ -770,6 +770,7 @@
mozilla_prefs_set_string ("general.useragent.override", user_agent);
g_free (user_agent);
+ g_free (value);
}
static void
--- src/appearance-prefs.c 27 Oct 2002 13:50:38 -0000 1.6
+++ src/appearance-prefs.c 29 Jun 2003 16:23:53 -0000
@@ -182,7 +182,7 @@
GaleonEmbedShell *shell;
const char *name;
char key[255];
- int pos;
+ int pos = 0;
GtkWidget *entry = GTK_COMBO(combo)->entry;
shell = galeon_shell_get_embed_shell (galeon_shell);
--- src/galeon-bookmarks-icon-provider.c 1 Apr 2003 18:04:35 -0000 1.6
+++ src/galeon-bookmarks-icon-provider.c 29 Jun 2003 16:23:54 -0000
@@ -170,10 +170,7 @@
gb_galeon_icon_provider_add_cache_url_to_bookmark
(GB_GALEON_ICON_PROVIDER (ip), curl, rb);
}
- else
- {
- g_free (curl);
- }
+ g_free (curl);
}
}
@@ -243,7 +240,7 @@
return;
}
- g_hash_table_insert (p->cache_url_to_bookmark, curl, b);
+ g_hash_table_insert (p->cache_url_to_bookmark, g_strdup(curl), b);
data = g_new (gpointer, 2);
data[0] = g_object_ref (gip);
--- src/galeon-favicon-cache.c 28 Aug 2002 19:05:15 -0000 1.8
+++ src/galeon-favicon-cache.c 29 Jun 2003 16:23:54 -0000
@@ -260,8 +260,10 @@
if (pixbuf == NULL)
{
pixbuf = gdk_pixbuf_new_from_file (pixbuf_location, NULL);
- if (pixbuf == NULL)
+ if (pixbuf == NULL) {
+ g_free (cache_url);
return;
+ }
if (gdk_pixbuf_get_width (pixbuf) > 16 ||
gdk_pixbuf_get_height (pixbuf) > 16)
@@ -277,8 +279,10 @@
pixbuf);
}
- if (pixbuf == NULL)
+ if (pixbuf == NULL) {
+ g_free (cache_url);
return;
+ }
g_object_ref (G_OBJECT (pixbuf));
--- src/galeon-spinner.c 8 Mar 2003 12:54:23 -0000 1.7
+++ src/galeon-spinner.c 29 Jun 2003 16:23:55 -0000
@@ -601,6 +601,7 @@
spinner->details->image_list = g_list_reverse (image_list);
g_free (image_theme);
+ g_free (path);
}
static gboolean
--- src/galeon-tab.c 15 Jun 2003 14:26:50 -0000 1.94
+++ src/galeon-tab.c 29 Jun 2003 16:23:55 -0000
@@ -354,6 +354,8 @@
g_free (tab->priv->link_message);
g_free (tab->priv->js_message);
+ g_free (tab->priv->title);
+ g_free (tab->priv->location);
g_free (tab->priv);
G_OBJECT_CLASS (parent_class)->finalize (object);
--- src/galeon-window.c 29 Jun 2003 14:38:37 -0000 1.168
+++ src/galeon-window.c 29 Jun 2003 16:23:57 -0000
@@ -800,10 +800,15 @@
static void
setup_web_menu (GaleonWindow *window)
{
+ GConfValue *gcvalue;
+
BonoboUIComponent *ui_component = BONOBO_UI_COMPONENT (window->ui_component);
- radio_menu_group_set_from_value(ui_component, COOKIES,
- eel_gconf_get_value(CONF_PERSISTENT_COOKIES_BEHAVIOR));
+ gcvalue = eel_gconf_get_value(CONF_PERSISTENT_COOKIES_BEHAVIOR);
+
+ radio_menu_group_set_from_value(ui_component, COOKIES, gcvalue);
+
+ gconf_value_free (gcvalue);
bonobo_ui_component_add_listener(ui_component, "AcceptCookiesAlways",
accept_cookies_bonoboui_changed_cb,
@@ -881,10 +886,13 @@
static void
setup_images_menu(GaleonWindow *window)
{
+ GConfValue *gcvalue;
BonoboUIComponent *ui_component = BONOBO_UI_COMPONENT(window->ui_component);
- radio_menu_group_set_from_value(ui_component, IMAGES,
- eel_gconf_get_value(CONF_FILTERING_IMAGE_LOADING_TYPE));
+ gcvalue = eel_gconf_get_value(CONF_FILTERING_IMAGE_LOADING_TYPE);
+ radio_menu_group_set_from_value(ui_component, IMAGES, gcvalue);
+
+ gconf_value_free (gcvalue);
bonobo_ui_component_add_listener(ui_component, "ViewImagesAlways",
view_images_bonoboui_changed_cb,
galeon_startup.diff
(text/x-patch, 937 B)
Index: src/galeon-main.c
===================================================================
RCS file: /cvs/gnome/galeon/src/galeon-main.c,v
retrieving revision 1.27
diff -u -r1.27 galeon-main.c
--- src/galeon-main.c 22 Jun 2003 08:32:26 -0000 1.27
+++ src/galeon-main.c 29 Jun 2003 16:27:24 -0000
@@ -158,6 +158,11 @@
galeon_shell_new ();
galeon_main_start ();
+
+ /* Flush any pending GTK events, this works around crashes when
+ * it takes a long time to startup. */
+ while (gtk_events_pending())
+ gtk_main_iteration();
galeon_automation_complete_initialization ();
@@ -166,6 +171,12 @@
bonobo_main ();
gnome_vfs_shutdown ();
+ }
+ else
+ {
+#if GTK_CHECK_VERSION(2,2,0)
+ gdk_notify_startup_complete ();
+#endif
}
return 0;
@@ -270,10 +281,6 @@
}
CORBA_exception_free (&corba_env);
-
-#if GTK_CHECK_VERSION(2,2,0)
- gdk_notify_startup_complete ();
-#endif
}
static gboolean