You are not logged in.

#1 2013-02-24 17:05:48

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Hello everyone,

Here I am, accouncing any of my projects publicly for the first time! I am trying to switch to as much GTK3 applications as possible (and, ultimately, try ditch as many GTK2). It has always bothered me that there is no GTK3 alternative to something as simple as Gcolor2. Today, I just quickly whipped it up myself, after having gained some experience in GTK3 from my previous (yet unnanounced) project.

It's very, very simple (93 SLOC, of which most are the About dialog tongue) and for now, it consists of a color wheel and number of sliders and entry boxes for color parameters. You can also pick a color on the desktop. I never used the color-saving feature of Gcolor2, so for now I have not implemented it. Anything is possible though, upon request wink

Screenshot

Feedback - on everything; the application itself and the Makefile - would be appreciated. My experience with Makefiles is limited, so if anything could be improved (in general, or to help compatibility with other distributions for example) please let me know!

I think that's it! smile

EDIT: Oh, darn, it's not. You can find the project here!

AUR: https://aur.archlinux.org/packages/gcolor3/
AUR Git version: https://aur.archlinux.org/packages/gcolor3-git/

Last edited by Unia (2013-06-21 14:39:24)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#2 2013-02-25 03:21:07

anonymous_user
Member
Registered: 2009-08-28
Posts: 3,059

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Very nice smile

Offline

#3 2013-02-25 09:39:24

nbvcxz
Member
From: Poland
Registered: 2007-12-29
Posts: 202

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

+1 very nice replacement for Gcolor2


Lenovo G50 | LXQT-git | compton | conky

Offline

#4 2013-02-25 10:25:11

OK100
Member
From: [U==]
Registered: 2010-04-26
Posts: 455

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Did you know about "zenity --color-selection"? tongue

Offline

#5 2013-02-25 11:38:51

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Congratulation. I was looking for a small gtk3 alternative for a long time.

Do you make use of the "Color Selector" from GTK which can be found when you run gtk-demo?

Offline

#6 2013-02-25 12:41:58

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

OK100 wrote:

Did you know about "zenity --color-selection"? tongue

Nope, I did not. Oh well big_smile

orschiro wrote:

Congratulation. I was looking for a small gtk3 alternative for a long time.

Do you make use of the "Color Selector" from GTK which can be found when you run gtk-demo?

Nope, gtk-demo is still gtk2.

Thanks for the positive replies, guys!


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#7 2013-02-25 13:25:33

ivoarch
Member
Registered: 2011-03-31
Posts: 436

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

nbvcxz wrote:

+1 very nice replacement for Gcolor2

 
+1


