gtk_widget_set_size_request() not functioning as intended

  Kiến thức lập trình

I’ve created an action_bar widget with 3 children, a label and 2 buttons. I’ve tried multiple width and height dimensions in the gtk_widget_set_size_request() method. No matter the dimensions I put the action bar ALWAYS is the same height no matter the size of the window itself.

This is my code I have for the entire project. I’m sorry that all the code is squished together. I had some copy and pasting issues…

#include <gtk/gtk.h>
#include <pango/pango.h>
#include <stdio.h>
//READERS! This code is meant to be easily read for people who want to learn!
//Handles initializing the window
static void activateWindow(GtkApplication *app) {
        GtkWidget *window = gtk_application_window_new(app);
        //TopActionBar | Creation
        GtkWidget *topActionBar = gtk_action_bar_new();
        //This line is the issue.
        gtk_widget_set_size_request(GTK_WIDGET(topActionBar), -1, 17);
        //TopActionBar | TITLE
                GtkWidget *bideLabel = gtk_label_new(NULL);
                gchar *bideLabelText = g_markup_printf_escaped("<b>BIDE</b>");
                gtk_label_set_markup(GTK_LABEL(bideLabel), bideLabelText);
                gtk_action_bar_pack_start(GTK_ACTION_BAR(topActionBar), GTK_WIDGET(bideLabel));
                //TopActionBar | Open Folder Button
                GtkWidget *openFolder = gtk_button_new();
                gtk_button_set_label(GTK_BUTTON(openFolder), "Open Folder");
                gtk_action_bar_pack_start(GTK_ACTION_BAR(topActionBar), GTK_WIDGET(openFolder));
                //TopActionBar | Help Menu Button
                gchar *helpButtonText = g_markup_printf_escaped("<u>HELP</u>");
                GtkWidget *helpButton = gtk_button_new();
                GtkWidget *helpLabel = gtk_label_new("Help");
                gtk_label_set_markup(GTK_LABEL(helpLabel), helpButtonText);
                gtk_button_set_child(GTK_BUTTON(helpButton), GTK_WIDGET(helpLabel));
                gtk_action_bar_pack_start(GTK_ACTION_BAR(topActionBar), GTK_WIDGET(helpButton));
        gtk_window_set_child(GTK_WINDOW(window), GTK_WIDGET(topActionBar));
        gtk_window_present(GTK_WINDOW(window));

}
int main(int argc, char *argv[]){
        GtkApplication *app = gtk_application_new("me.lufthor.bide", G_APPLICATION_DEFAULT_FLAGS);
        g_signal_connect(app, "activate", G_CALLBACK(activateWindow), NULL);
        return g_application_run(G_APPLICATION(app), argc, argv);

}

I tried messing around with the height and width values and NOTHING. Nothing changed.

New contributor

Toost is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT