~ubuntu-branches/ubuntu/edgy/xfce-mcs-plugins/edgy

« back to all changes in this revision

Viewing changes to plugins/shortcuts_plugin/shortcuts_plugin.c

  • Committer: Bazaar Package Importer
  • Author(s): Jani Monoses
  • Date: 2006-03-10 10:05:40 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20060310100540-b4b36j29k5tao09d
Tags: 4.3.0svn+r20306-0ubuntu1
* Upstream svn snapshot
* Switch to CDBS
* Add gettext domain to desktop files
* Recommend xkill

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*      $Id: shortcuts_plugin.c 19936 2006-02-18 08:52:32Z olivier $
 
1
/*      $Id: shortcuts_plugin.c 20281 2006-03-07 21:17:33Z olivier $
2
2
 *
3
3
 * Copyright (c) 2006 Jean-Francois Wauthy <pollux@xfce.org>
4
4
 *                    Olivier Fourdan <fourdan@xfce.org>
172
172
                    g_error_free (error);
173
173
                }
174
174
            }
175
 
            break;
 
175
            return;
176
176
        }
177
177
    }
 
178
    g_warning ("Shortcut not found in list!");
178
179
}
179
180
 
180
181
static void
317
318
struct ShortcutsFileParserState
318
319
{
319
320
    gboolean started;
320
 
    gboolean grab;
321
321
    GtkWidget *treeview;
322
322
    GQueue *parents;
323
323
    gchar *theme_name;
373
373
    gchar *file_contents = NULL;
374
374
    GMarkupParseContext *gpcontext = NULL;
375
375
    struct stat st;
376
 
    struct ShortcutsFileParserState state = { FALSE, FALSE, NULL, NULL, NULL };
 
376
    struct ShortcutsFileParserState state = { FALSE, NULL, NULL, NULL };
377
377
    GMarkupParser gmparser = { get_theme_name_start, get_theme_name_end, NULL, NULL, NULL };
378
378
    GError *err = NULL;
379
379
#ifdef HAVE_MMAP
482
482
                                COLUMN_SHORTCUT, attribute_values[i] ? attribute_values[i] : "", -1);
483
483
        }
484
484
        
485
 
        if (state->grab && attribute_values[i])
 
485
        if (attribute_values[i])
486
486
        {
487
487
            launcher *shortcut;
488
488
 
506
506
}
507
507
 
508
508
static gboolean
509
 
parse_theme (const gchar * filename, McsDialog * dialog, gboolean grab)
 
509
parse_theme (const gchar * filename, McsDialog * dialog)
510
510
{
511
511
    gboolean ret = FALSE;
512
512
    GtkTreeModel *model;
513
513
    gchar *file_contents = NULL;
514
514
    GMarkupParseContext *gpcontext = NULL;
515
515
    struct stat st;
516
 
    struct ShortcutsFileParserState state = { FALSE, TRUE, NULL, NULL, NULL };
 
516
    struct ShortcutsFileParserState state = { FALSE, NULL, NULL, NULL };
517
517
    GMarkupParser gmparser = { parse_theme_start, parse_theme_end, NULL, NULL, NULL };
518
518
    GError *err = NULL;
519
519
#ifdef HAVE_MMAP
550
550
    }
551
551
 
552
552
    state.started = FALSE;
553
 
    state.grab = grab;
554
553
    state.parents = g_queue_new ();
555
554
    if (dialog)
556
555
    {
847
846
                save_settings (mcs_plugin);
848
847
 
849
848
                /* load the new theme in the treeview */
850
 
                parse_theme (new_path, dialog, TRUE);
 
849
                parse_theme (new_path, dialog);
851
850
            }
852
851
            else
853
852
            {
1994
1993
    }
1995
1994
 
1996
1995
    init_modifiers ();
1997
 
    parse_theme (theme_path, NULL, TRUE);
 
1996
    parse_theme (theme_path, NULL);
1998
1997
    add_event_listener ();
1999
1998
 
2000
1999
    return (MCS_PLUGIN_INIT_OK);
2003
2002
static void
2004
2003
run_dialog (McsPlugin * plugin)
2005
2004
{
2006
 
    McsDialog *dialog;
 
2005
    static McsDialog *dialog = NULL;
2007
2006
    gchar *path = NULL;
2008
2007
 
 
2008
    xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
2009
2009
    if (is_running)
 
2010
    {
 
2011
        if((dialog) && (dialog->shortcuts_dialog))
 
2012
        {
 
2013
            gtk_window_present(GTK_WINDOW(dialog->shortcuts_dialog));
 
2014
            gtk_window_set_focus (GTK_WINDOW(dialog->shortcuts_dialog), NULL);
 
2015
        }
2010
2016
        return;
 
2017
    }
2011
2018
 
2012
2019
    is_running = TRUE;
2013
2020
 
2014
 
    xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
2015
 
 
2016
2021
    /* check XDG_CONFIG_HOME/xfce4/shortcuts/ exists; if not it creates it */
2017
2022
    path = xfce_resource_save_location (XFCE_RESOURCE_CONFIG, "xfce4/shortcuts/", TRUE);
2018
2023
    if (G_UNLIKELY (path == NULL))
2024
2029
 
2025
2030
    dialog = create_dialog (plugin);
2026
2031
    setup_dialog (dialog);
2027
 
    /* Parse to show ion treevew, but do not grab again since it was already done at startup... */
2028
 
    parse_theme (theme_path, dialog, FALSE);
 
2032
    parse_theme (theme_path, dialog);
2029
2033
 
2030
2034
    xfce_gtk_window_center_on_monitor_with_pointer (GTK_WINDOW (dialog->shortcuts_dialog));
 
2035
    gdk_x11_window_set_user_time(GTK_WIDGET (dialog->shortcuts_dialog)->window, 
 
2036
            gdk_x11_get_server_time (GTK_WIDGET (dialog->shortcuts_dialog)->window));
2031
2037
    gtk_widget_show (dialog->shortcuts_dialog);
2032
2038
}
2033
2039