Author: kelnos
Date: 2006-07-21 04:06:39 +0000 (Fri, 21 Jul 2006)
New Revision: 22502
Modified:
xfce-utils/trunk/xfrun/xfrun-dbus.c
xfce-utils/trunk/xfrun/xfrun-dialog.c
Log:
* fix returning focus to the entry widget if the box is canceled
* unref the dbus connection (patch from nick schermer). not really necessary,
but can't hurt.
* if the xfrun4 client can't contact the dbus session bus, pop up a dialog
on our own
Modified: xfce-utils/trunk/xfrun/xfrun-dbus.c
===================================================================
--- xfce-utils/trunk/xfrun/xfrun-dbus.c 2006-07-20 23:18:31 UTC (rev 22501)
+++ xfce-utils/trunk/xfrun/xfrun-dbus.c 2006-07-21 04:06:39 UTC (rev 22502)
@@ -288,6 +288,7 @@
}
dbus_message_unref(result);
+ dbus_connection_unref(connection);
return TRUE;
}
@@ -314,15 +315,24 @@
dbus_message_unref(method);
if(result)
dbus_message_unref(result);
+
+ dbus_connection_unref(connection);
}
int
main(int argc,
char **argv)
{
+ gboolean have_gtk = gtk_init_check(&argc, &argv);
+
if(argc > 1 && !strcmp(argv[1], "--quit"))
xfrun_send_quit();
else if(argc > 1 && !strcmp(argv[1], "--daemon")) {
+ if(!have_gtk) {
+ g_critical("GTK is not available, failing.");
+ return 1;
+ }
+
if(argc == 2 || strcmp(argv[2], "--no-detach")) { /* for debugging
purposes... */
#ifdef HAVE_DAEMON
if(daemon(1, 1)) {
@@ -356,8 +366,6 @@
#endif
}
- gtk_init(&argc, &argv);
-
static_dialog = xfrun_dialog_new(NULL);
xfrun_dialog_set_destroy_on_close(XFRUN_DIALOG(static_dialog), FALSE);
g_signal_connect(G_OBJECT(static_dialog), "closed",
@@ -368,9 +376,23 @@
gtk_main();
} else {
- gdk_init(&argc, &argv);
+ if(!have_gtk) {
+ g_critical("GTK is not available, failing.");
+ return 1;
+ }
- xfrun_show_dialog(argc > 1 ? argv[1] : NULL);
+ if(!xfrun_show_dialog(argc > 1 ? argv[1] : NULL)) {
+ GtkWidget *fallback_dialog = xfrun_dialog_new(argc > 1
+ ? argv[1]
+ : NULL);
+ xfrun_dialog_set_destroy_on_close(XFRUN_DIALOG(fallback_dialog),
+ TRUE);
+ g_signal_connect(G_OBJECT(fallback_dialog), "destroy",
+ G_CALLBACK(gtk_main_quit), NULL);
+ gtk_widget_show(fallback_dialog);
+
+ gtk_main();
+ }
}
return 0;
Modified: xfce-utils/trunk/xfrun/xfrun-dialog.c
===================================================================
--- xfce-utils/trunk/xfrun/xfrun-dialog.c 2006-07-20 23:18:31 UTC (rev
22501)
+++ xfce-utils/trunk/xfrun/xfrun-dialog.c 2006-07-21 04:06:39 UTC (rev
22502)
@@ -320,8 +320,12 @@
if(dialog->priv->destroy_on_close)
gtk_widget_destroy(widget);
- else
+ else {
+ /* assume we're going to use this again */
+ xfrun_setup_entry_completion(dialog);
+ gtk_widget_grab_focus(dialog->priv->entry);
gtk_widget_hide(widget);
+ }
return TRUE;
}
@@ -630,11 +634,6 @@
xfrun_spawn_child_setup, NULL, NULL, &error))
{
xfrun_add_to_history(entry_str, in_terminal);
- if(!dialog->priv->destroy_on_close) {
- /* assume we're going to use this again */
- xfrun_setup_entry_completion(dialog);
- gtk_widget_grab_focus(dialog->priv->entry);
- }
xfrun_dialog_delete_event(GTK_WIDGET(dialog), NULL);
} else {
gchar *primary = g_strdup_printf(_("The command \"%s\" failed to
run:"),
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits