Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
9.2 kB
2
Indexable
Never
// Include gtk
#include <gtk/gtk.h>
#include <stdio.h>
#include <gio/gio.h>


void btn_clicked_1 (GtkButton *self, GPtrArray *textos);
void btn_clicked_2 (GtkButton *self, GPtrArray *textos);


static void on_activate (GtkApplication *app)
{
  GtkWidget *window = gtk_application_window_new (app);

  gtk_window_set_position (GTK_WINDOW(window),GTK_WIN_POS_CENTER);
  //gtk_window_set_default_size(GTK_WINDOW(window), 300,200);
  gtk_window_set_default_size(GTK_WINDOW(window), 800,500);
  //gtk_container_set_border_width(GTK_CONTAINER(window),10);

  GtkWidget *header = g_object_new(
    GTK_TYPE_HEADER_BAR,
    "visible", TRUE,
    "show-close-button", TRUE,
    "title", "Installer Arch Linux - Arcris",
    NULL
  );

  GtkWidget *button_header = gtk_button_new ();
  GIcon     *icon_header   = g_themed_icon_new ("dialog-question"); 
  GtkWidget *image_header  = gtk_image_new_from_gicon (icon_header, GTK_ICON_SIZE_BUTTON);
  
  //gtk_header_bar_set_custom_title (GTK_HEADER_BAR (header), gtk_button_new_with_label ("Middle"));
  g_object_unref (icon_header);
  gtk_container_add (GTK_CONTAINER (button_header), image_header);
  gtk_header_bar_pack_start (GTK_HEADER_BAR (header), button_header);

  GtkWidget *menu1 = g_object_new(
    GTK_TYPE_LABEL,
    "visible", TRUE,
    "label", "\tBienvenida\t    ",
    "halign", GTK_ALIGN_START,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );

  GtkWidget *menu2 = g_object_new(
    GTK_TYPE_LABEL,
    "visible", TRUE,
    "label", "\tUbicación\t    ",
    "halign", GTK_ALIGN_START,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );

  GtkWidget *menu3 = g_object_new(
    GTK_TYPE_LABEL,
    "visible", TRUE,
    "label", "\tDisco\t    ",
    "halign", GTK_ALIGN_START,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );

  GtkWidget *menu4 = g_object_new(
    GTK_TYPE_LABEL,
    "visible", TRUE,
    "label", "\tUsuario\t    ",
    "halign", GTK_ALIGN_START,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );

  GtkWidget *menu5 = g_object_new(
    GTK_TYPE_LABEL,
    "visible", TRUE,
    "label", "\tEscritorio\t    ",
    "halign", GTK_ALIGN_START,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );


  GtkWidget *menu6 = g_object_new(
    GTK_TYPE_LABEL,
    "visible", TRUE,
    "label", "\tExtras\t    ",
    "halign", GTK_ALIGN_START,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );


  GtkWidget *menu7 = g_object_new(
    GTK_TYPE_LABEL,
    "visible", TRUE,
    "label", "\tInstalación\t    ",
    "halign", GTK_ALIGN_START,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );


  GtkWidget *menu8 = g_object_new(
    GTK_TYPE_LABEL,
    "visible", TRUE,
    "label", "\tFinalizar\t    ",
    "halign", GTK_ALIGN_START,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );


  GtkWidget *menu9 = g_object_new(
    GTK_TYPE_LABEL,
    "visible", TRUE,
    "label", "Versión\n   0.1\t",
    "halign", GTK_ALIGN_CENTER,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );


  GtkWidget *box_principal = g_object_new(
    GTK_TYPE_BOX,
    "visible", TRUE,
    "orientation", GTK_ORIENTATION_HORIZONTAL,
    NULL
  );

  GtkWidget *btn1 = g_object_new(
    GTK_TYPE_BUTTON,
    "visible", TRUE,
    "label", "Anterior",
    "halign", GTK_ALIGN_CENTER,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );

  GtkWidget *btn2 = g_object_new(
    GTK_TYPE_BUTTON,
    "visible", TRUE,
    "label", "Siguiente",
    "halign", GTK_ALIGN_CENTER,
    "valign", GTK_ALIGN_CENTER,
    NULL
  );

  GtkWidget *box_menu= g_object_new(
    GTK_TYPE_BOX,
    "visible", TRUE,
    "orientation", GTK_ORIENTATION_VERTICAL,
    "spacing", 0,
    NULL
  );

  GtkWidget *box_botones= g_object_new(
    GTK_TYPE_BOX,
    "visible", TRUE,
    "orientation", GTK_ORIENTATION_HORIZONTAL,
    "spacing", 10,
    NULL
  );


  GdkPixbuf *logoscale = gdk_pixbuf_new_from_file_at_scale("Logo.png",70,70,TRUE,NULL);
  GtkWidget *logo = gtk_image_new_from_pixbuf (logoscale);

  GtkWidget *separador = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
  gtk_widget_set_size_request (separador,3, 0);

  gtk_widget_set_size_request (menu1,0, 30);
  gtk_widget_set_size_request (menu2,0, 30);
  gtk_widget_set_size_request (menu3,0, 30);
  gtk_widget_set_size_request (menu4,0, 30);
  gtk_widget_set_size_request (menu5,0, 30);
  gtk_widget_set_size_request (menu6,0, 30);
  gtk_widget_set_size_request (menu7,0, 30);
  gtk_widget_set_size_request (menu8,0, 30);
  gtk_widget_set_size_request (menu9,0, 30);

  gtk_window_set_titlebar(GTK_WINDOW(window), header);
  gtk_box_pack_start(GTK_BOX(box_principal), box_menu, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box_principal), separador, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box_principal), box_botones, TRUE, FALSE, 0);

  gtk_box_pack_start(GTK_BOX(box_menu), logo, TRUE, FALSE, 15);
  gtk_box_pack_start(GTK_BOX(box_menu), menu1, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box_menu), menu2, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box_menu), menu3, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box_menu), menu4, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box_menu), menu5, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box_menu), menu6, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box_menu), menu7, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box_menu), menu8, FALSE, FALSE, 0);
  gtk_box_pack_end(GTK_BOX(box_menu), menu9, TRUE, FALSE, 5);

  gtk_box_pack_start(GTK_BOX(box_botones), btn1, TRUE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(box_botones), btn2, TRUE, FALSE, 0);
  gtk_container_add(GTK_CONTAINER(window), box_principal);


  gtk_widget_set_name( menu1 , "menu1" );
  gtk_widget_set_name( separador , "box_centro" );
  gtk_widget_set_name( box_menu , "box_izquierda" );
  

  GPtrArray *textos = g_ptr_array_new();
  g_ptr_array_add(textos, menu1);
  g_ptr_array_add(textos, menu2);

  GtkCssProvider *cssProvider = gtk_css_provider_new();
  gtk_css_provider_load_from_path(cssProvider, "estilo.css", NULL);
  gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(cssProvider), GTK_STYLE_PROVIDER_PRIORITY_USER);


  g_signal_connect(btn1, "clicked", G_CALLBACK(btn_clicked_1), textos);
  g_signal_connect(btn2, "clicked", G_CALLBACK(btn_clicked_2), textos);

  // Para GTK 3.10 y superior > gtk_window_close
  // Para GTK menor de 3.10 > gtk_main_quit
  g_signal_connect (window, "destroy", G_CALLBACK (gtk_window_close), NULL);
  gtk_widget_show_all (window);

}

