Merge lp:~samuelbf/ltsp/menu-flat into lp:ltsp/ldm

Proposed by SamuelBF on 2018-06-29
Status: Needs review
Proposed branch: lp:~samuelbf/ltsp/menu-flat
Merge into: lp:ltsp/ldm
Diff against target: 190 lines (+113/-32)
1 file modified
gtkgreet/greeter.c (+113/-32)
To merge this branch: bzr merge lp:~samuelbf/ltsp/menu-flat
Reviewer Review Type Date Requested Status
LTSP5 developers 2018-06-29 Pending
Review via email: mp+348743@code.launchpad.net

Commit message

In LDM, adding an option to have options (host, language, session ...) in one line rather than under a menu "preferences".

The name of the option is LDM_MENU_FLAT in lts.conf.

To post a comment you must log in.

Unmerged revisions

1601. By Samuel Bizien-Filippi <email address hidden> on 2018-06-29

Adding an option to replace the "Preferences" menu by list of buttons.
The option is LDM_MENU_FLAT

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gtkgreet/greeter.c'
2--- gtkgreet/greeter.c 2017-06-16 13:30:25 +0000
3+++ gtkgreet/greeter.c 2018-06-29 09:32:31 +0000
4@@ -583,6 +583,110 @@
5 return;
6 }
7
8+GtkWidget *button_with_icon(char *label, char *iconsrc, GCallback callback, gpointer data)
9+{
10+ GtkWidget *button, *icon;
11+
12+ button = gtk_button_new_with_mnemonic(_(label));
13+ icon = gtk_image_new_from_file(ldm_theme_file(iconsrc));
14+ gtk_button_set_image((GtkButton *) button, icon);
15+
16+ gtk_button_set_relief((GtkButton *) button, GTK_RELIEF_NONE);
17+ gtk_button_set_focus_on_click((GtkButton *) button, FALSE);
18+
19+ g_signal_connect(G_OBJECT(button), "clicked",
20+ callback, data);
21+
22+ return button;
23+}
24+
25+static void draw_flatmenu(GtkWidget *BottomBarBox, GtkWidget *window)
26+{
27+ GtkWidget *lang_button, *sess_button, *host_button, *custom_button,
28+ *halt_button, *reboot_button;
29+ gchar custom_env_var[20], *custom_mnemonic, *custom_command;
30+ int i;
31+
32+ if (getenv("LDM_FORCE_LANGUAGE") == NULL) {
33+ lang_button = button_with_icon("Select _Language ...", "language",
34+ G_CALLBACK(langwin), window);
35+ gtk_box_pack_start(GTK_BOX(BottomBarBox),
36+ GTK_WIDGET(lang_button), FALSE, FALSE, 5);
37+ }
38+
39+ if (getenv("LDM_FORCE_SESSION") == NULL) {
40+ sess_button = button_with_icon("Select _Session ...", "session",
41+ G_CALLBACK(sesswin), window);
42+ gtk_box_pack_start(GTK_BOX(BottomBarBox),
43+ GTK_WIDGET(sess_button), FALSE, FALSE, 5);
44+ }
45+
46+ if (ldminfo_size() > 1) {
47+ host_button = button_with_icon("Select _Host ...", "host",
48+ G_CALLBACK(hostwin), window);
49+ gtk_box_pack_start(GTK_BOX(BottomBarBox),
50+ GTK_WIDGET(host_button), FALSE, FALSE, 5);
51+ }
52+
53+ for (i = 0; i <= 9; i++) {
54+ g_sprintf(custom_env_var, "LDM_MENU_ITEM_%d", i);
55+ custom_mnemonic = getenv(custom_env_var);
56+ if (custom_mnemonic == NULL) {
57+ continue;
58+ }
59+ g_sprintf(custom_env_var, "LDM_MENU_COMMAND_%d", i);
60+ custom_command = getenv(custom_env_var);
61+ if (custom_command == NULL) {
62+ continue;
63+ }
64+ custom_button = button_with_icon(custom_mnemonic, "backend",
65+ G_CALLBACK(spawn_command), g_strdup(custom_command));
66+ gtk_box_pack_start(GTK_BOX(BottomBarBox),
67+ GTK_WIDGET(custom_button), FALSE, FALSE, 5);
68+ }
69+
70+ reboot_button = button_with_icon("_Reboot", "reboot",
71+ G_CALLBACK(spawn_command), "/sbin/reboot");
72+ gtk_box_pack_start(GTK_BOX(BottomBarBox),
73+ GTK_WIDGET(reboot_button), FALSE, FALSE, 5);
74+
75+ halt_button = button_with_icon("Shut_down", "shutdown",
76+ G_CALLBACK(spawn_command), "/sbin/poweroff");
77+ gtk_box_pack_start(GTK_BOX(BottomBarBox),
78+ GTK_WIDGET(halt_button), FALSE, FALSE, 5);
79+
80+ return;
81+}
82+
83+/*
84+ * draw_prefbutton : add a button "Preferences" poping up menu to bottombarbox.
85+ * (alternative to draw_flatmenu)
86+ */
87+static void draw_prefbutton(GtkWidget *BottomBarBox, GtkWidget *window)
88+{
89+ GtkWidget *optionbutton;
90+ GtkWidget *optionbutton_box, *optionbutton_spacer;
91+
92+ optionbutton = button_with_icon("_Preferences", "preferences", G_CALLBACK(popup_menu), window);
93+
94+#ifndef K12LINUX
95+ gtk_box_pack_start(GTK_BOX(BottomBarBox),
96+ GTK_WIDGET(optionbutton), FALSE, FALSE, 5);
97+#else
98+ optionbutton_box = gtk_vbox_new(FALSE, 0);
99+ optionbutton_spacer = gtk_label_new("");
100+ gtk_box_pack_start(GTK_BOX(optionbutton_box),
101+ GTK_WIDGET(optionbutton_spacer), TRUE, FALSE,
102+ 0);
103+ gtk_box_pack_end(GTK_BOX(optionbutton_box),
104+ GTK_WIDGET(optionbutton), FALSE, FALSE, 5);
105+ gtk_box_pack_start(GTK_BOX(BottomBarBox),
106+ GTK_WIDGET(optionbutton_box), FALSE, FALSE, 5);
107+#endif
108+
109+ return;
110+}
111+
112 /*
113 * scopy()
114 *
115@@ -634,8 +738,6 @@
116 GtkWidget *logo, *EntryBox;
117 GtkWidget *timeoutspacer1, *timeoutspacer2, *timeoutlabel;
118 GtkWidget *entryspacer1, *entryspacer2;
119- GtkWidget *optionico;
120- GtkWidget *optionbutton;
121 GdkWindow *root;
122 GdkPixbuf *pix;
123 gint width, height;
124@@ -708,21 +810,6 @@
125 /**** Create the login window ****/
126 loginWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL);
127
128- /* Create the options button */
129- {
130-
131-
132- optionbutton = gtk_button_new_with_mnemonic(_("_Preferences"));
133- optionico = gtk_image_new_from_file(ldm_theme_file("preferences"));
134- gtk_button_set_image((GtkButton *) optionbutton, optionico);
135-
136- gtk_button_set_relief((GtkButton *) optionbutton, GTK_RELIEF_NONE);
137- gtk_button_set_focus_on_click((GtkButton *) optionbutton, FALSE);
138-
139- g_signal_connect(G_OBJECT(optionbutton), "clicked",
140- G_CALLBACK(popup_menu), loginWindow);
141- }
142-
143 /**** Create the login window ****/
144 {
145 GtkWidget *guestbox, *guestspacer1, *guestspacer2, *vbox, *vbox2,
146@@ -762,8 +849,8 @@
147
148 UserPrompt = gtk_label_new("");
149
150- if (lw < 180)
151- lw = 180;
152+ if (lw < 360)
153+ lw = 360;
154
155 gtk_misc_set_alignment((GtkMisc *) UserPrompt, 1, 0.5);
156 gtk_widget_set_size_request(UserPrompt, (lw / 2), 0);
157@@ -859,26 +946,20 @@
158 gtk_widget_set_size_request(prefBar, width, BOTTOM_BAR_HEIGHT);
159
160 BottomBarBox = gtk_hbox_new(FALSE, 0);
161+
162+ if (ldm_getenv_bool("LDM_MENU_FLAT")) {
163+ draw_flatmenu(BottomBarBox, loginWindow);
164+ } else {
165+ draw_prefbutton(BottomBarBox, loginWindow);
166+ }
167+
168 #ifndef K12LINUX
169- gtk_box_pack_start(GTK_BOX(BottomBarBox),
170- GTK_WIDGET(optionbutton), FALSE, FALSE, 5);
171-
172 gtk_box_pack_end(GTK_BOX(BottomBarBox),
173 GTK_WIDGET(timelabel), FALSE, FALSE, 5);
174
175 gtk_box_pack_end(GTK_BOX(BottomBarBox),
176 GTK_WIDGET(syslabel), FALSE, FALSE, 0);
177 #else
178- optionbutton_box = gtk_vbox_new(FALSE, 0);
179- optionbutton_spacer = gtk_label_new("");
180- gtk_box_pack_start(GTK_BOX(optionbutton_box),
181- GTK_WIDGET(optionbutton_spacer), TRUE, FALSE,
182- 0);
183- gtk_box_pack_end(GTK_BOX(optionbutton_box),
184- GTK_WIDGET(optionbutton), FALSE, FALSE, 5);
185- gtk_box_pack_start(GTK_BOX(BottomBarBox),
186- GTK_WIDGET(optionbutton_box), FALSE, FALSE, 5);
187-
188 if (has_bottom_right_image == TRUE) {
189 bottom_right_box = gtk_vbox_new(FALSE, 0);
190 bottom_right_spacer = gtk_label_new("");

Subscribers

People subscribed via source and target branches

to all changes: