We have this code in test.c file:
#include <gtk/gtk.h>
#define UNUSED(x) (void)(x)
static void activate(GtkApplication* app, gpointer user_data)
{
GtkWidget* window;
UNUSED(user_data);
window = gtk_application_window_new(app);
gtk_window_set_title(GTK_WINDOW(window), "Window");
gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
gtk_widget_show_all(window);
}
int main(int argc, char** argv)
{
GtkApplication* app;
int status;
app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE);
g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
status = g_application_run(G_APPLICATION(app), argc, argv);
g_object_unref(app);
return status;
}
And we compile it with:
gcc -o app test.c `pkg-config --cflags --libs gtk+-3.0\`
with output like this: screenshot for example 1
And this is not resizable. So it is what we are looking for.
So if we put same code in main.c of project with structure like this: proj struct and Makefile:
CC = gcc
CFLAGS = -Wall -Wextra -Werror
CPPFLAGS = -MMD -Isrc -Isrc/libdb -Isrc/libsqlite3
SRCDIR = src
OBJDIR = obj/src
BINDIR = bin
OBJINT = obj/libint
OBJDB = obj/db
OBJSQLITE3 = obj/sqlite3
PKG-CONFIG = `pkg-config --cflags --libs gtk+-3.0`
TARGET = $(BINDIR)/todo
SRCS_INT = $(SRCDIR)/libint/interface.c $(SRCDIR)/libint/interface.h
SRCS_MAIN = $(SRCDIR)/todolist/main.c
SRCS_LIB_DB = $(SRCDIR)/libdb/db.c $(SRCDIR)/libdb/db.h
SRCS_LIB_SQLITE3 = $(SRCDIR)/libsqlite3/sqlite3.c $(SRCDIR)/libsqlite3/sqlite3.h $(SRCDIR)/libsqlite3/sqlite3ext.h
OBJS_LIB_INT = $(OBJINT)/interface.o
OBJS_MAIN = $(OBJDIR)/main.o
OBJS_LIB_DB = $(OBJDB)/db.o
OBJS_LIB_SQLITE3 = $(OBJSQLITE3)/sqlite3.o
DEPS = $(OBJS_MAIN:.o=.d) $(OBJS_LIB_DB:.o=.d) $(OBJS_LIB_SQLITE3:.o=.d) $(OBJS_LIB_INT:.o=.d)
# Rule for building the executable file
$(TARGET): $(OBJS_MAIN) $(OBJDB)/libdb.a $(OBJSQLITE3)/libsqlite3.a $(OBJINT)/libint.a
$(CC) $(CFLAGS) $^ -o $@ -lm $(PKG-CONFIG)
# Rule for building the static libraries
$(OBJDB)/libdb.a: $(OBJS_LIB_DB)
ar rcs $@ $^
$(OBJSQLITE3)/libsqlite3.a: $(OBJS_LIB_SQLITE3)
ar rcs $@ $^
$(OBJINT)/libint.a: $(OBJS_LIB_INT)
ar rcs $@ $^
# Rules for building object files
$(OBJS_MAIN): $(SRCS_MAIN)
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ $(PKG-CONFIG)
$(OBJS_LIB_DB): $(SRCS_LIB_DB)
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJS_LIB_SQLITE3): $(SRCS_LIB_SQLITE3)
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(OBJS_LIB_INT): $(SRCS_INT)
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ $(PKG-CONFIG)
.PHONY: clean
clear:
rm -f $(TARGET) $(OBJS_MAIN) $(OBJS_LIB_DB) $(OBJS_LIB_SQLITE3) $(OBJS_LIB_INT) obj/src/*.o obj/src/*.d obj/db/*.o \
obj/db/*.d obj/db/*.a obj/sqlite3/*.o obj/sqlite3/*.d obj/sqlite3/*.a obj/libint/*.o obj/libint/*.d obj/libint/*.a
-include $(DEPS)
run: $(TARGET)
sudo ./$(TARGET)
it will give this result: screenshot for example 2 and this is resizable. (Even with set of resizable FALSE)
I've tried to play with the Makefile but it didn't help. What is the problem? (https://imgur.com/a/Okfkehl same problem in simple Makefile)
Update: make output is:
gcc -c -Wall -Wextra -Werror -MMD -Isrc -Isrc/libdb -Isrc/libsqlite3 src/todolist/main.c -o obj/src/main.o \`pkg-config --cflags --libs gtk+-3.0\`
gcc -c -Wall -Wextra -Werror -MMD -Isrc -Isrc/libdb -Isrc/libsqlite3 src/libdb/db.c -o obj/db/db.o
ar rcs obj/db/libdb.a obj/db/db.o
gcc -c -Wall -Wextra -Werror -MMD -Isrc -Isrc/libdb -Isrc/libsqlite3 src/libsqlite3/sqlite3.c -o obj/sqlite3/sqlite3.o
ar rcs obj/sqlite3/libsqlite3.a obj/sqlite3/sqlite3.o
gcc -c -Wall -Wextra -Werror -MMD -Isrc -Isrc/libdb -Isrc/libsqlite3 src/libint/interface.c -o obj/libint/interface.o \`pkg-config --cflags --libs gtk+-3.0\`
ar rcs obj/libint/libint.a obj/libint/interface.o
gcc -Wall -Wextra -Werror obj/src/main.o obj/db/libdb.a obj/sqlite3/libsqlite3.a obj/libint/libint.a -o bin/todo -lm \`pkg-config --cflags --libs gtk+-3.0\`
The problem was in sudo
command in run
option of makefile. If we start gtk app with sudo
it will be no resizable and it has different interface. I dont really know why but thats it.