17
17
* GNU General Public License for more details.
19
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software
21
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
* along with this program; if not, see <http://www.gnu.org/licenses/>.
24
23
#include <config.h>
31
30
#include <gtk/gtk.h>
33
32
#include <panel-applet.h>
34
#include <gconf/gconf-client.h>
35
33
#include "mini-commander_applet.h"
36
34
#include "preferences.h"
37
35
#include "command_line.h"
38
#include "gsettings.h"
41
40
#include "browser-mini.xpm"
42
41
#include "history-mini.xpm"
49
48
static gboolean icons_initialized = FALSE;
50
49
static GtkIconSize button_icon_size = 0;
52
static const GtkActionEntry mini_commander_menu_actions [] = {
53
{ "Props", GTK_STOCK_PROPERTIES, N_("_Preferences"),
55
G_CALLBACK (mc_show_preferences) },
56
{ "Help", GTK_STOCK_HELP, N_("_Help"),
58
G_CALLBACK (show_help) },
59
{ "About", GTK_STOCK_ABOUT, N_("_About"),
61
G_CALLBACK (about_box) }
51
static const GActionEntry mini_commander_menu_actions [] = {
52
{ "preferences", mc_show_preferences, NULL, NULL, NULL },
53
{ "help", show_help, NULL, NULL, NULL },
54
{ "about", about_box, NULL, NULL, NULL }
205
198
if ( ((mc->orient == PANEL_APPLET_ORIENT_LEFT) || (mc->orient == PANEL_APPLET_ORIENT_RIGHT)) && (prefs.panel_size_x < 36) )
206
mc->applet_box = gtk_vbox_new (FALSE, 0);
199
mc->applet_box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
208
mc->applet_box = gtk_hbox_new (FALSE, 0);
201
mc->applet_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
210
203
gtk_container_set_border_width (GTK_CONTAINER (mc->applet_box), 0);
219
212
/* hbox for message label and buttons */
220
213
if ((mc->orient == PANEL_APPLET_ORIENT_LEFT) || (mc->orient == PANEL_APPLET_ORIENT_RIGHT))
221
214
if (prefs.panel_size_x < 36)
222
hbox_buttons = gtk_vbox_new (TRUE, 0);
215
hbox_buttons = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
224
hbox_buttons = gtk_hbox_new (TRUE, 0);
217
hbox_buttons = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
226
219
if (prefs.normal_size_y > 36)
227
hbox_buttons = gtk_vbox_new (TRUE, 0);
220
hbox_buttons = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
229
hbox_buttons = gtk_hbox_new (TRUE, 0);
222
hbox_buttons = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
224
gtk_box_set_homogeneous (GTK_BOX (hbox_buttons), TRUE);
231
226
/* add file-browser button */
232
227
button = gtk_button_new ();
276
271
mc_destroyed (GtkWidget *widget,
274
if (mc->global_settings) {
275
g_object_unref (mc->global_settings);
276
mc->global_settings = NULL;
282
client = gconf_client_get_default ();
283
for (i = 0; i < MC_NUM_LISTENERS; i++) {
284
gconf_client_notify_remove (client, mc->listeners [i]);
285
mc->listeners [i] = 0;
280
g_object_unref (mc->settings);
287
g_object_unref (client);
289
284
mc_macros_free (mc->preferences.macros);
286
if (mc->preferences.cmd_line_color_fg)
287
g_free (mc->preferences.cmd_line_color_fg);
289
if (mc->preferences.cmd_line_color_bg)
290
g_free (mc->preferences.cmd_line_color_bg);
291
292
if (mc->prefs_dialog.dialog)
292
293
gtk_widget_destroy (mc->prefs_dialog.dialog);
331
332
mini_commander_applet_fill (PanelApplet *applet)
335
GtkActionGroup *action_group;
336
GSimpleActionGroup *action_group;
338
client = gconf_client_get_default ();
339
if (gconf_client_get_bool (client, "/desktop/gnome/lockdown/inhibit_command_line", NULL)) {
340
settings = g_settings_new (GNOME_DESKTOP_LOCKDOWN_SCHEMA);
341
if (g_settings_get_boolean (settings, "disable-command-line")) {
340
342
GtkWidget *error_dialog;
342
344
error_dialog = gtk_message_dialog_new (NULL,
364
367
mc = g_new0 (MCData, 1);
365
368
mc->applet = applet;
367
panel_applet_add_preferences (applet, "/schemas/apps/mini-commander/prefs", NULL);
370
mc->global_settings = g_settings_new (MINI_COMMANDER_GLOBAL_SCHEMA);
371
mc->settings = panel_applet_settings_new (applet, MINI_COMMANDER_SCHEMA);
368
373
panel_applet_set_flags (applet, PANEL_APPLET_EXPAND_MINOR);
369
374
mc_load_preferences (mc);
370
375
command_line_init_stock_icons ();
374
379
g_signal_connect (mc->applet, "size_allocate",
375
380
G_CALLBACK (mc_pixel_size_changed), mc);
377
mc->preferences.normal_size_y = panel_applet_get_size (applet);
378
382
mc->orient = panel_applet_get_orient (applet);
379
383
mc_applet_draw(mc);
380
384
gtk_widget_show (GTK_WIDGET (mc->applet));
385
389
g_signal_connect (mc->applet, "key_press_event",
386
390
G_CALLBACK (key_press_cb), mc);
388
action_group = gtk_action_group_new ("MiniCommander Applet Actions");
389
gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
390
gtk_action_group_add_actions (action_group,
391
mini_commander_menu_actions,
392
G_N_ELEMENTS (mini_commander_menu_actions),
392
action_group = g_simple_action_group_new ();
393
g_action_map_add_action_entries (G_ACTION_MAP (action_group),
394
mini_commander_menu_actions,
395
G_N_ELEMENTS (mini_commander_menu_actions),
394
397
ui_path = g_build_filename (MC_MENU_UI_DIR, "mini-commander-applet-menu.xml", NULL);
395
panel_applet_setup_menu_from_file (mc->applet, ui_path, action_group);
397
if (panel_applet_get_locked_down (mc->applet)) {
400
action = gtk_action_group_get_action (action_group, "Props");
401
gtk_action_set_visible (action, FALSE);
398
panel_applet_setup_menu_from_file (mc->applet, ui_path, action_group, GETTEXT_PACKAGE);
400
gtk_widget_insert_action_group (GTK_WIDGET (applet), "mc",
401
G_ACTION_GROUP (action_group));
403
action = g_action_map_lookup_action (G_ACTION_MAP (action_group), "preferences");
404
g_object_bind_property (applet, "locked-down",
406
G_BINDING_DEFAULT|G_BINDING_INVERT_BOOLEAN|G_BINDING_SYNC_CREATE);
403
408
g_object_unref (action_group);
405
410
set_atk_name_description (GTK_WIDGET (applet),