int main (int argc, char *argv[]) 
{

  GtkApplication *app = gtk_application_new ("com.github.CodigoCristo.Arcris",
                                             G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (on_activate), NULL);
  return g_application_run (G_APPLICATION (app), argc, argv);
}





void btn_clicked_1 (GtkButton *self, GPtrArray *textos) {


  gtk_widget_set_name( g_ptr_array_index(textos,0) , "menu1" );
  gtk_widget_set_name( g_ptr_array_index(textos,1) , "" );

}

void btn_clicked_2 (GtkButton *self, GPtrArray *textos) {

  gtk_widget_set_name( g_ptr_array_index(textos,0) , "" );
  gtk_widget_set_name( g_ptr_array_index(textos,1) , "menu1" );

}











/* https://gist.github.com/heckflosse/99d747c9bb5a7601fd92542b486b2f34 */


window {
    background-color: #191919;

}


headerbar button {
    background: #1E2832;
    color: #ffffff;
    border-color: rgba(255,255,255,.20);
    /*padding: 5px;*/
    box-shadow: rgba(255,255,255,.20);
    border: none;

}

headerbar button.titlebutton.minimize {
    background: #191919;
    color: #ffffff;
    border-color: rgba(255,255,255,.20);
    margin: 0px 0px 0px 0px;
    padding: 3px 3px 3px 3px;
    border: none; 
}

headerbar button.titlebutton.maximize {
    background: #191919;
    color: #ffffff;
    border-color: rgba(255,255,255,.20);
    margin: 0px 0px 0px 0px;
    padding: 3px 3px 3px 3px;
    border: none; 
}

headerbar button.titlebutton.close {
    background: #191919;
    color: #ffffff;
    border-color: rgba(255,255,255,.20);
    margin: 0px 0px 0px 0px;
    padding: 3px 3px 3px 3px;
    border: none; 
}


headerbar {
    background: #191919;
    color: #ffffff;
    box-shadow: none;
    min-height: 0px;
    padding-left: 15px; 
    padding-right: 15px;
    border-color: #101010;
    border-bottom-width: 3px;
}


#menu1 {
    background-color: rgba(255,255,255,.20);
    color: #ffffff;
    /*font: 13px Sans; 
    border-width:20px; 
    padding-top: 10px;
    padding-bottom: 10px;
    border-radius: 0px; 
    border-color: #202020; */
    padding: 0px;
    font-weight : 600;
    font-size: 14px;

}

#box_centro {
    background-color: #101010;  
}


#box_izquierda {
    background-color: #1E2832;
    box-shadow: none;
    color: rgba(255,255,255,.50);
    font-size: 15px;
    /*font: 12px Sans;
    border-width:20px;
    padding-top: 20px; */
    border-color: #202020;
    font-weight : 500;
}