diff options
author | Havoc Pennington <hp@pobox.com> | 2002-05-30 03:54:10 +0000 |
---|---|---|
committer | Havoc Pennington <hp@src.gnome.org> | 2002-05-30 03:54:10 +0000 |
commit | 90ff51acdb483a306632b65d521d7114f58fa8a0 (patch) | |
tree | f7a4e27c7da074a0fe97744f718160efd6721200 /src/metacity-dialog.c | |
parent | f7c2b446f2a8b4eaa412b04c8d6a9544299f273e (diff) | |
download | metacity-90ff51acdb483a306632b65d521d7114f58fa8a0.tar.gz |
improve error about failing to open session manager.
2002-05-29 Havoc Pennington <hp@pobox.com>
* src/session.c (meta_session_init): improve error about failing
to open session manager.
(shutdown_cancelled_callback): send SmcSaveYourselfDone when we
get cancelled
(interact_callback): implement an interact callback that complains
about lame clients that can't be saved. Still somewhat buggy
in that it sends InteractDone before the user has closed the
dialog.
Diffstat (limited to 'src/metacity-dialog.c')
-rw-r--r-- | src/metacity-dialog.c | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/src/metacity-dialog.c b/src/metacity-dialog.c index 1e9b2f72..6a8a6a91 100644 --- a/src/metacity-dialog.c +++ b/src/metacity-dialog.c @@ -109,6 +109,156 @@ kill_window_question (const char *window_name, return 0; } +static char* +latin1_to_utf8 (const char *text) +{ + GString *str; + const char *p; + + str = g_string_new (""); + + p = text; + while (*p) + { + g_string_append_unichar (str, *p); + ++p; + } + + return g_string_free (str, FALSE); +} + +enum +{ + COLUMN_TITLE, + COLUMN_CLASS, + COLUMN_LAST +}; + +static GtkWidget* +create_lame_apps_list (char **lame_apps) +{ + GtkTreeSelection *selection; + GtkCellRenderer *cell; + GtkWidget *tree_view; + GtkTreeViewColumn *column; + GtkListStore *model; + GtkTreeIter iter; + int i; + + model = gtk_list_store_new (COLUMN_LAST, + G_TYPE_STRING, + G_TYPE_STRING); + + tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model)); + + g_object_unref (G_OBJECT (model)); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); + + gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection), + GTK_SELECTION_NONE); + + i = 0; + while (lame_apps[i]) + { + char *s; + + gtk_list_store_append (model, &iter); + + /* window class is latin-1 */ + s = latin1_to_utf8 (lame_apps[i+1]); + + gtk_list_store_set (model, + &iter, + COLUMN_TITLE, lame_apps[i], + COLUMN_CLASS, s, + -1); + + g_free (s); + + i += 2; + } + + cell = gtk_cell_renderer_text_new (); + + g_object_set (G_OBJECT (cell), + "xpad", 2, + NULL); + + column = gtk_tree_view_column_new_with_attributes (_("Title"), + cell, + "text", COLUMN_TITLE, + NULL); + + gtk_tree_view_column_set_sort_column_id (column, COLUMN_TITLE); + + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), + GTK_TREE_VIEW_COLUMN (column)); + + cell = gtk_cell_renderer_text_new (); + + column = gtk_tree_view_column_new_with_attributes (_("Class"), + cell, + "text", COLUMN_CLASS, + NULL); + + gtk_tree_view_column_set_sort_column_id (column, COLUMN_CLASS); + + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), + GTK_TREE_VIEW_COLUMN (column)); + + return tree_view; +} + +static int +warn_about_no_sm_support (char **lame_apps) +{ + GtkWidget *dialog; + GtkWidget *list; + GtkWidget *sw; + + dialog = gtk_message_dialog_new (NULL, + 0, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_CLOSE, + _("These windows do not support \"save current setup\" and will have to be restarted manually next time you log in.")); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (gtk_main_quit), + NULL); + + list = create_lame_apps_list (lame_apps); + + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_container_set_border_width (GTK_CONTAINER (sw), 3); + + gtk_container_add (GTK_CONTAINER (sw), list); + + /* sw as geometry widget */ + gtk_window_set_geometry_hints (GTK_WINDOW (dialog), + sw, NULL, 0); + + /* applies to geometry widget; try to avoid scrollbars, + * but don't make the window huge + */ + gtk_window_set_default_size (GTK_WINDOW (dialog), + 400, 225); + + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), + sw, + TRUE, TRUE, 0); + + gtk_widget_show_all (dialog); + + gtk_main (); + + return 0; +} + int main (int argc, char **argv) { @@ -134,6 +284,17 @@ main (int argc, char **argv) return kill_window_question (argv[2], argv[3]); } + else if (strcmp (argv[1], "--warn-about-no-sm-support") == 0) + { + /* argc must be even because we want title-class pairs */ + if (argc < 3 || (argc % 2) != 0) + { + g_printerr ("bad args to metacity-dialog\n"); + return 1; + } + + return warn_about_no_sm_support (&argv[2]); + } g_printerr ("bad args to metacity-dialog\n"); return 1; |