~ubuntu-branches/ubuntu/wily/xpad/wily

« back to all changes in this revision

Viewing changes to src/xpad-pad.c

  • Committer: Package Import Robot
  • Author(s): Julien Lavergne
  • Date: 2015-01-01 16:47:10 UTC
  • mfrom: (1.1.14)
  • Revision ID: package-import@ubuntu.com-20150101164710-23jl44w283qkzt8q
Tags: 4.5.0-0ubuntu1
* New upstream release.
* debian/patches:
 - help_dir.diff: Remove, merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
*/
25
25
 
26
26
#include "../config.h"
 
27
 
27
28
#include "xpad-pad.h"
28
 
#include <gtk/gtk.h>
29
 
#include <glib/gi18n.h>
30
29
#include "fio.h"
31
30
#include "help.h"
32
31
#include "xpad-app.h"
38
37
#include "xpad-toolbar.h"
39
38
#include "xpad-tray.h"
40
39
 
 
40
#include <gtk/gtk.h>
 
41
#include <glib/gi18n.h>
 
42
 
41
43
struct XpadPadPrivate
42
44
{
43
45
        /* saved values */
506
508
        gboolean decorations;
507
509
        g_object_get (pad->priv->settings, "has-decorations", &decorations, NULL);
508
510
 
509
 
        /* Update pad menu with the new status */
510
 
        GtkWidget *menu_item = g_object_get_data (G_OBJECT (pad->priv->menu), "has-decorations");
511
 
        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), decorations);
512
 
 
513
511
        /*
514
512
         *  There are two modes of operation:  a normal mode and a 'stealth' mode.
515
513
         *  If decorations are disabled, we also don't show up in the taskbar or pager. 
535
533
        gboolean has_toolbar, autohide_toolbar;
536
534
        g_object_get (pad->priv->settings, "has-toolbar", &has_toolbar, "autohide-toolbar", &autohide_toolbar, NULL);
537
535
 
538
 
        /* Update pad menu with the new status */
539
 
        GtkWidget *menu_item = g_object_get_data (G_OBJECT (pad->priv->menu), "has-toolbar");
540
 
        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), has_toolbar);
541
 
        menu_item = g_object_get_data (G_OBJECT (pad->priv->menu), "has-autohide-toolbar");
542
 
        gtk_widget_set_sensitive (menu_item, has_toolbar);
543
 
 
544
536
        if (has_toolbar && !autohide_toolbar)
545
537
                xpad_pad_show_toolbar (pad);
546
538
        else
553
545
        gboolean autohide_toolbar;
554
546
        g_object_get (pad->priv->settings, "autohide-toolbar", &autohide_toolbar, NULL);
555
547
 
556
 
        /* Update pad menu with the new status */
557
 
        GtkWidget *menu_item = g_object_get_data (G_OBJECT (pad->priv->menu), "has-autohide-toolbar");
558
 
        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), autohide_toolbar);
559
 
 
560
548
        if (autohide_toolbar)
561
549
        {
562
550
                /* Likely not to be in pad when turning setting on */
579
567
        gboolean has_scrollbar;
580
568
        g_object_get (pad->priv->settings, "has-scrollbar", &has_scrollbar, NULL);
581
569
 
582
 
        /* Update pad menu with the new status */
583
 
        GtkWidget *menu_item = g_object_get_data (G_OBJECT (pad->priv->menu), "has-scrollbar");
584
 
        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item), has_scrollbar);
585
 
 
586
570
        if (has_scrollbar)
587
571
                gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (pad->priv->scrollbar),
588
572
                        GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
892
876
        if (!pad->priv->properties)
893
877
                return;
894
878
 
895
 
        title = g_strdup_printf (_("'%s' Properties"), gtk_window_get_title (GTK_WINDOW (pad)));
 
879
        title = g_strdup_printf (_("'%s' Layout"), gtk_window_get_title (GTK_WINDOW (pad)));
896
880
        gtk_window_set_title (GTK_WINDOW (pad->priv->properties), title);
897
881
        g_free (title);
898
882
}
1304
1288
                gtk_widget_override_background_color (pad->priv->textview, GTK_STATE_FLAG_SELECTED, &text_color);
1305
1289
        }
1306
1290
 
1307
 
        /*
1308
 
         * Find the sticky notes menu setting for this pad (which is on the global default),
1309
 
         * and change its setting to the setting from the info file (pad specific default).
1310
 
         */
