Subject: bug#68055: lightdm and lightdm-gtk-greeter do not show session menu in guix.

From: Feng Shu <[email-masked]>
Date: Wed, 27 Dec 2023 15:14:15 +0800

See previous info:   https://issues.guix.gnu.org/57168

> It works fine, but there are a few gotchas:

> 1. The session selection menu doesn't show the items.  I don't know why.
> Perhaps a regresssion with newer GTK+.

I use below code to test:

1. lightdm-gtk-greeter code:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >
>     /* Session menu */                                                                                                    >
>     g_debug ("XXXX: Call lightdm_get_sessions functions from main");                                                      >
>     items = lightdm_get_sessions ();                                                                                      >
>     g_debug ("XXXX: Session menuitem create start.");                                                                     >
>     if (gtk_widget_get_visible (session_menuitem))                                                                        >
>     {                                                                                                                     >
>         GSList *sessions = NULL;                                                                                          >
>                                                                                                                           >
>         if (gtk_icon_theme_has_icon (icon_theme, "document-properties-symbolic"))                                         >
>             session_badge = gtk_image_new_from_icon_name ("document-properties-symbolic", GTK_ICON_SIZE_MENU);            >
>         else                                                                                                              >
>             session_badge = gtk_image_new_from_icon_name ("document-properties", GTK_ICON_SIZE_MENU);                     >
>         gtk_widget_show (session_badge);                                                                                  >
>         gtk_container_add (GTK_CONTAINER (session_menuitem), session_badge);                                              >
>                                                                                                                           >
>         items = lightdm_get_sessions ();                                                                                  >
>         for (item = items; item; item = item->next)                                                                       >
>         {                                                                                                                 >
>             LightDMSession *session = item->data;                                                                         >
>             GtkWidget *radiomenuitem;                                                                                     >
>                                                                                                                           >
>             g_debug ("XXXX: Session items: %s", lightdm_session_get_key (session));                                       >
>                                                                                                                           >
>             radiomenuitem = gtk_radio_menu_item_new_with_label (sessions, lightdm_session_get_name (session));            >
>             g_object_set_data (G_OBJECT (radiomenuitem), SESSION_DATA_KEY, (gpointer) lightdm_session_get_key (session)); >
>             sessions = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (radiomenuitem));                               >
>             g_signal_connect (G_OBJECT (radiomenuitem), "activate", G_CALLBACK (session_selected_cb), NULL);              >
>             gtk_menu_shell_append (GTK_MENU_SHELL (session_menu), radiomenuitem);                                         >
>             gtk_widget_show (GTK_WIDGET (radiomenuitem));                                                                 >
>         }                                                                                                                 >
>                                                                                                                           >
>         set_session (NULL);                                                                                               >
>     }                                                                                                                     >
>                                                                                                                           >
>     g_debug ("XXXX: Session menuitem create stop.");                                                                      >
>                                                                                                                           >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >

2. liblightdm_gobject code:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >
> /**                                                                                       >
>  * lightdm_get_sessions:                                                                  >
>  *                                                                                        >
>  * Get the available sessions.                                                            >
>  *                                                                                        >
>  * Return value: (element-type LightDMSession) (transfer none): A list of #LightDMSession >
>  **/                                                                                      >
> GList *                                                                                   >
> lightdm_get_sessions (void)                                                               >
> {                                                                                         >
>     g_debug ("Run lightdm_get_session function.");    
>     update_sessions ();                                                                   >
>     return local_sessions;                                                                >
> }                                                                                         >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >

In my debian machine, it will show the below log, and I find that
lightdm_get_session will be called successfully.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >
> DEBUG-Message: 10:51:53.859: XXXX: Call lightdm_get_sessions functions from main                                                  >
> DEBUG-Message: 10:51:53.859: Run lightdm_get_session function.                                                                    >
> DEBUG-Message: 10:51:53.859: Sessions_dir /usr/share/lightdm/sessions:/usr/share/xsessions:/usr/share/wayland-sessions            >
> DEBUG-Message: 10:51:53.859: Run lightdm_session_class_init.                                                                      >
> DEBUG-Message: 10:51:53.859: Run lightdm_session_init.                                                                            >
> DEBUG-Message: 10:51:53.859: Loaded session /usr/share/xsessions/lightdm-xsession.desktop (Default Xsession, )                    >
> DEBUG-Message: 10:51:53.860: Run lightdm_session_init.                                                                            >
> DEBUG-Message: 10:51:53.860: Loaded session /usr/share/xsessions/xfce.desktop (Xfce 会话, 使用此会话将 Xfce 作为您的桌面环境运行) >
> DEBUG-Message: 10:51:53.860: Run lightdm_session_init.                                                                            >
> DEBUG-Message: 10:51:53.860: Loaded session /usr/share/xsessions/icewm-session.desktop (IceWM Session, 此会话使您登录到 IceWM)    >
> DEBUG-Message: 10:51:53.861: Run lightdm_session_init.                                                                            >
> DEBUG-Message: 10:51:53.861: Loaded session /usr/share/wayland-sessions/weston.desktop (Weston, The reference Wayland server)     >
> DEBUG-Message: 10:51:53.861: XXXX: Session menuitem create start.                                                                 >
> DEBUG-Message: 10:51:53.864: Run lightdm_get_session function.                                                                    >
> DEBUG-Message: 10:51:53.864: XXXX: Session items: lightdm-xsession                                                                >
> DEBUG-Message: 10:51:53.864: XXXX: Session items: icewm-session                                                                   >
> DEBUG-Message: 10:51:53.864: XXXX: Session items: weston                                                                          >
> DEBUG-Message: 10:51:53.864: XXXX: Session items: xfce                                                                            >
> DEBUG-Message: 10:51:53.864: XXXX: Call lightdm_get_sessions functions from set_session, argument: (null)                         >
> DEBUG-Message: 10:51:53.864: Run lightdm_get_session function.                                                                    >
> DEBUG-Message: 10:51:53.864: XXXX: Call lightdm_get_sessions functions from set_session, argument: xfce                           >
> DEBUG-Message: 10:51:53.864: Run lightdm_get_session function.                                                                    >
> DEBUG-Message: 10:51:53.864: XXXX: Session menuitem create stop.                                                                  >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >

But in guix, lightdm_get_sessions seem to not be called, for I can not
find string "Run lightdm_get_session function. " in log file, just like
the below:

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >
> DEBUG-Message: 10:51:53.859: XXXX: Call lightdm_get_sessions functions from main                                                  >
> DEBUG-Message: 10:51:53.861: XXXX: Session menuitem create start.                                                                 >
> DEBUG-Message: 10:51:53.864: XXXX: Session menuitem create stop.                                                                  >
> >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> >

liblightdm-gobject shared library seem to be loaded, for when I remove this lib,
gtk-greeter will not show. 

but why lightdm_get_sessions function do not be called while
liblightdm-gobject is loaded? 

--