Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options for vertical OR horizontal menu. #2

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
149 changes: 149 additions & 0 deletions resources/ui-horizontal.glade
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkImage" id="close">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="resource">/shutdown-dialog/close.png</property>
</object>
<object class="GtkImage" id="logout">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_top">16</property>
<property name="margin_bottom">16</property>
<property name="resource">/shutdown-dialog/logout.png</property>
</object>
<object class="GtkImage" id="reboot">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_top">16</property>
<property name="margin_bottom">16</property>
<property name="resource">/shutdown-dialog/reboot.png</property>
</object>
<object class="GtkImage" id="shutdown">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_top">16</property>
<property name="margin_bottom">16</property>
<property name="resource">/shutdown-dialog/shutdown.png</property>
</object>
<object class="GtkImage" id="suspend">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_top">16</property>
<property name="margin_bottom">16</property>
<property name="resource">/shutdown-dialog/suspend.png</property>
</object>
<object class="GtkWindow" id="window">
<property name="can_focus">True</property>
<property name="events">GDK_KEY_PRESS_MASK | GDK_STRUCTURE_MASK</property>
<property name="type">popup</property>
<property name="window_position">center-always</property>
<property name="skip_taskbar_hint">True</property>
<property name="decorated">False</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkOverlay">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkGrid" id="grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_top">16</property>
<property name="margin_bottom">16</property>
<property name="orientation">vertical</property>
<property name="row_spacing">8</property>
<child>
<object class="GtkButton" id="shutdown-button">
<property name="name">shutdown</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="receives_default">True</property>
<property name="image">shutdown</property>
<property name="relief">none</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="reboot-button">
<property name="name">reboot</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">reboot</property>
<property name="relief">none</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="suspend-button">
<property name="name">suspend</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">suspend</property>
<property name="relief">none</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="logout-button">
<property name="name">logout</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="image">logout</property>
<property name="relief">none</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="index">-1</property>
</packing>
</child>
<child type="overlay">
<object class="GtkButton" id="close-button">
<property name="name">close</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<property name="halign">end</property>
<property name="valign">start</property>
<property name="margin_right">2</property>
<property name="margin_top">2</property>
<property name="image">close</property>
<property name="relief">none</property>
</object>
</child>
</object>
</child>
</object>
</interface>
File renamed without changes.
18 changes: 16 additions & 2 deletions shutdown-dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,22 @@ int main(int argc, char *argv[]) {
GtkWidget *window, *btn_close, *btn_shutdown, *btn_reboot, *btn_suspend, *btn_logout;

gtk_init(&argc, &argv);

builder = gtk_builder_new_from_resource("/shutdown-dialog/ui.glade");

int opt;

//Defaults
builder = gtk_builder_new_from_resource("/shutdown-dialog/ui-vertical.glade");

//Options here
while ((opt = getopt(argc, argv, "vh")) != -1) {
switch (opt) {
case 'v':
builder = gtk_builder_new_from_resource("/shutdown-dialog/ui-vertical.glade"); break;
case 'h':
builder = gtk_builder_new_from_resource("/shutdown-dialog/ui-horizontal.glade");
}
}

window = GTK_WIDGET(gtk_builder_get_object(builder, "window"));
btn_close = GTK_WIDGET(gtk_builder_get_object(builder, "close-button"));
btn_shutdown = GTK_WIDGET(gtk_builder_get_object(builder, "shutdown-button"));
Expand Down
3 changes: 2 additions & 1 deletion shutdown-dialog.gresource.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/shutdown-dialog">
<file preprocess="xml-stripblanks">ui.glade</file>
<file preprocess="xml-stripblanks">ui-vertical.glade</file>
<file preprocess="xml-stripblanks">ui-horizontal.glade</file>
<file>close.png</file>
<file>shutdown.png</file>
<file>reboot.png</file>
Expand Down