filmov
tv
C++ the Basic Way 2025 (4) | GTK Header Bar all Code no XML ui File | Native Linux GUI

Показать описание
This video came out much later than I planned. Besides normal day-to-day matters such as keeping up with obligations, the core concept in this video is achievable in less than 2 days. However, it took me nearly a week. The upside is I encountered an issue that will help others who may struggle with GTK HeaderBar and GTK Menu and putting them together.
The issue is not a technical issue. My opinion is there is an issue with the documentation. While I feel the documentation is great. Again, my opinion. It does not go far enough in some cases or almost forces you do things a certain way when there are other approaches that are just as valid. I showcase an approach which is often better for performance, executable size, and reduced build complexity.
Yes, I spent 4 to 5 days on a GTK HeaderBar. Some would laugh at the unyielding focus to build the code and not give in to a short-term easy choice. I wanted that typical Gnome flip down menu.
The problem? Well, I am glad you asked. You see, the documentation on how to set them up together was not as clear. A GTK HeaderBar is the long strip at the top of a window. You can add a menu to this strip where you can program in functions common to a window. All that is easy in concept but it has to be done in a particular sequence.
The video has chapters for those that want to skip straight to the discussion which occurs starting at timestamps 10:56 and 17:11. The rest of the video helps those coming in fresh with getting caught up on the context for why and how we got here.
In this video I explore multiple avenues where I "chased down" the proper way to do this without having to resort to a GTK Builder .ui xml file. I wanted to setup the GTK HeaderBar and Menu using only C++ code and that process could not be more difficult when blindly following the documentation.
I wanted the header and menu for the software I am building to look a certain way and I persisted until I achieved the goal. I paid a price in terms of time. Despite the cost, I refused to be defeated by an industry perspective that seems increasingly designed to guide the way people write software directly by making obvious elements more obscure.
Walk with me as I decode this process with respect to GTK HeaderBar and Menu to setup functionality to present a configuration window. Yes, 4 to 5 days on a menu. I could have just placed a button on the screen just under the list of barcodes but since this is a private software program, I have the option of not compromising on my objectives.
My original plan for the week of Jan. 27, 2025 was to build out a configuration window and a file export function. It got in my head to make access to these functions work the way many Gnome apps work on Linux. People call it a 'hamburger menu'. I guess it looks like a hamburger. I don't know who came up with that term but the menu button has 3 horizontal lines. You click on it and additional functions are shown. Before I showed a configuration window, I wanted this window invoked the modern way.
Again, on Linux Gnome environments, many mainstream Gnome apps use a menu approach that is arguably more modern and streamlined. I thought I would try my hand in achieving this menu. I have done menus in other software platforms before. I always found it easy. I think the concepts in the Gnome world in as far as GTK makes sense and in many ways are simpler than what I have done on other platforms.
Keep in mind, it is not difficult to do menus in C++ and GTKMM except the information on how to do it using only C++ is not as clear versus the examples favoring embedded XML strings. I think the approach of embedding XML (or json or sql) is a fine concept and I have no problem with that with Microsoft WPF for example. However, sometimes you want to build your UI with only code and not extra tools for many reasons. Some of those reasons is to have better control over the way the UI comes together and streamline the way it compiles into an executable.
A snapshot in time version of the program source code is posted in the comments. I will continue to evolve this program and it will quickly mature into a very nice C++ program. I will have a future video that will go much more in-depth on the technology choices made in this project. I touched on that in earlier videos but a video is coming where this concept will be explained more in-depth.
00:00 Start
00:17 Linux Gnome Classic
01:16 Start simple
02:21 Test data - barcode sheet
03:12 Complete desktop GUI
04:37 C++ source code expansion
08:32 Clean technology
09:26 GUI layout on paper
10:56 GTK HeaderBar
17:11 Pure code C++ GTKMM HeaderBar
34:38 Officially the 4th Iteration
38:00 Pursuit of Perfection
38:25 Next iteration
40:20 Levels of inception
40:49 Software wisdom
44:00 Premeditated efficiency
45:00 Infinitude of consciousness
45:45 Wrap up
The issue is not a technical issue. My opinion is there is an issue with the documentation. While I feel the documentation is great. Again, my opinion. It does not go far enough in some cases or almost forces you do things a certain way when there are other approaches that are just as valid. I showcase an approach which is often better for performance, executable size, and reduced build complexity.
Yes, I spent 4 to 5 days on a GTK HeaderBar. Some would laugh at the unyielding focus to build the code and not give in to a short-term easy choice. I wanted that typical Gnome flip down menu.
The problem? Well, I am glad you asked. You see, the documentation on how to set them up together was not as clear. A GTK HeaderBar is the long strip at the top of a window. You can add a menu to this strip where you can program in functions common to a window. All that is easy in concept but it has to be done in a particular sequence.
The video has chapters for those that want to skip straight to the discussion which occurs starting at timestamps 10:56 and 17:11. The rest of the video helps those coming in fresh with getting caught up on the context for why and how we got here.
In this video I explore multiple avenues where I "chased down" the proper way to do this without having to resort to a GTK Builder .ui xml file. I wanted to setup the GTK HeaderBar and Menu using only C++ code and that process could not be more difficult when blindly following the documentation.
I wanted the header and menu for the software I am building to look a certain way and I persisted until I achieved the goal. I paid a price in terms of time. Despite the cost, I refused to be defeated by an industry perspective that seems increasingly designed to guide the way people write software directly by making obvious elements more obscure.
Walk with me as I decode this process with respect to GTK HeaderBar and Menu to setup functionality to present a configuration window. Yes, 4 to 5 days on a menu. I could have just placed a button on the screen just under the list of barcodes but since this is a private software program, I have the option of not compromising on my objectives.
My original plan for the week of Jan. 27, 2025 was to build out a configuration window and a file export function. It got in my head to make access to these functions work the way many Gnome apps work on Linux. People call it a 'hamburger menu'. I guess it looks like a hamburger. I don't know who came up with that term but the menu button has 3 horizontal lines. You click on it and additional functions are shown. Before I showed a configuration window, I wanted this window invoked the modern way.
Again, on Linux Gnome environments, many mainstream Gnome apps use a menu approach that is arguably more modern and streamlined. I thought I would try my hand in achieving this menu. I have done menus in other software platforms before. I always found it easy. I think the concepts in the Gnome world in as far as GTK makes sense and in many ways are simpler than what I have done on other platforms.
Keep in mind, it is not difficult to do menus in C++ and GTKMM except the information on how to do it using only C++ is not as clear versus the examples favoring embedded XML strings. I think the approach of embedding XML (or json or sql) is a fine concept and I have no problem with that with Microsoft WPF for example. However, sometimes you want to build your UI with only code and not extra tools for many reasons. Some of those reasons is to have better control over the way the UI comes together and streamline the way it compiles into an executable.
A snapshot in time version of the program source code is posted in the comments. I will continue to evolve this program and it will quickly mature into a very nice C++ program. I will have a future video that will go much more in-depth on the technology choices made in this project. I touched on that in earlier videos but a video is coming where this concept will be explained more in-depth.
00:00 Start
00:17 Linux Gnome Classic
01:16 Start simple
02:21 Test data - barcode sheet
03:12 Complete desktop GUI
04:37 C++ source code expansion
08:32 Clean technology
09:26 GUI layout on paper
10:56 GTK HeaderBar
17:11 Pure code C++ GTKMM HeaderBar
34:38 Officially the 4th Iteration
38:00 Pursuit of Perfection
38:25 Next iteration
40:20 Levels of inception
40:49 Software wisdom
44:00 Premeditated efficiency
45:00 Infinitude of consciousness
45:45 Wrap up
Комментарии