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
27 #include <libanjuta/anjuta-plugin-manager.h>
31 #define ANJUTA_PIXMAP_LOGO "anjuta_logo.png"
32 #define ABOUT_AUTHORS "AUTHORS"
34 #define MAX_CREDIT 500
36 static const gchar
*authors
[MAX_CREDIT
];
37 static const gchar
*documenters
[MAX_CREDIT
];
38 static gchar
*translators
;
42 about_read_line(FILE *fp
)
44 static gchar tpn
[MAX_CAR
];
49 while( ((c
=getc(fp
))!='\n') && (c
!=EOF
) && ((pt
-tpn
)<MAX_CAR
) )
59 about_read_developers(FILE *fp
, gchar
*line
, gint
*index
, const gchar
**tab
)
63 if (*index
< MAX_CREDIT
)
64 tab
[(*index
)++] = g_strdup_printf("%s", line
);
65 if ( !(line
= about_read_line(fp
)))
67 line
= g_strchomp(line
);
69 while (!g_str_has_suffix(line
, ":") );
75 read_documenters(FILE *fp
, gchar
*line
, gint
*index
, const gchar
**tab
)
79 if (*index
< MAX_CREDIT
)
80 tab
[(*index
)++] = g_strdup_printf("%s", line
);
81 if ( !(line
= about_read_line(fp
)))
83 line
= g_strchomp(line
);
85 while ( !g_str_has_suffix(line
, ":") );
91 read_translators(FILE *fp
, gchar
*line
)
93 gboolean found
= FALSE
;
94 gchar
*env_lang
= getenv("LANG");
98 if ( !(line
= about_read_line(fp
)))
101 line
= g_strchug(line
);
102 if (!found
&& g_str_has_prefix(line
, env_lang
) )
105 gchar
*tmp
= g_strdup(line
+ strlen(env_lang
));
106 tmp
= g_strchug(tmp
);
107 translators
= g_strconcat("\n\n", tmp
, NULL
);
110 line
= g_strchomp(line
);
112 while ( !g_str_has_suffix(line
, ":") );
118 about_read_file(void)
125 fp
= fopen(PACKAGE_DATA_DIR
"/"ABOUT_AUTHORS
, "r");
127 g_return_if_fail (fp
!= NULL
);
128 line
= about_read_line(fp
);
131 line
= g_strchomp(line
);
132 if (g_str_has_suffix(line
, "Developer:") ||
133 g_str_has_suffix(line
, "Developers:") ||
134 g_str_has_suffix(line
, "Contributors:") ||
135 g_str_has_suffix(line
, "Note:"))
137 line
= about_read_developers(fp
, line
, &i_auth
, authors
);
139 else if (g_str_has_suffix(line
, "Website:") ||
140 g_str_has_suffix(line
, "Documenters:") )
142 line
= read_documenters(fp
, line
, &i_doc
, documenters
);
144 else if (g_str_has_suffix(line
, "Translators:") )
146 line
= read_translators(fp
, line
);
149 line
= about_read_line(fp
);
156 about_free_credit(void)
160 gchar
** ptr
= (gchar
**) authors
;
161 for(i
=0; ptr
[i
]; i
++)
163 ptr
= (gchar
**) documenters
;
164 for(i
=0; ptr
[i
]; i
++)
171 about_box_new (GtkWindow
*parent
)
174 GError
* error
= NULL
;
176 /* Parse AUTHORS file */
179 dialog
= gtk_about_dialog_new();
180 gtk_window_set_transient_for(GTK_WINDOW(dialog
), parent
);
181 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
183 gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(dialog
), "Anjuta");
184 gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog
), VERSION
);
185 gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog
),
186 _("Copyright © Naba Kumar"));
187 gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog
),
188 _("Integrated Development Environment"));
189 gtk_about_dialog_set_license_type(GTK_ABOUT_DIALOG(dialog
),
190 GTK_LICENSE_GPL_2_0
);
191 gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dialog
), "http://www.anjuta.org");
192 gtk_about_dialog_set_logo_icon_name(GTK_ABOUT_DIALOG(dialog
), "anjuta");
194 gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(dialog
), authors
);
195 gtk_about_dialog_set_documenters(GTK_ABOUT_DIALOG(dialog
), documenters
);
196 gtk_about_dialog_set_translator_credits(GTK_ABOUT_DIALOG(dialog
), translators
);
197 /* We should fill this!
198 gtk_about_dialog_set_artists(GTK_ABOUT_DIALOG(dialog), ???);*/
199 /* Free authors, documenters, translators */
205 on_about_plugin_activate (GtkMenuItem
*item
, AnjutaShell
*shell
)
208 gchar
*authors
= NULL
;
209 gchar
*license
= NULL
;
210 gchar
**authors_v
= NULL
;
213 GdkPixbuf
*pix
= NULL
;
215 AnjutaPluginDescription
*desc
;
217 desc
= g_object_get_data (G_OBJECT (item
), "plugin-desc");
219 anjuta_plugin_description_get_locale_string (desc
, "Anjuta Plugin",
221 anjuta_plugin_description_get_locale_string (desc
, "Anjuta Plugin",
223 anjuta_plugin_description_get_string (desc
, "Anjuta Plugin",
225 anjuta_plugin_description_get_string (desc
, "Anjuta Plugin",
226 "Authors", &authors
);
227 anjuta_plugin_description_get_string (desc
, "Anjuta Plugin",
228 "License", &license
);
231 gchar
*path
= g_build_filename (PACKAGE_PIXMAPS_DIR
, icon
, NULL
);
232 pix
= gdk_pixbuf_new_from_file (path
, NULL
);
237 authors_v
= g_strsplit(authors
, ",", -1);
239 dialog
= gtk_about_dialog_new();
240 gtk_window_set_transient_for(GTK_WINDOW(dialog
), GTK_WINDOW(shell
));
241 gtk_window_set_modal(GTK_WINDOW(dialog
), TRUE
);
243 gtk_about_dialog_set_program_name(GTK_ABOUT_DIALOG(dialog
), name
);
244 gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog
), VERSION
);
246 gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog
),
248 gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog
),d
);
249 gtk_about_dialog_set_logo(GTK_ABOUT_DIALOG(dialog
), pix
);
251 gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(dialog
),
252 (const gchar
**)authors_v
);
254 gtk_widget_show (dialog
);
256 g_signal_connect (dialog
, "response", G_CALLBACK (gtk_widget_destroy
), NULL
);
258 g_object_unref (pix
);
259 g_strfreev (authors_v
);
268 about_create_plugins_submenu (AnjutaShell
*shell
, GtkWidget
*menuitem
)
271 GList
*plugin_handles
, *node
;
273 g_return_if_fail (ANJUTA_IS_SHELL (shell
));
274 g_return_if_fail (GTK_IS_MENU_ITEM (menuitem
));
276 submenu
= gtk_menu_new ();
277 gtk_widget_show (submenu
);
278 gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem
), submenu
);
281 anjuta_plugin_manager_query (anjuta_shell_get_plugin_manager (shell
, NULL
),
282 NULL
, NULL
, NULL
, NULL
);
283 node
= plugin_handles
;
288 AnjutaPluginHandle
*handle
= (AnjutaPluginHandle
*)node
->data
;
289 AnjutaPluginDescription
*desc
= anjuta_plugin_handle_get_description (handle
);
290 if (anjuta_plugin_description_get_locale_string (desc
, "Anjuta Plugin",
293 gchar
*authors
= NULL
;
294 gchar
*license
= NULL
;
295 if (anjuta_plugin_description_get_string (desc
, "Anjuta Plugin",
296 "Authors", &authors
) ||
297 anjuta_plugin_description_get_string (desc
, "Anjuta Plugin",
298 "License", &license
))
300 item
= gtk_menu_item_new_with_label (label
);
301 gtk_widget_show (item
);
303 g_object_set_data (G_OBJECT (item
), "plugin-desc", desc
);
304 g_signal_connect (G_OBJECT (item
), "activate",
305 G_CALLBACK (on_about_plugin_activate
),
307 gtk_menu_shell_append (GTK_MENU_SHELL (submenu
), item
);
313 node
= g_list_next (node
);
315 g_list_free (plugin_handles
);