PRBool
nsGNOMEShellService::KeyMatchesAppName(const char *aKeyValue) const
{

  gchar *commandPath;
  if (mUseLocaleFilenames) {
    gchar *nativePath = g_filename_from_utf8(aKeyValue, -1, NULL, NULL, NULL);
    if (!nativePath) {
      NS_ERROR("Error converting path to filesystem encoding");
      return PR_FALSE;
    }

    commandPath = g_find_program_in_path(nativePath);
    g_free(nativePath);
  } else {
    commandPath = g_find_program_in_path(aKeyValue);
  }

  if (!commandPath)
    return PR_FALSE;

  PRBool matches = mAppPath.Equals(commandPath);
  g_free(commandPath);
  return matches;
}
bool
nsGNOMEShellService::HandlerMatchesAppName(const char* aHandler)
{
  bool matches = false;
  gint argc;
  gchar** argv;
  if (g_shell_parse_argv(aHandler, &argc, &argv, nullptr) && argc > 0) {
    gchar* command = nullptr;
    if (!mUseLocaleFilenames)
      command = g_find_program_in_path(argv[0]);
    else {
      gchar* nativeFile = g_filename_from_utf8(argv[0], -1,
                                               nullptr, nullptr, nullptr);
      if (nativeFile) {
        command = g_find_program_in_path(nativeFile);
        g_free(nativeFile);
      }
    }
    matches = command && mAppPath.Equals(command);
    g_free(command);
    g_strfreev(argv);
  }

  return matches;
}
PRBool
nsGNOMEShellService::GetAppPathFromLauncher()
{
  gchar *tmp;

  const char *launcher = PR_GetEnv("MOZ_APP_LAUNCHER");
  if (!launcher)
    return PR_FALSE;

  if (g_path_is_absolute(launcher)) {
    mAppPath = launcher;
    tmp = g_path_get_basename(launcher);
    gchar *fullpath = g_find_program_in_path(tmp);
    if (fullpath && mAppPath.Equals(fullpath))
      mAppIsInPath = PR_TRUE;
    g_free(fullpath);
  } else {
    tmp = g_find_program_in_path(launcher);
    if (!tmp)
      return PR_FALSE;
    mAppPath = tmp;
    mAppIsInPath = PR_TRUE;
  }

  g_free(tmp);
  return PR_TRUE;
}
bool
nsMailGNOMEIntegration::GetAppPathFromLauncher()
{
  gchar *tmp;

  const char *launcher = PR_GetEnv("MOZ_APP_LAUNCHER");
  if (!launcher)
    return false;

  if (g_path_is_absolute(launcher)) {
    mAppPath = launcher;
    tmp = g_path_get_basename(launcher);
    gchar *fullpath = g_find_program_in_path(tmp);
    if (fullpath && mAppPath.Equals(fullpath)) {
      mAppIsInPath = true;
    }
    g_free(fullpath);
  } else {
    tmp = g_find_program_in_path(launcher);
    if (!tmp)
      return false;
    mAppPath = tmp;
    mAppIsInPath = true;
  }

  g_free(tmp);
  return true;
}
Beispiel #5
0
static gboolean
locate_fortune_command (FishApplet   *fish,
			int          *argcp,
			char       ***argvp)
{
	char *prog = NULL;

	if (fish->command
	    && g_shell_parse_argv (fish->command, argcp, argvp, NULL)) {
		prog = g_find_program_in_path ((*argvp)[0]);
		if (prog) {
			g_free (prog);
			return TRUE;
		}

		g_strfreev (*argvp);
	}

	prog = g_find_program_in_path ("fortune");
	if (prog) {
		g_free (prog);
		if (g_shell_parse_argv ("fortune", argcp, argvp, NULL))
			return FALSE;
	}

	if (g_file_test ("/usr/games/fortune", G_FILE_TEST_IS_EXECUTABLE)
	    && g_shell_parse_argv ("/usr/games/fortune", argcp, argvp, NULL))
		return FALSE;

	something_fishy_going_on (fish,
				  _("Unable to locate the command to execute"));
	*argvp = NULL;
	return FALSE;
}
Beispiel #6
0
static void
maybe_lock_screen (ShellStatusMenu *status)
{
  char *args[3];
  GError *err;
  GdkScreen *screen;
  gboolean use_gscreensaver = TRUE;
  gboolean res;

  g_debug ("Attempting to lock screen");

  args[0] = g_find_program_in_path ("gnome-screensaver-command");
  if (args[0] == NULL)
    {
      args[0] = g_find_program_in_path ("xscreensaver-command");
      use_gscreensaver = FALSE;
    }

  if (args[0] == NULL)
    return;

  if (use_gscreensaver)
    args[1] = "--lock";
  else
    args[1] = "-lock";
  args[2] = NULL;

  screen = gdk_screen_get_default ();

  err = NULL;
  res = gdk_spawn_on_screen (screen, g_get_home_dir (), args, NULL, 0, NULL,
      NULL, NULL, &err);
  if (!res)
    {
      g_warning (_("Can't lock screen: %s"), err->message);
      g_error_free (err);
    }

  if (use_gscreensaver)
    args[1] = "--throttle";
  else
    args[1] = "-throttle";

  err = NULL;
  res = gdk_spawn_on_screen (screen, g_get_home_dir (), args, NULL,
      (G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_STDOUT_TO_DEV_NULL), NULL, NULL,
      NULL, &err);
  if (!res)
    {
      g_warning (_("Can't temporarily set screensaver to blank screen: %s"),
          err->message);
      g_error_free (err);
    }

  g_free (args[0]);
}
Beispiel #7
0
gboolean
authorg_util_run_mkisofs (const gchar *tmpfolder, const gchar *isoname, GError **p_error)
{
	GtkWidget *spawn_dialog;
	gchar *tmp, *mkisofs;
	GError *error = NULL;
				
	mkisofs = g_find_program_in_path ("mkisofs");

	if (mkisofs == NULL)
	{
		/* TODO: error message */
		return FALSE;
	}

	spawn_dialog = authorg_spawn_dialog_new ();
	authorg_spawn_dialog_set_info (AUTHORG_SPAWN_DIALOG (spawn_dialog),
			_("Creating the DVD ISO file"));
	tmp = g_strconcat (
				mkisofs = g_find_program_in_path ("mkisofs"),
				" -gui -dvd-video -o ",
				isoname,
				" ",
				tmpfolder,
				NULL);

	g_free (mkisofs);

	g_signal_connect (G_OBJECT (spawn_dialog), "line-read",
			G_CALLBACK (_mkisofs_parse_progress), NULL);

	if (!authorg_spawn_dialog_run_command_line (
			AUTHORG_SPAWN_DIALOG (spawn_dialog), tmp, &error))
	{
			gtk_widget_hide (spawn_dialog);
			if (!g_error_matches (error, AUTHORG_SPAWN_DIALOG_ERROR, AUTHORG_SPAWN_DIALOG_ERROR_CANCELED))
			{
				/* canceling is no "real" error, only show error if it was real */
				authorg_util_spawn_error ("mkisofs", error);
			}
			authorg_util_clear_tmp (isoname, TRUE);
			g_error_free (error);
			gtk_widget_destroy (spawn_dialog);
			g_free (tmp);

			return FALSE;
	}

	gtk_widget_destroy (spawn_dialog);
	g_free (tmp);

	return TRUE;
}
Beispiel #8
0
gchar* find_good_browser (void)
{
   gchar *t = g_find_program_in_path ("konqueror");
   if (! t)
      t = g_find_program_in_path ("opera");
      if (! t)
         t = g_find_program_in_path ("firefox");
         if (! t)
            t = g_find_program_in_path ("mozilla");
            if (! t)
                t = g_find_program_in_path ("galeon");

   return t;
}
Beispiel #9
0
static const gchar* determine_lock_screen(void)
{
    const gchar* program = NULL;

    if (g_find_program_in_path("lxlock"))
    {
        program = "lxlock";
    }
    else if (g_find_program_in_path("xdg-screensaver"))
    {
        program = "xdg-screensaver lock";
    }
    return program;
}
Beispiel #10
0
void cgraphics_open_browser( widget_t *w, char *url )
{
	char *browser, tmp[1024];
	int a, b, c;
	
	browser = g_find_program_in_path( "gnome-open" );
	if ( !browser ) /* if gnome-open doesn't exist, fall back on firefox */
		browser = g_find_program_in_path( "firefox" );
	
	if ( !browser ) /* if no gnome-open or firefox, bail out. */
		return;
	
	strcpy( tmp, browser );
	strcat( tmp, " \"" );
	c = strlen(tmp);
	for ( a = c, b = 0; a < 1023 && url[b] != 0; a++, b++ )
	{
		switch ( url[b] )
		{
			case ' ':
				strcat( tmp, "%20" );
				a += 2;
				break;
			case '"':
				strcat( tmp, "%22" );
				a += 2;
				break;
			case '\'':
				strcat( tmp, "%27" );
				a += 2;
				break;
			case '\\':
				strcat( tmp, "%5C" );
				a += 2;
				break;
			default:
				tmp[a] = url[b];
				tmp[a+1] = 0;
				break;
		}
	}
	tmp[a] = 0;
	strcat( tmp, "\"" );
	
	system( tmp );
	
	g_free( browser );
}
Beispiel #11
0
static gboolean
spawn_synaptic (GtkWindow   *window,
		const gchar *path,
		gint        *child_pid)
{
  gchar **argv;
  GError *error = NULL;
  gboolean retval = TRUE;
  gint i = 0;

  argv = g_new0 (gchar*, 6);
  argv[i++] = g_find_program_in_path ("gksudo");
  argv[i++] = g_strdup ("--desktop");
  argv[i++] = g_strdup ("/usr/share/applications/synaptic.desktop");
  argv[i++] = g_strdup ("--disable-grab");
  argv[i++] = get_synaptic_command_line (window, path);
  argv[i++] = NULL;

  if (!gdk_spawn_on_screen (gtk_window_get_screen (window),
			    NULL, argv, NULL,
			    G_SPAWN_SEARCH_PATH | G_SPAWN_DO_NOT_REAP_CHILD,
			    NULL, NULL, child_pid, &error))
    {
      show_error_dialog (window, (error) ? error->message : "");
      g_error_free (error);
      retval = FALSE;
    }

  g_strfreev (argv);

  return retval;
}
Beispiel #12
0
/* SYNTAX: UPGRADE [<irssi binary path>] */
static void cmd_upgrade(const char *data)
{
	CONFIG_REC *session;
	char *session_file, *str;
	char *binary;

	if (*data == '\0')
		data = irssi_binary;

	if ((binary = g_find_program_in_path(data)) == NULL)
		cmd_return_error(CMDERR_PROGRAM_NOT_FOUND);

	/* save the session */
        session_file = g_strdup_printf("%s/session", get_irssi_dir());
	session = config_open(session_file, 0600);
        unlink(session_file);

	signal_emit("session save", 1, session);
        config_write(session, NULL, -1);
        config_close(session);

	/* data may contain some other program as well, like
	   /UPGRADE /usr/bin/screen irssi */
	str = g_strdup_printf("%s --noconnect --session=%s --home=%s --config=%s",
			      binary, session_file, get_irssi_dir(), get_irssi_config());
	g_free(binary);
	g_free(session_file);
        session_args = g_strsplit(str, " ", -1);
        g_free(str);

	signal_emit("gui exit", 0);
}
Beispiel #13
0
static RejillaBurnResult
rejilla_mkisofs_set_argv (RejillaProcess *process,
			  GPtrArray *argv,
			  GError **error)
{
	gchar *prog_name;
	RejillaJobAction action;
	RejillaMkisofs *mkisofs;
	RejillaBurnResult result;
	RejillaMkisofsPrivate *priv;

	mkisofs = REJILLA_MKISOFS (process);
	priv = REJILLA_MKISOFS_PRIVATE (process);

	prog_name = g_find_program_in_path ("mkisofs");
	if (prog_name && g_file_test (prog_name, G_FILE_TEST_IS_EXECUTABLE))
		g_ptr_array_add (argv, prog_name);
	else
		g_ptr_array_add (argv, g_strdup ("mkisofs"));

	if (priv->use_utf8) {
		g_ptr_array_add (argv, g_strdup ("-input-charset"));
		g_ptr_array_add (argv, g_strdup ("utf8"));
	}

	rejilla_job_get_action (REJILLA_JOB (mkisofs), &action);
	if (action == REJILLA_JOB_ACTION_SIZE)
		result = rejilla_mkisofs_set_argv_image (mkisofs, argv, error);
	else if (action == REJILLA_JOB_ACTION_IMAGE)
		result = rejilla_mkisofs_set_argv_image (mkisofs, argv, error);
	else
		REJILLA_JOB_NOT_SUPPORTED (mkisofs);

	return result;
}
Beispiel #14
0
/* Calls 'gnome-session-save arg' */
static void
gnome_session_save_command (const char *arg)
{
  char      *args[3];
  GError    *error;
  GdkScreen *screen;
  gboolean   res;

  args[0] = g_find_program_in_path ("gnome-session-save");
  if (args[0] == NULL)
    return;

  args[1] = (char *)arg;
  args[2] = NULL;

  screen = gdk_screen_get_default ();

  error = NULL;
  res = gdk_spawn_on_screen (screen, g_get_home_dir (), args, NULL, 0, NULL,
      NULL, NULL, &error);
  if (!res)
    {
      g_warning (_("Can't logout: %s"), error->message);
      g_error_free (error);
    }

  g_free (args[0]);
}
Beispiel #15
0
gboolean biblio_compile_bibliography (GuBiblio* bc, GuEditor* ec, GuLatex* lc) {
    gchar* dirname = g_path_get_dirname (ec->workfile);
    gchar* auxname = NULL;

    if (ec->filename) {
        auxname = g_strdup (ec->pdffile);
        auxname[strlen (auxname) -4] = 0;
    } else
        auxname = g_strdup (ec->fdname);

    if (g_find_program_in_path ("bibtex")) {
        gboolean success = FALSE;
        char* command = g_strdup_printf ("%s bibtex \"%s\"",
                                         C_TEXSEC, auxname);

        g_free (auxname);
        latex_update_workfile (lc, ec);
        latex_update_auxfile (lc, ec);
        Tuple2 res = utils_popen_r (command, dirname);
        gtk_widget_set_tooltip_text (GTK_WIDGET (bc->progressbar),
                (gchar*)res.second);
        g_free (command);
        g_free (dirname);
        success = ! (strstr ((gchar*)res.second, "Database file #1") == NULL);
        g_free (res.second);
        return success;
    }
    slog (L_WARNING, "bibtex command is not present or executable.\n");
    g_free (auxname);
    g_free (dirname);
    return FALSE;
}
Beispiel #16
0
int main(int argc, char **argv)
{
	gchar *backend = NULL;
	gchar *backend_opt = NULL;
	gchar *majacd_app = NULL;
	GOptionEntry entries[] =
	{
		{"backend", 'b', 0, G_OPTION_ARG_STRING, &backend_opt,
			"Path to majacd application", "<path>"},
		{NULL}
	};
	GError *err = NULL;
	GOptionContext *context;
	GtkWidget *err_dialog;

	context = g_option_context_new("- system tray icon to "
			"control the majacd application");
	g_option_context_add_group(context, gtk_get_option_group(TRUE));
	g_option_context_add_main_entries(context, entries, NULL);
	g_option_context_parse(context, &argc, &argv, &err);
	g_option_context_free(context);

	if (backend_opt)
	{
		backend = g_strdup(backend_opt);
	}
	else
	{
		backend = g_strdup(MAJACD_APP);
	}

	gtk_init(&argc, &argv);
	if (!(majacd_app = g_find_program_in_path(backend)))
	{
		err_dialog = gtk_message_dialog_new(NULL,
				GTK_DIALOG_MODAL,
				GTK_MESSAGE_ERROR,
				GTK_BUTTONS_CLOSE,
				"Could not locate the majacd application");
		gtk_window_set_title(GTK_WINDOW(err_dialog), "Error");
		gtk_dialog_run(GTK_DIALOG(err_dialog));
		gtk_widget_destroy(err_dialog);
		g_error("Could not locate the majacd application\n");
		/* NOT REACHED */
		return EXIT_FAILURE;
	}
	if (backend_ctl_command(CMD_INIT, (gpointer) majacd_app) < 0)
	{
		g_error("Error starting %s", majacd_app);
	}
	main_window_create();
	main_window_hide();
	tray_icon_create();
	gtk_main();

	g_free(backend);
	g_free(majacd_app);
	
	return EXIT_SUCCESS;
}
Beispiel #17
0
void
fe_tray_set_balloon (const char *title, const char *text)
{
#ifndef WIN32
	const char *argv[8];
	const char *path;
	char time[16];
	WinStatus ws;

	/* no balloons if the window is focused */
	ws = tray_get_window_status ();
	if (ws == WS_FOCUSED)
		return;

	/* bit 1 of flags means "no balloons unless hidden/iconified" */
	if (ws != WS_HIDDEN && (prefs.gui_tray_flags & 2))
		return;

	/* FIXME: this should close the current balloon */
	if (!text)
		return;

#ifdef LIBNOTIFY
	/* try it via libnotify.so */
	if (libnotify_notify_new (title, text, sticon))
		return;	/* success */
#endif

	/* try it the crude way */
	path = g_find_program_in_path ("notify-send");
	if (path)
	{
		sprintf(time, "%d000",prefs.input_balloon_time);
		argv[0] = path;
		argv[1] = "-i";
		argv[2] = "gtk-dialog-info";
		if (access (XCHATSHAREDIR"/pixmaps/xchat.png", R_OK) == 0)
			argv[2] = XCHATSHAREDIR"/pixmaps/xchat.png";
		argv[3] = "-t";
		argv[4] = time;
		argv[5] = title;
		text = strip_color (text, -1, STRIP_ALL|STRIP_ESCMARKUP);
		argv[6] = text;
		argv[7] = NULL;
		xchat_execv (argv);
		g_free ((char *)path);
		g_free ((char *)text);
	}
	else
	{
		/* show this error only once */
		static unsigned char said_it = FALSE;
		if (!said_it)
		{
			said_it = TRUE;
			fe_message (_("Cannot find 'notify-send' to open balloon alerts.\nPlease install libnotify."), FE_MSG_ERROR);
		}
	}
#endif
}
Beispiel #18
0
gboolean
mono_gdb_render_native_backtraces ()
{
	const char *argv [9];
	char buf1 [128];

	argv [0] = g_find_program_in_path ("gdb");
	if (argv [0] == NULL) {
		return FALSE;
	}

	argv [1] = "-ex";
	sprintf (buf1, "attach %ld", (long)getpid ());
	argv [2] = buf1;
	argv [3] = "--ex";
	argv [4] = "info threads";
	argv [5] = "--ex";
	argv [6] = "thread apply all bt";
	argv [7] = "--batch";
	argv [8] = 0;

	execv (argv [0], (char**)argv);

	return TRUE;
}
Beispiel #19
0
static GList *
deja_dup_nautilus_extension_get_background_items(NautilusMenuProvider *provider,
                                                 GtkWidget *window,
                                                 NautilusFileInfo *file)
{
  NautilusMenuItem *item;
  guint length;
  GList *file_copies;
  gchar *path;

  if (file == NULL)
    return NULL;

  path = g_find_program_in_path("deja-dup");
  if (!path)
    return NULL;
  g_free(path);

  if (!is_dir_included(nautilus_file_info_get_location(file)))
    return NULL;

  item = nautilus_menu_item_new("DejaDupNautilusExtension::restore_missing_item",
                                dgettext(GETTEXT_PACKAGE, "Restore Missing Files…"),
                                dgettext(GETTEXT_PACKAGE, "Restore deleted files from backup"),
                                "deja-dup");

  g_signal_connect(item, "activate", G_CALLBACK(restore_missing_files_callback), NULL);
  g_object_set_data_full (G_OBJECT(item), "deja_dup_extension_file",
                          g_object_ref(file),
                          (GDestroyNotify)g_object_unref);

  return g_list_append(NULL, item);
}
void
GTK_browse_server_executable(GtkWidget *entry, gpointer user_data)
{
    GtkWidget *w;
    const gchar *path = gtk_entry_get_text(GTK_ENTRY(entry));
    const gchar *os_path;
    gchar *s;
    w = gtk_file_selection_new("Select Local Executable");
    gtk_file_selection_hide_fileop_buttons(GTK_FILE_SELECTION(w));
    if (*path) {
	os_path = g_filename_from_utf8(path, -1, NULL, NULL, NULL);
	if (os_path) {
	    s = g_find_program_in_path(os_path);
	    gtk_file_selection_set_filename(GTK_FILE_SELECTION(w),
	      s ? s : os_path);
	    g_free(s);
	    g_free((void *)os_path);
	}
    }
    if (gtk_dialog_run(GTK_DIALOG(w)) == GTK_RESPONSE_OK) {
	os_path = gtk_file_selection_get_filename(GTK_FILE_SELECTION(w));
	path = g_filename_to_utf8(os_path, -1, NULL, NULL, NULL);
	if (path) {
	    gtk_entry_set_text(GTK_ENTRY(entry), path);
	    g_free((void *)path);
	}
    }
    gtk_widget_destroy(w);
}
/* Based on gdesktopappinfo.c in GIO */
static gchar *
find_terminal_executable (void)
{
  gsize i;
  gchar *path = NULL;
  g_autoptr(GSettings) terminal_settings = NULL;
  g_autofree gchar *gsettings_terminal = NULL;
  const gchar *terminals[] = {
    NULL,                     /* GSettings */
    "x-terminal-emulator",    /* Debian's alternative system */
    "gnome-terminal",
    NULL,                     /* getenv ("TERM") */
    "nxterm", "color-xterm",
    "rxvt", "xterm", "dtterm"
  };

  /* This is deprecated, but at least the user can specify it! */
  terminal_settings = g_settings_new ("org.gnome.desktop.default-applications.terminal");
  gsettings_terminal = g_settings_get_string (terminal_settings, "exec");
  terminals[0] = gsettings_terminal;

  /* This is generally one of the fallback terminals */
  terminals[3] = g_getenv ("TERM");

  for (i = 0; i < G_N_ELEMENTS (terminals) && path == NULL; ++i)
    {
      if (terminals[i] != NULL)
        {
          G_GNUC_BEGIN_IGNORE_DEPRECATIONS
          path = g_find_program_in_path (terminals[i]);
          G_GNUC_END_IGNORE_DEPRECATIONS
        }
    }
Beispiel #22
0
static void call_system_monitor(GtkAction* action, TasklistData* tasklist)
{
#if !GTK_CHECK_VERSION (3, 0, 0)
	char* argv[2] = {NULL, NULL};
#endif
	char* programpath;
	int i;

	for (i = 0; i < G_N_ELEMENTS(system_monitors); i += 1)
	{
		programpath = g_find_program_in_path(system_monitors[i]);

		if (programpath != NULL)
		{
			g_free(programpath);

#if GTK_CHECK_VERSION (3, 0, 0)
			mate_gdk_spawn_command_line_on_screen(gtk_widget_get_screen(tasklist->applet),
				      system_monitors[i],
				      NULL);
#else
			argv[0] = system_monitors[i];
			gdk_spawn_on_screen(gtk_widget_get_screen(tasklist->applet), NULL, argv, NULL,
				      G_SPAWN_SEARCH_PATH,
				      NULL, NULL, NULL, NULL);
#endif

			return;
		}
	}
}
static const char *
get_python_executable() {
    static const char *python = NULL;
    if (python != NULL) {
        return python;
    }

    static const char *try_list[] = {
        "python2.7",
        "python27",
        "python2.6",
        "python26",
    };

    int i;
    for (i = 0; i < G_N_ELEMENTS(try_list); i++) {
        char *binary = g_find_program_in_path (try_list[i]);
        if (binary != NULL) {
            python = binary;
            break;
        }
    }

    if (python == NULL) {
        python = g_getenv ("PYTHON");
        if (python == NULL) {
            python = "python";
        }
    }

    return python;
}
Beispiel #24
0
static int
is_in_path (char *cmd)
{
	char *prog = strdup (cmd + 1);	/* 1st char is "!" */
	char *space, *path, *orig;

	orig = prog; /* save for free()ing */
	/* special-case these default entries. */
	/*                  123456789012345678 */
	if (strncmp (prog, "gnome-terminal -x ", 18) == 0)
	/* don't check for gnome-terminal, but the thing it's executing! */
		prog += 18;

	space = strchr (prog, ' ');	/* this isn't 100% but good enuf */
	if (space)
		*space = 0;

	path = g_find_program_in_path (prog);
	if (path)
	{
		g_free (path);
		g_free (orig);
		return 1;
	}

	g_free (orig);
	return 0;
}
Beispiel #25
0
char *
execute_lsof(pid_t pid) {
	char *output = NULL;
	char *lsof;
	char *command;
	int   exit_status;

	lsof = g_find_program_in_path("lsof");
	if (lsof == NULL)
		return NULL;

	command = g_strdup_printf("%s -n -P -Fftn -p %d", lsof, pid);
	g_free(lsof);

	if (g_spawn_command_line_sync (command, &output, NULL, &exit_status, NULL)) {
		if (exit_status != 0) {
			g_warning("Could not execute \"%s\" (%i)", command,
				   exit_status);
			output = NULL;
		}
	}

	g_free(command);
	return output;
}
Beispiel #26
0
static void
spawn_external (ShellStatusMenu *status, const char *program)
{
  char *args[2];
  GError *error;
  GdkScreen *screen;
  gboolean res;

  args[0] = g_find_program_in_path (program);
  if (args[0] == NULL)
    return;
  args[1] = NULL;

  screen = gdk_screen_get_default ();

  error = NULL;
  res = gdk_spawn_on_screen (screen, g_get_home_dir (), args, NULL, 0, NULL,
      NULL, NULL, &error);
  if (!res)
    {
      g_warning ("Failed to exec %s: %s", program, error->message);
      g_clear_error (&error);
    }

  g_free (args[0]);

}
Beispiel #27
0
static void
set_engine_name (GtkWidget *w, Settings *s)
{
	int engine_id;

	s->w_engine = w; 
	engine_id = GPOINTER_TO_INT (
	               g_object_get_data (G_OBJECT (s->w_engine), "id"));
	if (g_find_program_in_path (engine[engine_id]) == NULL) {
		if (gtk_toggle_button_get_active (
		                GTK_TOGGLE_BUTTON (button[engine_id]))) {
			GString *msg = g_string_new (
			               _("Engine <span weight=\"bold\" size=\"large\">"));
			msg = g_string_append (msg, engine[engine_id]);
			msg = g_string_append (msg, 
			              _("</span> not found\nThe engine is unable to locate "
			                "the external program."));
			oregano_warning_with_title (_("Warning"), msg->str);
			g_string_free (msg, TRUE);
			engine_id = (engine_id +1) % 2;
			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button[engine_id]),
			                              TRUE);
		}	
		else
			gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button[engine_id]),
		                                  FALSE);
	}
}
Beispiel #28
0
static void
on_quit_session_activate (GtkMenuItem   *item,
                          ShellStatusMenu *status)
{
  char      *args[3];
  GError    *error;
  GdkScreen *screen;
  gboolean   res;

  args[0] = g_find_program_in_path ("gnome-session-save");
  if (args[0] == NULL)
    return;

  args[1] = "--logout-dialog";
  args[2] = NULL;

  screen = gdk_screen_get_default ();

  error = NULL;
  res = gdk_spawn_on_screen (screen, g_get_home_dir (), args, NULL, 0, NULL,
      NULL, NULL, &error);
  if (!res)
    {
      g_warning (_("Can't logout: %s"), error->message);
      g_error_free (error);
    }

  g_free (args[0]);
}
Beispiel #29
0
void
mono_gdb_render_native_backtraces (pid_t crashed_pid)
{
	const char *argv [5];
	char gdb_template [] = "/tmp/mono-gdb-commands.XXXXXX";

	argv [0] = g_find_program_in_path ("gdb");
	if (argv [0] == NULL) {
		return;
	}

	if (mkstemp (gdb_template) != -1) {
		FILE *gdb_commands = fopen (gdb_template, "w");

		fprintf (gdb_commands, "attach %ld\n", (long) crashed_pid);
		fprintf (gdb_commands, "info threads\n");
		fprintf (gdb_commands, "thread apply all bt\n");

		fflush (gdb_commands);
		fclose (gdb_commands);

		argv [1] = "-batch";
		argv [2] = "-x";
		argv [3] = gdb_template;
		argv [4] = 0;

		execv (argv [0], (char**)argv);

		unlink (gdb_template);
	}
}
Beispiel #30
0
static G_GNUC_UNUSED GSList *
get_available_spell_languages (void)
{
#ifdef HAVE_GTKSPELL
	GSList *rv = NULL;
	gchar *prgm, *cmd;
	gchar *prgm_err, *prgm_out;
	gint exit_status, i;
	GError *err = NULL;
	eSpellLanguage *lang;
	gchar **lang_arr;

	if ((prgm = g_find_program_in_path ("aspell")) == NULL)
		return NULL;
	cmd = g_strdup_printf ("%s dump dicts", prgm);
	g_spawn_command_line_sync (cmd, &prgm_out, &prgm_err, &exit_status, &err);
	g_free (cmd);
	g_free (prgm);
	if (err)
	{
		g_warning ("Failed to get language list: %s", err->message);
		g_error_free (err);
		return NULL;
	}
	if (exit_status != 0)
	{
		g_warning ("Failed to get language list, program output was: %s", prgm_err);
		g_free (prgm_out);
		g_free (prgm_err);
		return NULL;
	}
	lang_arr = g_strsplit (prgm_out, "\n", -1);

	i = 0;
	while (lang_arr[i])
	{
		g_strstrip (lang_arr[i]);
		if (*(lang_arr[i]) != '\0')
		{
			lang = g_new0 (eSpellLanguage, 1);
			/* For now, set realname == label */
			lang->realname = g_strdup (lang_arr[i]);
			lang->label = g_strdup (lang_arr[i]);
			rv = g_slist_insert_sorted (rv, lang, (GCompareFunc) g_str_equal);
		}
		i++;
	}
	g_strfreev (lang_arr);

	lang = g_new0 (eSpellLanguage, 1);
	/* Context: Spell check dictionary */
	lang->label = g_strdup (_("System default"));
	lang->realname = g_strdup ("");
	rv = g_slist_prepend (rv, lang);

	return rv;
#else
	return NULL;
#endif /* HAVE_GTKSPELL */
}