Closed
Bug 121258
Opened 23 years ago
Closed 22 years ago
gtk2 needs to have icons hooked up
Categories
(Core :: XUL, defect)
Tracking
()
RESOLVED
FIXED
People
(Reporter: blizzard, Assigned: yinbolian)
References
Details
Attachments
(3 files, 3 obsolete files)
2.88 KB,
image/x-xpixmap
|
Details | |
5.35 KB,
application/x-gzip
|
Details | |
4.79 KB,
patch
|
Details | Diff | Splinter Review |
gtk2 needs to have icon code hooked up.
I am working on this bug now. Chris, what is your idea? Do you think we should load different icons for different windows, like load chrome/icons/default/editorWindow for a composer? Or we should just port gtk1 code here and set the same icon (mozilla/icons/mozicon16.xpm & mozicon50.xpm) for all mozilla windows?
Reporter | ||
Comment 2•22 years ago
|
||
Interesting. I never noticed that the SetIcon() call on gtk wasn't using the name spec that was passed in as part of the call. We have the ability to set the icon to a different value. We might as well do that here. Have a look at the code in the windows front end code as to how to turn the resource into a path name. From there, you should be able to load the image and set the icon. There are probably easy to use gtk2 apis for that, too.
Attachment #86775 -
Attachment description: The Mozilla icon file → default.xpm, a mozilla icon for all windows.
Set different icons for different windows using the name spec that was passed in. If there is no match xpm file for the window, default.xpm will be used as its icon.
Copy the file to mozilla/dist/bin/chrome, then "tar xvzf icons.tar.gz". Run your mozilla and enjoy. You won't need to find your mailnews window from a bunch of navigator windows anymore. P.S: these icons are copied from Netscape 6 windows version, just for test purpose.
Use the native file path. Chris, could you review it?
Attachment #86778 -
Attachment is obsolete: true
Reporter | ||
Comment 7•22 years ago
|
||
Comment on attachment 89397 [details] [diff] [review] patch V2 We need to add the .xpm files to the packages-unix files. >+ // Global default icon >+ static GdkPixmap *default_iconPixmap = nsnull; >+ static GdkBitmap *default_mask = nsnull; Please don't mid underscores and mixed case in the same variable name. It doesn't flow well. Instead of using function level statics, can you add a static to the class? I don't usually use function level statics. >+ >+ GtkStyle *w_style; >+ w_style = gtk_widget_get_style (mShell); >+ >+ // Start at the app chrome directory. >+ nsCOMPtr<nsIFile> chromeDir; >+ if (NS_FAILED(NS_GetSpecialDirectory(NS_APP_CHROME_DIR, >+ getter_AddRefs(chromeDir)))) { >+ return NS_ERROR_FAILURE; >+ } I much prefer a style like this: rv = NS_GetSpecialDirectory(...); if (NS_FAILED(rv)) return rv; that way the error is propagated, and it's much more readable and consistent with the rest of the style in the module. >+ nsCOMPtr<nsILocalFile> defaultPathConverter; >+ if (NS_SUCCEEDED(NS_NewLocalFile( >+ defaultPath, >+ PR_TRUE, >+ getter_AddRefs(defaultPathConverter)))) { Once again, please use a return value, as above. >+ nsCAutoString aPath; >+ defaultPathConverter->GetNativePath(aPath); >+ >+ default_iconPixmap = gdk_pixmap_create_from_xpm( >+ mShell->window, >+ &default_mask, >+ &(w_style->bg[GTK_STATE_NORMAL]), >+ aPath.get()); I would rather that you use something like: default_iconPixmap = gdk_pixmap_create_from_xpm(mShell->window, &default_mask, ...); >+ GdkPixmap *iconPixmap = nsnull; >+ GdkBitmap *w_mask = nsnull; Same thing as above, please pick a style and stick with it. >+ >+ nsCOMPtr<nsILocalFile> pathConverter; >+ if (NS_SUCCEEDED(NS_NewLocalFile(iconPath, >+ PR_TRUE, >+ getter_AddRefs(pathConverter)))) { Same as above with the return value. >+ iconPixmap = gdk_pixmap_create_from_xpm( >+ mShell->window, >+ &w_mask, >+ &(w_style->bg[GTK_STATE_NORMAL]), >+ aPath.get()); Same as above with indenting. >+ if (!iconPixmap) { >+ if (default_iconPixmap) { >+ gdk_window_set_icon(mShell->window, (GdkWindow*)nsnull, >+ default_iconPixmap, default_mask); >+ return NS_OK; >+ } >+ return NS_ERROR_FAILURE; >+ } >+ >+ gdk_window_set_icon(mShell->window, (GdkWindow*)nsnull, iconPixmap, w_mask); >+ >+ return NS_OK; I think this is broken. It should be: if (iconPixmap) { gdk_window_set_icon(... iconPixmap ...); } else if (default_iconPixmap) { gdk_window_set_icon(... default_iconPixmap ...); } the set_icon call is always called with the iconPixmap, even if iconPixmap is NULL in the code above.
Attachment #89397 -
Flags: needs-work+
Chris, thank you for your review, very helpful. I'll pay more attention to coding style.
Attachment #89397 -
Attachment is obsolete: true
Reporter | ||
Comment 9•22 years ago
|
||
I went and looked at the documentation and I think that we should be using gtk_window_set_icon_list() instead of gdk_window_set_icon(). Have a look at the documentation to see what I'm talking about. http://developer.gnome.org/doc/API/2.0/gdk/gdk-windows.html#gdk-window-set-icon http://developer.gnome.org/doc/API/2.0/gtk/gtkwindow.html#gtk-window-set-icon-list
Comment 10•22 years ago
|
||
Use gtk_window_set_default_icon_list() & gtk_window_set_icon ()
Attachment #90041 -
Attachment is obsolete: true
Reporter | ||
Comment 13•22 years ago
|
||
Checked in after minor cleanup. Thanks!
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Comment 14•22 years ago
|
||
How about some of the icons at http://genghis.winamp.com/~steve/archive/?dir=mozilla ?
You need to log in
before you can comment on or make changes to this bug.
Description
•