From e87f96c70676e317136df45e3c08e1533095efd2 Mon Sep 17 00:00:00 2001 From: George Lebl Date: Sat, 11 Aug 2001 05:53:49 +0000 Subject: use selected state for titlebar when window focused, normal when Fri Aug 10 22:56:21 2001 George Lebl * gui/gdmlogin.c: use selected state for titlebar when window focused, normal when otherwise, get rid of handle crap and the frame to make titlebar slimer. --- gui/gdmconfig.c | 46 +++++++++++------------ gui/gdmconfig.h | 6 +-- gui/gdmlogin.c | 114 ++++++++++++++++++++++++++++---------------------------- 3 files changed, 82 insertions(+), 84 deletions(-) (limited to 'gui') diff --git a/gui/gdmconfig.c b/gui/gdmconfig.c index 64f60cfe..73083134 100644 --- a/gui/gdmconfig.c +++ b/gui/gdmconfig.c @@ -725,7 +725,7 @@ gdm_config_parse_most (gboolean factory) * things up. */ if (strcmp (g_basename (s), t) != 0) { - printf ("recording %s as default session.\n", t); + /* printf ("recording %s as default session.\n", t); */ g_free (default_session_link_name); default_session_link_name = g_strdup (dent->d_name); g_free (default_session_name); @@ -738,8 +738,7 @@ gdm_config_parse_most (gboolean factory) if ((statbuf.st_mode & (S_IRUSR|S_IXUSR)) == (S_IRUSR|S_IXUSR) && (statbuf.st_mode & (S_IRGRP|S_IXGRP)) == (S_IRGRP|S_IXGRP) && - (statbuf.st_mode & (S_IROTH|S_IXOTH)) == (S_IROTH|S_IXOTH)) - { + (statbuf.st_mode & (S_IROTH|S_IXOTH)) == (S_IROTH|S_IXOTH)) { gchar *row[1]; int rowNum; GdmConfigSession *this_session; @@ -748,14 +747,17 @@ gdm_config_parse_most (gboolean factory) this_session = g_malloc0 (sizeof (GdmConfigSession)); this_session->name = g_strdup(dent->d_name); script_file = fopen(s, "r"); - if (!script_file) { - gnome_error_dialog_parented (_("Error reading session script!"), - GTK_WINDOW (GDMconfigurator)); - this_session->script_contents = g_strdup (_("Error reading this session script")); - this_session->changable = FALSE; + if (script_file == NULL) { + gnome_error_dialog_parented + (_("Error reading session script!"), + GTK_WINDOW (GDMconfigurator)); + this_session->script_contents = + g_strdup (_("Error reading this session script")); + this_session->changable = FALSE; } else { GString *str = g_string_new (NULL); gchar buffer[BUFSIZ]; + while (fgets (buffer, sizeof (buffer), script_file) != NULL) { g_string_append (str, buffer); @@ -764,8 +766,8 @@ gdm_config_parse_most (gboolean factory) g_string_free (str, FALSE); /* printf ("got script contents:\n%s.\n", this_session->script_contents); */ this_session->changable = TRUE; + fclose (script_file); } - fclose (script_file); this_session->changed = FALSE; this_session->is_default = FALSE; @@ -777,11 +779,11 @@ gdm_config_parse_most (gboolean factory) rowNum, this_session); - } - else + } else { /* FIXME: this should have an error dialog I suppose */ syslog (LOG_ERR, "Wrong permissions on %s/%s. Should be readable/executable for all.", sessions_directory, dent->d_name); + } } dent = readdir (sessdir); @@ -798,7 +800,7 @@ gdm_config_parse_most (gboolean factory) g_assert (data != NULL); if (strcmp(default_session_name, data->name) == 0) { - printf ("coloring session %s.\n", data->name); + /*printf ("coloring session %s.\n", data->name);*/ gdk_color_parse ("#d6e8ff", &col); gdk_color_alloc (gdk_colormap_get_system(), &col); @@ -1160,7 +1162,7 @@ write_config (void) full_deleted_file = g_strconcat (sessions_directory, "/", file_basename, ".deleted", NULL); - printf ("deleting: %s.\n", full_file); + /*printf ("deleting: %s.\n", full_file);*/ /* remove old backup file */ unlink (full_deleted_file); errno = 0; @@ -1199,7 +1201,7 @@ write_config (void) char *old; old = g_strconcat (sessions_directory, "/", session->old_name, NULL); - printf ("removing %s\n", session->old_name); + /* printf ("removing %s\n", session->old_name); */ errno = 0; if (unlink (old) < 0) { if (errors == NULL) @@ -1223,8 +1225,7 @@ write_config (void) } /* Now write out files that were changed (or renamed above) */ - for (i=0; irows; i++) - { + for (i=0; irows; i++) { GdmConfigSession *session; session = gtk_clist_get_row_data (GTK_CLIST(get_widget ("sessions_clist")), i); @@ -1242,7 +1243,7 @@ write_config (void) else filename = g_strconcat (sessions_directory, "/", session->name, NULL); - printf ("writing changes to: %s.\n", filename); + /* printf ("writing changes to: %s.\n", filename); */ errno = 0; fp = fopen(filename, "w"); if (fp == NULL) { @@ -1273,8 +1274,7 @@ write_config (void) /* all went well */ session->changed = FALSE; } - - } + } if (old_current_default_session != current_default_session) { if (default_session_link_name != NULL) { @@ -1392,8 +1392,7 @@ revert_to_factory_settings (GtkMenuItem *menu_item, } void -write_new_config_file (GtkButton *button, - gpointer user_data) +write_new_config_file (GtkButton *button, gpointer user_data) { write_config (); } @@ -1430,8 +1429,7 @@ open_help_page (GtkButton *button, gint -exit_configurator (void *gnomedialog, - gpointer user_data) +exit_configurator (GtkWidget *gnomedialog, gpointer user_data) { gtk_main_quit(); return 0; @@ -1781,7 +1779,7 @@ add_session_real (gchar *new_session_name, gpointer data) char *label[1]; int rowNum; - printf ("Will add session with %s.\n", new_session_name); + /* printf ("Will add session with %s.\n", new_session_name); */ a_session = g_malloc0 (sizeof (GdmConfigSession)); a_session->name = g_strdup (new_session_name); diff --git a/gui/gdmconfig.h b/gui/gdmconfig.h index 4415a410..25d93210 100644 --- a/gui/gdmconfig.h +++ b/gui/gdmconfig.h @@ -158,9 +158,9 @@ write_and_close (GtkButton *button, void open_help_page (GtkButton *button, gpointer user_data); -gint -exit_configurator (void *gnomedialog, - gpointer user_data); + +gint exit_configurator (GtkWidget *gnomedialog, gpointer user_data); + void can_apply_now (GtkEditable *editable, gpointer user_data); diff --git a/gui/gdmlogin.c b/gui/gdmlogin.c index b2557e7d..62fe3aef 100644 --- a/gui/gdmlogin.c +++ b/gui/gdmlogin.c @@ -123,6 +123,8 @@ static gboolean GdmShowLastSession; static GtkWidget *login; static GtkWidget *label; +static GtkWidget *icon_button = NULL; +static GtkWidget *title_box = NULL; static GtkWidget *clock_label = NULL; static GtkWidget *entry; static GtkWidget *ok_button; @@ -1232,6 +1234,26 @@ gdm_login_entry_handler (GtkWidget *widget, GdkEventKey *event) return (TRUE); } +static gboolean +gdm_login_focus_in (GtkWidget *widget, GdkEventFocus *event) +{ + if (title_box != NULL) + gtk_widget_set_state (title_box, GTK_STATE_SELECTED); + + if (icon_button != NULL) + gtk_widget_set_state (icon_button, GTK_STATE_NORMAL); + + return FALSE; +} + +static gboolean +gdm_login_focus_out (GtkWidget *widget, GdkEventFocus *event) +{ + if (title_box != NULL) + gtk_widget_set_state (title_box, GTK_STATE_NORMAL); + + return FALSE; +} static void gdm_login_session_handler (GtkWidget *widget) @@ -1843,7 +1865,8 @@ get_gnome_session (const char *sess_string) static gboolean err_box_clear (gpointer data) { - gtk_label_set_text (GTK_LABEL (err_box), ""); + if (err_box != NULL) + gtk_label_set_text (GTK_LABEL (err_box), ""); err_box_clear_handler = 0; return FALSE; @@ -2303,24 +2326,6 @@ gdm_login_browser_unselect (GtkWidget *widget, gint selected, GdkEvent *event) return (TRUE); } -static gboolean -handle_expose (GtkWidget *handle, GdkEventExpose *event, gpointer data) -{ - if (handle->window != NULL) - gtk_paint_handle (handle->style, - handle->window, - handle->state, - GTK_SHADOW_NONE, - &event->area, - handle, - "gdm-handle", - 0, 0, - handle->allocation.width, - handle->allocation.height, - GTK_ORIENTATION_HORIZONTAL); - return TRUE; -} - static gboolean gdm_login_handle_pressed (GtkWidget *widget, GdkEventButton *event) { @@ -2425,71 +2430,60 @@ minimize_expose (GtkWidget *icon, GdkEventExpose *event, gpointer data) static GtkWidget * create_handle (void) { - GtkWidget *ebox, *hbox, *frame, *w; + GtkWidget *hbox, *w; - ebox = gtk_event_box_new (); - gtk_signal_connect (GTK_OBJECT (ebox), "button_press_event", + title_box = gtk_event_box_new (); + gtk_signal_connect (GTK_OBJECT (title_box), "button_press_event", GTK_SIGNAL_FUNC (gdm_login_handle_pressed), NULL); - gtk_signal_connect (GTK_OBJECT (ebox), "button_release_event", + gtk_signal_connect (GTK_OBJECT (title_box), "button_release_event", GTK_SIGNAL_FUNC (gdm_login_handle_released), NULL); - gtk_signal_connect (GTK_OBJECT (ebox), "motion_notify_event", + gtk_signal_connect (GTK_OBJECT (title_box), "motion_notify_event", GTK_SIGNAL_FUNC (gdm_login_handle_motion), NULL); - frame = gtk_frame_new (NULL); - gtk_container_add (GTK_CONTAINER (ebox), frame); - gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_OUT); - hbox = gtk_hbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (frame), hbox); - - w = gtk_drawing_area_new (); - gtk_signal_connect (GTK_OBJECT (w), "expose_event", - GTK_SIGNAL_FUNC (handle_expose), - NULL); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); + gtk_container_add (GTK_CONTAINER (title_box), hbox); w = gtk_label_new (_("GNOME Desktop Manager")); - gtk_misc_set_padding (GTK_MISC (w), GNOME_PAD_SMALL, GNOME_PAD_SMALL); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, GNOME_PAD_SMALL); + gtk_misc_set_padding (GTK_MISC (w), + GNOME_PAD_SMALL, GNOME_PAD_SMALL); + gtk_box_pack_start (GTK_BOX (hbox), w, + TRUE, TRUE, GNOME_PAD_SMALL); - w = gtk_drawing_area_new (); - gtk_signal_connect (GTK_OBJECT (w), "expose_event", - GTK_SIGNAL_FUNC (handle_expose), - NULL); - gtk_box_pack_start (GTK_BOX (hbox), w, TRUE, TRUE, 0); - if (GdmIcon != NULL) { if (access (GdmIcon, R_OK)) { syslog (LOG_WARNING, _("Can't open icon file: %s. Suspending iconify feature!"), GdmIcon); } else { GtkWidget *icon; - w = gtk_button_new (); - gtk_container_border_width (GTK_CONTAINER (w), 2); + icon_button = gtk_button_new (); + gtk_container_border_width + (GTK_CONTAINER (icon_button), 2); icon = gtk_drawing_area_new (); gtk_signal_connect (GTK_OBJECT (icon), "expose_event", GTK_SIGNAL_FUNC (minimize_expose), NULL); gtk_widget_set_usize (icon, 16, -1); - gtk_container_add (GTK_CONTAINER (w), icon); + gtk_container_add (GTK_CONTAINER (icon_button), icon); gtk_signal_connect - (GTK_OBJECT (w), "clicked", + (GTK_OBJECT (icon_button), "clicked", GTK_SIGNAL_FUNC (gdm_login_iconify_handler), NULL); - GTK_WIDGET_UNSET_FLAGS (w, GTK_CAN_FOCUS); - GTK_WIDGET_UNSET_FLAGS (w, GTK_CAN_DEFAULT); - gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - gtk_tooltips_set_tip (tooltips, GTK_WIDGET (w), + GTK_WIDGET_UNSET_FLAGS (icon_button, GTK_CAN_FOCUS); + GTK_WIDGET_UNSET_FLAGS (icon_button, GTK_CAN_DEFAULT); + gtk_box_pack_start (GTK_BOX (hbox), icon_button, + FALSE, FALSE, 0); + gtk_tooltips_set_tip (tooltips, + GTK_WIDGET (icon_button), _("Iconify the login window"), NULL); } } - gtk_widget_show_all (ebox); + gtk_widget_show_all (title_box); - return ebox; + return title_box; } static void @@ -3026,10 +3020,9 @@ gdm_login_gui_init (void) gtk_table_attach (GTK_TABLE (stack), entry, 0, 1, 4, 5, (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), (GtkAttachOptions) (0), 10, 0); - gtk_signal_connect_object (GTK_OBJECT(entry), - "key_press_event", - GTK_SIGNAL_FUNC (gdm_login_entry_handler), - NULL); + gtk_signal_connect (GTK_OBJECT(entry), "key_press_event", + GTK_SIGNAL_FUNC (gdm_login_entry_handler), + NULL); hline2 = gtk_hseparator_new (); gtk_widget_ref (hline2); @@ -3116,6 +3109,13 @@ gdm_login_gui_init (void) gdm_wm_center_window (GTK_WINDOW (login)); } + gtk_signal_connect (GTK_OBJECT (login), "focus_in_event", + GTK_SIGNAL_FUNC (gdm_login_focus_in), + NULL); + gtk_signal_connect (GTK_OBJECT (login), "focus_out_event", + GTK_SIGNAL_FUNC (gdm_login_focus_out), + NULL); + gtk_widget_show_all (GTK_WIDGET (login)); } -- cgit v1.2.1