I love GnuEmacs, GnuScreen, ratpoison, and conkeror.
Github )||( Weblog

Offline

#8 2013-03-03 18:45:24

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Update: Gcolor3 now has a treeview inside an expander (just as Gcolor2, of course) which lists your saved colors. These colors are also exported to a file ($HOME/.rgb.txt), just like - of course - Gcolor2.

I am currently aware of one bug, but I have not yet discovered why. A quick example: save three colors:

#FF0000 RED
#00FF00 GREEN
#0000FF BLUE

Then, delete GREEN. As expected, the green color is removed from the treeview and the rgb.txt file. However, also the blue color is removed from the rgb.txt file. If you could help me decipher a pattern, I would appreciate this smile


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#9 2013-03-04 02:58:11

sujoy
Member
From: India
Registered: 2008-02-08
Posts: 94
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Unia wrote:

Update: Gcolor3 now has a treeview inside an expander (just as Gcolor2, of course) which lists your saved colors. These colors are also exported to a file ($HOME/.rgb.txt), just like - of course - Gcolor2.

I am currently aware of one bug, but I have not yet discovered why. A quick example: save three colors:

#FF0000 RED
#00FF00 GREEN
#0000FF BLUE

Then, delete GREEN. As expected, the green color is removed from the treeview and the rgb.txt file. However, also the blue color is removed from the rgb.txt file. If you could help me decipher a pattern, I would appreciate this smile


Also while saving even when we click on cancel, the color is getting saved.

Heres the patch for both of this, just very minor change, so adding it in here

diff --git a/gcolor3.c b/gcolor3.c
index f5ca753..7ed1f09 100644
--- a/gcolor3.c
+++ b/gcolor3.c
@@ -149,7 +149,7 @@ save_dialog_open (void)
 
 	save_dialog_cancel_button = gtk_button_new_from_stock ("gtk-cancel");
 	gtk_widget_show (save_dialog_cancel_button);
-	gtk_dialog_add_action_widget (GTK_DIALOG (save_dialog), save_dialog_cancel_button, GTK_RESPONSE_OK);
+	gtk_dialog_add_action_widget (GTK_DIALOG (save_dialog), save_dialog_cancel_button, GTK_RESPONSE_CANCEL);
 	gtk_widget_set_sensitive (save_dialog_cancel_button, TRUE);
 	gtk_widget_set_can_default(save_dialog_cancel_button, TRUE);
 
@@ -319,7 +319,7 @@ delete_color (gchar *color_name, gchar *color_value)
 
 		/* make sure to only remove the first matching color; both value and name must match */
 		if (found || strcmp (file_color_name, color_name) != 0 || strcmp (g_ascii_strup (file_color_value, -1), color_value) != 0) {
-			g_sprintf (newstuff, "%s%3d %3d %3d\t\t%s\n", newstuff, r, g, b, file_color_name);
+			g_sprintf (newstuff+strlen(newstuff), "%3d %3d %3d\t\t%s\n", r, g, b, file_color_name);
 		} else {
 			found = TRUE;
 		}

Offline

#10 2013-03-04 11:33:13

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Whoops, I didn't notice that save_dialog_cancel_button bug. Thanks for reporting!

Also, your fix for deleting colors works! I will look into it as to why, since gcolor2 (where I based this code on) does not have it and it works there.

Thanks for your time and input; I appreciate it!

Last edited by Unia (2013-03-04 11:35:44)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#11 2013-03-04 13:09:50

sujoy
Member
From: India
Registered: 2008-02-08
Posts: 94
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

@Unia

I guess for while printing to buffer 'newstuff' it overwrites the existing one, since it starts from the first position always.

I looked through the documentation to see if writing back the buffer to itself should cause any problem, but didn't find anything, However, that is what is causing the error.
Do let me know if you find any documentation on this.

Offline

#12 2013-03-04 13:15:59

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

I quickly skimmed through Gcolor2's code again and noticed my function was slightly altered:

Gcolor2: g_sprintf (file_color_value, "#%2X%2X%2X", r, g, b);
Gcolor3: g_sprintf (file_color_value, "#%.2X%.2X%.2X", r, g, b);

I remember changing it, because otherwise it wouldn't even delete a color from the treeview (and when it can't delete from the treeview, it won't delete from the file either).

So, I guess that had something to do with it aswell, because otherwise I didn't change anything in the delete function from Gcolor2.

Writing back into the same buffer shouldn't cause any problem, AFAIK.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#13 2013-03-12 21:56:09

don_crissti
Member
Registered: 2009-03-17
Posts: 35

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

This is nice. Thanks !

Offline

#14 2013-03-12 22:09:14

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

You're welcome!


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#15 2013-03-12 22:23:44

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Feel free to copy features from pychrom. If you copy enough then I won't have to rewrite it. wink


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#16 2013-03-12 22:25:51

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Xyne wrote:

Feel free to copy features from pychrom. If you copy enough then I won't have to rewrite it. wink

Just name a feature you would like to see implemented and I'll see what I can do wink


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#17 2013-03-31 21:27:04

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Just pushed a big update to GitHub: the source is now split across multiple files for easier editing and I cleaned it up a tad. No features were removed or added, but I thought I'd give you a heads up in case you rebuilt it and notice new bugs big_smile


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#18 2013-06-08 19:35:05

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

I've just imported Gcolor3 into Anjuta for easier project management and to be (more easily) compatible with other distributions. I'm still exploring things (I still have to figure out how to install the .desktop file, for example) but I thought I'd give you a heads up. There's no actual changes to the code, but a big advantage from this switch is the enabling of translations.

Yes, that's right, you can now translate Gcolor3 in your own language. Since it's a small application, the translating should not take more than five minutes. I would highly appreciate your efforts if you could translate! Instructions can be found in the GitHub repository's README.md.

Last edited by Unia (2013-06-09 19:51:01)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#19 2013-06-10 12:51:14

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

As we're nearing a stable 1.0 release (I finally solved the bug that was there since I added the treeview and that I've been looking into for a month big_smile), I thought it would be time to have a Page on GitHub. Perhaps this will help spread the word on Gcolor3!

http://unia.github.io/gcolor3/

Last edited by Unia (2013-06-10 12:52:26)


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#20 2013-06-11 17:59:14

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

I've released version 1.0! From now on, I will only add bug fixes and add new or update existing translations.


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#21 2013-09-13 11:38:06

masnormen
Member
From: between Asia and Australia
Registered: 2012-06-03
Posts: 29

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

This is nice! big_smile


Sorry for my bad English roll

Offline

#22 2013-10-20 14:42:08

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Gcolor3 just got updated to version 1.2! It now uses GTK 3.10's GtkHeaderbar and a GtkStack to switch between the color chooser and the saved colors. Functionally, it's completely the same wink

Let me know what you think!


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#23 2013-10-20 16:19:36

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

@Unia

Pretty impressing. Gcolor3 looks even more professional now! smile

Offline

#24 2013-10-20 16:32:48

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

Thank you! smile


If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#25 2013-10-20 17:07:54

ooo
Member
Registered: 2013-04-10
Posts: 1,637

Re: Gcolor3 - a simple color chooser dialog in GTK3, much alike gcolor2.

I was just going to switch gcolor2 to this, but I gotta admit I don't like the new layout at all.

it takes too much screen estate compared to old version. also the gtk header bar looks very ununiform, at least with my theme and language settings. also the bottom of the window looks weird for my eye somehow, now that there's no spacing below the color selector.

maybe you could make the header more compact somehow, by using icons instead of text for example, or maybe unifying the buttons to a single menu although that would make it slightly less 'usable'.
the rgb spin buttons should be thinner as well. The maximum value for those has 3 digits, and currently there's space for nearly 15 digits which seems just pointless.

please don't take this the wrong way. I really appreciate what you've done, simply wanted to give some honest constructive criticism smile

keep up the good work.

Offline

Board footer

Powered by FluxBB