mirror of https://github.com/daleclack/My_GtkUi
Rewrite mydock class
This commit is contained in:
parent
2051a3cc5a
commit
c3ca2ad56d
|
@ -46,7 +46,10 @@ void create_main_stack(GtkWindow *win)
|
|||
G_N_ELEMENTS(entries), win);
|
||||
|
||||
// Add dock and finder
|
||||
add_dock(main_page);
|
||||
GtkWidget *dock = my_dock_new();
|
||||
gtk_widget_set_hexpand(dock, TRUE);
|
||||
gtk_widget_set_vexpand(dock, TRUE);
|
||||
gtk_box_append(GTK_BOX(main_page), dock);
|
||||
|
||||
// Link Signals
|
||||
g_signal_connect(btnlogin, "clicked", G_CALLBACK(btnlogin_clicked), stack);
|
||||
|
|
|
@ -1,42 +1,65 @@
|
|||
#include "MyDock.h"
|
||||
#include "MyFinder.h"
|
||||
|
||||
void add_dock(GtkWidget *main_page1)
|
||||
struct _MyDock
|
||||
{
|
||||
GtkBox parent_instance;
|
||||
GtkBuilder *dock_builder;
|
||||
GtkWidget *dock_box, *main_box, *finder_box,
|
||||
*dock_left, *icons_sw, *main_overlay;
|
||||
GtkWidget *main_pic, *finder;
|
||||
GtkWidget *btnlaunch, *launchpad_stack,
|
||||
*default_page, *launchpad_page;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE(MyDock, my_dock, GTK_TYPE_BOX)
|
||||
|
||||
static void my_dock_init(MyDock *self)
|
||||
{
|
||||
// Builder for the main dock
|
||||
GtkBuilder *dock_builder = gtk_builder_new_from_resource("/org/gtk/daleclack/mydock.ui");
|
||||
self->dock_builder = gtk_builder_new_from_resource("/org/gtk/daleclack/mydock.ui");
|
||||
|
||||
// Get widgets
|
||||
GtkWidget *dock_box = GTK_WIDGET(gtk_builder_get_object(dock_builder, "dock_box"));
|
||||
GtkWidget *main_box = GTK_WIDGET(gtk_builder_get_object(dock_builder, "main_box"));
|
||||
GtkWidget *finder_box = GTK_WIDGET(gtk_builder_get_object(dock_builder, "finder_box"));
|
||||
GtkWidget *dock_left = GTK_WIDGET(gtk_builder_get_object(dock_builder, "dock_left"));
|
||||
GtkWidget *icons_sw = GTK_WIDGET(gtk_builder_get_object(dock_builder, "icons_sw"));
|
||||
self->dock_box = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "dock_box"));
|
||||
self->main_box = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "main_box"));
|
||||
self->finder_box = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "finder_box"));
|
||||
self->dock_left = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "dock_left"));
|
||||
self->icons_sw = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "icons_sw"));
|
||||
self->btnlaunch = GTK_WIDGET(gtk_builder_get_object(self->dock_builder, "btnlaunch"));
|
||||
|
||||
// Add background widget
|
||||
GtkWidget *main_overlay = gtk_overlay_new();
|
||||
self->main_overlay = gtk_overlay_new();
|
||||
|
||||
// Set default background
|
||||
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_resource("/org/gtk/daleclack/final_approach.png", NULL);
|
||||
GdkPixbuf *sized = gdk_pixbuf_scale_simple(pixbuf, 1024, 576, GDK_INTERP_BILINEAR);
|
||||
GtkWidget *main_pic = gtk_picture_new_for_pixbuf(sized);
|
||||
self->main_pic = gtk_picture_new_for_pixbuf(sized);
|
||||
g_object_unref(pixbuf);
|
||||
g_object_unref(sized);
|
||||
|
||||
// Add finder
|
||||
GtkWidget *finder = my_finder_new(GTK_ORIENTATION_HORIZONTAL, 5);
|
||||
gtk_box_append(GTK_BOX(finder_box), finder);
|
||||
self->finder = my_finder_new(GTK_ORIENTATION_HORIZONTAL, 5);
|
||||
gtk_box_append(GTK_BOX(self->finder_box), self->finder);
|
||||
|
||||
// Pack widgets
|
||||
|
||||
// Dock position and mode, will be changable soon
|
||||
gtk_widget_set_vexpand(icons_sw, TRUE);
|
||||
gtk_widget_set_valign(icons_sw, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign(dock_box, GTK_ALIGN_FILL);
|
||||
gtk_box_append(GTK_BOX(dock_left), dock_box);
|
||||
gtk_widget_set_vexpand(self->icons_sw, TRUE);
|
||||
gtk_widget_set_valign(self->icons_sw, GTK_ALIGN_FILL);
|
||||
gtk_widget_set_valign(self->dock_box, GTK_ALIGN_FILL);
|
||||
gtk_box_append(GTK_BOX(self->dock_left), self->dock_box);
|
||||
|
||||
// Others
|
||||
gtk_overlay_set_child(GTK_OVERLAY(main_overlay), main_pic);
|
||||
gtk_overlay_add_overlay(GTK_OVERLAY(main_overlay), main_box);
|
||||
gtk_box_append(GTK_BOX(main_page1), main_overlay);
|
||||
gtk_overlay_set_child(GTK_OVERLAY(self->main_overlay), self->main_pic);
|
||||
gtk_overlay_add_overlay(GTK_OVERLAY(self->main_overlay), self->main_box);
|
||||
gtk_box_append(GTK_BOX(self), self->main_overlay);
|
||||
}
|
||||
|
||||
static void my_dock_class_init(MyDockClass *klass)
|
||||
{
|
||||
}
|
||||
|
||||
GtkWidget *my_dock_new()
|
||||
{
|
||||
return GTK_WIDGET(g_object_new(my_dock_get_type(), NULL));
|
||||
}
|
||||
|
|
|
@ -2,4 +2,6 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
void add_dock(GtkWidget *main_page1);
|
||||
G_DECLARE_FINAL_TYPE(MyDock, my_dock, MY, DOCK, GtkBox)
|
||||
|
||||
GtkWidget *my_dock_new();
|
||||
|
|
|
@ -80,7 +80,7 @@ static void my_finder_init(MyFinder *self)
|
|||
gtk_button_set_has_frame(GTK_BUTTON(self->audio_button), FALSE);
|
||||
gtk_button_set_has_frame(GTK_BUTTON(self->network_button), FALSE);
|
||||
gtk_button_set_has_frame(GTK_BUTTON(self->menu_button), FALSE);
|
||||
gtk_button_set_has_frame(GTK_BUTTON(self->time_button), FALSE);
|
||||
gtk_menu_button_set_has_frame(GTK_MENU_BUTTON(self->time_button), FALSE);
|
||||
|
||||
// Add labels to the menu button
|
||||
gtk_menu_button_set_child(GTK_MENU_BUTTON(self->btntitle), self->label_title);
|
||||
|
|
Loading…
Reference in New Issue