1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 Copyright (C) 2002 Naba Kumar <naba@gnome.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <gtk/gtkaboutdialog.h>
26 #include <libanjuta/anjuta-plugin-manager.h>
30 #define ANJUTA_PIXMAP_LOGO "anjuta_logo.png"
31 #define ABOUT_AUTHORS "AUTHORS"
33 #define MAX_CREDIT 500
35 const gchar
*authors
[MAX_CREDIT
];
36 const gchar
*documenters
[MAX_CREDIT
];
41 about_read_line(FILE *fp
)
43 static gchar tpn
[MAX_CAR
];
48 while( ((c
=getc(fp
))!='\n') && (c
!=EOF
) && ((pt
-tpn
)<MAX_CAR
) )
58 about_read_developers(FILE *fp
, gchar
*line
, gint
*index
, const gchar
**tab
)
62 if (*index
< MAX_CREDIT
)
63 tab
[(*index
)++] = g_strdup_printf("%s", line
);
64 if ( !(line
= about_read_line(fp
)))
66 line
= g_strchomp(line
);
68 while (!g_str_has_suffix(line
, ":") );
74 read_documenters(FILE *fp
, gchar
*line
, gint
*index
, const gchar
**tab
)
78 if (*index
< MAX_CREDIT
)
79 tab
[(*index
)++] = g_strdup_printf("%s", line
);
80 if ( !(line
= about_read_line(fp
)))
82 line
= g_strchomp(line
);
84 while ( !g_str_has_suffix(line
, ":") );
90 read_translators(FILE *fp
, gchar
*line
)
92 gboolean found
= FALSE
;
93 gchar
*env_lang
= getenv("LANG");
97 if ( !(line
= about_read_line(fp
)))
100 line
= g_strchug(line
);
101 if (!found
&& g_str_has_prefix(line
, env_lang
) )
104 gchar
*tmp
= g_strdup(line
+ strlen(env_lang
));
105 tmp
= g_strchug(tmp
);
106 translators
= g_strconcat("\n\n", tmp
, NULL
);
109 line
= g_strchomp(line
);
111 while ( !g_str_has_suffix(line
, ":") );
117 about_read_file(void)
124 fp
= fopen(PACKAGE_DATA_DIR
"/"ABOUT_AUTHORS
, "r");
126 g_return_if_fail (fp
!= NULL
);
127 line
= about_read_line(fp
);
130 line
= g_strchomp(line
);
131 if (g_str_has_suffix(line
, "Developer:") ||
132 g_str_has_suffix(line
, "Developers:") ||
133 g_str_has_suffix(line
, "Contributors:") ||
134 g_str_has_suffix(line
, "Note:"))
136 line
= about_read_developers(fp
, line
, &i_auth
, authors
);
138 else if (g_str_has_suffix(line
, "Website:") ||
139 g_str_has_suffix(line
, "Documenters:") )
141 line
= read_documenters(fp
, line
, &i_doc
, documenters
);
143 else if (g_str_has_suffix(line
, "Translators:") )
145 line
= read_translators(fp
, line
);
148 line
= about_read_line(fp
);
155 about_free_credit(void)
159 gchar
** ptr
= (gchar
**) authors
;
160 for(i
=0; ptr
[i
]; i
++)
162 ptr
= (gchar
**) documenters
;
163 for(i
=0; ptr
[i
]; i
++)
175 /* Parse AUTHORS file */
178 pix
= gdk_pixbuf_new_from_file (PACKAGE_PIXMAPS_DIR
"/"ANJUTA_PIXMAP_LOGO
,
181 dialog
= gtk_about_dialog_new();
182 gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(dialog
), "Anjuta");
183 gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog
), VERSION
);
184 gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog
),
185 _("Copyright (c) Naba Kumar"));
186 gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog
),
187 _("Integrated Development Environment"));
188 gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dialog
),
190 gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dialog
), "http://www.anjuta.org");
191 gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog
), pix
);
193 gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(dialog
), authors
);
194 gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(dialog
), documenters
);
195 gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(dialog
), translators
);
196 /* We should fill this!
197 gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(dialog), ???);*/
198 /* Free authors, documenters, translators */
200 g_object_unref (pix
);
205 on_about_plugin_activate (GtkMenuItem
*item
, AnjutaPluginDescription
*desc
)
208 gchar
*authors
= NULL
;
209 gchar
**authors_v
= NULL
;
212 GdkPixbuf
*pix
= NULL
;
215 anjuta_plugin_description_get_locale_string (desc
, "Anjuta Plugin",
217 anjuta_plugin_description_get_locale_string (desc
, "Anjuta Plugin",
219 anjuta_plugin_description_get_string (desc
, "Anjuta Plugin",
221 anjuta_plugin_description_get_string (desc
, "Anjuta Plugin",
222 "Authors", &authors
);
225 gchar
*path
= g_build_filename (PACKAGE_PIXMAPS_DIR
, icon
, NULL
);
226 pix
= gdk_pixbuf_new_from_file (path
, NULL
);
231 authors_v
= g_strsplit(authors
, ",", -1);
233 dialog
= gtk_about_dialog_new();
234 gtk_about_dialog_set_name(GTK_ABOUT_DIALOG(dialog
), name
);
235 gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog
), VERSION
);
236 gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog
),
238 gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog
),d
);
239 gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog
), pix
);
241 gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(dialog
),
242 (const gchar
**)authors_v
);
244 gtk_widget_show (dialog
);
245 g_object_unref (pix
);
246 g_strfreev (authors_v
);
254 about_create_plugins_submenu (AnjutaShell
*shell
, GtkWidget
*menuitem
)
257 GList
*plugin_descs
, *node
;
259 g_return_if_fail (ANJUTA_IS_SHELL (shell
));
260 g_return_if_fail (GTK_IS_MENU_ITEM (menuitem
));
262 submenu
= gtk_menu_new ();
263 gtk_widget_show (submenu
);
264 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem
), submenu
);
267 anjuta_plugin_manager_query (anjuta_shell_get_plugin_manager (shell
, NULL
),
268 NULL
, NULL
, NULL
, NULL
);
274 AnjutaPluginDescription
*desc
= node
->data
;
275 if (anjuta_plugin_description_get_locale_string (desc
, "Anjuta Plugin",
279 if (anjuta_plugin_description_get_string (desc
, "Anjuta Plugin",
280 "Authors", &authors
))
282 item
= gtk_menu_item_new_with_label (label
);
283 gtk_widget_show (item
);
284 g_signal_connect (G_OBJECT (item
), "activate",
285 G_CALLBACK (on_about_plugin_activate
),
287 gtk_menu_shell_append (GTK_MENU_SHELL (submenu
), item
);
292 node
= g_list_next (node
);