1311
 
        if (GTK_IS_CONTAINER (pad->priv->menu)) {
1312
 
                GObject *obj;
1313
 
                GList *elem, *children;
1314
 
                children = gtk_container_get_children (GTK_CONTAINER (pad->priv->menu));
1315
 
 
1316
 
                for (elem = children; elem; elem = elem->next) {
1317
 
                        obj = (GObject *) elem->data;
1318
 
 
1319
 
                        if (GTK_IS_BIN (obj) && GTK_IS_MENU_ITEM (obj)) {
1320
 
                                GList *elem2, *children2;
1321
 
                                children2 = gtk_container_get_children (GTK_CONTAINER (gtk_menu_item_get_submenu (GTK_MENU_ITEM(obj))));
1322
 
                                for(elem2 = children2; elem2; elem2 = elem2->next) {
1323
 
                                        obj = (GObject *) elem2->data;
1324
 
                                        if (GTK_IS_CHECK_MENU_ITEM (obj)) {
1325
 
                                                if (!g_strcmp0(gtk_menu_item_get_label (GTK_MENU_ITEM (obj)), "Show on _All Workspaces")) {
1326
 
                                                        gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (obj), pad->priv->sticky);
1327
 
                                                        break;
1328
 
                                                }
1329
 
                                        }
1330
 
                                }
1331
 
                                g_list_free(elem2);
1332
 
                        }
1333
 
                }
1334
 
                g_list_free(elem);
1335
 
        }
1336
 
        else
1337
 
                g_warning("For some reason the variable pad->priv->menu is not a container. This results in not having a unique sticky setting for this pad. Falling back to the global sticky setting. Please send a bugreport.");
1338
 
 
1339
1291
        if (pad->priv->sticky)
1340
1292
                gtk_window_stick (GTK_WINDOW (pad));
1341
1293
        else
1537
1489
        menu_toggle_tag (pad, "strikethrough");
1538
1490
}
1539
1491
 
1540
 
/*
1541
 
 * Make the pad visually stick to the workspace and save this setting to the individual pad info file,
1542
 
 * because this function has been probably been called, because of a menu toggle.
1543
 
 */
1544
 
static void
1545
 
menu_sticky (GtkCheckMenuItem *check, XpadPad *pad)
1546
 
{
1547
 
        pad->priv->sticky = gtk_check_menu_item_get_active (check);
1548
 
        if (pad->priv->sticky)
1549
 
                gtk_window_stick (GTK_WINDOW (pad));
1550
 
        else
1551
 
                gtk_window_unstick (GTK_WINDOW (pad));
1552
 
        xpad_pad_save_info_delayed (pad);
1553
 
}
1554
 
 
1555
 
static void
1556
 
menu_toolbar (GtkCheckMenuItem *check, XpadPad *pad)
1557
 
{
1558
 
        g_object_set (pad->priv->settings, "has-toolbar", gtk_check_menu_item_get_active (check), NULL);
1559
 
}
1560
 
 
1561
 
static void
1562
 
menu_scrollbar (GtkCheckMenuItem *check, XpadPad *pad)
1563
 
{
1564
 
        g_object_set (pad->priv->settings, "has-scrollbar", gtk_check_menu_item_get_active (check), NULL);
1565
 
}
1566
 
 
1567
 
static void
1568
 
menu_autohide (GtkCheckMenuItem *check, XpadPad *pad)
1569
 
{
1570
 
        g_object_set (pad->priv->settings, "autohide-toolbar", gtk_check_menu_item_get_active (check), NULL);
1571
 
}
1572
 
 
1573
 
static void
1574
 
menu_decorated (GtkCheckMenuItem *check, XpadPad *pad)
1575
 
