Add icons for open/close
This commit is contained in:
parent
28ddbd9585
commit
997fed147a
|
@ -31,7 +31,10 @@ set(SOURCE_FILE src/main.cpp src/MainWin.cpp)
|
|||
#Compile Resource
|
||||
|
||||
set(RESOURCE_LIST
|
||||
style.css)
|
||||
style.css
|
||||
icons/scalable/status/win_close.svg
|
||||
icons/scalable/status/win_maximize.svg
|
||||
icons/scalable/status/win_minimize.svg)
|
||||
|
||||
compile_gresources(RESOURCE_FILE
|
||||
XML_OUT
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 733 B |
|
@ -0,0 +1,3 @@
|
|||
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4.795 3.912l-.883.883.147.146L7.117 8 4.06 11.059l-.147.146.883.883.146-.147L8 8.883l3.059 3.058.146.147.883-.883-.147-.146L8.883 8l3.058-3.059.147-.146-.883-.883-.146.147L8 7.117 4.941 4.06z" fill="gray" fill-rule="evenodd" font-family="sans-serif" font-weight="400" overflow="visible" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none" white-space="normal"/>
|
||||
</svg>
|
After Width: | Height: | Size: 760 B |
|
@ -0,0 +1,3 @@
|
|||
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4 4v8h8V4zm1 1h6v6H5z" fill="gray" font-family="sans-serif" font-weight="400" overflow="visible" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none" white-space="normal"/>
|
||||
</svg>
|
After Width: | Height: | Size: 570 B |
|
@ -0,0 +1,3 @@
|
|||
<svg viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="m4 10v1h8v-1z" fill="gray" font-family="sans-serif" font-weight="400" overflow="visible" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none" white-space="normal"/>
|
||||
</svg>
|
After Width: | Height: | Size: 561 B |
|
@ -1,5 +1,11 @@
|
|||
|
||||
/* A slim headerbar style for widgets */
|
||||
headerbar{
|
||||
min-height:20px;
|
||||
min-height:10px;
|
||||
margin:0px;
|
||||
}
|
||||
|
||||
button{
|
||||
min-height: 8px;
|
||||
margin: 0px;
|
||||
}
|
|
@ -3,12 +3,27 @@
|
|||
static void gtkmain(GtkApplication *app, gpointer user_data)
|
||||
{
|
||||
GtkWidget *window, *header;
|
||||
GtkWidget *btn_close, *btn_mini;
|
||||
GtkWidget *img_close, *img_mini;
|
||||
|
||||
// Create widgets
|
||||
window = gtk_application_window_new(app);
|
||||
header = gtk_header_bar_new();
|
||||
gtk_window_set_titlebar(GTK_WINDOW(window), header);
|
||||
|
||||
// Initalize headerbar
|
||||
gtk_header_bar_set_show_title_buttons(GTK_HEADER_BAR(header), FALSE);
|
||||
|
||||
// Add a close button
|
||||
btn_close = gtk_button_new();
|
||||
|
||||
gtk_header_bar_pack_start(GTK_HEADER_BAR(header), btn_close);
|
||||
|
||||
// Add a minimize button
|
||||
btn_mini = gtk_button_new();
|
||||
|
||||
gtk_header_bar_pack_start(GTK_HEADER_BAR(header), btn_mini);
|
||||
|
||||
// Add style for headerbar
|
||||
GtkCssProvider *provider = gtk_css_provider_new();
|
||||
gtk_css_provider_load_from_resource(provider, "/org/gtk/daleclack/style.css");
|
||||
|
@ -16,8 +31,23 @@ static void gtkmain(GtkApplication *app, gpointer user_data)
|
|||
GTK_STYLE_PROVIDER(provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
g_signal_connect_swapped(btn_close, "clicked", G_CALLBACK(gtk_window_close), window);
|
||||
g_signal_connect_swapped(btn_mini, "clicked", G_CALLBACK(gtk_window_minimize), window);
|
||||
// show the window
|
||||
gtk_window_present(GTK_WINDOW(window));
|
||||
|
||||
// Get Scale factor
|
||||
GdkSurface *surface = gtk_native_get_surface(GTK_NATIVE(window));
|
||||
double scale = gdk_surface_get_scale(surface);
|
||||
g_print("%f\n", scale);
|
||||
|
||||
img_close = gtk_image_new_from_icon_name("win_close");
|
||||
gtk_image_set_pixel_size(GTK_IMAGE(img_close), 12 / scale);
|
||||
gtk_button_set_child(GTK_BUTTON(btn_close), img_close);
|
||||
|
||||
img_mini = gtk_image_new_from_icon_name("win_minimize");
|
||||
gtk_image_set_pixel_size(GTK_IMAGE(img_mini), 12 / scale);
|
||||
gtk_button_set_child(GTK_BUTTON(btn_mini), img_mini);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
|
Loading…
Reference in New Issue