{
1576
 
        g_object_set (pad->priv->settings, "has-decorations", gtk_check_menu_item_get_active (check), NULL);
1577
 
}
1578
 
 
1579
1492
static gint
1580
1493
menu_title_compare (GtkWindow *a, GtkWindow *b)
1581
1494
{
1625
1538
menu_get_popup_no_highlight (XpadPad *pad, GtkAccelGroup *accel_group)
1626
1539
{
1627
1540
        GtkWidget *uppermenu, *menu, *item;
1628
 
        gboolean has_toolbar, autohide_toolbar, has_scrollbar, decorations;
1629
 
 
1630
 
        g_object_get (pad->priv->settings,
1631
 
                        "has-toolbar", &has_toolbar,
1632
 
                        "autohide-toolbar", &autohide_toolbar,
1633
 
                        "has-decorations", &decorations,
1634
 
                        "has-scrollbar", &has_scrollbar, NULL);
1635
 
 
 
1541
 
 
1542
        /* Upper menu */
1636
1543
        uppermenu = gtk_menu_new ();
1637
1544
        gtk_menu_set_accel_group (GTK_MENU (uppermenu), accel_group);
1638
 
 
1639
 
        /* Pad submenu */
1640
 
        item = gtk_menu_item_new_with_mnemonic (_("_Pad"));
1641
 
        gtk_container_add (GTK_CONTAINER (uppermenu), item);
1642
 
        menu = gtk_menu_new ();
1643
 
        gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
 
1545
        menu = uppermenu;
1644
1546
        MENU_ADD (_("_New"), "document-new", GDK_KEY_N, GDK_CONTROL_MASK, xpad_pad_spawn);
1645
 
        MENU_ADD_SEP ();
1646
 
        MENU_ADD_CHECK (_("Show on _All Workspaces"), pad->priv->sticky, menu_sticky);
1647
 
        g_object_set_data (G_OBJECT (uppermenu), "sticky", item);
1648
 
        MENU_ADD (_("_Properties"), "document-properties", 0, 0, xpad_pad_open_properties);
1649
 
        MENU_ADD_SEP ();
 
1547
        MENU_ADD (_("_Delete"), "edit-delete", GDK_KEY_Delete, GDK_SHIFT_MASK, xpad_pad_delete);
1650
1548
        MENU_ADD (_("_Close"), "window-close", 0, 0, xpad_pad_close);
1651
 
        MENU_ADD (_("_Delete"), "edit-delete", GDK_KEY_Delete, GDK_SHIFT_MASK, xpad_pad_delete);
1652
1549
 
1653
1550
        /* Edit submenu */
1654
1551
        item = gtk_menu_item_new_with_mnemonic (_("_Edit"));
1662
1559
        MENU_ADD_SEP();
1663
1560
        MENU_ADD (_("_Paste"), "edit-paste", 0, 0, xpad_pad_paste);
1664
1561
        g_object_set_data (G_OBJECT (uppermenu), "paste", item);
1665
 
        MENU_ADD_SEP ();
1666
 
        MENU_ADD (_("_Preferences"), "preferences-system", 0, 0, xpad_pad_open_preferences);
 
1562
        MENU_ADD_SEP();
 
1563
        MENU_ADD (_("_Layout"), "document-properties", 0, 0, xpad_pad_open_properties);
1667
1564
 
1668
 
        /* View submenu */
1669
 
        item = gtk_menu_item_new_with_mnemonic (_("_View"));
1670
 
        gtk_container_add (GTK_CONTAINER (uppermenu), item);
1671
 
        menu = gtk_menu_new ();
1672
 
        gtk_menu_item_set_submenu (GTK_MENU_ITEM (item), menu);
1673
 
        MENU_ADD_CHECK (_("_Toolbar"), has_toolbar, menu_toolbar);
1674
 
        g_object_set_data (G_OBJECT (uppermenu), "has-toolbar", item);
1675
 
        MENU_ADD_CHECK (_("_Autohide Toolbar"), autohide_toolbar, menu_autohide);
1676
 
        g_object_set_data (G_OBJECT (uppermenu), "has-autohide-toolbar", item);
1677
 
        gtk_widget_set_sensitive (item, has_toolbar);
1678
 
        MENU_ADD_CHECK (_("_Scrollbar"), has_scrollbar, menu_scrollbar);
1679
 
        g_object_set_data (G_OBJECT (uppermenu), "has-scrollbar", item);
1680
 
        MENU_ADD_CHECK (_("_Window Decorations"), decorations, menu_decorated);
1681
 
        g_object_set_data (G_OBJECT (uppermenu), "has-decorations", item);
 
1565
        menu = uppermenu;
 
1566
        MENU_ADD_SEP();
1682
1567
 
1683
1568
        /* Notes submenu - The list of notes will get added in the prep function below */
1684
1569
        item = gtk_menu_item_new_with_mnemonic (_("_Notes"));
1697
1582
        MENU_ADD (_("_Help"), "help-browser", GDK_KEY_F1, 0, show_help);
1698
1583
        MENU_ADD (_("_About"), "help-about", 0, 0, menu_about);
1699
1584
 
 
1585
        /* Upper menu */
 
1586
        menu = uppermenu;
 
1587
        MENU_ADD_SEP ();
 
1588
        MENU_ADD (_("_Preferences"), "preferences-system", 0, 0, xpad_pad_open_preferences);
 
1589
 
1700
1590
        gtk_widget_show_all (uppermenu);
1701
1591
 
1702
1592
        return uppermenu;